xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/include/acpiosxf.h (revision 986e4abce4efeccd9418eb8cdc7a710487f093b9)
1 /******************************************************************************
2  *
3  * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These
4  *                    interfaces must be implemented by OSL to interface the
5  *                    ACPI components to the host operating system.
6  *
7  *****************************************************************************/
8 
9 
10 /******************************************************************************
11  *
12  * 1. Copyright Notice
13  *
14  * Some or all of this work - Copyright (c) 1999 - 2013, Intel Corp.
15  * All rights reserved.
16  *
17  * 2. License
18  *
19  * 2.1. This is your license from Intel Corp. under its intellectual property
20  * rights. You may have additional license terms from the party that provided
21  * you this software, covering your right to use that party's intellectual
22  * property rights.
23  *
24  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
25  * copy of the source code appearing in this file ("Covered Code") an
26  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
27  * base code distributed originally by Intel ("Original Intel Code") to copy,
28  * make derivatives, distribute, use and display any portion of the Covered
29  * Code in any form, with the right to sublicense such rights; and
30  *
31  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
32  * license (with the right to sublicense), under only those claims of Intel
33  * patents that are infringed by the Original Intel Code, to make, use, sell,
34  * offer to sell, and import the Covered Code and derivative works thereof
35  * solely to the minimum extent necessary to exer
36  se the above copyright
37  * license, and in no event shall the patent license extend to any additions
38  * to or modifications of the Original Intel Code. No other license or right
39  * is granted directly or by implication, estoppel or otherwise;
40  *
41  * The above copyright and patent license is granted only if the following
42  * conditions are met:
43  *
44  * 3. Conditions
45  *
46  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
47  * Redistribution of source code of any substantial portion of the Covered
48  * Code or modification with rights to further distribute source must include
49  * the above Copyright Notice, the above License, this list of Conditions,
50  * and the following Disclaimer and Export Compliance provision. In addition,
51  * Licensee must cause all Covered Code to which Licensee contributes to
52  * contain a file documenting the changes Licensee made to create that Covered
53  * Code and the date of any change. Licensee must include in that file the
54  * documentation of any changes made by any predecessor Licensee. Licensee
55  * must include a prominent statement that the modification is derived,
56  * directly or indirectly, from Original Intel Code.
57  *
58  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
59  * Redistribution of source code of any substantial portion of the Covered
60  * Code or modification without rights to further distribute source must
61  * include the following Disclaimer and Export Compliance provision in the
62  * documentation and/or other materials provided with distribution. In
63  * addition, Licensee may not authorize further sublicense of source of any
64  * portion of the Covered Code, and must include terms to the effect that the
65  * license from Licensee to its licensee is limited to the intellectual
66  * property embodied in the software Licensee provides to its licensee, and
67  * not to intellectual property embodied in modifications its licensee may
68  * make.
69  *
70  * 3.3. Redistribution of Executable. Redistribution in executable form of any
71  * substantial portion of the Covered Code or modification must reproduce the
72  * above Copyright Notice, and the following Disclaimer and Export Compliance
73  * provision in the documentation and/or other materials provided with the
74  * distribution.
75  *
76  * 3.4. Intel retains all right, title, and interest in and to the Original
77  * Intel Code.
78  *
79  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
80  * Intel shall be used in advertising or otherwise to promote the sale, use or
81  * other dealings in products derived from or relating to the Covered Code
82  * without prior written authorization from Intel.
83  *
84  * 4. Disclaimer and Export Compliance
85  *
86  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
87  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
88  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
89  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
90  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
91  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
92  * PARTICULAR PURPOSE.
93  *
94  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
95  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
96  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
97  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
98  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
99  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
100  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
101  * LIMITED REMEDY.
102  *
103  * 4.3. Licensee shall not export, either directly or indirectly, any of this
104  * software or system incorporating such software without first obtaining any
105  * required license or other approval from the U. S. Department of Commerce or
106  * any other agency or department of the United States Government. In the
107  * event Licensee exports any such software from the United States or
108  * re-exports any such software from a foreign destination, Licensee shall
109  * ensure that the distribution and export/re-export of the software is in
110  * compliance with all laws, regulations, orders, or other restrictions of the
111  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
112  * any of its subsidiaries will export/re-export any technical data, process,
113  * software, or service, directly or indirectly, to any country for which the
114  * United States government or any agency thereof requires an export license,
115  * other governmental approval, or letter of assurance, without first obtaining
116  * such license, approval or letter.
117  *
118  *****************************************************************************/
119 
120 #ifndef __ACPIOSXF_H__
121 #define __ACPIOSXF_H__
122 
123 #include "platform/acenv.h"
124 #include "actypes.h"
125 
126 
127 /* Types for AcpiOsExecute */
128 
129 typedef enum
130 {
131     OSL_GLOBAL_LOCK_HANDLER,
132     OSL_NOTIFY_HANDLER,
133     OSL_GPE_HANDLER,
134     OSL_DEBUGGER_THREAD,
135     OSL_EC_POLL_HANDLER,
136     OSL_EC_BURST_HANDLER
137 
138 } ACPI_EXECUTE_TYPE;
139 
140 #define ACPI_NO_UNIT_LIMIT          ((UINT32) -1)
141 #define ACPI_MUTEX_SEM              1
142 
143 
144 /* Functions for AcpiOsSignal */
145 
146 #define ACPI_SIGNAL_FATAL           0
147 #define ACPI_SIGNAL_BREAKPOINT      1
148 
149 typedef struct acpi_signal_fatal_info
150 {
151     UINT32                  Type;
152     UINT32                  Code;
153     UINT32                  Argument;
154 
155 } ACPI_SIGNAL_FATAL_INFO;
156 
157 
158 /*
159  * OSL Initialization and shutdown primitives
160  */
161 ACPI_STATUS
162 AcpiOsInitialize (
163     void);
164 
165 ACPI_STATUS
166 AcpiOsTerminate (
167     void);
168 
169 
170 /*
171  * ACPI Table interfaces
172  */
173 ACPI_PHYSICAL_ADDRESS
174 AcpiOsGetRootPointer (
175     void);
176 
177 ACPI_STATUS
178 AcpiOsPredefinedOverride (
179     const ACPI_PREDEFINED_NAMES *InitVal,
180     ACPI_STRING                 *NewVal);
181 
182 ACPI_STATUS
183 AcpiOsTableOverride (
184     ACPI_TABLE_HEADER       *ExistingTable,
185     ACPI_TABLE_HEADER       **NewTable);
186 
187 ACPI_STATUS
188 AcpiOsPhysicalTableOverride (
189     ACPI_TABLE_HEADER       *ExistingTable,
190     ACPI_PHYSICAL_ADDRESS   *NewAddress,
191     UINT32                  *NewTableLength);
192 
193 
194 /*
195  * Spinlock primitives
196  */
197 #ifndef AcpiOsCreateLock
198 ACPI_STATUS
199 AcpiOsCreateLock (
200     ACPI_SPINLOCK           *OutHandle);
201 #endif
202 
203 void
204 AcpiOsDeleteLock (
205     ACPI_SPINLOCK           Handle);
206 
207 ACPI_CPU_FLAGS
208 AcpiOsAcquireLock (
209     ACPI_SPINLOCK           Handle);
210 
211 void
212 AcpiOsReleaseLock (
213     ACPI_SPINLOCK           Handle,
214     ACPI_CPU_FLAGS          Flags);
215 
216 
217 /*
218  * Semaphore primitives
219  */
220 ACPI_STATUS
221 AcpiOsCreateSemaphore (
222     UINT32                  MaxUnits,
223     UINT32                  InitialUnits,
224     ACPI_SEMAPHORE          *OutHandle);
225 
226 ACPI_STATUS
227 AcpiOsDeleteSemaphore (
228     ACPI_SEMAPHORE          Handle);
229 
230 ACPI_STATUS
231 AcpiOsWaitSemaphore (
232     ACPI_SEMAPHORE          Handle,
233     UINT32                  Units,
234     UINT16                  Timeout);
235 
236 ACPI_STATUS
237 AcpiOsSignalSemaphore (
238     ACPI_SEMAPHORE          Handle,
239     UINT32                  Units);
240 
241 
242 /*
243  * Mutex primitives. May be configured to use semaphores instead via
244  * ACPI_MUTEX_TYPE (see platform/acenv.h)
245  */
246 #if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE)
247 
248 ACPI_STATUS
249 AcpiOsCreateMutex (
250     ACPI_MUTEX              *OutHandle);
251 
252 void
253 AcpiOsDeleteMutex (
254     ACPI_MUTEX              Handle);
255 
256 ACPI_STATUS
257 AcpiOsAcquireMutex (
258     ACPI_MUTEX              Handle,
259     UINT16                  Timeout);
260 
261 void
262 AcpiOsReleaseMutex (
263     ACPI_MUTEX              Handle);
264 #endif
265 
266 
267 /*
268  * Memory allocation and mapping
269  */
270 void *
271 AcpiOsAllocate (
272     ACPI_SIZE               Size);
273 
274 void
275 AcpiOsFree (
276     void *                  Memory);
277 
278 void *
279 AcpiOsMapMemory (
280     ACPI_PHYSICAL_ADDRESS   Where,
281     ACPI_SIZE               Length);
282 
283 void
284 AcpiOsUnmapMemory (
285     void                    *LogicalAddress,
286     ACPI_SIZE               Size);
287 
288 ACPI_STATUS
289 AcpiOsGetPhysicalAddress (
290     void                    *LogicalAddress,
291     ACPI_PHYSICAL_ADDRESS   *PhysicalAddress);
292 
293 
294 /*
295  * Memory/Object Cache
296  */
297 ACPI_STATUS
298 AcpiOsCreateCache (
299     char                    *CacheName,
300     UINT16                  ObjectSize,
301     UINT16                  MaxDepth,
302     ACPI_CACHE_T            **ReturnCache);
303 
304 ACPI_STATUS
305 AcpiOsDeleteCache (
306     ACPI_CACHE_T            *Cache);
307 
308 ACPI_STATUS
309 AcpiOsPurgeCache (
310     ACPI_CACHE_T            *Cache);
311 
312 void *
313 AcpiOsAcquireObject (
314     ACPI_CACHE_T            *Cache);
315 
316 ACPI_STATUS
317 AcpiOsReleaseObject (
318     ACPI_CACHE_T            *Cache,
319     void                    *Object);
320 
321 
322 /*
323  * Interrupt handlers
324  */
325 ACPI_STATUS
326 AcpiOsInstallInterruptHandler (
327     UINT32                  InterruptNumber,
328     ACPI_OSD_HANDLER        ServiceRoutine,
329     void                    *Context);
330 
331 ACPI_STATUS
332 AcpiOsRemoveInterruptHandler (
333     UINT32                  InterruptNumber,
334     ACPI_OSD_HANDLER        ServiceRoutine);
335 
336 
337 /*
338  * Threads and Scheduling
339  */
340 ACPI_THREAD_ID
341 AcpiOsGetThreadId (
342     void);
343 
344 ACPI_STATUS
345 AcpiOsExecute (
346     ACPI_EXECUTE_TYPE       Type,
347     ACPI_OSD_EXEC_CALLBACK  Function,
348     void                    *Context);
349 
350 void
351 AcpiOsWaitEventsComplete (
352     void);
353 
354 void
355 AcpiOsSleep (
356     UINT64                  Milliseconds);
357 
358 void
359 AcpiOsStall (
360     UINT32                  Microseconds);
361 
362 
363 /*
364  * Platform and hardware-independent I/O interfaces
365  */
366 ACPI_STATUS
367 AcpiOsReadPort (
368     ACPI_IO_ADDRESS         Address,
369     UINT32                  *Value,
370     UINT32                  Width);
371 
372 ACPI_STATUS
373 AcpiOsWritePort (
374     ACPI_IO_ADDRESS         Address,
375     UINT32                  Value,
376     UINT32                  Width);
377 
378 
379 /*
380  * Platform and hardware-independent physical memory interfaces
381  */
382 ACPI_STATUS
383 AcpiOsReadMemory (
384     ACPI_PHYSICAL_ADDRESS   Address,
385     UINT64                  *Value,
386     UINT32                  Width);
387 
388 ACPI_STATUS
389 AcpiOsWriteMemory (
390     ACPI_PHYSICAL_ADDRESS   Address,
391     UINT64                  Value,
392     UINT32                  Width);
393 
394 
395 /*
396  * Platform and hardware-independent PCI configuration space access
397  * Note: Can't use "Register" as a parameter, changed to "Reg" --
398  * certain compilers complain.
399  */
400 ACPI_STATUS
401 AcpiOsReadPciConfiguration (
402     ACPI_PCI_ID             *PciId,
403     UINT32                  Reg,
404     UINT64                  *Value,
405     UINT32                  Width);
406 
407 ACPI_STATUS
408 AcpiOsWritePciConfiguration (
409     ACPI_PCI_ID             *PciId,
410     UINT32                  Reg,
411     UINT64                  Value,
412     UINT32                  Width);
413 
414 
415 /*
416  * Miscellaneous
417  */
418 BOOLEAN
419 AcpiOsReadable (
420     void                    *Pointer,
421     ACPI_SIZE               Length);
422 
423 BOOLEAN
424 AcpiOsWritable (
425     void                    *Pointer,
426     ACPI_SIZE               Length);
427 
428 UINT64
429 AcpiOsGetTimer (
430     void);
431 
432 ACPI_STATUS
433 AcpiOsSignal (
434     UINT32                  Function,
435     void                    *Info);
436 
437 
438 /*
439  * Debug print routines
440  */
441 void ACPI_INTERNAL_VAR_XFACE
442 AcpiOsPrintf (
443     const char              *Format,
444     ...);
445 
446 void
447 AcpiOsVprintf (
448     const char              *Format,
449     va_list                 Args);
450 
451 void
452 AcpiOsRedirectOutput (
453     void                    *Destination);
454 
455 
456 /*
457  * Debug input
458  */
459 ACPI_STATUS
460 AcpiOsGetLine (
461     char                    *Buffer,
462     UINT32                  BufferLength,
463     UINT32                  *BytesRead);
464 
465 
466 /*
467  * Obtain ACPI table(s)
468  */
469 ACPI_STATUS
470 AcpiOsGetTableByName (
471     char                    *Signature,
472     UINT32                  Instance,
473     ACPI_TABLE_HEADER       **Table,
474     ACPI_PHYSICAL_ADDRESS   *Address);
475 
476 ACPI_STATUS
477 AcpiOsGetTableByIndex (
478     UINT32                  Index,
479     ACPI_TABLE_HEADER       **Table,
480     UINT32                  *Instance,
481     ACPI_PHYSICAL_ADDRESS   *Address);
482 
483 ACPI_STATUS
484 AcpiOsGetTableByAddress (
485     ACPI_PHYSICAL_ADDRESS   Address,
486     ACPI_TABLE_HEADER       **Table);
487 
488 
489 /*
490  * Directory manipulation
491  */
492 void *
493 AcpiOsOpenDirectory (
494     char                    *Pathname,
495     char                    *WildcardSpec,
496     char                    RequestedFileType);
497 
498 /* RequesteFileType values */
499 
500 #define REQUEST_FILE_ONLY                   0
501 #define REQUEST_DIR_ONLY                    1
502 
503 
504 char *
505 AcpiOsGetNextFilename (
506     void                    *DirHandle);
507 
508 void
509 AcpiOsCloseDirectory (
510     void                    *DirHandle);
511 
512 
513 #endif /* __ACPIOSXF_H__ */
514