1 /******************************************************************************
3 * Module Name: oswinxf - Windows OSL
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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;
106 /******************************************************************************
108 * FUNCTION: AcpiOsTerminate
114 * DESCRIPTION: Nothing to do for windows
116 *****************************************************************************/
126 /******************************************************************************
128 * FUNCTION: AcpiOsInitialize
134 * DESCRIPTION: Init this OSL
136 *****************************************************************************/
143 LARGE_INTEGER LocalTimerFrequency;
146 #ifndef ACPI_SINGLE_THREADED
147 /* Clear the semaphore info array */
149 memset (AcpiGbl_Semaphores, 0x00, sizeof (AcpiGbl_Semaphores));
152 AcpiGbl_OutputFile = stdout;
154 /* Get the timer frequency for use in AcpiOsGetTimer */
157 if (QueryPerformanceFrequency (&LocalTimerFrequency))
159 /* Frequency is in ticks per second */
161 TimerFrequency = LocalTimerFrequency.QuadPart;
164 Status = AcpiOsCreateLock (&AcpiGbl_PrintLock);
165 if (ACPI_FAILURE (Status))
174 #ifndef ACPI_USE_NATIVE_RSDP_POINTER
175 /******************************************************************************
177 * FUNCTION: AcpiOsGetRootPointer
181 * RETURN: RSDP physical address
183 * DESCRIPTION: Gets the root pointer (RSDP)
185 *****************************************************************************/
187 ACPI_PHYSICAL_ADDRESS
188 AcpiOsGetRootPointer (
197 /******************************************************************************
199 * FUNCTION: AcpiOsPredefinedOverride
201 * PARAMETERS: InitVal - Initial value of the predefined object
202 * NewVal - The new value for the object
204 * RETURN: Status, pointer to value. Null pointer returned if not
207 * DESCRIPTION: Allow the OS to override predefined names
209 *****************************************************************************/
212 AcpiOsPredefinedOverride (
213 const ACPI_PREDEFINED_NAMES *InitVal,
217 if (!InitVal || !NewVal)
219 return (AE_BAD_PARAMETER);
227 /******************************************************************************
229 * FUNCTION: AcpiOsTableOverride
231 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
232 * NewTable - Where an entire new table is returned.
234 * RETURN: Status, pointer to new table. Null pointer returned if no
235 * table is available to override
237 * DESCRIPTION: Return a different version of a table if one is available
239 *****************************************************************************/
242 AcpiOsTableOverride (
243 ACPI_TABLE_HEADER *ExistingTable,
244 ACPI_TABLE_HEADER **NewTable)
247 if (!ExistingTable || !NewTable)
249 return (AE_BAD_PARAMETER);
257 /* Call back up to AcpiExec */
259 AeTableOverride (ExistingTable, NewTable);
266 /******************************************************************************
268 * FUNCTION: AcpiOsPhysicalTableOverride
270 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
271 * NewAddress - Where new table address is returned
273 * NewTableLength - Where new table length is returned
275 * RETURN: Status, address/length of new table. Null pointer returned
276 * if no table is available to override.
278 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
280 *****************************************************************************/
283 AcpiOsPhysicalTableOverride (
284 ACPI_TABLE_HEADER *ExistingTable,
285 ACPI_PHYSICAL_ADDRESS *NewAddress,
286 UINT32 *NewTableLength)
293 /******************************************************************************
295 * FUNCTION: AcpiOsGetTimer
299 * RETURN: Current ticks in 100-nanosecond units
301 * DESCRIPTION: Get the value of a system timer
303 ******************************************************************************/
312 /* Attempt to use hi-granularity timer first */
314 if (TimerFrequency &&
315 QueryPerformanceCounter (&Timer))
317 /* Convert to 100 nanosecond ticks */
319 return ((UINT64) ((Timer.QuadPart * (UINT64) ACPI_100NSEC_PER_SEC) /
323 /* Fall back to the lo-granularity timer */
327 /* Convert milliseconds to 100 nanosecond ticks */
329 return ((UINT64) GetTickCount() * ACPI_100NSEC_PER_MSEC);
334 /******************************************************************************
336 * FUNCTION: AcpiOsReadable
338 * PARAMETERS: Pointer - Area to be verified
339 * Length - Size of area
341 * RETURN: TRUE if readable for entire length
343 * DESCRIPTION: Verify that a pointer is valid for reading
345 *****************************************************************************/
353 return ((BOOLEAN) !IsBadReadPtr (Pointer, Length));
357 /******************************************************************************
359 * FUNCTION: AcpiOsWritable
361 * PARAMETERS: Pointer - Area to be verified
362 * Length - Size of area
364 * RETURN: TRUE if writable for entire length
366 * DESCRIPTION: Verify that a pointer is valid for writing
368 *****************************************************************************/
376 return ((BOOLEAN) !IsBadWritePtr (Pointer, Length));
380 /******************************************************************************
382 * FUNCTION: AcpiOsRedirectOutput
384 * PARAMETERS: Destination - An open file handle/pointer
388 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
390 *****************************************************************************/
393 AcpiOsRedirectOutput (
397 AcpiGbl_OutputFile = Destination;
401 /******************************************************************************
403 * FUNCTION: AcpiOsPrintf
405 * PARAMETERS: Fmt, ... - Standard printf format
409 * DESCRIPTION: Formatted output
411 *****************************************************************************/
413 void ACPI_INTERNAL_VAR_XFACE
422 Flags = AcpiGbl_DbOutputFlags;
423 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
425 /* Output is directable to either a file (if open) or the console */
427 if (AcpiGbl_DebugFile)
429 /* Output file is open, send the output there */
431 va_start (Args, Fmt);
432 vfprintf (AcpiGbl_DebugFile, Fmt, Args);
437 /* No redirection, send output to console (once only!) */
439 Flags |= ACPI_DB_CONSOLE_OUTPUT;
443 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
445 va_start (Args, Fmt);
446 vfprintf (AcpiGbl_OutputFile, Fmt, Args);
454 /******************************************************************************
456 * FUNCTION: AcpiOsVprintf
458 * PARAMETERS: Fmt - Standard printf format
459 * Args - Argument list
463 * DESCRIPTION: Formatted output with argument list pointer
465 *****************************************************************************/
476 Flags = AcpiGbl_DbOutputFlags;
477 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
479 /* Output is directable to either a file (if open) or the console */
481 if (AcpiGbl_DebugFile)
483 /* Output file is open, send the output there */
485 Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
489 /* No redirection, send output to console (once only!) */
491 Flags |= ACPI_DB_CONSOLE_OUTPUT;
495 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
497 Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
504 /******************************************************************************
506 * FUNCTION: AcpiOsGetLine
508 * PARAMETERS: Buffer - Where to return the command line
509 * BufferLength - Maximum length of Buffer
510 * BytesRead - Where the actual byte count is returned
512 * RETURN: Status and actual bytes read
514 * DESCRIPTION: Formatted input with argument list pointer
516 *****************************************************************************/
530 if (i >= BufferLength)
532 return (AE_BUFFER_OVERFLOW);
535 if ((Temp = getchar ()) == EOF)
540 if (!Temp || Temp == '\n')
545 Buffer [i] = (char) Temp;
548 /* Null terminate the buffer */
552 /* Return the number of bytes in the string */
563 #ifndef ACPI_USE_NATIVE_MEMORY_MAPPING
564 /******************************************************************************
566 * FUNCTION: AcpiOsMapMemory
568 * PARAMETERS: Where - Physical address of memory to be mapped
569 * Length - How much memory to map
571 * RETURN: Pointer to mapped memory. Null on error.
573 * DESCRIPTION: Map physical memory into caller's address space
575 *****************************************************************************/
579 ACPI_PHYSICAL_ADDRESS Where,
583 return (ACPI_TO_POINTER ((ACPI_SIZE) Where));
587 /******************************************************************************
589 * FUNCTION: AcpiOsUnmapMemory
591 * PARAMETERS: Where - Logical address of memory to be unmapped
592 * Length - How much memory to unmap
596 * DESCRIPTION: Delete a previously created mapping. Where and Length must
597 * correspond to a previous mapping exactly.
599 *****************************************************************************/
612 /******************************************************************************
614 * FUNCTION: AcpiOsAllocate
616 * PARAMETERS: Size - Amount to allocate, in bytes
618 * RETURN: Pointer to the new allocation. Null on error.
620 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
622 *****************************************************************************/
631 Mem = (void *) malloc ((size_t) Size);
636 #ifdef USE_NATIVE_ALLOCATE_ZEROED
637 /******************************************************************************
639 * FUNCTION: AcpiOsAllocateZeroed
641 * PARAMETERS: Size - Amount to allocate, in bytes
643 * RETURN: Pointer to the new allocation. Null on error.
645 * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
647 *****************************************************************************/
650 AcpiOsAllocateZeroed (
656 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",
783 ACPI_OS_MAX_SEMAPHORES));
787 /* Create an OS semaphore */
789 Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
792 ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
793 return (AE_NO_MEMORY);
796 AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
797 AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
798 AcpiGbl_Semaphores[i].OsHandle = Mutex;
800 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX,
801 "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
802 i, MaxUnits, InitialUnits, Mutex));
804 *OutHandle = (void *) i;
809 /******************************************************************************
811 * FUNCTION: AcpiOsDeleteSemaphore
813 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
817 * DESCRIPTION: Delete an OS semaphore
819 *****************************************************************************/
822 AcpiOsDeleteSemaphore (
823 ACPI_SEMAPHORE Handle)
825 UINT32 Index = (UINT32) Handle;
828 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
829 !AcpiGbl_Semaphores[Index].OsHandle)
831 return (AE_BAD_PARAMETER);
834 CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
835 AcpiGbl_Semaphores[Index].OsHandle = NULL;
840 /******************************************************************************
842 * FUNCTION: AcpiOsWaitSemaphore
844 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
845 * Units - How many units to wait for
846 * Timeout - How long to wait
850 * DESCRIPTION: Wait for units
852 *****************************************************************************/
855 AcpiOsWaitSemaphore (
856 ACPI_SEMAPHORE Handle,
860 UINT32 Index = (UINT32) Handle;
862 UINT32 OsTimeout = Timeout;
865 ACPI_FUNCTION_ENTRY ();
868 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
869 !AcpiGbl_Semaphores[Index].OsHandle)
871 return (AE_BAD_PARAMETER);
876 printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
877 return (AE_NOT_IMPLEMENTED);
880 if (Timeout == ACPI_WAIT_FOREVER)
882 OsTimeout = INFINITE;
883 if (AcpiGbl_DebugTimeout)
885 /* The debug timeout will prevent hang conditions */
887 OsTimeout = ACPI_OS_DEBUG_TIMEOUT;
892 /* Add 10ms to account for clock tick granularity */
897 WaitStatus = WaitForSingleObject (
898 AcpiGbl_Semaphores[Index].OsHandle, OsTimeout);
899 if (WaitStatus == WAIT_TIMEOUT)
901 if (AcpiGbl_DebugTimeout)
903 ACPI_EXCEPTION ((AE_INFO, AE_TIME,
904 "Debug timeout on semaphore 0x%04X (%ums)\n",
905 Index, ACPI_OS_DEBUG_TIMEOUT));
911 if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
913 ACPI_ERROR ((AE_INFO,
914 "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
915 AcpiUtGetMutexName (Index), Timeout, WaitStatus));
920 AcpiGbl_Semaphores[Index].CurrentUnits--;
925 /******************************************************************************
927 * FUNCTION: AcpiOsSignalSemaphore
929 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
930 * Units - Number of units to send
934 * DESCRIPTION: Send units
936 *****************************************************************************/
939 AcpiOsSignalSemaphore (
940 ACPI_SEMAPHORE Handle,
943 UINT32 Index = (UINT32) Handle;
946 ACPI_FUNCTION_ENTRY ();
949 if (Index >= ACPI_OS_MAX_SEMAPHORES)
951 printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
952 return (AE_BAD_PARAMETER);
955 if (!AcpiGbl_Semaphores[Index].OsHandle)
957 printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
958 return (AE_BAD_PARAMETER);
963 printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index);
964 return (AE_NOT_IMPLEMENTED);
967 if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) >
968 AcpiGbl_Semaphores[Index].MaxUnits)
970 ACPI_ERROR ((AE_INFO,
971 "Oversignalled semaphore[%u]! Current %u Max %u",
972 Index, AcpiGbl_Semaphores[Index].CurrentUnits,
973 AcpiGbl_Semaphores[Index].MaxUnits));
978 AcpiGbl_Semaphores[Index].CurrentUnits++;
979 ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
984 #endif /* ACPI_SINGLE_THREADED */
987 /******************************************************************************
989 * FUNCTION: Spinlock interfaces
991 * DESCRIPTION: Map these interfaces to semaphore interfaces
993 *****************************************************************************/
997 ACPI_SPINLOCK *OutHandle)
999 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1004 ACPI_SPINLOCK Handle)
1006 AcpiOsDeleteSemaphore (Handle);
1011 ACPI_SPINLOCK Handle)
1013 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
1019 ACPI_SPINLOCK Handle,
1020 ACPI_CPU_FLAGS Flags)
1022 AcpiOsSignalSemaphore (Handle, 1);
1026 #if ACPI_FUTURE_IMPLEMENTATION
1028 /* Mutex interfaces, just implement with a semaphore */
1032 ACPI_MUTEX *OutHandle)
1034 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1041 AcpiOsDeleteSemaphore (Handle);
1045 AcpiOsAcquireMutex (
1049 AcpiOsWaitSemaphore (Handle, 1, Timeout);
1054 AcpiOsReleaseMutex (
1057 AcpiOsSignalSemaphore (Handle, 1);
1062 /******************************************************************************
1064 * FUNCTION: AcpiOsInstallInterruptHandler
1066 * PARAMETERS: InterruptNumber - Level handler should respond to.
1067 * ServiceRoutine - Address of the ACPI interrupt handler
1068 * Context - User context
1070 * RETURN: Handle to the newly installed handler.
1072 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1073 * OS-independent handler.
1075 *****************************************************************************/
1078 AcpiOsInstallInterruptHandler (
1079 UINT32 InterruptNumber,
1080 ACPI_OSD_HANDLER ServiceRoutine,
1088 /******************************************************************************
1090 * FUNCTION: AcpiOsRemoveInterruptHandler
1092 * PARAMETERS: Handle - Returned when handler was installed
1096 * DESCRIPTION: Uninstalls an interrupt handler.
1098 *****************************************************************************/
1101 AcpiOsRemoveInterruptHandler (
1102 UINT32 InterruptNumber,
1103 ACPI_OSD_HANDLER ServiceRoutine)
1110 /******************************************************************************
1112 * FUNCTION: AcpiOsStall
1114 * PARAMETERS: Microseconds - Time to stall
1116 * RETURN: None. Blocks until stall is completed.
1118 * DESCRIPTION: Sleep at microsecond granularity
1120 *****************************************************************************/
1124 UINT32 Microseconds)
1127 Sleep ((Microseconds / ACPI_USEC_PER_MSEC) + 1);
1132 /******************************************************************************
1134 * FUNCTION: AcpiOsSleep
1136 * PARAMETERS: Milliseconds - Time to sleep
1138 * RETURN: None. Blocks until sleep is completed.
1140 * DESCRIPTION: Sleep at millisecond granularity
1142 *****************************************************************************/
1146 UINT64 Milliseconds)
1149 /* Add 10ms to account for clock tick granularity */
1151 Sleep (((unsigned long) Milliseconds) + 10);
1156 /******************************************************************************
1158 * FUNCTION: AcpiOsReadPciConfiguration
1160 * PARAMETERS: PciId - Seg/Bus/Dev
1161 * Register - Device Register
1162 * Value - Buffer where value is placed
1163 * Width - Number of bits
1167 * DESCRIPTION: Read data from PCI configuration space
1169 *****************************************************************************/
1172 AcpiOsReadPciConfiguration (
1184 /******************************************************************************
1186 * FUNCTION: AcpiOsWritePciConfiguration
1188 * PARAMETERS: PciId - Seg/Bus/Dev
1189 * Register - Device Register
1190 * Value - Value to be written
1191 * Width - Number of bits
1195 * DESCRIPTION: Write data to PCI configuration space
1197 *****************************************************************************/
1200 AcpiOsWritePciConfiguration (
1211 /******************************************************************************
1213 * FUNCTION: AcpiOsReadPort
1215 * PARAMETERS: Address - Address of I/O port/register to read
1216 * Value - Where value is placed
1217 * Width - Number of bits
1219 * RETURN: Value read from port
1221 * DESCRIPTION: Read data from an I/O port or register
1223 *****************************************************************************/
1227 ACPI_IO_ADDRESS Address,
1231 ACPI_FUNCTION_NAME (OsReadPort);
1248 *Value = 0xFFFFFFFF;
1253 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1254 return (AE_BAD_PARAMETER);
1261 /******************************************************************************
1263 * FUNCTION: AcpiOsWritePort
1265 * PARAMETERS: Address - Address of I/O port/register to write
1266 * Value - Value to write
1267 * Width - Number of bits
1271 * DESCRIPTION: Write data to an I/O port or register
1273 *****************************************************************************/
1277 ACPI_IO_ADDRESS Address,
1281 ACPI_FUNCTION_NAME (OsWritePort);
1284 if ((Width == 8) || (Width == 16) || (Width == 32))
1289 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1290 return (AE_BAD_PARAMETER);
1294 /******************************************************************************
1296 * FUNCTION: AcpiOsReadMemory
1298 * PARAMETERS: Address - Physical Memory Address to read
1299 * Value - Where value is placed
1300 * Width - Number of bits (8,16,32, or 64)
1302 * RETURN: Value read from physical memory address. Always returned
1303 * as a 64-bit integer, regardless of the read width.
1305 * DESCRIPTION: Read data from a physical memory address
1307 *****************************************************************************/
1311 ACPI_PHYSICAL_ADDRESS Address,
1328 return (AE_BAD_PARAMETER);
1336 /******************************************************************************
1338 * FUNCTION: AcpiOsWriteMemory
1340 * PARAMETERS: Address - Physical Memory Address to write
1341 * Value - Value to write
1342 * Width - Number of bits (8,16,32, or 64)
1346 * DESCRIPTION: Write data to a physical memory address
1348 *****************************************************************************/
1352 ACPI_PHYSICAL_ADDRESS Address,
1361 /******************************************************************************
1363 * FUNCTION: AcpiOsSignal
1365 * PARAMETERS: Function - ACPICA signal function code
1366 * Info - Pointer to function-dependent structure
1370 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1372 *****************************************************************************/
1382 case ACPI_SIGNAL_FATAL:
1386 case ACPI_SIGNAL_BREAKPOINT:
1399 /******************************************************************************
1401 * FUNCTION: Local cache interfaces
1403 * DESCRIPTION: Implements cache interfaces via malloc/free for testing
1406 *****************************************************************************/
1408 #ifndef ACPI_USE_LOCAL_CACHE
1415 ACPI_CACHE_T **ReturnCache)
1417 ACPI_MEMORY_LIST *NewCache;
1420 NewCache = malloc (sizeof (ACPI_MEMORY_LIST));
1423 return (AE_NO_MEMORY);
1426 memset (NewCache, 0, sizeof (ACPI_MEMORY_LIST));
1427 NewCache->ListName = CacheName;
1428 NewCache->ObjectSize = ObjectSize;
1429 NewCache->MaxDepth = MaxDepth;
1431 *ReturnCache = (ACPI_CACHE_T) NewCache;
1437 ACPI_CACHE_T *Cache)
1445 ACPI_CACHE_T *Cache)
1451 AcpiOsAcquireObject (
1452 ACPI_CACHE_T *Cache)
1456 NewObject = malloc (((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1457 memset (NewObject, 0, ((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1463 AcpiOsReleaseObject (
1464 ACPI_CACHE_T *Cache,
1471 #endif /* ACPI_USE_LOCAL_CACHE */
1474 /* Optional multi-thread support */
1476 #ifndef ACPI_SINGLE_THREADED
1477 /******************************************************************************
1479 * FUNCTION: AcpiOsGetThreadId
1483 * RETURN: Id of the running thread
1485 * DESCRIPTION: Get the Id of the current (running) thread
1487 *****************************************************************************/
1495 /* Ensure ID is never 0 */
1497 ThreadId = GetCurrentThreadId ();
1498 return ((ACPI_THREAD_ID) (ThreadId + 1));
1502 /******************************************************************************
1504 * FUNCTION: AcpiOsExecute
1506 * PARAMETERS: Type - Type of execution
1507 * Function - Address of the function to execute
1508 * Context - Passed as a parameter to the function
1512 * DESCRIPTION: Execute a new thread
1514 *****************************************************************************/
1518 ACPI_EXECUTE_TYPE Type,
1519 ACPI_OSD_EXEC_CALLBACK Function,
1523 _beginthread (Function, (unsigned) 0, Context);
1527 #else /* ACPI_SINGLE_THREADED */
1537 ACPI_EXECUTE_TYPE Type,
1538 ACPI_OSD_EXEC_CALLBACK Function,
1546 #endif /* ACPI_SINGLE_THREADED */
1549 /******************************************************************************
1551 * FUNCTION: AcpiOsWaitEventsComplete
1557 * DESCRIPTION: Wait for all asynchronous events to complete. This
1558 * implementation does nothing.
1560 *****************************************************************************/
1563 AcpiOsWaitEventsComplete (