1 /******************************************************************************
3 * Module Name: oswinxf - Windows OSL
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
119 * These interfaces are required in order to link to the ACPI subsystem
120 * parser. They are called during the execution of the parser, and all
121 * map directly to Clibrary calls.
125 #pragma warning(disable:4115) /* warning C4115: named type definition in parentheses (caused by rpcasync.h> */
132 #include <windowsx.h>
144 #define _COMPONENT ACPI_OS_SERVICES
145 ACPI_MODULE_NAME ("oswinxf")
148 #define NUM_SEMAPHORES 128
150 typedef struct semaphore_entry
158 SEMAPHORE_ENTRY AcpiGbl_Semaphores
[NUM_SEMAPHORES
];
159 extern FILE *AcpiGbl_DebugFile
;
161 ACPI_PHYSICAL_ADDRESS
162 AeLocalGetRootPointer (
165 FILE *AcpiGbl_OutputFile
;
166 UINT64 TimerFrequency
;
169 /******************************************************************************
171 * FUNCTION: OsTerminate
177 * DESCRIPTION: Nothing to do for windows
179 *****************************************************************************/
182 AcpiOsTerminate (void)
188 #ifndef ACPI_EXEC_APP
189 /* Used by both iASL and AcpiDump applications */
193 /******************************************************************************
195 * FUNCTION: OsGetTable
199 * RETURN: Pointer to the table. NULL if failure
201 * DESCRIPTION: Get an ACPI table from the Windows registry.
203 *****************************************************************************/
216 ACPI_TABLE_HEADER
*Buffer
;
217 char *Signature
= TableName
;
220 /* Get a handle to the DSDT key */
224 ACPI_STRCPY (s
, "HARDWARE\\ACPI\\");
225 ACPI_STRCAT (s
, Signature
);
227 Status
= RegOpenKeyEx (HKEY_LOCAL_MACHINE
, s
,
228 0L, KEY_ALL_ACCESS
, &Handle
);
230 if (Status
!= ERROR_SUCCESS
)
233 * Somewhere along the way, MS changed the registry entry for
235 * HARDWARE/ACPI/FACP to
236 * HARDWARE/ACPI/FADT.
238 * This code allows for both.
240 if (ACPI_COMPARE_NAME (Signature
, "FACP"))
246 AcpiOsPrintf ("Could not find %s in registry at %s\n", TableName
, s
);
256 /* Actual table is down a couple of levels */
260 Status
= RegEnumKey (Handle
, i
, s
, sizeof(s
));
262 if (Status
== ERROR_NO_MORE_ITEMS
)
267 Status
= RegOpenKey (Handle
, s
, &SubKey
);
268 if (Status
!= ERROR_SUCCESS
)
270 AcpiOsPrintf ("Could not open %s entry\n", TableName
);
274 RegCloseKey (Handle
);
279 /* Find the table entry */
283 NameSize
= sizeof (s
);
284 Status
= RegEnumValue (Handle
, i
, s
, &NameSize
,
285 NULL
, &Type
, NULL
, 0 );
286 if (Status
!= ERROR_SUCCESS
)
288 AcpiOsPrintf ("Could not get %s registry entry\n", TableName
);
292 if (Type
== REG_BINARY
)
299 /* Get the size of the table */
301 Status
= RegQueryValueEx (Handle
, s
, NULL
, NULL
, NULL
, &DataSize
);
302 if (Status
!= ERROR_SUCCESS
)
304 AcpiOsPrintf ("Could not read the %s table size\n", TableName
);
308 /* Allocate a new buffer for the table */
310 Buffer
= AcpiOsAllocate (DataSize
);
316 /* Get the actual table from the registry */
318 Status
= RegQueryValueEx (Handle
, s
, NULL
, NULL
, (UCHAR
*) Buffer
, &DataSize
);
319 if (Status
!= ERROR_SUCCESS
)
321 AcpiOsPrintf ("Could not read %s data\n", TableName
);
326 RegCloseKey (Handle
);
332 /******************************************************************************
334 * FUNCTION: AcpiOsInitialize, AcpiOsTerminate
340 * DESCRIPTION: Init this OSL
342 *****************************************************************************/
345 AcpiOsInitialize (void)
348 LARGE_INTEGER LocalTimerFrequency
;
351 AcpiGbl_OutputFile
= stdout
;
353 for (i
= 0; i
< NUM_SEMAPHORES
; i
++)
355 AcpiGbl_Semaphores
[i
].OsHandle
= NULL
;
359 if (QueryPerformanceFrequency (&LocalTimerFrequency
))
361 /* Frequency is in ticks per second */
363 TimerFrequency
= LocalTimerFrequency
.QuadPart
;
370 /******************************************************************************
372 * FUNCTION: AcpiOsGetRootPointer
376 * RETURN: RSDP physical address
378 * DESCRIPTION: Gets the root pointer (RSDP)
380 *****************************************************************************/
382 ACPI_PHYSICAL_ADDRESS
383 AcpiOsGetRootPointer (
387 return (AeLocalGetRootPointer ());
391 /******************************************************************************
393 * FUNCTION: AcpiOsPredefinedOverride
395 * PARAMETERS: InitVal - Initial value of the predefined object
396 * NewVal - The new value for the object
398 * RETURN: Status, pointer to value. Null pointer returned if not
401 * DESCRIPTION: Allow the OS to override predefined names
403 *****************************************************************************/
406 AcpiOsPredefinedOverride (
407 const ACPI_PREDEFINED_NAMES
*InitVal
,
411 if (!InitVal
|| !NewVal
)
413 return (AE_BAD_PARAMETER
);
421 /******************************************************************************
423 * FUNCTION: AcpiOsTableOverride
425 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
426 * NewTable - Where an entire new table is returned.
428 * RETURN: Status, pointer to new table. Null pointer returned if no
429 * table is available to override
431 * DESCRIPTION: Return a different version of a table if one is available
433 *****************************************************************************/
436 AcpiOsTableOverride (
437 ACPI_TABLE_HEADER
*ExistingTable
,
438 ACPI_TABLE_HEADER
**NewTable
)
440 #ifndef ACPI_EXEC_APP
441 char TableName
[ACPI_NAME_SIZE
+ 1];
445 if (!ExistingTable
|| !NewTable
)
447 return (AE_BAD_PARAMETER
);
455 /* This code exercises the table override mechanism in the core */
457 if (ACPI_COMPARE_NAME (ExistingTable
->Signature
, ACPI_SIG_DSDT
))
459 /* override DSDT with itself */
461 *NewTable
= AcpiGbl_DbTablePtr
;
466 /* Construct a null-terminated string from table signature */
468 TableName
[ACPI_NAME_SIZE
] = 0;
469 ACPI_STRNCPY (TableName
, ExistingTable
->Signature
, ACPI_NAME_SIZE
);
471 *NewTable
= OsGetTable (TableName
);
474 AcpiOsPrintf ("%s obtained from registry, %d bytes\n",
475 TableName
, (*NewTable
)->Length
);
479 AcpiOsPrintf ("Could not read %s from registry\n", TableName
);
487 /******************************************************************************
489 * FUNCTION: AcpiOsGetTimer
493 * RETURN: Current ticks in 100-nanosecond units
495 * DESCRIPTION: Get the value of a system timer
497 ******************************************************************************/
506 // return ((UINT64) GetTickCount() * 10000);
508 /* Attempt to use hi-granularity timer first */
510 if (TimerFrequency
&&
511 QueryPerformanceCounter (&Timer
))
513 /* Convert to 100 nanosecond ticks */
515 return ((UINT64
) ((Timer
.QuadPart
* (UINT64
) 10000000) / TimerFrequency
));
518 /* Fall back to the lo-granularity timer */
522 /* Convert milliseconds to 100 nanosecond ticks */
524 return ((UINT64
) GetTickCount() * 10000);
529 /******************************************************************************
531 * FUNCTION: AcpiOsReadable
533 * PARAMETERS: Pointer - Area to be verified
534 * Length - Size of area
536 * RETURN: TRUE if readable for entire length
538 * DESCRIPTION: Verify that a pointer is valid for reading
540 *****************************************************************************/
548 return ((BOOLEAN
) !IsBadReadPtr (Pointer
, Length
));
552 /******************************************************************************
554 * FUNCTION: AcpiOsWritable
556 * PARAMETERS: Pointer - Area to be verified
557 * Length - Size of area
559 * RETURN: TRUE if writable for entire length
561 * DESCRIPTION: Verify that a pointer is valid for writing
563 *****************************************************************************/
571 return ((BOOLEAN
) !IsBadWritePtr (Pointer
, Length
));
575 /******************************************************************************
577 * FUNCTION: AcpiOsRedirectOutput
579 * PARAMETERS: Destination - An open file handle/pointer
583 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
585 *****************************************************************************/
588 AcpiOsRedirectOutput (
592 AcpiGbl_OutputFile
= Destination
;
596 /******************************************************************************
598 * FUNCTION: AcpiOsPrintf
600 * PARAMETERS: fmt, ... Standard printf format
604 * DESCRIPTION: Formatted output
606 *****************************************************************************/
608 void ACPI_INTERNAL_VAR_XFACE
616 va_start (Args
, Fmt
);
618 AcpiOsVprintf (Fmt
, Args
);
625 /******************************************************************************
627 * FUNCTION: AcpiOsVprintf
629 * PARAMETERS: fmt Standard printf format
634 * DESCRIPTION: Formatted output with argument list pointer
636 *****************************************************************************/
647 Flags
= AcpiGbl_DbOutputFlags
;
648 if (Flags
& ACPI_DB_REDIRECTABLE_OUTPUT
)
650 /* Output is directable to either a file (if open) or the console */
652 if (AcpiGbl_DebugFile
)
654 /* Output file is open, send the output there */
656 Count
= vfprintf (AcpiGbl_DebugFile
, Fmt
, Args
);
660 /* No redirection, send output to console (once only!) */
662 Flags
|= ACPI_DB_CONSOLE_OUTPUT
;
666 if (Flags
& ACPI_DB_CONSOLE_OUTPUT
)
668 Count
= vfprintf (AcpiGbl_OutputFile
, Fmt
, Args
);
675 /******************************************************************************
677 * FUNCTION: AcpiOsGetLine
679 * PARAMETERS: fmt Standard printf format
682 * RETURN: Actual bytes read
684 * DESCRIPTION: Formatted input with argument list pointer
686 *****************************************************************************/
698 scanf ("%1c", &Temp
);
699 if (!Temp
|| Temp
== '\n')
707 /* Null terminate the buffer */
711 /* Return the number of bytes in the string */
716 /******************************************************************************
718 * FUNCTION: AcpiOsMapMemory
720 * PARAMETERS: where Physical address of memory to be mapped
721 * length How much memory to map
723 * RETURN: Pointer to mapped memory. Null on error.
725 * DESCRIPTION: Map physical memory into caller's address space
727 *****************************************************************************/
731 ACPI_PHYSICAL_ADDRESS where
,
735 return (ACPI_TO_POINTER ((ACPI_NATIVE_UINT
) where
));
739 /******************************************************************************
741 * FUNCTION: AcpiOsUnmapMemory
743 * PARAMETERS: where Logical address of memory to be unmapped
744 * length How much memory to unmap
748 * DESCRIPTION: Delete a previously created mapping. Where and Length must
749 * correspond to a previous mapping exactly.
751 *****************************************************************************/
763 /******************************************************************************
765 * FUNCTION: AcpiOsAllocate
767 * PARAMETERS: Size Amount to allocate, in bytes
769 * RETURN: Pointer to the new allocation. Null on error.
771 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
773 *****************************************************************************/
782 Mem
= (void *) malloc ((size_t) size
);
788 /******************************************************************************
790 * FUNCTION: AcpiOsFree
792 * PARAMETERS: mem Pointer to previously allocated memory
796 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
798 *****************************************************************************/
809 /******************************************************************************
811 * FUNCTION: AcpiOsCreateSemaphore
813 * PARAMETERS: MaxUnits - Maximum units that can be sent
814 * InitialUnits - Units to be assigned to the new semaphore
815 * OutHandle - Where a handle will be returned
819 * DESCRIPTION: Create an OS semaphore
821 *****************************************************************************/
824 AcpiOsCreateSemaphore (
827 ACPI_SEMAPHORE
*OutHandle
)
829 #ifdef _MULTI_THREADED
833 ACPI_FUNCTION_NAME (OsCreateSemaphore
);
837 if (MaxUnits
== ACPI_UINT32_MAX
)
842 if (InitialUnits
== ACPI_UINT32_MAX
)
844 InitialUnits
= MaxUnits
;
847 if (InitialUnits
> MaxUnits
)
849 return AE_BAD_PARAMETER
;
852 #ifdef _MULTI_THREADED
854 /* Find an empty slot */
856 for (i
= 0; i
< NUM_SEMAPHORES
; i
++)
858 if (!AcpiGbl_Semaphores
[i
].OsHandle
)
863 if (i
>= NUM_SEMAPHORES
)
868 /* Create an OS semaphore */
870 Mutex
= CreateSemaphore (NULL
, InitialUnits
, MaxUnits
, NULL
);
873 ACPI_ERROR ((AE_INFO
, "Could not create semaphore"));
877 AcpiGbl_Semaphores
[i
].MaxUnits
= (UINT16
) MaxUnits
;
878 AcpiGbl_Semaphores
[i
].CurrentUnits
= (UINT16
) InitialUnits
;
879 AcpiGbl_Semaphores
[i
].OsHandle
= Mutex
;
881 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX
, "Handle=%d, Max=%d, Current=%d, OsHandle=%p\n",
882 i
, MaxUnits
, InitialUnits
, Mutex
));
884 *OutHandle
= (void *) i
;
890 /******************************************************************************
892 * FUNCTION: AcpiOsDeleteSemaphore
894 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
898 * DESCRIPTION: Delete an OS semaphore
900 *****************************************************************************/
903 AcpiOsDeleteSemaphore (
904 ACPI_SEMAPHORE Handle
)
906 UINT32 Index
= (UINT32
) Handle
;
909 if ((Index
>= NUM_SEMAPHORES
) ||
910 !AcpiGbl_Semaphores
[Index
].OsHandle
)
912 return AE_BAD_PARAMETER
;
916 #ifdef _MULTI_THREADED
918 CloseHandle (AcpiGbl_Semaphores
[Index
].OsHandle
);
919 AcpiGbl_Semaphores
[Index
].OsHandle
= NULL
;
926 /******************************************************************************
928 * FUNCTION: AcpiOsWaitSemaphore
930 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
931 * Units - How many units to wait for
932 * Timeout - How long to wait
936 * DESCRIPTION: Wait for units
938 *****************************************************************************/
941 AcpiOsWaitSemaphore (
942 ACPI_SEMAPHORE Handle
,
946 #ifdef _MULTI_THREADED
947 UINT32 Index
= (UINT32
) Handle
;
949 UINT32 OsTimeout
= Timeout
;
952 ACPI_FUNCTION_ENTRY ();
955 if ((Index
>= NUM_SEMAPHORES
) ||
956 !AcpiGbl_Semaphores
[Index
].OsHandle
)
958 return AE_BAD_PARAMETER
;
963 printf ("WaitSemaphore: Attempt to receive %d units\n", Units
);
964 return AE_NOT_IMPLEMENTED
;
968 /* TBD: Make this a command line option so that we can catch
969 * synchronization deadlocks
971 if (Timeout == INFINITE)
975 if (Timeout
== ACPI_WAIT_FOREVER
)
977 OsTimeout
= INFINITE
;
981 /* Add 10ms to account for clock tick granularity */
986 WaitStatus
= WaitForSingleObject (AcpiGbl_Semaphores
[Index
].OsHandle
, OsTimeout
);
987 if (WaitStatus
== WAIT_TIMEOUT
)
989 /* Make optional -- wait of 0 is used to detect if unit is available
990 ACPI_ERROR ((AE_INFO, "Timeout on semaphore %d",
996 if (AcpiGbl_Semaphores
[Index
].CurrentUnits
== 0)
998 ACPI_ERROR ((AE_INFO
, "%s - No unit received. Timeout %X, OSstatus 0x%X",
999 AcpiUtGetMutexName (Index
), Timeout
, WaitStatus
));
1004 AcpiGbl_Semaphores
[Index
].CurrentUnits
--;
1011 /******************************************************************************
1013 * FUNCTION: AcpiOsSignalSemaphore
1015 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
1016 * Units - Number of units to send
1020 * DESCRIPTION: Send units
1022 *****************************************************************************/
1025 AcpiOsSignalSemaphore (
1026 ACPI_SEMAPHORE Handle
,
1029 #ifdef _MULTI_THREADED
1031 UINT32 Index
= (UINT32
) Handle
;
1034 ACPI_FUNCTION_ENTRY ();
1037 if (Index
>= NUM_SEMAPHORES
)
1039 printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index
);
1040 return AE_BAD_PARAMETER
;
1043 if (!AcpiGbl_Semaphores
[Index
].OsHandle
)
1045 printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index
);
1046 return AE_BAD_PARAMETER
;
1051 printf ("SignalSemaphore: Attempt to signal %d units, Index %2.2X\n", Units
, Index
);
1052 return AE_NOT_IMPLEMENTED
;
1055 if ((AcpiGbl_Semaphores
[Index
].CurrentUnits
+ 1) >
1056 AcpiGbl_Semaphores
[Index
].MaxUnits
)
1058 ACPI_ERROR ((AE_INFO
,
1059 "Oversignalled semaphore[%d]! Current %d Max %d",
1060 Index
, AcpiGbl_Semaphores
[Index
].CurrentUnits
,
1061 AcpiGbl_Semaphores
[Index
].MaxUnits
));
1066 AcpiGbl_Semaphores
[Index
].CurrentUnits
++;
1067 ReleaseSemaphore (AcpiGbl_Semaphores
[Index
].OsHandle
, Units
, NULL
);
1075 /* Spinlock interfaces, just implement with a semaphore */
1079 ACPI_SPINLOCK
*OutHandle
)
1081 return (AcpiOsCreateSemaphore (1, 1, OutHandle
));
1086 ACPI_SPINLOCK Handle
)
1088 AcpiOsDeleteSemaphore (Handle
);
1093 ACPI_SPINLOCK Handle
)
1095 AcpiOsWaitSemaphore (Handle
, 1, 0xFFFF);
1101 ACPI_SPINLOCK Handle
,
1102 ACPI_CPU_FLAGS Flags
)
1104 AcpiOsSignalSemaphore (Handle
, 1);
1108 #if ACPI_FUTURE_IMPLEMENTATION
1110 /* Mutex interfaces, just implement with a semaphore */
1114 ACPI_MUTEX
*OutHandle
)
1116 return (AcpiOsCreateSemaphore (1, 1, OutHandle
));
1123 AcpiOsDeleteSemaphore (Handle
);
1127 AcpiOsAcquireMutex (
1131 AcpiOsWaitSemaphore (Handle
, 1, Timeout
);
1136 AcpiOsReleaseMutex (
1139 AcpiOsSignalSemaphore (Handle
, 1);
1144 /******************************************************************************
1146 * FUNCTION: AcpiOsInstallInterruptHandler
1148 * PARAMETERS: InterruptNumber Level handler should respond to.
1149 * Isr Address of the ACPI interrupt handler
1150 * ExceptPtr Where status is returned
1152 * RETURN: Handle to the newly installed handler.
1154 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1155 * OS-independent handler.
1157 *****************************************************************************/
1160 AcpiOsInstallInterruptHandler (
1161 UINT32 InterruptNumber
,
1162 ACPI_OSD_HANDLER ServiceRoutine
,
1170 /******************************************************************************
1172 * FUNCTION: AcpiOsRemoveInterruptHandler
1174 * PARAMETERS: Handle Returned when handler was installed
1178 * DESCRIPTION: Uninstalls an interrupt handler.
1180 *****************************************************************************/
1183 AcpiOsRemoveInterruptHandler (
1184 UINT32 InterruptNumber
,
1185 ACPI_OSD_HANDLER ServiceRoutine
)
1192 /******************************************************************************
1194 * FUNCTION: AcpiOsGetThreadId
1198 * RETURN: Id of the running thread
1200 * DESCRIPTION: Get the Id of the current (running) thread
1202 *****************************************************************************/
1210 /* Ensure ID is never 0 */
1212 ThreadId
= GetCurrentThreadId ();
1213 return (ThreadId
+ 1);
1217 /******************************************************************************
1219 * FUNCTION: AcpiOsExecute
1221 * PARAMETERS: Type - Type of execution
1222 * Function - Address of the function to execute
1223 * Context - Passed as a parameter to the function
1227 * DESCRIPTION: Execute a new thread
1229 *****************************************************************************/
1233 ACPI_EXECUTE_TYPE Type
,
1234 ACPI_OSD_EXEC_CALLBACK Function
,
1238 #ifdef _MULTI_THREADED
1239 _beginthread (Function
, (unsigned) 0, Context
);
1246 /******************************************************************************
1248 * FUNCTION: AcpiOsStall
1250 * PARAMETERS: microseconds To sleep
1252 * RETURN: Blocks until sleep is completed.
1254 * DESCRIPTION: Sleep at microsecond granularity
1256 *****************************************************************************/
1260 UINT32 microseconds
)
1263 Sleep ((microseconds
/ 1000) + 1);
1268 /******************************************************************************
1270 * FUNCTION: AcpiOsSleep
1272 * PARAMETERS: milliseconds To sleep
1274 * RETURN: Blocks until sleep is completed.
1276 * DESCRIPTION: Sleep at millisecond granularity
1278 *****************************************************************************/
1282 ACPI_INTEGER milliseconds
)
1285 /* Add 10ms to account for clock tick granularity */
1287 Sleep (((unsigned long) milliseconds
) + 10);
1292 /******************************************************************************
1294 * FUNCTION: AcpiOsValidateInterface
1296 * PARAMETERS: Interface - Requested interface to be validated
1298 * RETURN: AE_OK if interface is supported, AE_SUPPORT otherwise
1300 * DESCRIPTION: Match an interface string to the interfaces supported by the
1301 * host. Strings originate from an AML call to the _OSI method.
1303 *****************************************************************************/
1306 AcpiOsValidateInterface (
1310 return (AE_SUPPORT
);
1314 /******************************************************************************
1316 * FUNCTION: AcpiOsValidateAddress
1318 * PARAMETERS: SpaceId - ACPI space ID
1319 * Address - Physical address
1320 * Length - Address length
1322 * RETURN: AE_OK if Address/Length is valid for the SpaceId. Otherwise,
1323 * should return AE_AML_ILLEGAL_ADDRESS.
1325 * DESCRIPTION: Validate a system address via the host OS. Used to validate
1326 * the addresses accessed by AML operation regions.
1328 *****************************************************************************/
1331 AcpiOsValidateAddress (
1333 ACPI_PHYSICAL_ADDRESS Address
,
1341 /******************************************************************************
1343 * FUNCTION: AcpiOsReadPciConfiguration
1345 * PARAMETERS: PciId Seg/Bus/Dev
1346 * Register Device Register
1347 * Value Buffer where value is placed
1348 * Width Number of bits
1352 * DESCRIPTION: Read data from PCI configuration space
1354 *****************************************************************************/
1357 AcpiOsReadPciConfiguration (
1368 /******************************************************************************
1370 * FUNCTION: AcpiOsWritePciConfiguration
1372 * PARAMETERS: PciId Seg/Bus/Dev
1373 * Register Device Register
1374 * Value Value to be written
1375 * Width Number of bits
1379 * DESCRIPTION: Write data to PCI configuration space
1381 *****************************************************************************/
1384 AcpiOsWritePciConfiguration (
1394 /* TEMPORARY STUB FUNCTION */
1397 ACPI_HANDLE rhandle
,
1398 ACPI_HANDLE chandle
,
1399 ACPI_PCI_ID
**PciId
)
1406 /******************************************************************************
1408 * FUNCTION: AcpiOsReadPort
1410 * PARAMETERS: Address Address of I/O port/register to read
1411 * Value Where value is placed
1412 * Width Number of bits
1414 * RETURN: Value read from port
1416 * DESCRIPTION: Read data from an I/O port or register
1418 *****************************************************************************/
1422 ACPI_IO_ADDRESS Address
,
1438 *Value
= 0xFFFFFFFF;
1442 return (AE_BAD_PARAMETER
);
1449 /******************************************************************************
1451 * FUNCTION: AcpiOsWritePort
1453 * PARAMETERS: Address Address of I/O port/register to write
1454 * Value Value to write
1455 * Width Number of bits
1459 * DESCRIPTION: Write data to an I/O port or register
1461 *****************************************************************************/
1465 ACPI_IO_ADDRESS Address
,
1474 /******************************************************************************
1476 * FUNCTION: AcpiOsReadMemory
1478 * PARAMETERS: Address Physical Memory Address to read
1479 * Value Where value is placed
1480 * Width Number of bits
1482 * RETURN: Value read from physical memory address. Always returned
1483 * as a 32-bit integer, regardless of the read width.
1485 * DESCRIPTION: Read data from a physical memory address
1487 *****************************************************************************/
1491 ACPI_PHYSICAL_ADDRESS Address
,
1505 return (AE_BAD_PARAMETER
);
1513 /******************************************************************************
1515 * FUNCTION: AcpiOsWriteMemory
1517 * PARAMETERS: Address Physical Memory Address to write
1518 * Value Value to write
1519 * Width Number of bits
1523 * DESCRIPTION: Write data to a physical memory address
1525 *****************************************************************************/
1529 ACPI_PHYSICAL_ADDRESS Address
,
1538 /******************************************************************************
1540 * FUNCTION: AcpiOsSignal
1542 * PARAMETERS: Function ACPI CA signal function code
1543 * Info Pointer to function-dependent structure
1547 * DESCRIPTION: Miscellaneous functions
1549 *****************************************************************************/
1559 case ACPI_SIGNAL_FATAL
:
1562 case ACPI_SIGNAL_BREAKPOINT
:
1566 AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info
);
1570 AcpiOsPrintf ("At AcpiOsBreakpoint ****\n");