1 /******************************************************************************
3 * Module Name: oswinxf - Windows OSL
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2014, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
48 #pragma warning(disable:4115) /* warning C4115: named type definition in parentheses (caused by rpcasync.h> */
63 #define _COMPONENT ACPI_OS_SERVICES
64 ACPI_MODULE_NAME ("oswinxf")
67 FILE *AcpiGbl_OutputFile;
68 UINT64 TimerFrequency;
69 char TableName[ACPI_NAME_SIZE + 1];
71 #define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */
74 /* Upcalls to AcpiExec application */
77 AeLocalGetRootPointer (
82 ACPI_TABLE_HEADER *ExistingTable,
83 ACPI_TABLE_HEADER **NewTable);
86 * Real semaphores are only used for a multi-threaded application
88 #ifndef ACPI_SINGLE_THREADED
90 /* Semaphore information structure */
92 typedef struct acpi_os_semaphore_info
98 } ACPI_OS_SEMAPHORE_INFO;
100 /* Need enough semaphores to run the large aslts suite */
102 #define ACPI_OS_MAX_SEMAPHORES 256
104 ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES];
106 #endif /* ACPI_SINGLE_THREADED */
108 BOOLEAN AcpiGbl_DebugTimeout = FALSE;
110 /******************************************************************************
112 * FUNCTION: AcpiOsTerminate
118 * DESCRIPTION: Nothing to do for windows
120 *****************************************************************************/
130 /******************************************************************************
132 * FUNCTION: AcpiOsInitialize
138 * DESCRIPTION: Init this OSL
140 *****************************************************************************/
146 LARGE_INTEGER LocalTimerFrequency;
149 #ifndef ACPI_SINGLE_THREADED
150 /* Clear the semaphore info array */
152 memset (AcpiGbl_Semaphores, 0x00, sizeof (AcpiGbl_Semaphores));
155 AcpiGbl_OutputFile = stdout;
157 /* Get the timer frequency for use in AcpiOsGetTimer */
160 if (QueryPerformanceFrequency (&LocalTimerFrequency))
162 /* Frequency is in ticks per second */
164 TimerFrequency = LocalTimerFrequency.QuadPart;
171 /******************************************************************************
173 * FUNCTION: AcpiOsGetRootPointer
177 * RETURN: RSDP physical address
179 * DESCRIPTION: Gets the root pointer (RSDP)
181 *****************************************************************************/
183 ACPI_PHYSICAL_ADDRESS
184 AcpiOsGetRootPointer (
188 return (AeLocalGetRootPointer ());
192 /******************************************************************************
194 * FUNCTION: AcpiOsPredefinedOverride
196 * PARAMETERS: InitVal - Initial value of the predefined object
197 * NewVal - The new value for the object
199 * RETURN: Status, pointer to value. Null pointer returned if not
202 * DESCRIPTION: Allow the OS to override predefined names
204 *****************************************************************************/
207 AcpiOsPredefinedOverride (
208 const ACPI_PREDEFINED_NAMES *InitVal,
212 if (!InitVal || !NewVal)
214 return (AE_BAD_PARAMETER);
222 /******************************************************************************
224 * FUNCTION: AcpiOsTableOverride
226 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
227 * NewTable - Where an entire new table is returned.
229 * RETURN: Status, pointer to new table. Null pointer returned if no
230 * table is available to override
232 * DESCRIPTION: Return a different version of a table if one is available
234 *****************************************************************************/
237 AcpiOsTableOverride (
238 ACPI_TABLE_HEADER *ExistingTable,
239 ACPI_TABLE_HEADER **NewTable)
242 if (!ExistingTable || !NewTable)
244 return (AE_BAD_PARAMETER);
252 /* Call back up to AcpiExec */
254 AeTableOverride (ExistingTable, NewTable);
261 /******************************************************************************
263 * FUNCTION: AcpiOsPhysicalTableOverride
265 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
266 * NewAddress - Where new table address is returned
268 * NewTableLength - Where new table length is returned
270 * RETURN: Status, address/length of new table. Null pointer returned
271 * if no table is available to override.
273 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
275 *****************************************************************************/
278 AcpiOsPhysicalTableOverride (
279 ACPI_TABLE_HEADER *ExistingTable,
280 ACPI_PHYSICAL_ADDRESS *NewAddress,
281 UINT32 *NewTableLength)
288 /******************************************************************************
290 * FUNCTION: AcpiOsGetTimer
294 * RETURN: Current ticks in 100-nanosecond units
296 * DESCRIPTION: Get the value of a system timer
298 ******************************************************************************/
307 /* Attempt to use hi-granularity timer first */
309 if (TimerFrequency &&
310 QueryPerformanceCounter (&Timer))
312 /* Convert to 100 nanosecond ticks */
314 return ((UINT64) ((Timer.QuadPart * (UINT64) ACPI_100NSEC_PER_SEC) /
318 /* Fall back to the lo-granularity timer */
322 /* Convert milliseconds to 100 nanosecond ticks */
324 return ((UINT64) GetTickCount() * ACPI_100NSEC_PER_MSEC);
329 /******************************************************************************
331 * FUNCTION: AcpiOsReadable
333 * PARAMETERS: Pointer - Area to be verified
334 * Length - Size of area
336 * RETURN: TRUE if readable for entire length
338 * DESCRIPTION: Verify that a pointer is valid for reading
340 *****************************************************************************/
348 return ((BOOLEAN) !IsBadReadPtr (Pointer, Length));
352 /******************************************************************************
354 * FUNCTION: AcpiOsWritable
356 * PARAMETERS: Pointer - Area to be verified
357 * Length - Size of area
359 * RETURN: TRUE if writable for entire length
361 * DESCRIPTION: Verify that a pointer is valid for writing
363 *****************************************************************************/
371 return ((BOOLEAN) !IsBadWritePtr (Pointer, Length));
375 /******************************************************************************
377 * FUNCTION: AcpiOsRedirectOutput
379 * PARAMETERS: Destination - An open file handle/pointer
383 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
385 *****************************************************************************/
388 AcpiOsRedirectOutput (
392 AcpiGbl_OutputFile = Destination;
396 /******************************************************************************
398 * FUNCTION: AcpiOsPrintf
400 * PARAMETERS: Fmt, ... - Standard printf format
404 * DESCRIPTION: Formatted output
406 *****************************************************************************/
408 void ACPI_INTERNAL_VAR_XFACE
417 Flags = AcpiGbl_DbOutputFlags;
418 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
420 /* Output is directable to either a file (if open) or the console */
422 if (AcpiGbl_DebugFile)
424 /* Output file is open, send the output there */
426 va_start (Args, Fmt);
427 vfprintf (AcpiGbl_DebugFile, Fmt, Args);
432 /* No redirection, send output to console (once only!) */
434 Flags |= ACPI_DB_CONSOLE_OUTPUT;
438 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
440 va_start (Args, Fmt);
441 vfprintf (AcpiGbl_OutputFile, Fmt, Args);
449 /******************************************************************************
451 * FUNCTION: AcpiOsVprintf
453 * PARAMETERS: Fmt - Standard printf format
454 * Args - Argument list
458 * DESCRIPTION: Formatted output with argument list pointer
460 *****************************************************************************/
471 Flags = AcpiGbl_DbOutputFlags;
472 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
474 /* Output is directable to either a file (if open) or the console */
476 if (AcpiGbl_DebugFile)
478 /* Output file is open, send the output there */
480 Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
484 /* No redirection, send output to console (once only!) */
486 Flags |= ACPI_DB_CONSOLE_OUTPUT;
490 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
492 Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
499 /******************************************************************************
501 * FUNCTION: AcpiOsGetLine
503 * PARAMETERS: Buffer - Where to return the command line
504 * BufferLength - Maximum length of Buffer
505 * BytesRead - Where the actual byte count is returned
507 * RETURN: Status and actual bytes read
509 * DESCRIPTION: Formatted input with argument list pointer
511 *****************************************************************************/
525 if (i >= BufferLength)
527 return (AE_BUFFER_OVERFLOW);
530 if ((Temp = getchar ()) == EOF)
535 if (!Temp || Temp == '\n')
540 Buffer [i] = (char) Temp;
543 /* Null terminate the buffer */
547 /* Return the number of bytes in the string */
557 /******************************************************************************
559 * FUNCTION: AcpiOsMapMemory
561 * PARAMETERS: Where - Physical address of memory to be mapped
562 * Length - How much memory to map
564 * RETURN: Pointer to mapped memory. Null on error.
566 * DESCRIPTION: Map physical memory into caller's address space
568 *****************************************************************************/
572 ACPI_PHYSICAL_ADDRESS Where,
576 return (ACPI_TO_POINTER ((ACPI_SIZE) Where));
580 /******************************************************************************
582 * FUNCTION: AcpiOsUnmapMemory
584 * PARAMETERS: Where - Logical address of memory to be unmapped
585 * Length - How much memory to unmap
589 * DESCRIPTION: Delete a previously created mapping. Where and Length must
590 * correspond to a previous mapping exactly.
592 *****************************************************************************/
604 /******************************************************************************
606 * FUNCTION: AcpiOsAllocate
608 * PARAMETERS: Size - Amount to allocate, in bytes
610 * RETURN: Pointer to the new allocation. Null on error.
612 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
614 *****************************************************************************/
623 Mem = (void *) malloc ((size_t) Size);
629 /******************************************************************************
631 * FUNCTION: AcpiOsFree
633 * PARAMETERS: Mem - Pointer to previously allocated memory
637 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
639 *****************************************************************************/
650 #ifdef ACPI_SINGLE_THREADED
651 /******************************************************************************
653 * FUNCTION: Semaphore stub functions
655 * DESCRIPTION: Stub functions used for single-thread applications that do
656 * not require semaphore synchronization. Full implementations
657 * of these functions appear after the stubs.
659 *****************************************************************************/
662 AcpiOsCreateSemaphore (
665 ACPI_HANDLE *OutHandle)
667 *OutHandle = (ACPI_HANDLE) 1;
672 AcpiOsDeleteSemaphore (
679 AcpiOsWaitSemaphore (
688 AcpiOsSignalSemaphore (
696 /******************************************************************************
698 * FUNCTION: AcpiOsCreateSemaphore
700 * PARAMETERS: MaxUnits - Maximum units that can be sent
701 * InitialUnits - Units to be assigned to the new semaphore
702 * OutHandle - Where a handle will be returned
706 * DESCRIPTION: Create an OS semaphore
708 *****************************************************************************/
711 AcpiOsCreateSemaphore (
714 ACPI_SEMAPHORE *OutHandle)
719 ACPI_FUNCTION_NAME (OsCreateSemaphore);
722 if (MaxUnits == ACPI_UINT32_MAX)
727 if (InitialUnits == ACPI_UINT32_MAX)
729 InitialUnits = MaxUnits;
732 if (InitialUnits > MaxUnits)
734 return (AE_BAD_PARAMETER);
737 /* Find an empty slot */
739 for (i = 0; i < ACPI_OS_MAX_SEMAPHORES; i++)
741 if (!AcpiGbl_Semaphores[i].OsHandle)
746 if (i >= ACPI_OS_MAX_SEMAPHORES)
748 ACPI_EXCEPTION ((AE_INFO, AE_LIMIT,
749 "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES));
753 /* Create an OS semaphore */
755 Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
758 ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
759 return (AE_NO_MEMORY);
762 AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
763 AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
764 AcpiGbl_Semaphores[i].OsHandle = Mutex;
766 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
767 i, MaxUnits, InitialUnits, Mutex));
769 *OutHandle = (void *) i;
774 /******************************************************************************
776 * FUNCTION: AcpiOsDeleteSemaphore
778 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
782 * DESCRIPTION: Delete an OS semaphore
784 *****************************************************************************/
787 AcpiOsDeleteSemaphore (
788 ACPI_SEMAPHORE Handle)
790 UINT32 Index = (UINT32) Handle;
793 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
794 !AcpiGbl_Semaphores[Index].OsHandle)
796 return (AE_BAD_PARAMETER);
799 CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
800 AcpiGbl_Semaphores[Index].OsHandle = NULL;
805 /******************************************************************************
807 * FUNCTION: AcpiOsWaitSemaphore
809 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
810 * Units - How many units to wait for
811 * Timeout - How long to wait
815 * DESCRIPTION: Wait for units
817 *****************************************************************************/
820 AcpiOsWaitSemaphore (
821 ACPI_SEMAPHORE Handle,
825 UINT32 Index = (UINT32) Handle;
827 UINT32 OsTimeout = Timeout;
830 ACPI_FUNCTION_ENTRY ();
833 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
834 !AcpiGbl_Semaphores[Index].OsHandle)
836 return (AE_BAD_PARAMETER);
841 printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
842 return (AE_NOT_IMPLEMENTED);
845 if (Timeout == ACPI_WAIT_FOREVER)
847 OsTimeout = INFINITE;
848 if (AcpiGbl_DebugTimeout)
850 /* The debug timeout will prevent hang conditions */
852 OsTimeout = ACPI_OS_DEBUG_TIMEOUT;
857 /* Add 10ms to account for clock tick granularity */
862 WaitStatus = WaitForSingleObject (AcpiGbl_Semaphores[Index].OsHandle, OsTimeout);
863 if (WaitStatus == WAIT_TIMEOUT)
865 if (AcpiGbl_DebugTimeout)
867 ACPI_EXCEPTION ((AE_INFO, AE_TIME,
868 "Debug timeout on semaphore 0x%04X (%ums)\n",
869 Index, ACPI_OS_DEBUG_TIMEOUT));
874 if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
876 ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
877 AcpiUtGetMutexName (Index), Timeout, WaitStatus));
882 AcpiGbl_Semaphores[Index].CurrentUnits--;
887 /******************************************************************************
889 * FUNCTION: AcpiOsSignalSemaphore
891 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
892 * Units - Number of units to send
896 * DESCRIPTION: Send units
898 *****************************************************************************/
901 AcpiOsSignalSemaphore (
902 ACPI_SEMAPHORE Handle,
905 UINT32 Index = (UINT32) Handle;
908 ACPI_FUNCTION_ENTRY ();
911 if (Index >= ACPI_OS_MAX_SEMAPHORES)
913 printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
914 return (AE_BAD_PARAMETER);
917 if (!AcpiGbl_Semaphores[Index].OsHandle)
919 printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
920 return (AE_BAD_PARAMETER);
925 printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index);
926 return (AE_NOT_IMPLEMENTED);
929 if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) >
930 AcpiGbl_Semaphores[Index].MaxUnits)
932 ACPI_ERROR ((AE_INFO,
933 "Oversignalled semaphore[%u]! Current %u Max %u",
934 Index, AcpiGbl_Semaphores[Index].CurrentUnits,
935 AcpiGbl_Semaphores[Index].MaxUnits));
940 AcpiGbl_Semaphores[Index].CurrentUnits++;
941 ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
946 #endif /* ACPI_SINGLE_THREADED */
949 /******************************************************************************
951 * FUNCTION: Spinlock interfaces
953 * DESCRIPTION: Map these interfaces to semaphore interfaces
955 *****************************************************************************/
959 ACPI_SPINLOCK *OutHandle)
961 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
966 ACPI_SPINLOCK Handle)
968 AcpiOsDeleteSemaphore (Handle);
973 ACPI_SPINLOCK Handle)
975 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
981 ACPI_SPINLOCK Handle,
982 ACPI_CPU_FLAGS Flags)
984 AcpiOsSignalSemaphore (Handle, 1);
988 #if ACPI_FUTURE_IMPLEMENTATION
990 /* Mutex interfaces, just implement with a semaphore */
994 ACPI_MUTEX *OutHandle)
996 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1003 AcpiOsDeleteSemaphore (Handle);
1007 AcpiOsAcquireMutex (
1011 AcpiOsWaitSemaphore (Handle, 1, Timeout);
1016 AcpiOsReleaseMutex (
1019 AcpiOsSignalSemaphore (Handle, 1);
1024 /******************************************************************************
1026 * FUNCTION: AcpiOsInstallInterruptHandler
1028 * PARAMETERS: InterruptNumber - Level handler should respond to.
1029 * ServiceRoutine - Address of the ACPI interrupt handler
1030 * Context - User context
1032 * RETURN: Handle to the newly installed handler.
1034 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1035 * OS-independent handler.
1037 *****************************************************************************/
1040 AcpiOsInstallInterruptHandler (
1041 UINT32 InterruptNumber,
1042 ACPI_OSD_HANDLER ServiceRoutine,
1050 /******************************************************************************
1052 * FUNCTION: AcpiOsRemoveInterruptHandler
1054 * PARAMETERS: Handle - Returned when handler was installed
1058 * DESCRIPTION: Uninstalls an interrupt handler.
1060 *****************************************************************************/
1063 AcpiOsRemoveInterruptHandler (
1064 UINT32 InterruptNumber,
1065 ACPI_OSD_HANDLER ServiceRoutine)
1072 /******************************************************************************
1074 * FUNCTION: AcpiOsStall
1076 * PARAMETERS: Microseconds - Time to stall
1078 * RETURN: None. Blocks until stall is completed.
1080 * DESCRIPTION: Sleep at microsecond granularity
1082 *****************************************************************************/
1086 UINT32 Microseconds)
1089 Sleep ((Microseconds / ACPI_USEC_PER_MSEC) + 1);
1094 /******************************************************************************
1096 * FUNCTION: AcpiOsSleep
1098 * PARAMETERS: Milliseconds - Time to sleep
1100 * RETURN: None. Blocks until sleep is completed.
1102 * DESCRIPTION: Sleep at millisecond granularity
1104 *****************************************************************************/
1108 UINT64 Milliseconds)
1111 /* Add 10ms to account for clock tick granularity */
1113 Sleep (((unsigned long) Milliseconds) + 10);
1118 /******************************************************************************
1120 * FUNCTION: AcpiOsReadPciConfiguration
1122 * PARAMETERS: PciId - Seg/Bus/Dev
1123 * Register - Device Register
1124 * Value - Buffer where value is placed
1125 * Width - Number of bits
1129 * DESCRIPTION: Read data from PCI configuration space
1131 *****************************************************************************/
1134 AcpiOsReadPciConfiguration (
1146 /******************************************************************************
1148 * FUNCTION: AcpiOsWritePciConfiguration
1150 * PARAMETERS: PciId - Seg/Bus/Dev
1151 * Register - Device Register
1152 * Value - Value to be written
1153 * Width - Number of bits
1157 * DESCRIPTION: Write data to PCI configuration space
1159 *****************************************************************************/
1162 AcpiOsWritePciConfiguration (
1173 /******************************************************************************
1175 * FUNCTION: AcpiOsReadPort
1177 * PARAMETERS: Address - Address of I/O port/register to read
1178 * Value - Where value is placed
1179 * Width - Number of bits
1181 * RETURN: Value read from port
1183 * DESCRIPTION: Read data from an I/O port or register
1185 *****************************************************************************/
1189 ACPI_IO_ADDRESS Address,
1193 ACPI_FUNCTION_NAME (OsReadPort);
1210 *Value = 0xFFFFFFFF;
1215 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1216 return (AE_BAD_PARAMETER);
1223 /******************************************************************************
1225 * FUNCTION: AcpiOsWritePort
1227 * PARAMETERS: Address - Address of I/O port/register to write
1228 * Value - Value to write
1229 * Width - Number of bits
1233 * DESCRIPTION: Write data to an I/O port or register
1235 *****************************************************************************/
1239 ACPI_IO_ADDRESS Address,
1243 ACPI_FUNCTION_NAME (OsWritePort);
1246 if ((Width == 8) || (Width == 16) || (Width == 32))
1251 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1252 return (AE_BAD_PARAMETER);
1256 /******************************************************************************
1258 * FUNCTION: AcpiOsReadMemory
1260 * PARAMETERS: Address - Physical Memory Address to read
1261 * Value - Where value is placed
1262 * Width - Number of bits (8,16,32, or 64)
1264 * RETURN: Value read from physical memory address. Always returned
1265 * as a 64-bit integer, regardless of the read width.
1267 * DESCRIPTION: Read data from a physical memory address
1269 *****************************************************************************/
1273 ACPI_PHYSICAL_ADDRESS Address,
1290 return (AE_BAD_PARAMETER);
1298 /******************************************************************************
1300 * FUNCTION: AcpiOsWriteMemory
1302 * PARAMETERS: Address - Physical Memory Address to write
1303 * Value - Value to write
1304 * Width - Number of bits (8,16,32, or 64)
1308 * DESCRIPTION: Write data to a physical memory address
1310 *****************************************************************************/
1314 ACPI_PHYSICAL_ADDRESS Address,
1323 /******************************************************************************
1325 * FUNCTION: AcpiOsSignal
1327 * PARAMETERS: Function - ACPI CA signal function code
1328 * Info - Pointer to function-dependent structure
1332 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1334 *****************************************************************************/
1344 case ACPI_SIGNAL_FATAL:
1348 case ACPI_SIGNAL_BREAKPOINT:
1361 /******************************************************************************
1363 * FUNCTION: Local cache interfaces
1365 * DESCRIPTION: Implements cache interfaces via malloc/free for testing
1368 *****************************************************************************/
1370 #ifndef ACPI_USE_LOCAL_CACHE
1377 ACPI_CACHE_T **ReturnCache)
1379 ACPI_MEMORY_LIST *NewCache;
1382 NewCache = malloc (sizeof (ACPI_MEMORY_LIST));
1385 return (AE_NO_MEMORY);
1388 memset (NewCache, 0, sizeof (ACPI_MEMORY_LIST));
1389 NewCache->ListName = CacheName;
1390 NewCache->ObjectSize = ObjectSize;
1391 NewCache->MaxDepth = MaxDepth;
1393 *ReturnCache = (ACPI_CACHE_T) NewCache;
1399 ACPI_CACHE_T *Cache)
1407 ACPI_CACHE_T *Cache)
1413 AcpiOsAcquireObject (
1414 ACPI_CACHE_T *Cache)
1418 NewObject = malloc (((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1419 memset (NewObject, 0, ((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1425 AcpiOsReleaseObject (
1426 ACPI_CACHE_T *Cache,
1433 #endif /* ACPI_USE_LOCAL_CACHE */
1436 /* Optional multi-thread support */
1438 #ifndef ACPI_SINGLE_THREADED
1439 /******************************************************************************
1441 * FUNCTION: AcpiOsGetThreadId
1445 * RETURN: Id of the running thread
1447 * DESCRIPTION: Get the Id of the current (running) thread
1449 *****************************************************************************/
1457 /* Ensure ID is never 0 */
1459 ThreadId = GetCurrentThreadId ();
1460 return ((ACPI_THREAD_ID) (ThreadId + 1));
1464 /******************************************************************************
1466 * FUNCTION: AcpiOsExecute
1468 * PARAMETERS: Type - Type of execution
1469 * Function - Address of the function to execute
1470 * Context - Passed as a parameter to the function
1474 * DESCRIPTION: Execute a new thread
1476 *****************************************************************************/
1480 ACPI_EXECUTE_TYPE Type,
1481 ACPI_OSD_EXEC_CALLBACK Function,
1485 _beginthread (Function, (unsigned) 0, Context);
1489 #endif /* ACPI_SINGLE_THREADED */
1492 /******************************************************************************
1494 * FUNCTION: AcpiOsWaitEventsComplete
1500 * DESCRIPTION: Wait for all asynchronous events to complete. This
1501 * implementation does nothing.
1503 *****************************************************************************/
1506 AcpiOsWaitEventsComplete (