acpiosxf.h revision 229989
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 - 2012, 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 <contrib/dev/acpica/include/platform/acenv.h>
52#include <contrib/dev/acpica/include/actypes.h>
53
54
55/* Types for AcpiOsExecute */
56
57typedef 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
77typedef 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 */
89ACPI_STATUS
90AcpiOsInitialize (
91    void);
92
93ACPI_STATUS
94AcpiOsTerminate (
95    void);
96
97
98/*
99 * ACPI Table interfaces
100 */
101ACPI_PHYSICAL_ADDRESS
102AcpiOsGetRootPointer (
103    void);
104
105ACPI_STATUS
106AcpiOsPredefinedOverride (
107    const ACPI_PREDEFINED_NAMES *InitVal,
108    ACPI_STRING                 *NewVal);
109
110ACPI_STATUS
111AcpiOsTableOverride (
112    ACPI_TABLE_HEADER       *ExistingTable,
113    ACPI_TABLE_HEADER       **NewTable);
114
115
116/*
117 * Spinlock primitives
118 */
119ACPI_STATUS
120AcpiOsCreateLock (
121    ACPI_SPINLOCK           *OutHandle);
122
123void
124AcpiOsDeleteLock (
125    ACPI_SPINLOCK           Handle);
126
127ACPI_CPU_FLAGS
128AcpiOsAcquireLock (
129    ACPI_SPINLOCK           Handle);
130
131void
132AcpiOsReleaseLock (
133    ACPI_SPINLOCK           Handle,
134    ACPI_CPU_FLAGS          Flags);
135
136
137/*
138 * Semaphore primitives
139 */
140ACPI_STATUS
141AcpiOsCreateSemaphore (
142    UINT32                  MaxUnits,
143    UINT32                  InitialUnits,
144    ACPI_SEMAPHORE          *OutHandle);
145
146ACPI_STATUS
147AcpiOsDeleteSemaphore (
148    ACPI_SEMAPHORE          Handle);
149
150ACPI_STATUS
151AcpiOsWaitSemaphore (
152    ACPI_SEMAPHORE          Handle,
153    UINT32                  Units,
154    UINT16                  Timeout);
155
156ACPI_STATUS
157AcpiOsSignalSemaphore (
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
168ACPI_STATUS
169AcpiOsCreateMutex (
170    ACPI_MUTEX              *OutHandle);
171
172void
173AcpiOsDeleteMutex (
174    ACPI_MUTEX              Handle);
175
176ACPI_STATUS
177AcpiOsAcquireMutex (
178    ACPI_MUTEX              Handle,
179    UINT16                  Timeout);
180
181void
182AcpiOsReleaseMutex (
183    ACPI_MUTEX              Handle);
184#endif
185
186
187/*
188 * Memory allocation and mapping
189 */
190void *
191AcpiOsAllocate (
192    ACPI_SIZE               Size);
193
194void
195AcpiOsFree (
196    void *                  Memory);
197
198void *
199AcpiOsMapMemory (
200    ACPI_PHYSICAL_ADDRESS   Where,
201    ACPI_SIZE               Length);
202
203void
204AcpiOsUnmapMemory (
205    void                    *LogicalAddress,
206    ACPI_SIZE               Size);
207
208ACPI_STATUS
209AcpiOsGetPhysicalAddress (
210    void                    *LogicalAddress,
211    ACPI_PHYSICAL_ADDRESS   *PhysicalAddress);
212
213
214/*
215 * Memory/Object Cache
216 */
217ACPI_STATUS
218AcpiOsCreateCache (
219    char                    *CacheName,
220    UINT16                  ObjectSize,
221    UINT16                  MaxDepth,
222    ACPI_CACHE_T            **ReturnCache);
223
224ACPI_STATUS
225AcpiOsDeleteCache (
226    ACPI_CACHE_T            *Cache);
227
228ACPI_STATUS
229AcpiOsPurgeCache (
230    ACPI_CACHE_T            *Cache);
231
232void *
233AcpiOsAcquireObject (
234    ACPI_CACHE_T            *Cache);
235
236ACPI_STATUS
237AcpiOsReleaseObject (
238    ACPI_CACHE_T            *Cache,
239    void                    *Object);
240
241
242/*
243 * Interrupt handlers
244 */
245ACPI_STATUS
246AcpiOsInstallInterruptHandler (
247    UINT32                  InterruptNumber,
248    ACPI_OSD_HANDLER        ServiceRoutine,
249    void                    *Context);
250
251ACPI_STATUS
252AcpiOsRemoveInterruptHandler (
253    UINT32                  InterruptNumber,
254    ACPI_OSD_HANDLER        ServiceRoutine);
255
256
257/*
258 * Threads and Scheduling
259 */
260ACPI_THREAD_ID
261AcpiOsGetThreadId (
262    void);
263
264ACPI_STATUS
265AcpiOsExecute (
266    ACPI_EXECUTE_TYPE       Type,
267    ACPI_OSD_EXEC_CALLBACK  Function,
268    void                    *Context);
269
270void
271AcpiOsWaitEventsComplete (
272    void                    *Context);
273
274void
275AcpiOsSleep (
276    UINT64                  Milliseconds);
277
278void
279AcpiOsStall (
280    UINT32                  Microseconds);
281
282
283/*
284 * Platform and hardware-independent I/O interfaces
285 */
286ACPI_STATUS
287AcpiOsReadPort (
288    ACPI_IO_ADDRESS         Address,
289    UINT32                  *Value,
290    UINT32                  Width);
291
292ACPI_STATUS
293AcpiOsWritePort (
294    ACPI_IO_ADDRESS         Address,
295    UINT32                  Value,
296    UINT32                  Width);
297
298
299/*
300 * Platform and hardware-independent physical memory interfaces
301 */
302ACPI_STATUS
303AcpiOsReadMemory (
304    ACPI_PHYSICAL_ADDRESS   Address,
305    UINT32                  *Value,
306    UINT32                  Width);
307
308ACPI_STATUS
309AcpiOsWriteMemory (
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 */
320ACPI_STATUS
321AcpiOsReadPciConfiguration (
322    ACPI_PCI_ID             *PciId,
323    UINT32                  Reg,
324    UINT64                  *Value,
325    UINT32                  Width);
326
327ACPI_STATUS
328AcpiOsWritePciConfiguration (
329    ACPI_PCI_ID             *PciId,
330    UINT32                  Reg,
331    UINT64                  Value,
332    UINT32                  Width);
333
334
335/*
336 * Miscellaneous
337 */
338BOOLEAN
339AcpiOsReadable (
340    void                    *Pointer,
341    ACPI_SIZE               Length);
342
343BOOLEAN
344AcpiOsWritable (
345    void                    *Pointer,
346    ACPI_SIZE               Length);
347
348UINT64
349AcpiOsGetTimer (
350    void);
351
352ACPI_STATUS
353AcpiOsSignal (
354    UINT32                  Function,
355    void                    *Info);
356
357
358/*
359 * Debug print routines
360 */
361void ACPI_INTERNAL_VAR_XFACE
362AcpiOsPrintf (
363    const char              *Format,
364    ...);
365
366void
367AcpiOsVprintf (
368    const char              *Format,
369    va_list                 Args);
370
371void
372AcpiOsRedirectOutput (
373    void                    *Destination);
374
375
376/*
377 * Debug input
378 */
379ACPI_STATUS
380AcpiOsGetLine (
381    char                    *Buffer,
382    UINT32                  BufferLength,
383    UINT32                  *BytesRead);
384
385
386/*
387 * Directory manipulation
388 */
389void *
390AcpiOsOpenDirectory (
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
401char *
402AcpiOsGetNextFilename (
403    void                    *DirHandle);
404
405void
406AcpiOsCloseDirectory (
407    void                    *DirHandle);
408
409
410#endif /* __ACPIOSXF_H__ */
411