xref: /illumos-gate/usr/src/uts/intel/sys/acpi/acpiosxf.h (revision d1e631af56641f21cde1f1efe3a9623ff9d6ee7c)
1 
2 /******************************************************************************
3  *
4  * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL).  These
5  *                    interfaces must be implemented by OSL to interface the
6  *                    ACPI components to the host operating system.
7  *
8  *****************************************************************************/
9 
10 
11 /*
12  * Copyright (C) 2000 - 2011, Intel Corp.
13  * All rights reserved.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions, and the following disclaimer,
20  *    without modification.
21  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
22  *    substantially similar to the "NO WARRANTY" disclaimer below
23  *    ("Disclaimer") and any redistribution must be conditioned upon
24  *    including a substantially similar Disclaimer requirement for further
25  *    binary redistribution.
26  * 3. Neither the names of the above-listed copyright holders nor the names
27  *    of any contributors may be used to endorse or promote products derived
28  *    from this software without specific prior written permission.
29  *
30  * Alternatively, this software may be distributed under the terms of the
31  * GNU General Public License ("GPL") version 2 as published by the Free
32  * Software Foundation.
33  *
34  * NO WARRANTY
35  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
38  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
43  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
44  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45  * POSSIBILITY OF SUCH DAMAGES.
46  */
47 
48 #ifndef __ACPIOSXF_H__
49 #define __ACPIOSXF_H__
50 
51 #include "platform/acenv.h"
52 #include "actypes.h"
53 
54 
55 /* Types for AcpiOsExecute */
56 
57 typedef enum
58 {
59     OSL_GLOBAL_LOCK_HANDLER,
60     OSL_NOTIFY_HANDLER,
61     OSL_GPE_HANDLER,
62     OSL_DEBUGGER_THREAD,
63     OSL_EC_POLL_HANDLER,
64     OSL_EC_BURST_HANDLER
65 
66 } ACPI_EXECUTE_TYPE;
67 
68 #define ACPI_NO_UNIT_LIMIT          ((UINT32) -1)
69 #define ACPI_MUTEX_SEM              1
70 
71 
72 /* Functions for AcpiOsSignal */
73 
74 #define ACPI_SIGNAL_FATAL           0
75 #define ACPI_SIGNAL_BREAKPOINT      1
76 
77 typedef struct acpi_signal_fatal_info
78 {
79     UINT32                  Type;
80     UINT32                  Code;
81     UINT32                  Argument;
82 
83 } ACPI_SIGNAL_FATAL_INFO;
84 
85 
86 /*
87  * OSL Initialization and shutdown primitives
88  */
89 ACPI_STATUS
90 AcpiOsInitialize (
91     void);
92 
93 ACPI_STATUS
94 AcpiOsTerminate (
95     void);
96 
97 
98 /*
99  * ACPI Table interfaces
100  */
101 ACPI_PHYSICAL_ADDRESS
102 AcpiOsGetRootPointer (
103     void);
104 
105 ACPI_STATUS
106 AcpiOsPredefinedOverride (
107     const ACPI_PREDEFINED_NAMES *InitVal,
108     ACPI_STRING                 *NewVal);
109 
110 ACPI_STATUS
111 AcpiOsTableOverride (
112     ACPI_TABLE_HEADER       *ExistingTable,
113     ACPI_TABLE_HEADER       **NewTable);
114 
115 
116 /*
117  * Spinlock primitives
118  */
119 ACPI_STATUS
120 AcpiOsCreateLock (
121     ACPI_SPINLOCK           *OutHandle);
122 
123 void
124 AcpiOsDeleteLock (
125     ACPI_SPINLOCK           Handle);
126 
127 ACPI_CPU_FLAGS
128 AcpiOsAcquireLock (
129     ACPI_SPINLOCK           Handle);
130 
131 void
132 AcpiOsReleaseLock (
133     ACPI_SPINLOCK           Handle,
134     ACPI_CPU_FLAGS          Flags);
135 
136 
137 /*
138  * Semaphore primitives
139  */
140 ACPI_STATUS
141 AcpiOsCreateSemaphore (
142     UINT32                  MaxUnits,
143     UINT32                  InitialUnits,
144     ACPI_SEMAPHORE          *OutHandle);
145 
146 ACPI_STATUS
147 AcpiOsDeleteSemaphore (
148     ACPI_SEMAPHORE          Handle);
149 
150 ACPI_STATUS
151 AcpiOsWaitSemaphore (
152     ACPI_SEMAPHORE          Handle,
153     UINT32                  Units,
154     UINT16                  Timeout);
155 
156 ACPI_STATUS
157 AcpiOsSignalSemaphore (
158     ACPI_SEMAPHORE          Handle,
159     UINT32                  Units);
160 
161 
162 /*
163  * Mutex primitives. May be configured to use semaphores instead via
164  * ACPI_MUTEX_TYPE (see platform/acenv.h)
165  */
166 #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
167 
168 ACPI_STATUS
169 AcpiOsCreateMutex (
170     ACPI_MUTEX              *OutHandle);
171 
172 void
173 AcpiOsDeleteMutex (
174     ACPI_MUTEX              Handle);
175 
176 ACPI_STATUS
177 AcpiOsAcquireMutex (
178     ACPI_MUTEX              Handle,
179     UINT16                  Timeout);
180 
181 void
182 AcpiOsReleaseMutex (
183     ACPI_MUTEX              Handle);
184 #endif
185 
186 
187 /*
188  * Memory allocation and mapping
189  */
190 void *
191 AcpiOsAllocate (
192     ACPI_SIZE               Size);
193 
194 void
195 AcpiOsFree (
196     void *                  Memory);
197 
198 void *
199 AcpiOsMapMemory (
200     ACPI_PHYSICAL_ADDRESS   Where,
201     ACPI_SIZE               Length);
202 
203 void
204 AcpiOsUnmapMemory (
205     void                    *LogicalAddress,
206     ACPI_SIZE               Size);
207 
208 ACPI_STATUS
209 AcpiOsGetPhysicalAddress (
210     void                    *LogicalAddress,
211     ACPI_PHYSICAL_ADDRESS   *PhysicalAddress);
212 
213 
214 /*
215  * Memory/Object Cache
216  */
217 ACPI_STATUS
218 AcpiOsCreateCache (
219     char                    *CacheName,
220     UINT16                  ObjectSize,
221     UINT16                  MaxDepth,
222     ACPI_CACHE_T            **ReturnCache);
223 
224 ACPI_STATUS
225 AcpiOsDeleteCache (
226     ACPI_CACHE_T            *Cache);
227 
228 ACPI_STATUS
229 AcpiOsPurgeCache (
230     ACPI_CACHE_T            *Cache);
231 
232 void *
233 AcpiOsAcquireObject (
234     ACPI_CACHE_T            *Cache);
235 
236 ACPI_STATUS
237 AcpiOsReleaseObject (
238     ACPI_CACHE_T            *Cache,
239     void                    *Object);
240 
241 
242 /*
243  * Interrupt handlers
244  */
245 ACPI_STATUS
246 AcpiOsInstallInterruptHandler (
247     UINT32                  InterruptNumber,
248     ACPI_OSD_HANDLER        ServiceRoutine,
249     void                    *Context);
250 
251 ACPI_STATUS
252 AcpiOsRemoveInterruptHandler (
253     UINT32                  InterruptNumber,
254     ACPI_OSD_HANDLER        ServiceRoutine);
255 
256 
257 /*
258  * Threads and Scheduling
259  */
260 ACPI_THREAD_ID
261 AcpiOsGetThreadId (
262     void);
263 
264 ACPI_STATUS
265 AcpiOsExecute (
266     ACPI_EXECUTE_TYPE       Type,
267     ACPI_OSD_EXEC_CALLBACK  Function,
268     void                    *Context);
269 
270 void
271 AcpiOsWaitEventsComplete (
272     void                    *Context);
273 
274 void
275 AcpiOsSleep (
276     UINT64                  Milliseconds);
277 
278 void
279 AcpiOsStall (
280     UINT32                  Microseconds);
281 
282 
283 /*
284  * Platform and hardware-independent I/O interfaces
285  */
286 ACPI_STATUS
287 AcpiOsReadPort (
288     ACPI_IO_ADDRESS         Address,
289     UINT32                  *Value,
290     UINT32                  Width);
291 
292 ACPI_STATUS
293 AcpiOsWritePort (
294     ACPI_IO_ADDRESS         Address,
295     UINT32                  Value,
296     UINT32                  Width);
297 
298 
299 /*
300  * Platform and hardware-independent physical memory interfaces
301  */
302 ACPI_STATUS
303 AcpiOsReadMemory (
304     ACPI_PHYSICAL_ADDRESS   Address,
305     UINT32                  *Value,
306     UINT32                  Width);
307 
308 ACPI_STATUS
309 AcpiOsWriteMemory (
310     ACPI_PHYSICAL_ADDRESS   Address,
311     UINT32                  Value,
312     UINT32                  Width);
313 
314 
315 /*
316  * Platform and hardware-independent PCI configuration space access
317  * Note: Can't use "Register" as a parameter, changed to "Reg" --
318  * certain compilers complain.
319  */
320 ACPI_STATUS
321 AcpiOsReadPciConfiguration (
322     ACPI_PCI_ID             *PciId,
323     UINT32                  Reg,
324     UINT64                  *Value,
325     UINT32                  Width);
326 
327 ACPI_STATUS
328 AcpiOsWritePciConfiguration (
329     ACPI_PCI_ID             *PciId,
330     UINT32                  Reg,
331     UINT64                  Value,
332     UINT32                  Width);
333 
334 
335 /*
336  * Miscellaneous
337  */
338 BOOLEAN
339 AcpiOsReadable (
340     void                    *Pointer,
341     ACPI_SIZE               Length);
342 
343 BOOLEAN
344 AcpiOsWritable (
345     void                    *Pointer,
346     ACPI_SIZE               Length);
347 
348 UINT64
349 AcpiOsGetTimer (
350     void);
351 
352 ACPI_STATUS
353 AcpiOsSignal (
354     UINT32                  Function,
355     void                    *Info);
356 
357 
358 /*
359  * Debug print routines
360  */
361 void ACPI_INTERNAL_VAR_XFACE
362 AcpiOsPrintf (
363     const char              *Format,
364     ...);
365 
366 void
367 AcpiOsVprintf (
368     const char              *Format,
369     va_list                 Args);
370 
371 void
372 AcpiOsRedirectOutput (
373     void                    *Destination);
374 
375 
376 /*
377  * Debug input
378  */
379 ACPI_STATUS
380 AcpiOsGetLine (
381     char                    *Buffer,
382     UINT32                  BufferLength,
383     UINT32                  *BytesRead);
384 
385 
386 /*
387  * Directory manipulation
388  */
389 void *
390 AcpiOsOpenDirectory (
391     char                    *Pathname,
392     char                    *WildcardSpec,
393     char                    RequestedFileType);
394 
395 /* RequesteFileType values */
396 
397 #define REQUEST_FILE_ONLY                   0
398 #define REQUEST_DIR_ONLY                    1
399 
400 
401 char *
402 AcpiOsGetNextFilename (
403     void                    *DirHandle);
404 
405 void
406 AcpiOsCloseDirectory (
407     void                    *DirHandle);
408 
409 
410 #endif /* __ACPIOSXF_H__ */
411