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);
634 #ifdef USE_NATIVE_ALLOCATE_ZEROED
635 /******************************************************************************
637 * FUNCTION: AcpiOsAllocateZeroed
639 * PARAMETERS: Size - Amount to allocate, in bytes
641 * RETURN: Pointer to the new allocation. Null on error.
643 * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
645 *****************************************************************************/
648 AcpiOsAllocateZeroed (
654 Mem = (void *) calloc (1, (size_t) Size);
660 /******************************************************************************
662 * FUNCTION: AcpiOsFree
664 * PARAMETERS: Mem - Pointer to previously allocated memory
668 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
670 *****************************************************************************/
681 #ifdef ACPI_SINGLE_THREADED
682 /******************************************************************************
684 * FUNCTION: Semaphore stub functions
686 * DESCRIPTION: Stub functions used for single-thread applications that do
687 * not require semaphore synchronization. Full implementations
688 * of these functions appear after the stubs.
690 *****************************************************************************/
693 AcpiOsCreateSemaphore (
696 ACPI_HANDLE *OutHandle)
698 *OutHandle = (ACPI_HANDLE) 1;
703 AcpiOsDeleteSemaphore (
710 AcpiOsWaitSemaphore (
719 AcpiOsSignalSemaphore (
727 /******************************************************************************
729 * FUNCTION: AcpiOsCreateSemaphore
731 * PARAMETERS: MaxUnits - Maximum units that can be sent
732 * InitialUnits - Units to be assigned to the new semaphore
733 * OutHandle - Where a handle will be returned
737 * DESCRIPTION: Create an OS semaphore
739 *****************************************************************************/
742 AcpiOsCreateSemaphore (
745 ACPI_SEMAPHORE *OutHandle)
750 ACPI_FUNCTION_NAME (OsCreateSemaphore);
753 if (MaxUnits == ACPI_UINT32_MAX)
758 if (InitialUnits == ACPI_UINT32_MAX)
760 InitialUnits = MaxUnits;
763 if (InitialUnits > MaxUnits)
765 return (AE_BAD_PARAMETER);
768 /* Find an empty slot */
770 for (i = 0; i < ACPI_OS_MAX_SEMAPHORES; i++)
772 if (!AcpiGbl_Semaphores[i].OsHandle)
777 if (i >= ACPI_OS_MAX_SEMAPHORES)
779 ACPI_EXCEPTION ((AE_INFO, AE_LIMIT,
780 "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES));
784 /* Create an OS semaphore */
786 Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);
789 ACPI_ERROR ((AE_INFO, "Could not create semaphore"));
790 return (AE_NO_MEMORY);
793 AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;
794 AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;
795 AcpiGbl_Semaphores[i].OsHandle = Mutex;
797 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
798 i, MaxUnits, InitialUnits, Mutex));
800 *OutHandle = (void *) i;
805 /******************************************************************************
807 * FUNCTION: AcpiOsDeleteSemaphore
809 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
813 * DESCRIPTION: Delete an OS semaphore
815 *****************************************************************************/
818 AcpiOsDeleteSemaphore (
819 ACPI_SEMAPHORE Handle)
821 UINT32 Index = (UINT32) Handle;
824 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
825 !AcpiGbl_Semaphores[Index].OsHandle)
827 return (AE_BAD_PARAMETER);
830 CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);
831 AcpiGbl_Semaphores[Index].OsHandle = NULL;
836 /******************************************************************************
838 * FUNCTION: AcpiOsWaitSemaphore
840 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
841 * Units - How many units to wait for
842 * Timeout - How long to wait
846 * DESCRIPTION: Wait for units
848 *****************************************************************************/
851 AcpiOsWaitSemaphore (
852 ACPI_SEMAPHORE Handle,
856 UINT32 Index = (UINT32) Handle;
858 UINT32 OsTimeout = Timeout;
861 ACPI_FUNCTION_ENTRY ();
864 if ((Index >= ACPI_OS_MAX_SEMAPHORES) ||
865 !AcpiGbl_Semaphores[Index].OsHandle)
867 return (AE_BAD_PARAMETER);
872 printf ("WaitSemaphore: Attempt to receive %u units\n", Units);
873 return (AE_NOT_IMPLEMENTED);
876 if (Timeout == ACPI_WAIT_FOREVER)
878 OsTimeout = INFINITE;
879 if (AcpiGbl_DebugTimeout)
881 /* The debug timeout will prevent hang conditions */
883 OsTimeout = ACPI_OS_DEBUG_TIMEOUT;
888 /* Add 10ms to account for clock tick granularity */
893 WaitStatus = WaitForSingleObject (AcpiGbl_Semaphores[Index].OsHandle, OsTimeout);
894 if (WaitStatus == WAIT_TIMEOUT)
896 if (AcpiGbl_DebugTimeout)
898 ACPI_EXCEPTION ((AE_INFO, AE_TIME,
899 "Debug timeout on semaphore 0x%04X (%ums)\n",
900 Index, ACPI_OS_DEBUG_TIMEOUT));
905 if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)
907 ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
908 AcpiUtGetMutexName (Index), Timeout, WaitStatus));
913 AcpiGbl_Semaphores[Index].CurrentUnits--;
918 /******************************************************************************
920 * FUNCTION: AcpiOsSignalSemaphore
922 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
923 * Units - Number of units to send
927 * DESCRIPTION: Send units
929 *****************************************************************************/
932 AcpiOsSignalSemaphore (
933 ACPI_SEMAPHORE Handle,
936 UINT32 Index = (UINT32) Handle;
939 ACPI_FUNCTION_ENTRY ();
942 if (Index >= ACPI_OS_MAX_SEMAPHORES)
944 printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);
945 return (AE_BAD_PARAMETER);
948 if (!AcpiGbl_Semaphores[Index].OsHandle)
950 printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);
951 return (AE_BAD_PARAMETER);
956 printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index);
957 return (AE_NOT_IMPLEMENTED);
960 if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) >
961 AcpiGbl_Semaphores[Index].MaxUnits)
963 ACPI_ERROR ((AE_INFO,
964 "Oversignalled semaphore[%u]! Current %u Max %u",
965 Index, AcpiGbl_Semaphores[Index].CurrentUnits,
966 AcpiGbl_Semaphores[Index].MaxUnits));
971 AcpiGbl_Semaphores[Index].CurrentUnits++;
972 ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL);
977 #endif /* ACPI_SINGLE_THREADED */
980 /******************************************************************************
982 * FUNCTION: Spinlock interfaces
984 * DESCRIPTION: Map these interfaces to semaphore interfaces
986 *****************************************************************************/
990 ACPI_SPINLOCK *OutHandle)
992 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
997 ACPI_SPINLOCK Handle)
999 AcpiOsDeleteSemaphore (Handle);
1004 ACPI_SPINLOCK Handle)
1006 AcpiOsWaitSemaphore (Handle, 1, 0xFFFF);
1012 ACPI_SPINLOCK Handle,
1013 ACPI_CPU_FLAGS Flags)
1015 AcpiOsSignalSemaphore (Handle, 1);
1019 #if ACPI_FUTURE_IMPLEMENTATION
1021 /* Mutex interfaces, just implement with a semaphore */
1025 ACPI_MUTEX *OutHandle)
1027 return (AcpiOsCreateSemaphore (1, 1, OutHandle));
1034 AcpiOsDeleteSemaphore (Handle);
1038 AcpiOsAcquireMutex (
1042 AcpiOsWaitSemaphore (Handle, 1, Timeout);
1047 AcpiOsReleaseMutex (
1050 AcpiOsSignalSemaphore (Handle, 1);
1055 /******************************************************************************
1057 * FUNCTION: AcpiOsInstallInterruptHandler
1059 * PARAMETERS: InterruptNumber - Level handler should respond to.
1060 * ServiceRoutine - Address of the ACPI interrupt handler
1061 * Context - User context
1063 * RETURN: Handle to the newly installed handler.
1065 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1066 * OS-independent handler.
1068 *****************************************************************************/
1071 AcpiOsInstallInterruptHandler (
1072 UINT32 InterruptNumber,
1073 ACPI_OSD_HANDLER ServiceRoutine,
1081 /******************************************************************************
1083 * FUNCTION: AcpiOsRemoveInterruptHandler
1085 * PARAMETERS: Handle - Returned when handler was installed
1089 * DESCRIPTION: Uninstalls an interrupt handler.
1091 *****************************************************************************/
1094 AcpiOsRemoveInterruptHandler (
1095 UINT32 InterruptNumber,
1096 ACPI_OSD_HANDLER ServiceRoutine)
1103 /******************************************************************************
1105 * FUNCTION: AcpiOsStall
1107 * PARAMETERS: Microseconds - Time to stall
1109 * RETURN: None. Blocks until stall is completed.
1111 * DESCRIPTION: Sleep at microsecond granularity
1113 *****************************************************************************/
1117 UINT32 Microseconds)
1120 Sleep ((Microseconds / ACPI_USEC_PER_MSEC) + 1);
1125 /******************************************************************************
1127 * FUNCTION: AcpiOsSleep
1129 * PARAMETERS: Milliseconds - Time to sleep
1131 * RETURN: None. Blocks until sleep is completed.
1133 * DESCRIPTION: Sleep at millisecond granularity
1135 *****************************************************************************/
1139 UINT64 Milliseconds)
1142 /* Add 10ms to account for clock tick granularity */
1144 Sleep (((unsigned long) Milliseconds) + 10);
1149 /******************************************************************************
1151 * FUNCTION: AcpiOsReadPciConfiguration
1153 * PARAMETERS: PciId - Seg/Bus/Dev
1154 * Register - Device Register
1155 * Value - Buffer where value is placed
1156 * Width - Number of bits
1160 * DESCRIPTION: Read data from PCI configuration space
1162 *****************************************************************************/
1165 AcpiOsReadPciConfiguration (
1177 /******************************************************************************
1179 * FUNCTION: AcpiOsWritePciConfiguration
1181 * PARAMETERS: PciId - Seg/Bus/Dev
1182 * Register - Device Register
1183 * Value - Value to be written
1184 * Width - Number of bits
1188 * DESCRIPTION: Write data to PCI configuration space
1190 *****************************************************************************/
1193 AcpiOsWritePciConfiguration (
1204 /******************************************************************************
1206 * FUNCTION: AcpiOsReadPort
1208 * PARAMETERS: Address - Address of I/O port/register to read
1209 * Value - Where value is placed
1210 * Width - Number of bits
1212 * RETURN: Value read from port
1214 * DESCRIPTION: Read data from an I/O port or register
1216 *****************************************************************************/
1220 ACPI_IO_ADDRESS Address,
1224 ACPI_FUNCTION_NAME (OsReadPort);
1241 *Value = 0xFFFFFFFF;
1246 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1247 return (AE_BAD_PARAMETER);
1254 /******************************************************************************
1256 * FUNCTION: AcpiOsWritePort
1258 * PARAMETERS: Address - Address of I/O port/register to write
1259 * Value - Value to write
1260 * Width - Number of bits
1264 * DESCRIPTION: Write data to an I/O port or register
1266 *****************************************************************************/
1270 ACPI_IO_ADDRESS Address,
1274 ACPI_FUNCTION_NAME (OsWritePort);
1277 if ((Width == 8) || (Width == 16) || (Width == 32))
1282 ACPI_ERROR ((AE_INFO, "Bad width parameter: %X", Width));
1283 return (AE_BAD_PARAMETER);
1287 /******************************************************************************
1289 * FUNCTION: AcpiOsReadMemory
1291 * PARAMETERS: Address - Physical Memory Address to read
1292 * Value - Where value is placed
1293 * Width - Number of bits (8,16,32, or 64)
1295 * RETURN: Value read from physical memory address. Always returned
1296 * as a 64-bit integer, regardless of the read width.
1298 * DESCRIPTION: Read data from a physical memory address
1300 *****************************************************************************/
1304 ACPI_PHYSICAL_ADDRESS Address,
1321 return (AE_BAD_PARAMETER);
1329 /******************************************************************************
1331 * FUNCTION: AcpiOsWriteMemory
1333 * PARAMETERS: Address - Physical Memory Address to write
1334 * Value - Value to write
1335 * Width - Number of bits (8,16,32, or 64)
1339 * DESCRIPTION: Write data to a physical memory address
1341 *****************************************************************************/
1345 ACPI_PHYSICAL_ADDRESS Address,
1354 /******************************************************************************
1356 * FUNCTION: AcpiOsSignal
1358 * PARAMETERS: Function - ACPICA signal function code
1359 * Info - Pointer to function-dependent structure
1363 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1365 *****************************************************************************/
1375 case ACPI_SIGNAL_FATAL:
1379 case ACPI_SIGNAL_BREAKPOINT:
1392 /******************************************************************************
1394 * FUNCTION: Local cache interfaces
1396 * DESCRIPTION: Implements cache interfaces via malloc/free for testing
1399 *****************************************************************************/
1401 #ifndef ACPI_USE_LOCAL_CACHE
1408 ACPI_CACHE_T **ReturnCache)
1410 ACPI_MEMORY_LIST *NewCache;
1413 NewCache = malloc (sizeof (ACPI_MEMORY_LIST));
1416 return (AE_NO_MEMORY);
1419 memset (NewCache, 0, sizeof (ACPI_MEMORY_LIST));
1420 NewCache->ListName = CacheName;
1421 NewCache->ObjectSize = ObjectSize;
1422 NewCache->MaxDepth = MaxDepth;
1424 *ReturnCache = (ACPI_CACHE_T) NewCache;
1430 ACPI_CACHE_T *Cache)
1438 ACPI_CACHE_T *Cache)
1444 AcpiOsAcquireObject (
1445 ACPI_CACHE_T *Cache)
1449 NewObject = malloc (((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1450 memset (NewObject, 0, ((ACPI_MEMORY_LIST *) Cache)->ObjectSize);
1456 AcpiOsReleaseObject (
1457 ACPI_CACHE_T *Cache,
1464 #endif /* ACPI_USE_LOCAL_CACHE */
1467 /* Optional multi-thread support */
1469 #ifndef ACPI_SINGLE_THREADED
1470 /******************************************************************************
1472 * FUNCTION: AcpiOsGetThreadId
1476 * RETURN: Id of the running thread
1478 * DESCRIPTION: Get the Id of the current (running) thread
1480 *****************************************************************************/
1488 /* Ensure ID is never 0 */
1490 ThreadId = GetCurrentThreadId ();
1491 return ((ACPI_THREAD_ID) (ThreadId + 1));
1495 /******************************************************************************
1497 * FUNCTION: AcpiOsExecute
1499 * PARAMETERS: Type - Type of execution
1500 * Function - Address of the function to execute
1501 * Context - Passed as a parameter to the function
1505 * DESCRIPTION: Execute a new thread
1507 *****************************************************************************/
1511 ACPI_EXECUTE_TYPE Type,
1512 ACPI_OSD_EXEC_CALLBACK Function,
1516 _beginthread (Function, (unsigned) 0, Context);
1520 #else /* ACPI_SINGLE_THREADED */
1530 ACPI_EXECUTE_TYPE Type,
1531 ACPI_OSD_EXEC_CALLBACK Function,
1540 #endif /* ACPI_SINGLE_THREADED */
1543 /******************************************************************************
1545 * FUNCTION: AcpiOsWaitEventsComplete
1551 * DESCRIPTION: Wait for all asynchronous events to complete. This
1552 * implementation does nothing.
1554 *****************************************************************************/
1557 AcpiOsWaitEventsComplete (