1 #include <l4/sys/compiler.h>
14 #include <l4/util/util.h>
15 #if defined(ARCH_amd64) || defined(ARCH_x86)
16 #include <l4/util/port_io.h>
22 #include <l4/re/util/cap_alloc>
24 #define DEBUG_OSL_PORT_IO 0
28 AcpiOsInitialize (void)
34 AcpiOsTerminate (void)
40 AcpiOsAllocate (ACPI_SIZE size)
46 AcpiOsFree (void * memory)
53 AcpiOsSleep (ACPI_INTEGER milliseconds)
55 l4_sleep(milliseconds);
59 AcpiOsStall (uint32_t microseconds)
61 l4_usleep(microseconds);
65 /******************************************************************************
67 * FUNCTION: AcpiOsPredefinedOverride
69 * PARAMETERS: InitVal - Initial value of the predefined object
70 * NewVal - The new value for the object
72 * RETURN: Status, pointer to value. Null pointer returned if not
75 * DESCRIPTION: Allow the OS to override predefined names
77 *****************************************************************************/
80 AcpiOsPredefinedOverride (
81 const ACPI_PREDEFINED_NAMES *InitVal,
85 if (!InitVal || !NewVal)
87 return (AE_BAD_PARAMETER);
95 /******************************************************************************
97 * FUNCTION: AcpiOsTableOverride
99 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
100 * NewTable - Where an entire new table is returned.
102 * RETURN: Status, pointer to new table. Null pointer returned if no
103 * table is available to override
105 * DESCRIPTION: Return a different version of a table if one is available
107 *****************************************************************************/
110 AcpiOsTableOverride (
111 ACPI_TABLE_HEADER *ExistingTable,
112 ACPI_TABLE_HEADER **NewTable)
115 if (!ExistingTable || !NewTable)
117 return (AE_BAD_PARAMETER);
124 /* This code exercises the table override mechanism in the core */
126 if (ACPI_COMPARE_NAME (ExistingTable->Signature, ACPI_SIG_DSDT))
128 /* override DSDT with itself */
130 *NewTable = AcpiGbl_DbTablePtr;
134 return AE_NO_ACPI_TABLES;
139 * ACPI Table interfaces
141 ACPI_PHYSICAL_ADDRESS
142 AcpiOsGetRootPointer (void)
144 ACPI_SIZE table_address = 0;
145 printf("Find root Pointer\n");
146 AcpiFindRootPointer(&table_address);
147 printf("Find root Pointer: %lx\n", (unsigned long)table_address);
148 return (ACPI_PHYSICAL_ADDRESS)table_address;
151 /******************************************************************************
153 * FUNCTION: AcpiOsSignal
155 * PARAMETERS: Function ACPI CA signal function code
156 * Info Pointer to function-dependent structure
160 * DESCRIPTION: Miscellaneous functions
162 *****************************************************************************/
172 case ACPI_SIGNAL_FATAL:
175 case ACPI_SIGNAL_BREAKPOINT:
179 AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info);
183 AcpiOsPrintf ("At AcpiOsBreakpoint ****\n");
193 /******************************************************************************
195 * FUNCTION: AcpiOsGetTimer
199 * RETURN: Current time in 100 nanosecond units
201 * DESCRIPTION: Get the current system time
203 *****************************************************************************/
206 AcpiOsGetTimer (void)
210 gettimeofday(&time, NULL);
212 /* Seconds * 10^7 = 100ns(10^-7), Microseconds(10^-6) * 10^1 = 100ns */
214 return (((UINT64) time.tv_sec * 10000000) + ((UINT64) time.tv_usec * 10));
218 // from: acpica/source/os_specific/service_layers/osunixxf.c
219 /******************************************************************************
221 * FUNCTION: AcpiOsReadMemory
223 * PARAMETERS: Address - Physical Memory Address to read
224 * Value - Where value is placed
225 * Width - Number of bits (8,16,32, or 64)
227 * RETURN: Value read from physical memory address. Always returned
228 * as a 64-bit integer, regardless of the read width.
230 * DESCRIPTION: Read data from a physical memory address
232 *****************************************************************************/
236 ACPI_PHYSICAL_ADDRESS Address,
241 printf("%s:%d:%s(%lx, %p, %u): UNINPLEMENTED\n",
242 __FILE__, __LINE__, __func__, (unsigned long)Address, Value, Width);
253 return (AE_BAD_PARAMETER);
259 /******************************************************************************
261 * FUNCTION: AcpiOsWriteMemory
263 * PARAMETERS: Address - Physical Memory Address to write
264 * Value - Value to write
265 * Width - Number of bits (8,16,32, or 64)
269 * DESCRIPTION: Write data to a physical memory address
271 *****************************************************************************/
275 ACPI_PHYSICAL_ADDRESS Address,
279 printf("%s:%d:%s(%lx, %llu, %u): UNINPLEMENTED\n",
280 __FILE__, __LINE__, __func__, (unsigned long)Address, Value, Width);
285 /******************************************************************************
287 * FUNCTION: AcpiOsPhysicalTableOverride
289 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
290 * NewAddress - Where new table address is returned
292 * NewTableLength - Where new table length is returned
294 * RETURN: Status, address/length of new table. Null pointer returned
295 * if no table is available to override.
297 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
299 *****************************************************************************/
302 AcpiOsPhysicalTableOverride (
303 ACPI_TABLE_HEADER *ExistingTable,
304 ACPI_PHYSICAL_ADDRESS *NewAddress,
305 UINT32 *NewTableLength)
308 (void)NewTableLength;
313 /******************************************************************************
315 * FUNCTION: AcpiOsWaitEventsComplete
321 * DESCRIPTION: Wait for all asynchronous events to complete. This
322 * implementation does nothing.
324 *****************************************************************************/
327 AcpiOsWaitEventsComplete (