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 UINT64 TimerFrequency;
68 char TableName[ACPI_NAME_SIZE + 1];
70 #define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */
73 /* Upcalls to AcpiExec application */
77 ACPI_TABLE_HEADER *ExistingTable,
78 ACPI_TABLE_HEADER **NewTable);
81 * Real semaphores are only used for a multi-threaded application
83 #ifndef ACPI_SINGLE_THREADED
85 /* Semaphore information structure */
87 typedef struct acpi_os_semaphore_info
93 } ACPI_OS_SEMAPHORE_INFO;
95 /* Need enough semaphores to run the large aslts suite */
97 #define ACPI_OS_MAX_SEMAPHORES 256
99 ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES];
101 #endif /* ACPI_SINGLE_THREADED */
103 BOOLEAN AcpiGbl_DebugTimeout = FALSE;
105 /******************************************************************************
107 * FUNCTION: AcpiOsTerminate
113 * DESCRIPTION: Nothing to do for windows
115 *****************************************************************************/
125 /******************************************************************************
127 * FUNCTION: AcpiOsInitialize
133 * DESCRIPTION: Init this OSL
135 *****************************************************************************/
142 LARGE_INTEGER LocalTimerFrequency;
145 #ifndef ACPI_SINGLE_THREADED
146 /* Clear the semaphore info array */
148 memset (AcpiGbl_Semaphores, 0x00, sizeof (AcpiGbl_Semaphores));
151 AcpiGbl_OutputFile = stdout;
153 /* Get the timer frequency for use in AcpiOsGetTimer */
156 if (QueryPerformanceFrequency (&LocalTimerFrequency))
158 /* Frequency is in ticks per second */
160 TimerFrequency = LocalTimerFrequency.QuadPart;
163 Status = AcpiOsCreateLock (&AcpiGbl_PrintLock);
164 if (ACPI_FAILURE (Status))
173 #ifndef ACPI_USE_NATIVE_RSDP_POINTER
174 /******************************************************************************
176 * FUNCTION: AcpiOsGetRootPointer
180 * RETURN: RSDP physical address
182 * DESCRIPTION: Gets the root pointer (RSDP)
184 *****************************************************************************/
186 ACPI_PHYSICAL_ADDRESS
187 AcpiOsGetRootPointer (
196 /******************************************************************************
198 * FUNCTION: AcpiOsPredefinedOverride
200 * PARAMETERS: InitVal - Initial value of the predefined object
201 * NewVal - The new value for the object
203 * RETURN: Status, pointer to value. Null pointer returned if not
206 * DESCRIPTION: Allow the OS to override predefined names
208 *****************************************************************************/
211 AcpiOsPredefinedOverride (
212 const ACPI_PREDEFINED_NAMES *InitVal,
216 if (!InitVal || !NewVal)
218 return (AE_BAD_PARAMETER);
226 /******************************************************************************
228 * FUNCTION: AcpiOsTableOverride
230 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
231 * NewTable - Where an entire new table is returned.
233 * RETURN: Status, pointer to new table. Null pointer returned if no
234 * table is available to override
236 * DESCRIPTION: Return a different version of a table if one is available
238 *****************************************************************************/
241 AcpiOsTableOverride (
242 ACPI_TABLE_HEADER *ExistingTable,
243 ACPI_TABLE_HEADER **NewTable)
246 if (!ExistingTable || !NewTable)
248 return (AE_BAD_PARAMETER);
256 /* Call back up to AcpiExec */
258 AeTableOverride (ExistingTable, NewTable);
265 /******************************************************************************
267 * FUNCTION: AcpiOsPhysicalTableOverride
269 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
270 * NewAddress - Where new table address is returned
272 * NewTableLength - Where new table length is returned
274 * RETURN: Status, address/length of new table. Null pointer returned
275 * if no table is available to override.
277 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
279 *****************************************************************************/
282 AcpiOsPhysicalTableOverride (
283 ACPI_TABLE_HEADER *ExistingTable,
284 ACPI_PHYSICAL_ADDRESS *NewAddress,
285 UINT32 *NewTableLength)
292 /******************************************************************************
294 * FUNCTION: AcpiOsGetTimer
298 * RETURN: Current ticks in 100-nanosecond units
300 * DESCRIPTION: Get the value of a system timer
302 ******************************************************************************/
311 /* Attempt to use hi-granularity timer first */
313 if (TimerFrequency &&
314 QueryPerformanceCounter (&Timer))
316 /* Convert to 100 nanosecond ticks */
318 return ((UINT64) ((Timer.QuadPart * (UINT64) ACPI_100NSEC_PER_SEC) /
322 /* Fall back to the lo-granularity timer */
326 /* Convert milliseconds to 100 nanosecond ticks */
328 return ((UINT64) GetTickCount() * ACPI_100NSEC_PER_MSEC);
333 /******************************************************************************
335 * FUNCTION: AcpiOsReadable
337 * PARAMETERS: Pointer - Area to be verified
338 * Length - Size of area
340 * RETURN: TRUE if readable for entire length
342 * DESCRIPTION: Verify that a pointer is valid for reading
344 *****************************************************************************/
352 return ((BOOLEAN) !IsBadReadPtr (Pointer, Length));
356 /******************************************************************************
358 * FUNCTION: AcpiOsWritable
360 * PARAMETERS: Pointer - Area to be verified
361 * Length - Size of area
363 * RETURN: TRUE if writable for entire length
365 * DESCRIPTION: Verify that a pointer is valid for writing
367 *****************************************************************************/
375 return ((BOOLEAN) !IsBadWritePtr (Pointer, Length));
379 /******************************************************************************
381 * FUNCTION: AcpiOsRedirectOutput
383 * PARAMETERS: Destination - An open file handle/pointer
387 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
389 *****************************************************************************/
392 AcpiOsRedirectOutput (
396 AcpiGbl_OutputFile = Destination;
400 /******************************************************************************
402 * FUNCTION: AcpiOsPrintf
404 * PARAMETERS: Fmt, ... - Standard printf format
408 * DESCRIPTION: Formatted output
410 *****************************************************************************/
412 void ACPI_INTERNAL_VAR_XFACE
421 Flags = AcpiGbl_DbOutputFlags;
422 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
424 /* Output is directable to either a file (if open) or the console */
426 if (AcpiGbl_DebugFile)
428 /* Output file is open, send the output there */
430 va_start (Args, Fmt);
431 vfprintf (AcpiGbl_DebugFile, Fmt, Args);
436 /* No redirection, send output to console (once only!) */
438 Flags |= ACPI_DB_CONSOLE_OUTPUT;
442 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
444 va_start (Args, Fmt);
445 vfprintf (AcpiGbl_OutputFile, Fmt, Args);
453 /******************************************************************************
455 * FUNCTION: AcpiOsVprintf
457 * PARAMETERS: Fmt - Standard printf format
458 * Args - Argument list
462 * DESCRIPTION: Formatted output with argument list pointer
464 *****************************************************************************/
475 Flags = AcpiGbl_DbOutputFlags;
476 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
478 /* Output is directable to either a file (if open) or the console */
480 if (AcpiGbl_DebugFile)
482 /* Output file is open, send the output there */
484 Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
488 /* No redirection, send output to console (once only!) */
490 Flags |= ACPI_DB_CONSOLE_OUTPUT;
494 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
496 Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
503 /******************************************************************************
505 * FUNCTION: AcpiOsGetLine
507 * PARAMETERS: Buffer - Where to return the command line
508 * BufferLength - Maximum length of Buffer
509 * BytesRead - Where the actual byte count is returned
511 * RETURN: Status and actual bytes read
513 * DESCRIPTION: Formatted input with argument list pointer
515 *****************************************************************************/
529 if (i >= BufferLength)
531 return (AE_BUFFER_OVERFLOW);
534 if ((Temp = getchar ()) == EOF)
539 if (!Temp || Temp == '\n')
544 Buffer [i] = (char) Temp;
547 /* Null terminate the buffer */
551 /* Return the number of bytes in the string */
561 #ifndef ACPI_USE_NATIVE_MEMORY_MAPPING
562 /******************************************************************************
564 * FUNCTION: AcpiOsMapMemory
566 * PARAMETERS: Where - Physical address of memory to be mapped
567 * Length - How much memory to map
569 * RETURN: Pointer to mapped memory. Null on error.
571 * DESCRIPTION: Map physical memory into caller's address space
573 *****************************************************************************/
577 ACPI_PHYSICAL_ADDRESS Where,
581 return (ACPI_TO_POINTER ((ACPI_SIZE) Where));
585 /******************************************************************************
587 * FUNCTION: AcpiOsUnmapMemory
589 * PARAMETERS: Where - Logical address of memory to be unmapped
590 * Length - How much memory to unmap
594 * DESCRIPTION: Delete a previously created mapping. Where and Length must
595 * correspond to a previous mapping exactly.
597 *****************************************************************************/
610 /******************************************************************************
612 * FUNCTION: AcpiOsAllocate
614 * PARAMETERS: Size - Amount to allocate, in bytes
616 * RETURN: Pointer to the new allocation. Null on error.
618 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
620 *****************************************************************************/
629 Mem = (void *) malloc ((size_t) Size);
635 #ifdef USE_NATIVE_ALLOCATE_ZEROED
636 /******************************************************************************
638 * FUNCTION: AcpiOsAllocateZeroed
640 * PARAMETERS: Size - Amount to allocate, in bytes
642 * RETURN: Pointer to the new allocation. Null on error.
644 * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
646 *****************************************************************************/
649 AcpiOsAllocateZeroed (
655 Mem = (void *) calloc (1, (size_t) Size);
662 /******************************************************************************
664 * FUNCTION: AcpiOsFree
666 * PARAMETERS: Mem - Pointer to previously allocated memory
670 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
672 *****************************************************************************/
683 #ifdef ACPI_SINGLE_THREADED
684 /******************************************************************************
686 * FUNCTION: Semaphore stub functions
688 * DESCRIPTION: Stub functions used for single-thread applications that do
689 * not require semaphore synchronization. Full implementations
690 * of these functions appear after the stubs.
692 *****************************************************************************/
695 AcpiOsCreateSemaphore (
698 ACPI_HANDLE *OutHandle)
700 *OutHandle = (ACPI_HANDLE) 1;
705 AcpiOsDeleteSemaphore (
712 AcpiOsWaitSemaphore (
721 AcpiOsSignalSemaphore (
729 /******************************************************************************
731 * FUNCTION: AcpiOsCreateSemaphore
733 * PARAMETERS: MaxUnits - Maximum units that can be sent
734 * InitialUnits - Units to be assigned to the new semaphore
735 * OutHandle - Where a handle will be returned
739 * DESCRIPTION: Create an OS semaphore
741 *****************************************************************************/
744 AcpiOsCreateSemaphore (
747 ACPI_SEMAPHORE *OutHandle)
752 ACPI_FUNCTION_NAME (OsCreateSemaphore);
755 if (MaxUnits == ACPI_UINT32_MAX)
760 if (InitialUnits == ACPI_UINT32_MAX)
762 InitialUnits = MaxUnits;
765 if (InitialUnits > MaxUnits)
767 return (AE_BAD_PARAMETER);
770 /* Find an empty slot */
772 for (i = 0; i < ACPI_OS_MAX_SEMAPHORES; i++)
774 if (!AcpiGbl_Semaphores[i].OsHandle)
779 if (i >= ACPI_OS_MAX_SEMAPHORES)
781 ACPI_EXCEPTION ((AE_INFO, AE_LIMIT,
782 "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES));
786 /* Create an OS semaphore */
788 Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
791 ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
792 return (AE_NO_MEMORY);
795 AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
796 AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
797 AcpiGbl_Semaphores[i].OsHandle = Mutex;
799 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
800 i, MaxUnits, InitialUnits, Mutex));
802 *OutHandle = (void *) i;
807 /******************************************************************************
809 * FUNCTION: AcpiOsDeleteSemaphore
811 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
815 * DESCRIPTION: Delete an OS semaphore
817 *****************************************************************************/
820 AcpiOsDeleteSemaphore (
821 ACPI_SEMAPHORE Handle)
823 UINT32 Index = (UINT32) Handle;
826 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
827 !AcpiGbl_Semaphores[Index].OsHandle)
829 return (AE_BAD_PARAMETER);
832 CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
833 AcpiGbl_Semaphores[Index].OsHandle = NULL;
838 /******************************************************************************
840 * FUNCTION: AcpiOsWaitSemaphore
842 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
843 * Units - How many units to wait for
844 * Timeout - How long to wait
848 * DESCRIPTION: Wait for units
850 *****************************************************************************/
853 AcpiOsWaitSemaphore (
854 ACPI_SEMAPHORE Handle,
858 UINT32 Index = (UINT32) Handle;
860 UINT32 OsTimeout = Timeout;
863 ACPI_FUNCTION_ENTRY ();
866 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
867 !AcpiGbl_Semaphores[Index].OsHandle)
869 return (AE_BAD_PARAMETER);
874 printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
875 return (AE_NOT_IMPLEMENTED);
878 if (Timeout == ACPI_WAIT_FOREVER)
880 OsTimeout = INFINITE;
881 if (AcpiGbl_DebugTimeout)
883 /* The debug timeout will prevent hang conditions */
885 OsTimeout = ACPI_OS_DEBUG_TIMEOUT;
890 /* Add 10ms to account for clock tick granularity */
895 WaitStatus = WaitForSingleObject (AcpiGbl_Semaphores[Index].OsHandle, OsTimeout);
896 if (WaitStatus == WAIT_TIMEOUT)
898 if (AcpiGbl_DebugTimeout)
900 ACPI_EXCEPTION ((AE_INFO, AE_TIME,
901 "Debug timeout on semaphore 0x%04X (%ums)\n",
902 Index, ACPI_OS_DEBUG_TIMEOUT));
907 if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
909 ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
910 AcpiUtGetMutexName (Index), Timeout, WaitStatus));
915 AcpiGbl_Semaphores[Index].CurrentUnits--;
920 /******************************************************************************
922 * FUNCTION: AcpiOsSignalSemaphore
924 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
925 * Units - Number of units to send
929 * DESCRIPTION: Send units
931 *****************************************************************************/
934 AcpiOsSignalSemaphore (
935 ACPI_SEMAPHORE Handle,
938 UINT32 Index = (UINT32) Handle;
941 ACPI_FUNCTION_ENTRY ();
944 if (Index >= ACPI_OS_MAX_SEMAPHORES)
946 printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
947 return (AE_BAD_PARAMETER);
950 if (!AcpiGbl_Semaphores[Index].OsHandle)
952 printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
953 return (AE_BAD_PARAMETER);
958 printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index);
959 return (AE_NOT_IMPLEMENTED);
962 if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) >
963 AcpiGbl_Semaphores[Index].MaxUnits)
965 ACPI_ERROR ((AE_INFO,
966 "Oversignalled semaphore[%u]! Current %u Max %u",
967 Index, AcpiGbl_Semaphores[Index].CurrentUnits,
968 AcpiGbl_Semaphores[Index].MaxUnits));
973 AcpiGbl_Semaphores[Index].CurrentUnits++;
974 ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
979 #endif /* ACPI_SINGLE_THREADED */
982 /******************************************************************************
984 * FUNCTION: Spinlock interfaces
986 * DESCRIPTION: Map these interfaces to semaphore interfaces
988 *****************************************************************************/
992 ACPI_SPINLOCK *OutHandle)
994 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
999 ACPI_SPINLOCK Handle)
1001 AcpiOsDeleteSemaphore (Handle);
1006 ACPI_SPINLOCK Handle)
1008 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
1014 ACPI_SPINLOCK Handle,
1015 ACPI_CPU_FLAGS Flags)
1017 AcpiOsSignalSemaphore (Handle, 1);
1021 #if ACPI_FUTURE_IMPLEMENTATION
1023 /* Mutex interfaces, just implement with a semaphore */
1027 ACPI_MUTEX *OutHandle)
1029 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1036 AcpiOsDeleteSemaphore (Handle);
1040 AcpiOsAcquireMutex (
1044 AcpiOsWaitSemaphore (Handle, 1, Timeout);
1049 AcpiOsReleaseMutex (
1052 AcpiOsSignalSemaphore (Handle, 1);
1057 /******************************************************************************
1059 * FUNCTION: AcpiOsInstallInterruptHandler
1061 * PARAMETERS: InterruptNumber - Level handler should respond to.
1062 * ServiceRoutine - Address of the ACPI interrupt handler
1063 * Context - User context
1065 * RETURN: Handle to the newly installed handler.
1067 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1068 * OS-independent handler.
1070 *****************************************************************************/
1073 AcpiOsInstallInterruptHandler (
1074 UINT32 InterruptNumber,
1075 ACPI_OSD_HANDLER ServiceRoutine,
1083 /******************************************************************************
1085 * FUNCTION: AcpiOsRemoveInterruptHandler
1087 * PARAMETERS: Handle - Returned when handler was installed
1091 * DESCRIPTION: Uninstalls an interrupt handler.
1093 *****************************************************************************/
1096 AcpiOsRemoveInterruptHandler (
1097 UINT32 InterruptNumber,
1098 ACPI_OSD_HANDLER ServiceRoutine)
1105 /******************************************************************************
1107 * FUNCTION: AcpiOsStall
1109 * PARAMETERS: Microseconds - Time to stall
1111 * RETURN: None. Blocks until stall is completed.
1113 * DESCRIPTION: Sleep at microsecond granularity
1115 *****************************************************************************/
1119 UINT32 Microseconds)
1122 Sleep ((Microseconds / ACPI_USEC_PER_MSEC) + 1);
1127 /******************************************************************************
1129 * FUNCTION: AcpiOsSleep
1131 * PARAMETERS: Milliseconds - Time to sleep
1133 * RETURN: None. Blocks until sleep is completed.
1135 * DESCRIPTION: Sleep at millisecond granularity
1137 *****************************************************************************/
1141 UINT64 Milliseconds)
1144 /* Add 10ms to account for clock tick granularity */
1146 Sleep (((unsigned long) Milliseconds) + 10);
1151 /******************************************************************************
1153 * FUNCTION: AcpiOsReadPciConfiguration
1155 * PARAMETERS: PciId - Seg/Bus/Dev
1156 * Register - Device Register
1157 * Value - Buffer where value is placed
1158 * Width - Number of bits
1162 * DESCRIPTION: Read data from PCI configuration space
1164 *****************************************************************************/
1167 AcpiOsReadPciConfiguration (
1179 /******************************************************************************
1181 * FUNCTION: AcpiOsWritePciConfiguration
1183 * PARAMETERS: PciId - Seg/Bus/Dev
1184 * Register - Device Register
1185 * Value - Value to be written
1186 * Width - Number of bits
1190 * DESCRIPTION: Write data to PCI configuration space
1192 *****************************************************************************/
1195 AcpiOsWritePciConfiguration (
1206 /******************************************************************************
1208 * FUNCTION: AcpiOsReadPort
1210 * PARAMETERS: Address - Address of I/O port/register to read
1211 * Value - Where value is placed
1212 * Width - Number of bits
1214 * RETURN: Value read from port
1216 * DESCRIPTION: Read data from an I/O port or register
1218 *****************************************************************************/
1222 ACPI_IO_ADDRESS Address,
1226 ACPI_FUNCTION_NAME (OsReadPort);
1243 *Value = 0xFFFFFFFF;
1248 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1249 return (AE_BAD_PARAMETER);
1256 /******************************************************************************
1258 * FUNCTION: AcpiOsWritePort
1260 * PARAMETERS: Address - Address of I/O port/register to write
1261 * Value - Value to write
1262 * Width - Number of bits
1266 * DESCRIPTION: Write data to an I/O port or register
1268 *****************************************************************************/
1272 ACPI_IO_ADDRESS Address,
1276 ACPI_FUNCTION_NAME (OsWritePort);
1279 if ((Width == 8) || (Width == 16) || (Width == 32))
1284 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1285 return (AE_BAD_PARAMETER);
1289 /******************************************************************************
1291 * FUNCTION: AcpiOsReadMemory
1293 * PARAMETERS: Address - Physical Memory Address to read
1294 * Value - Where value is placed
1295 * Width - Number of bits (8,16,32, or 64)
1297 * RETURN: Value read from physical memory address. Always returned
1298 * as a 64-bit integer, regardless of the read width.
1300 * DESCRIPTION: Read data from a physical memory address
1302 *****************************************************************************/
1306 ACPI_PHYSICAL_ADDRESS Address,
1323 return (AE_BAD_PARAMETER);
1331 /******************************************************************************
1333 * FUNCTION: AcpiOsWriteMemory
1335 * PARAMETERS: Address - Physical Memory Address to write
1336 * Value - Value to write
1337 * Width - Number of bits (8,16,32, or 64)
1341 * DESCRIPTION: Write data to a physical memory address
1343 *****************************************************************************/
1347 ACPI_PHYSICAL_ADDRESS Address,
1356 /******************************************************************************
1358 * FUNCTION: AcpiOsSignal
1360 * PARAMETERS: Function - ACPICA signal function code
1361 * Info - Pointer to function-dependent structure
1365 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1367 *****************************************************************************/
1377 case ACPI_SIGNAL_FATAL:
1381 case ACPI_SIGNAL_BREAKPOINT:
1394 /******************************************************************************
1396 * FUNCTION: Local cache interfaces
1398 * DESCRIPTION: Implements cache interfaces via malloc/free for testing
1401 *****************************************************************************/
1403 #ifndef ACPI_USE_LOCAL_CACHE
1410 ACPI_CACHE_T **ReturnCache)
1412 ACPI_MEMORY_LIST *NewCache;
1415 NewCache = malloc (sizeof (ACPI_MEMORY_LIST));
1418 return (AE_NO_MEMORY);
1421 memset (NewCache, 0, sizeof (ACPI_MEMORY_LIST));
1422 NewCache->ListName = CacheName;
1423 NewCache->ObjectSize = ObjectSize;
1424 NewCache->MaxDepth = MaxDepth;
1426 *ReturnCache = (ACPI_CACHE_T) NewCache;
1432 ACPI_CACHE_T *Cache)
1440 ACPI_CACHE_T *Cache)
1446 AcpiOsAcquireObject (
1447 ACPI_CACHE_T *Cache)
1451 NewObject = malloc (((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1452 memset (NewObject, 0, ((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1458 AcpiOsReleaseObject (
1459 ACPI_CACHE_T *Cache,
1466 #endif /* ACPI_USE_LOCAL_CACHE */
1469 /* Optional multi-thread support */
1471 #ifndef ACPI_SINGLE_THREADED
1472 /******************************************************************************
1474 * FUNCTION: AcpiOsGetThreadId
1478 * RETURN: Id of the running thread
1480 * DESCRIPTION: Get the Id of the current (running) thread
1482 *****************************************************************************/
1490 /* Ensure ID is never 0 */
1492 ThreadId = GetCurrentThreadId ();
1493 return ((ACPI_THREAD_ID) (ThreadId + 1));
1497 /******************************************************************************
1499 * FUNCTION: AcpiOsExecute
1501 * PARAMETERS: Type - Type of execution
1502 * Function - Address of the function to execute
1503 * Context - Passed as a parameter to the function
1507 * DESCRIPTION: Execute a new thread
1509 *****************************************************************************/
1513 ACPI_EXECUTE_TYPE Type,
1514 ACPI_OSD_EXEC_CALLBACK Function,
1518 _beginthread (Function, (unsigned) 0, Context);
1522 #else /* ACPI_SINGLE_THREADED */
1532 ACPI_EXECUTE_TYPE Type,
1533 ACPI_OSD_EXEC_CALLBACK Function,
1542 #endif /* ACPI_SINGLE_THREADED */
1545 /******************************************************************************
1547 * FUNCTION: AcpiOsWaitEventsComplete
1553 * DESCRIPTION: Wait for all asynchronous events to complete. This
1554 * implementation does nothing.
1556 *****************************************************************************/
1559 AcpiOsWaitEventsComplete (