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