1 /******************************************************************************
3 * Module Name: oswinxf - Windows OSL
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, 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)
241 #ifdef ACPI_ASL_COMPILER
243 ACPI_PHYSICAL_ADDRESS Address;
246 if (!ExistingTable || !NewTable)
248 return (AE_BAD_PARAMETER);
256 /* Call back up to AcpiExec */
258 AeTableOverride (ExistingTable, NewTable);
262 #ifdef ACPI_ASL_COMPILER
264 /* Attempt to get the table from the registry */
266 /* Construct a null-terminated string from table signature */
268 ACPI_MOVE_NAME (TableName, ExistingTable->Signature);
269 TableName[ACPI_NAME_SIZE] = 0;
271 Status = AcpiOsGetTableByName (TableName, 0, NewTable, &Address);
272 if (ACPI_SUCCESS (Status))
274 AcpiOsPrintf ("Table [%s] obtained from registry, %u bytes\n",
275 TableName, (*NewTable)->Length);
279 AcpiOsPrintf ("Could not read table %s from registry (%s)\n",
280 TableName, AcpiFormatException (Status));
288 /******************************************************************************
290 * FUNCTION: AcpiOsPhysicalTableOverride
292 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
293 * NewAddress - Where new table address is returned
295 * NewTableLength - Where new table length is returned
297 * RETURN: Status, address/length of new table. Null pointer returned
298 * if no table is available to override.
300 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
302 *****************************************************************************/
305 AcpiOsPhysicalTableOverride (
306 ACPI_TABLE_HEADER *ExistingTable,
307 ACPI_PHYSICAL_ADDRESS *NewAddress,
308 UINT32 *NewTableLength)
315 /******************************************************************************
317 * FUNCTION: AcpiOsGetTimer
321 * RETURN: Current ticks in 100-nanosecond units
323 * DESCRIPTION: Get the value of a system timer
325 ******************************************************************************/
334 /* Attempt to use hi-granularity timer first */
336 if (TimerFrequency &&
337 QueryPerformanceCounter (&Timer))
339 /* Convert to 100 nanosecond ticks */
341 return ((UINT64) ((Timer.QuadPart * (UINT64) ACPI_100NSEC_PER_SEC) /
345 /* Fall back to the lo-granularity timer */
349 /* Convert milliseconds to 100 nanosecond ticks */
351 return ((UINT64) GetTickCount() * ACPI_100NSEC_PER_MSEC);
356 /******************************************************************************
358 * FUNCTION: AcpiOsReadable
360 * PARAMETERS: Pointer - Area to be verified
361 * Length - Size of area
363 * RETURN: TRUE if readable for entire length
365 * DESCRIPTION: Verify that a pointer is valid for reading
367 *****************************************************************************/
375 return ((BOOLEAN) !IsBadReadPtr (Pointer, Length));
379 /******************************************************************************
381 * FUNCTION: AcpiOsWritable
383 * PARAMETERS: Pointer - Area to be verified
384 * Length - Size of area
386 * RETURN: TRUE if writable for entire length
388 * DESCRIPTION: Verify that a pointer is valid for writing
390 *****************************************************************************/
398 return ((BOOLEAN) !IsBadWritePtr (Pointer, Length));
402 /******************************************************************************
404 * FUNCTION: AcpiOsRedirectOutput
406 * PARAMETERS: Destination - An open file handle/pointer
410 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
412 *****************************************************************************/
415 AcpiOsRedirectOutput (
419 AcpiGbl_OutputFile = Destination;
423 /******************************************************************************
425 * FUNCTION: AcpiOsPrintf
427 * PARAMETERS: Fmt, ... - Standard printf format
431 * DESCRIPTION: Formatted output
433 *****************************************************************************/
435 void ACPI_INTERNAL_VAR_XFACE
444 Flags = AcpiGbl_DbOutputFlags;
445 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
447 /* Output is directable to either a file (if open) or the console */
449 if (AcpiGbl_DebugFile)
451 /* Output file is open, send the output there */
453 va_start (Args, Fmt);
454 vfprintf (AcpiGbl_DebugFile, Fmt, Args);
459 /* No redirection, send output to console (once only!) */
461 Flags |= ACPI_DB_CONSOLE_OUTPUT;
465 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
467 va_start (Args, Fmt);
468 vfprintf (AcpiGbl_OutputFile, Fmt, Args);
476 /******************************************************************************
478 * FUNCTION: AcpiOsVprintf
480 * PARAMETERS: Fmt - Standard printf format
481 * Args - Argument list
485 * DESCRIPTION: Formatted output with argument list pointer
487 *****************************************************************************/
498 Flags = AcpiGbl_DbOutputFlags;
499 if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT)
501 /* Output is directable to either a file (if open) or the console */
503 if (AcpiGbl_DebugFile)
505 /* Output file is open, send the output there */
507 Count = vfprintf (AcpiGbl_DebugFile, Fmt, Args);
511 /* No redirection, send output to console (once only!) */
513 Flags |= ACPI_DB_CONSOLE_OUTPUT;
517 if (Flags & ACPI_DB_CONSOLE_OUTPUT)
519 Count = vfprintf (AcpiGbl_OutputFile, Fmt, Args);
526 /******************************************************************************
528 * FUNCTION: AcpiOsGetLine
530 * PARAMETERS: Buffer - Where to return the command line
531 * BufferLength - Maximum length of Buffer
532 * BytesRead - Where the actual byte count is returned
534 * RETURN: Status and actual bytes read
536 * DESCRIPTION: Formatted input with argument list pointer
538 *****************************************************************************/
552 if (i >= BufferLength)
554 return (AE_BUFFER_OVERFLOW);
557 if ((Temp = getchar ()) == EOF)
562 if (!Temp || Temp == '\n')
567 Buffer [i] = (char) Temp;
570 /* Null terminate the buffer */
574 /* Return the number of bytes in the string */
584 /******************************************************************************
586 * FUNCTION: AcpiOsMapMemory
588 * PARAMETERS: Where - Physical address of memory to be mapped
589 * Length - How much memory to map
591 * RETURN: Pointer to mapped memory. Null on error.
593 * DESCRIPTION: Map physical memory into caller's address space
595 *****************************************************************************/
599 ACPI_PHYSICAL_ADDRESS Where,
603 return (ACPI_TO_POINTER ((ACPI_SIZE) Where));
607 /******************************************************************************
609 * FUNCTION: AcpiOsUnmapMemory
611 * PARAMETERS: Where - Logical address of memory to be unmapped
612 * Length - How much memory to unmap
616 * DESCRIPTION: Delete a previously created mapping. Where and Length must
617 * correspond to a previous mapping exactly.
619 *****************************************************************************/
631 /******************************************************************************
633 * FUNCTION: AcpiOsAllocate
635 * PARAMETERS: Size - Amount to allocate, in bytes
637 * RETURN: Pointer to the new allocation. Null on error.
639 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
641 *****************************************************************************/
650 Mem = (void *) malloc ((size_t) Size);
656 /******************************************************************************
658 * FUNCTION: AcpiOsFree
660 * PARAMETERS: Mem - Pointer to previously allocated memory
664 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
666 *****************************************************************************/
677 #ifdef ACPI_SINGLE_THREADED
678 /******************************************************************************
680 * FUNCTION: Semaphore stub functions
682 * DESCRIPTION: Stub functions used for single-thread applications that do
683 * not require semaphore synchronization. Full implementations
684 * of these functions appear after the stubs.
686 *****************************************************************************/
689 AcpiOsCreateSemaphore (
692 ACPI_HANDLE *OutHandle)
694 *OutHandle = (ACPI_HANDLE) 1;
699 AcpiOsDeleteSemaphore (
706 AcpiOsWaitSemaphore (
715 AcpiOsSignalSemaphore (
723 /******************************************************************************
725 * FUNCTION: AcpiOsCreateSemaphore
727 * PARAMETERS: MaxUnits - Maximum units that can be sent
728 * InitialUnits - Units to be assigned to the new semaphore
729 * OutHandle - Where a handle will be returned
733 * DESCRIPTION: Create an OS semaphore
735 *****************************************************************************/
738 AcpiOsCreateSemaphore (
741 ACPI_SEMAPHORE *OutHandle)
746 ACPI_FUNCTION_NAME (OsCreateSemaphore);
749 if (MaxUnits == ACPI_UINT32_MAX)
754 if (InitialUnits == ACPI_UINT32_MAX)
756 InitialUnits = MaxUnits;
759 if (InitialUnits > MaxUnits)
761 return (AE_BAD_PARAMETER);
764 /* Find an empty slot */
766 for (i = 0; i < ACPI_OS_MAX_SEMAPHORES; i++)
768 if (!AcpiGbl_Semaphores[i].OsHandle)
773 if (i >= ACPI_OS_MAX_SEMAPHORES)
775 ACPI_EXCEPTION ((AE_INFO, AE_LIMIT,
776 "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES));
780 /* Create an OS semaphore */
782 Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
785 ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
786 return (AE_NO_MEMORY);
789 AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
790 AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
791 AcpiGbl_Semaphores[i].OsHandle = Mutex;
793 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
794 i, MaxUnits, InitialUnits, Mutex));
796 *OutHandle = (void *) i;
801 /******************************************************************************
803 * FUNCTION: AcpiOsDeleteSemaphore
805 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
809 * DESCRIPTION: Delete an OS semaphore
811 *****************************************************************************/
814 AcpiOsDeleteSemaphore (
815 ACPI_SEMAPHORE Handle)
817 UINT32 Index = (UINT32) Handle;
820 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
821 !AcpiGbl_Semaphores[Index].OsHandle)
823 return (AE_BAD_PARAMETER);
826 CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
827 AcpiGbl_Semaphores[Index].OsHandle = NULL;
832 /******************************************************************************
834 * FUNCTION: AcpiOsWaitSemaphore
836 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
837 * Units - How many units to wait for
838 * Timeout - How long to wait
842 * DESCRIPTION: Wait for units
844 *****************************************************************************/
847 AcpiOsWaitSemaphore (
848 ACPI_SEMAPHORE Handle,
852 UINT32 Index = (UINT32) Handle;
854 UINT32 OsTimeout = Timeout;
857 ACPI_FUNCTION_ENTRY ();
860 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
861 !AcpiGbl_Semaphores[Index].OsHandle)
863 return (AE_BAD_PARAMETER);
868 printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
869 return (AE_NOT_IMPLEMENTED);
872 if (Timeout == ACPI_WAIT_FOREVER)
874 OsTimeout = INFINITE;
875 if (AcpiGbl_DebugTimeout)
877 /* The debug timeout will prevent hang conditions */
879 OsTimeout = ACPI_OS_DEBUG_TIMEOUT;
884 /* Add 10ms to account for clock tick granularity */
889 WaitStatus = WaitForSingleObject (AcpiGbl_Semaphores[Index].OsHandle, OsTimeout);
890 if (WaitStatus == WAIT_TIMEOUT)
892 if (AcpiGbl_DebugTimeout)
894 ACPI_EXCEPTION ((AE_INFO, AE_TIME,
895 "Debug timeout on semaphore 0x%04X (%ums)\n",
896 Index, ACPI_OS_DEBUG_TIMEOUT));
901 if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
903 ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
904 AcpiUtGetMutexName (Index), Timeout, WaitStatus));
909 AcpiGbl_Semaphores[Index].CurrentUnits--;
914 /******************************************************************************
916 * FUNCTION: AcpiOsSignalSemaphore
918 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
919 * Units - Number of units to send
923 * DESCRIPTION: Send units
925 *****************************************************************************/
928 AcpiOsSignalSemaphore (
929 ACPI_SEMAPHORE Handle,
932 UINT32 Index = (UINT32) Handle;
935 ACPI_FUNCTION_ENTRY ();
938 if (Index >= ACPI_OS_MAX_SEMAPHORES)
940 printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
941 return (AE_BAD_PARAMETER);
944 if (!AcpiGbl_Semaphores[Index].OsHandle)
946 printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
947 return (AE_BAD_PARAMETER);
952 printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index);
953 return (AE_NOT_IMPLEMENTED);
956 if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) >
957 AcpiGbl_Semaphores[Index].MaxUnits)
959 ACPI_ERROR ((AE_INFO,
960 "Oversignalled semaphore[%u]! Current %u Max %u",
961 Index, AcpiGbl_Semaphores[Index].CurrentUnits,
962 AcpiGbl_Semaphores[Index].MaxUnits));
967 AcpiGbl_Semaphores[Index].CurrentUnits++;
968 ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
973 #endif /* ACPI_SINGLE_THREADED */
976 /******************************************************************************
978 * FUNCTION: Spinlock interfaces
980 * DESCRIPTION: Map these interfaces to semaphore interfaces
982 *****************************************************************************/
986 ACPI_SPINLOCK *OutHandle)
988 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
993 ACPI_SPINLOCK Handle)
995 AcpiOsDeleteSemaphore (Handle);
1000 ACPI_SPINLOCK Handle)
1002 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
1008 ACPI_SPINLOCK Handle,
1009 ACPI_CPU_FLAGS Flags)
1011 AcpiOsSignalSemaphore (Handle, 1);
1015 #if ACPI_FUTURE_IMPLEMENTATION
1017 /* Mutex interfaces, just implement with a semaphore */
1021 ACPI_MUTEX *OutHandle)
1023 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1030 AcpiOsDeleteSemaphore (Handle);
1034 AcpiOsAcquireMutex (
1038 AcpiOsWaitSemaphore (Handle, 1, Timeout);
1043 AcpiOsReleaseMutex (
1046 AcpiOsSignalSemaphore (Handle, 1);
1051 /******************************************************************************
1053 * FUNCTION: AcpiOsInstallInterruptHandler
1055 * PARAMETERS: InterruptNumber - Level handler should respond to.
1056 * ServiceRoutine - Address of the ACPI interrupt handler
1057 * Context - User context
1059 * RETURN: Handle to the newly installed handler.
1061 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1062 * OS-independent handler.
1064 *****************************************************************************/
1067 AcpiOsInstallInterruptHandler (
1068 UINT32 InterruptNumber,
1069 ACPI_OSD_HANDLER ServiceRoutine,
1077 /******************************************************************************
1079 * FUNCTION: AcpiOsRemoveInterruptHandler
1081 * PARAMETERS: Handle - Returned when handler was installed
1085 * DESCRIPTION: Uninstalls an interrupt handler.
1087 *****************************************************************************/
1090 AcpiOsRemoveInterruptHandler (
1091 UINT32 InterruptNumber,
1092 ACPI_OSD_HANDLER ServiceRoutine)
1099 /******************************************************************************
1101 * FUNCTION: AcpiOsStall
1103 * PARAMETERS: Microseconds - Time to stall
1105 * RETURN: None. Blocks until stall is completed.
1107 * DESCRIPTION: Sleep at microsecond granularity
1109 *****************************************************************************/
1113 UINT32 Microseconds)
1116 Sleep ((Microseconds / ACPI_USEC_PER_MSEC) + 1);
1121 /******************************************************************************
1123 * FUNCTION: AcpiOsSleep
1125 * PARAMETERS: Milliseconds - Time to sleep
1127 * RETURN: None. Blocks until sleep is completed.
1129 * DESCRIPTION: Sleep at millisecond granularity
1131 *****************************************************************************/
1135 UINT64 Milliseconds)
1138 /* Add 10ms to account for clock tick granularity */
1140 Sleep (((unsigned long) Milliseconds) + 10);
1145 /******************************************************************************
1147 * FUNCTION: AcpiOsReadPciConfiguration
1149 * PARAMETERS: PciId - Seg/Bus/Dev
1150 * Register - Device Register
1151 * Value - Buffer where value is placed
1152 * Width - Number of bits
1156 * DESCRIPTION: Read data from PCI configuration space
1158 *****************************************************************************/
1161 AcpiOsReadPciConfiguration (
1173 /******************************************************************************
1175 * FUNCTION: AcpiOsWritePciConfiguration
1177 * PARAMETERS: PciId - Seg/Bus/Dev
1178 * Register - Device Register
1179 * Value - Value to be written
1180 * Width - Number of bits
1184 * DESCRIPTION: Write data to PCI configuration space
1186 *****************************************************************************/
1189 AcpiOsWritePciConfiguration (
1200 /******************************************************************************
1202 * FUNCTION: AcpiOsReadPort
1204 * PARAMETERS: Address - Address of I/O port/register to read
1205 * Value - Where value is placed
1206 * Width - Number of bits
1208 * RETURN: Value read from port
1210 * DESCRIPTION: Read data from an I/O port or register
1212 *****************************************************************************/
1216 ACPI_IO_ADDRESS Address,
1220 ACPI_FUNCTION_NAME (OsReadPort);
1237 *Value = 0xFFFFFFFF;
1242 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1243 return (AE_BAD_PARAMETER);
1250 /******************************************************************************
1252 * FUNCTION: AcpiOsWritePort
1254 * PARAMETERS: Address - Address of I/O port/register to write
1255 * Value - Value to write
1256 * Width - Number of bits
1260 * DESCRIPTION: Write data to an I/O port or register
1262 *****************************************************************************/
1266 ACPI_IO_ADDRESS Address,
1270 ACPI_FUNCTION_NAME (OsWritePort);
1273 if ((Width == 8) || (Width == 16) || (Width == 32))
1278 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1279 return (AE_BAD_PARAMETER);
1283 /******************************************************************************
1285 * FUNCTION: AcpiOsReadMemory
1287 * PARAMETERS: Address - Physical Memory Address to read
1288 * Value - Where value is placed
1289 * Width - Number of bits (8,16,32, or 64)
1291 * RETURN: Value read from physical memory address. Always returned
1292 * as a 64-bit integer, regardless of the read width.
1294 * DESCRIPTION: Read data from a physical memory address
1296 *****************************************************************************/
1300 ACPI_PHYSICAL_ADDRESS Address,
1317 return (AE_BAD_PARAMETER);
1325 /******************************************************************************
1327 * FUNCTION: AcpiOsWriteMemory
1329 * PARAMETERS: Address - Physical Memory Address to write
1330 * Value - Value to write
1331 * Width - Number of bits (8,16,32, or 64)
1335 * DESCRIPTION: Write data to a physical memory address
1337 *****************************************************************************/
1341 ACPI_PHYSICAL_ADDRESS Address,
1350 /******************************************************************************
1352 * FUNCTION: AcpiOsSignal
1354 * PARAMETERS: Function - ACPI CA signal function code
1355 * Info - Pointer to function-dependent structure
1359 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1361 *****************************************************************************/
1371 case ACPI_SIGNAL_FATAL:
1375 case ACPI_SIGNAL_BREAKPOINT:
1388 /******************************************************************************
1390 * FUNCTION: Local cache interfaces
1392 * DESCRIPTION: Implements cache interfaces via malloc/free for testing
1395 *****************************************************************************/
1397 #ifndef ACPI_USE_LOCAL_CACHE
1404 ACPI_CACHE_T **ReturnCache)
1406 ACPI_MEMORY_LIST *NewCache;
1409 NewCache = malloc (sizeof (ACPI_MEMORY_LIST));
1412 return (AE_NO_MEMORY);
1415 memset (NewCache, 0, sizeof (ACPI_MEMORY_LIST));
1416 NewCache->ListName = CacheName;
1417 NewCache->ObjectSize = ObjectSize;
1418 NewCache->MaxDepth = MaxDepth;
1420 *ReturnCache = (ACPI_CACHE_T) NewCache;
1426 ACPI_CACHE_T *Cache)
1434 ACPI_CACHE_T *Cache)
1440 AcpiOsAcquireObject (
1441 ACPI_CACHE_T *Cache)
1445 NewObject = malloc (((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1446 memset (NewObject, 0, ((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1452 AcpiOsReleaseObject (
1453 ACPI_CACHE_T *Cache,
1460 #endif /* ACPI_USE_LOCAL_CACHE */
1463 /* Optional multi-thread support */
1465 #ifndef ACPI_SINGLE_THREADED
1466 /******************************************************************************
1468 * FUNCTION: AcpiOsGetThreadId
1472 * RETURN: Id of the running thread
1474 * DESCRIPTION: Get the Id of the current (running) thread
1476 *****************************************************************************/
1484 /* Ensure ID is never 0 */
1486 ThreadId = GetCurrentThreadId ();
1487 return ((ACPI_THREAD_ID) (ThreadId + 1));
1491 /******************************************************************************
1493 * FUNCTION: AcpiOsExecute
1495 * PARAMETERS: Type - Type of execution
1496 * Function - Address of the function to execute
1497 * Context - Passed as a parameter to the function
1501 * DESCRIPTION: Execute a new thread
1503 *****************************************************************************/
1507 ACPI_EXECUTE_TYPE Type,
1508 ACPI_OSD_EXEC_CALLBACK Function,
1512 _beginthread (Function, (unsigned) 0, Context);
1516 #endif /* ACPI_SINGLE_THREADED */
1519 /******************************************************************************
1521 * FUNCTION: AcpiOsWaitEventsComplete
1527 * DESCRIPTION: Wait for all asynchronous events to complete. This
1528 * implementation does nothing.
1530 *****************************************************************************/
1533 AcpiOsWaitEventsComplete (