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 extern FILE *AcpiGbl_DebugFile
;
69 FILE *AcpiGbl_OutputFile
;
70 UINT64 TimerFrequency
;
71 char TableName
[ACPI_NAME_SIZE
+ 1];
73 #define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */
76 /* Upcalls to AcpiExec application */
79 AeLocalGetRootPointer (
84 ACPI_TABLE_HEADER
*ExistingTable
,
85 ACPI_TABLE_HEADER
**NewTable
);
88 * Real semaphores are only used for a multi-threaded application
90 #ifndef ACPI_SINGLE_THREADED
92 /* Semaphore information structure */
94 typedef struct acpi_os_semaphore_info
100 } ACPI_OS_SEMAPHORE_INFO
;
102 /* Need enough semaphores to run the large aslts suite */
104 #define ACPI_OS_MAX_SEMAPHORES 256
106 ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores
[ACPI_OS_MAX_SEMAPHORES
];
108 #endif /* ACPI_SINGLE_THREADED */
110 BOOLEAN AcpiGbl_DebugTimeout
= FALSE
;
112 /******************************************************************************
114 * FUNCTION: AcpiOsTerminate
120 * DESCRIPTION: Nothing to do for windows
122 *****************************************************************************/
132 /******************************************************************************
134 * FUNCTION: AcpiOsInitialize
140 * DESCRIPTION: Init this OSL
142 *****************************************************************************/
148 LARGE_INTEGER LocalTimerFrequency
;
151 #ifndef ACPI_SINGLE_THREADED
152 /* Clear the semaphore info array */
154 memset (AcpiGbl_Semaphores
, 0x00, sizeof (AcpiGbl_Semaphores
));
157 AcpiGbl_OutputFile
= stdout
;
159 /* Get the timer frequency for use in AcpiOsGetTimer */
162 if (QueryPerformanceFrequency (&LocalTimerFrequency
))
164 /* Frequency is in ticks per second */
166 TimerFrequency
= LocalTimerFrequency
.QuadPart
;
173 /******************************************************************************
175 * FUNCTION: AcpiOsGetRootPointer
179 * RETURN: RSDP physical address
181 * DESCRIPTION: Gets the root pointer (RSDP)
183 *****************************************************************************/
185 ACPI_PHYSICAL_ADDRESS
186 AcpiOsGetRootPointer (
190 return (AeLocalGetRootPointer ());
194 /******************************************************************************
196 * FUNCTION: AcpiOsPredefinedOverride
198 * PARAMETERS: InitVal - Initial value of the predefined object
199 * NewVal - The new value for the object
201 * RETURN: Status, pointer to value. Null pointer returned if not
204 * DESCRIPTION: Allow the OS to override predefined names
206 *****************************************************************************/
209 AcpiOsPredefinedOverride (
210 const ACPI_PREDEFINED_NAMES
*InitVal
,
214 if (!InitVal
|| !NewVal
)
216 return (AE_BAD_PARAMETER
);
224 /******************************************************************************
226 * FUNCTION: AcpiOsTableOverride
228 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
229 * NewTable - Where an entire new table is returned.
231 * RETURN: Status, pointer to new table. Null pointer returned if no
232 * table is available to override
234 * DESCRIPTION: Return a different version of a table if one is available
236 *****************************************************************************/
239 AcpiOsTableOverride (
240 ACPI_TABLE_HEADER
*ExistingTable
,
241 ACPI_TABLE_HEADER
**NewTable
)
243 #ifdef ACPI_ASL_COMPILER
245 ACPI_PHYSICAL_ADDRESS Address
;
248 if (!ExistingTable
|| !NewTable
)
250 return (AE_BAD_PARAMETER
);
258 /* Call back up to AcpiExec */
260 AeTableOverride (ExistingTable
, NewTable
);
264 #ifdef ACPI_ASL_COMPILER
266 /* Attempt to get the table from the registry */
268 /* Construct a null-terminated string from table signature */
270 ACPI_MOVE_NAME (TableName
, ExistingTable
->Signature
);
271 TableName
[ACPI_NAME_SIZE
] = 0;
273 Status
= AcpiOsGetTableByName (TableName
, 0, NewTable
, &Address
);
274 if (ACPI_SUCCESS (Status
))
276 AcpiOsPrintf ("Table [%s] obtained from registry, %u bytes\n",
277 TableName
, (*NewTable
)->Length
);
281 AcpiOsPrintf ("Could not read table %s from registry (%s)\n",
282 TableName
, AcpiFormatException (Status
));
290 /******************************************************************************
292 * FUNCTION: AcpiOsPhysicalTableOverride
294 * PARAMETERS: ExistingTable - Header of current table (probably firmware)
295 * NewAddress - Where new table address is returned
297 * NewTableLength - Where new table length is returned
299 * RETURN: Status, address/length of new table. Null pointer returned
300 * if no table is available to override.
302 * DESCRIPTION: Returns AE_SUPPORT, function not used in user space.
304 *****************************************************************************/
307 AcpiOsPhysicalTableOverride (
308 ACPI_TABLE_HEADER
*ExistingTable
,
309 ACPI_PHYSICAL_ADDRESS
*NewAddress
,
310 UINT32
*NewTableLength
)
317 /******************************************************************************
319 * FUNCTION: AcpiOsGetTimer
323 * RETURN: Current ticks in 100-nanosecond units
325 * DESCRIPTION: Get the value of a system timer
327 ******************************************************************************/
336 /* Attempt to use hi-granularity timer first */
338 if (TimerFrequency
&&
339 QueryPerformanceCounter (&Timer
))
341 /* Convert to 100 nanosecond ticks */
343 return ((UINT64
) ((Timer
.QuadPart
* (UINT64
) ACPI_100NSEC_PER_SEC
) /
347 /* Fall back to the lo-granularity timer */
351 /* Convert milliseconds to 100 nanosecond ticks */
353 return ((UINT64
) GetTickCount() * ACPI_100NSEC_PER_MSEC
);
358 /******************************************************************************
360 * FUNCTION: AcpiOsReadable
362 * PARAMETERS: Pointer - Area to be verified
363 * Length - Size of area
365 * RETURN: TRUE if readable for entire length
367 * DESCRIPTION: Verify that a pointer is valid for reading
369 *****************************************************************************/
377 return ((BOOLEAN
) !IsBadReadPtr (Pointer
, Length
));
381 /******************************************************************************
383 * FUNCTION: AcpiOsWritable
385 * PARAMETERS: Pointer - Area to be verified
386 * Length - Size of area
388 * RETURN: TRUE if writable for entire length
390 * DESCRIPTION: Verify that a pointer is valid for writing
392 *****************************************************************************/
400 return ((BOOLEAN
) !IsBadWritePtr (Pointer
, Length
));
404 /******************************************************************************
406 * FUNCTION: AcpiOsRedirectOutput
408 * PARAMETERS: Destination - An open file handle/pointer
412 * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf
414 *****************************************************************************/
417 AcpiOsRedirectOutput (
421 AcpiGbl_OutputFile
= Destination
;
425 /******************************************************************************
427 * FUNCTION: AcpiOsPrintf
429 * PARAMETERS: Fmt, ... - Standard printf format
433 * DESCRIPTION: Formatted output
435 *****************************************************************************/
437 void ACPI_INTERNAL_VAR_XFACE
446 Flags
= AcpiGbl_DbOutputFlags
;
447 if (Flags
& ACPI_DB_REDIRECTABLE_OUTPUT
)
449 /* Output is directable to either a file (if open) or the console */
451 if (AcpiGbl_DebugFile
)
453 /* Output file is open, send the output there */
455 va_start (Args
, Fmt
);
456 vfprintf (AcpiGbl_DebugFile
, Fmt
, Args
);
461 /* No redirection, send output to console (once only!) */
463 Flags
|= ACPI_DB_CONSOLE_OUTPUT
;
467 if (Flags
& ACPI_DB_CONSOLE_OUTPUT
)
469 va_start (Args
, Fmt
);
470 vfprintf (AcpiGbl_OutputFile
, Fmt
, Args
);
478 /******************************************************************************
480 * FUNCTION: AcpiOsVprintf
482 * PARAMETERS: Fmt - Standard printf format
483 * Args - Argument list
487 * DESCRIPTION: Formatted output with argument list pointer
489 *****************************************************************************/
500 Flags
= AcpiGbl_DbOutputFlags
;
501 if (Flags
& ACPI_DB_REDIRECTABLE_OUTPUT
)
503 /* Output is directable to either a file (if open) or the console */
505 if (AcpiGbl_DebugFile
)
507 /* Output file is open, send the output there */
509 Count
= vfprintf (AcpiGbl_DebugFile
, Fmt
, Args
);
513 /* No redirection, send output to console (once only!) */
515 Flags
|= ACPI_DB_CONSOLE_OUTPUT
;
519 if (Flags
& ACPI_DB_CONSOLE_OUTPUT
)
521 Count
= vfprintf (AcpiGbl_OutputFile
, Fmt
, Args
);
528 /******************************************************************************
530 * FUNCTION: AcpiOsGetLine
532 * PARAMETERS: Buffer - Where to return the command line
533 * BufferLength - Maximum length of Buffer
534 * BytesRead - Where the actual byte count is returned
536 * RETURN: Status and actual bytes read
538 * DESCRIPTION: Formatted input with argument list pointer
540 *****************************************************************************/
554 if (i
>= BufferLength
)
556 return (AE_BUFFER_OVERFLOW
);
559 if ((Temp
= getchar ()) == EOF
)
564 if (!Temp
|| Temp
== '\n')
569 Buffer
[i
] = (char) Temp
;
572 /* Null terminate the buffer */
576 /* Return the number of bytes in the string */
586 /******************************************************************************
588 * FUNCTION: AcpiOsMapMemory
590 * PARAMETERS: Where - Physical address of memory to be mapped
591 * Length - How much memory to map
593 * RETURN: Pointer to mapped memory. Null on error.
595 * DESCRIPTION: Map physical memory into caller's address space
597 *****************************************************************************/
601 ACPI_PHYSICAL_ADDRESS Where
,
605 return (ACPI_TO_POINTER ((ACPI_SIZE
) Where
));
609 /******************************************************************************
611 * FUNCTION: AcpiOsUnmapMemory
613 * PARAMETERS: Where - Logical address of memory to be unmapped
614 * Length - How much memory to unmap
618 * DESCRIPTION: Delete a previously created mapping. Where and Length must
619 * correspond to a previous mapping exactly.
621 *****************************************************************************/
633 /******************************************************************************
635 * FUNCTION: AcpiOsAllocate
637 * PARAMETERS: Size - Amount to allocate, in bytes
639 * RETURN: Pointer to the new allocation. Null on error.
641 * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
643 *****************************************************************************/
652 Mem
= (void *) malloc ((size_t) Size
);
658 /******************************************************************************
660 * FUNCTION: AcpiOsFree
662 * PARAMETERS: Mem - Pointer to previously allocated memory
666 * DESCRIPTION: Free memory allocated via AcpiOsAllocate
668 *****************************************************************************/
679 #ifdef ACPI_SINGLE_THREADED
680 /******************************************************************************
682 * FUNCTION: Semaphore stub functions
684 * DESCRIPTION: Stub functions used for single-thread applications that do
685 * not require semaphore synchronization. Full implementations
686 * of these functions appear after the stubs.
688 *****************************************************************************/
691 AcpiOsCreateSemaphore (
694 ACPI_HANDLE
*OutHandle
)
696 *OutHandle
= (ACPI_HANDLE
) 1;
701 AcpiOsDeleteSemaphore (
708 AcpiOsWaitSemaphore (
717 AcpiOsSignalSemaphore (
725 /******************************************************************************
727 * FUNCTION: AcpiOsCreateSemaphore
729 * PARAMETERS: MaxUnits - Maximum units that can be sent
730 * InitialUnits - Units to be assigned to the new semaphore
731 * OutHandle - Where a handle will be returned
735 * DESCRIPTION: Create an OS semaphore
737 *****************************************************************************/
740 AcpiOsCreateSemaphore (
743 ACPI_SEMAPHORE
*OutHandle
)
748 ACPI_FUNCTION_NAME (OsCreateSemaphore
);
751 if (MaxUnits
== ACPI_UINT32_MAX
)
756 if (InitialUnits
== ACPI_UINT32_MAX
)
758 InitialUnits
= MaxUnits
;
761 if (InitialUnits
> MaxUnits
)
763 return (AE_BAD_PARAMETER
);
766 /* Find an empty slot */
768 for (i
= 0; i
< ACPI_OS_MAX_SEMAPHORES
; i
++)
770 if (!AcpiGbl_Semaphores
[i
].OsHandle
)
775 if (i
>= ACPI_OS_MAX_SEMAPHORES
)
777 ACPI_EXCEPTION ((AE_INFO
, AE_LIMIT
,
778 "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES
));
782 /* Create an OS semaphore */
784 Mutex
= CreateSemaphore (NULL
, InitialUnits
, MaxUnits
, NULL
);
787 ACPI_ERROR ((AE_INFO
, "Could not create semaphore"));
788 return (AE_NO_MEMORY
);
791 AcpiGbl_Semaphores
[i
].MaxUnits
= (UINT16
) MaxUnits
;
792 AcpiGbl_Semaphores
[i
].CurrentUnits
= (UINT16
) InitialUnits
;
793 AcpiGbl_Semaphores
[i
].OsHandle
= Mutex
;
795 ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX
, "Handle=%u, Max=%u, Current=%u, OsHandle=%p\n",
796 i
, MaxUnits
, InitialUnits
, Mutex
));
798 *OutHandle
= (void *) i
;
803 /******************************************************************************
805 * FUNCTION: AcpiOsDeleteSemaphore
807 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
811 * DESCRIPTION: Delete an OS semaphore
813 *****************************************************************************/
816 AcpiOsDeleteSemaphore (
817 ACPI_SEMAPHORE Handle
)
819 UINT32 Index
= (UINT32
) Handle
;
822 if ((Index
>= ACPI_OS_MAX_SEMAPHORES
) ||
823 !AcpiGbl_Semaphores
[Index
].OsHandle
)
825 return (AE_BAD_PARAMETER
);
828 CloseHandle (AcpiGbl_Semaphores
[Index
].OsHandle
);
829 AcpiGbl_Semaphores
[Index
].OsHandle
= NULL
;
834 /******************************************************************************
836 * FUNCTION: AcpiOsWaitSemaphore
838 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
839 * Units - How many units to wait for
840 * Timeout - How long to wait
844 * DESCRIPTION: Wait for units
846 *****************************************************************************/
849 AcpiOsWaitSemaphore (
850 ACPI_SEMAPHORE Handle
,
854 UINT32 Index
= (UINT32
) Handle
;
856 UINT32 OsTimeout
= Timeout
;
859 ACPI_FUNCTION_ENTRY ();
862 if ((Index
>= ACPI_OS_MAX_SEMAPHORES
) ||
863 !AcpiGbl_Semaphores
[Index
].OsHandle
)
865 return (AE_BAD_PARAMETER
);
870 printf ("WaitSemaphore: Attempt to receive %u units\n", Units
);
871 return (AE_NOT_IMPLEMENTED
);
874 if (Timeout
== ACPI_WAIT_FOREVER
)
876 OsTimeout
= INFINITE
;
877 if (AcpiGbl_DebugTimeout
)
879 /* The debug timeout will prevent hang conditions */
881 OsTimeout
= ACPI_OS_DEBUG_TIMEOUT
;
886 /* Add 10ms to account for clock tick granularity */
891 WaitStatus
= WaitForSingleObject (AcpiGbl_Semaphores
[Index
].OsHandle
, OsTimeout
);
892 if (WaitStatus
== WAIT_TIMEOUT
)
894 if (AcpiGbl_DebugTimeout
)
896 ACPI_EXCEPTION ((AE_INFO
, AE_TIME
,
897 "Debug timeout on semaphore 0x%04X (%ums)\n",
898 Index
, ACPI_OS_DEBUG_TIMEOUT
));
903 if (AcpiGbl_Semaphores
[Index
].CurrentUnits
== 0)
905 ACPI_ERROR ((AE_INFO
, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X",
906 AcpiUtGetMutexName (Index
), Timeout
, WaitStatus
));
911 AcpiGbl_Semaphores
[Index
].CurrentUnits
--;
916 /******************************************************************************
918 * FUNCTION: AcpiOsSignalSemaphore
920 * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore
921 * Units - Number of units to send
925 * DESCRIPTION: Send units
927 *****************************************************************************/
930 AcpiOsSignalSemaphore (
931 ACPI_SEMAPHORE Handle
,
934 UINT32 Index
= (UINT32
) Handle
;
937 ACPI_FUNCTION_ENTRY ();
940 if (Index
>= ACPI_OS_MAX_SEMAPHORES
)
942 printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index
);
943 return (AE_BAD_PARAMETER
);
946 if (!AcpiGbl_Semaphores
[Index
].OsHandle
)
948 printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index
);
949 return (AE_BAD_PARAMETER
);
954 printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units
, Index
);
955 return (AE_NOT_IMPLEMENTED
);
958 if ((AcpiGbl_Semaphores
[Index
].CurrentUnits
+ 1) >
959 AcpiGbl_Semaphores
[Index
].MaxUnits
)
961 ACPI_ERROR ((AE_INFO
,
962 "Oversignalled semaphore[%u]! Current %u Max %u",
963 Index
, AcpiGbl_Semaphores
[Index
].CurrentUnits
,
964 AcpiGbl_Semaphores
[Index
].MaxUnits
));
969 AcpiGbl_Semaphores
[Index
].CurrentUnits
++;
970 ReleaseSemaphore (AcpiGbl_Semaphores
[Index
].OsHandle
, Units
, NULL
);
975 #endif /* ACPI_SINGLE_THREADED */
978 /******************************************************************************
980 * FUNCTION: Spinlock interfaces
982 * DESCRIPTION: Map these interfaces to semaphore interfaces
984 *****************************************************************************/
988 ACPI_SPINLOCK
*OutHandle
)
990 return (AcpiOsCreateSemaphore (1, 1, OutHandle
));
995 ACPI_SPINLOCK Handle
)
997 AcpiOsDeleteSemaphore (Handle
);
1002 ACPI_SPINLOCK Handle
)
1004 AcpiOsWaitSemaphore (Handle
, 1, 0xFFFF);
1010 ACPI_SPINLOCK Handle
,
1011 ACPI_CPU_FLAGS Flags
)
1013 AcpiOsSignalSemaphore (Handle
, 1);
1017 #if ACPI_FUTURE_IMPLEMENTATION
1019 /* Mutex interfaces, just implement with a semaphore */
1023 ACPI_MUTEX
*OutHandle
)
1025 return (AcpiOsCreateSemaphore (1, 1, OutHandle
));
1032 AcpiOsDeleteSemaphore (Handle
);
1036 AcpiOsAcquireMutex (
1040 AcpiOsWaitSemaphore (Handle
, 1, Timeout
);
1045 AcpiOsReleaseMutex (
1048 AcpiOsSignalSemaphore (Handle
, 1);
1053 /******************************************************************************
1055 * FUNCTION: AcpiOsInstallInterruptHandler
1057 * PARAMETERS: InterruptNumber - Level handler should respond to.
1058 * ServiceRoutine - Address of the ACPI interrupt handler
1059 * Context - User context
1061 * RETURN: Handle to the newly installed handler.
1063 * DESCRIPTION: Install an interrupt handler. Used to install the ACPI
1064 * OS-independent handler.
1066 *****************************************************************************/
1069 AcpiOsInstallInterruptHandler (
1070 UINT32 InterruptNumber
,
1071 ACPI_OSD_HANDLER ServiceRoutine
,
1079 /******************************************************************************
1081 * FUNCTION: AcpiOsRemoveInterruptHandler
1083 * PARAMETERS: Handle - Returned when handler was installed
1087 * DESCRIPTION: Uninstalls an interrupt handler.
1089 *****************************************************************************/
1092 AcpiOsRemoveInterruptHandler (
1093 UINT32 InterruptNumber
,
1094 ACPI_OSD_HANDLER ServiceRoutine
)
1101 /******************************************************************************
1103 * FUNCTION: AcpiOsStall
1105 * PARAMETERS: Microseconds - Time to stall
1107 * RETURN: None. Blocks until stall is completed.
1109 * DESCRIPTION: Sleep at microsecond granularity
1111 *****************************************************************************/
1115 UINT32 Microseconds
)
1118 Sleep ((Microseconds
/ ACPI_USEC_PER_MSEC
) + 1);
1123 /******************************************************************************
1125 * FUNCTION: AcpiOsSleep
1127 * PARAMETERS: Milliseconds - Time to sleep
1129 * RETURN: None. Blocks until sleep is completed.
1131 * DESCRIPTION: Sleep at millisecond granularity
1133 *****************************************************************************/
1137 UINT64 Milliseconds
)
1140 /* Add 10ms to account for clock tick granularity */
1142 Sleep (((unsigned long) Milliseconds
) + 10);
1147 /******************************************************************************
1149 * FUNCTION: AcpiOsReadPciConfiguration
1151 * PARAMETERS: PciId - Seg/Bus/Dev
1152 * Register - Device Register
1153 * Value - Buffer where value is placed
1154 * Width - Number of bits
1158 * DESCRIPTION: Read data from PCI configuration space
1160 *****************************************************************************/
1163 AcpiOsReadPciConfiguration (
1175 /******************************************************************************
1177 * FUNCTION: AcpiOsWritePciConfiguration
1179 * PARAMETERS: PciId - Seg/Bus/Dev
1180 * Register - Device Register
1181 * Value - Value to be written
1182 * Width - Number of bits
1186 * DESCRIPTION: Write data to PCI configuration space
1188 *****************************************************************************/
1191 AcpiOsWritePciConfiguration (
1202 /******************************************************************************
1204 * FUNCTION: AcpiOsReadPort
1206 * PARAMETERS: Address - Address of I/O port/register to read
1207 * Value - Where value is placed
1208 * Width - Number of bits
1210 * RETURN: Value read from port
1212 * DESCRIPTION: Read data from an I/O port or register
1214 *****************************************************************************/
1218 ACPI_IO_ADDRESS Address
,
1222 ACPI_FUNCTION_NAME (OsReadPort
);
1239 *Value
= 0xFFFFFFFF;
1244 ACPI_ERROR ((AE_INFO
, "Bad width parameter: %X", Width
));
1245 return (AE_BAD_PARAMETER
);
1252 /******************************************************************************
1254 * FUNCTION: AcpiOsWritePort
1256 * PARAMETERS: Address - Address of I/O port/register to write
1257 * Value - Value to write
1258 * Width - Number of bits
1262 * DESCRIPTION: Write data to an I/O port or register
1264 *****************************************************************************/
1268 ACPI_IO_ADDRESS Address
,
1272 ACPI_FUNCTION_NAME (OsWritePort
);
1275 if ((Width
== 8) || (Width
== 16) || (Width
== 32))
1280 ACPI_ERROR ((AE_INFO
, "Bad width parameter: %X", Width
));
1281 return (AE_BAD_PARAMETER
);
1285 /******************************************************************************
1287 * FUNCTION: AcpiOsReadMemory
1289 * PARAMETERS: Address - Physical Memory Address to read
1290 * Value - Where value is placed
1291 * Width - Number of bits (8,16,32, or 64)
1293 * RETURN: Value read from physical memory address. Always returned
1294 * as a 64-bit integer, regardless of the read width.
1296 * DESCRIPTION: Read data from a physical memory address
1298 *****************************************************************************/
1302 ACPI_PHYSICAL_ADDRESS Address
,
1319 return (AE_BAD_PARAMETER
);
1327 /******************************************************************************
1329 * FUNCTION: AcpiOsWriteMemory
1331 * PARAMETERS: Address - Physical Memory Address to write
1332 * Value - Value to write
1333 * Width - Number of bits (8,16,32, or 64)
1337 * DESCRIPTION: Write data to a physical memory address
1339 *****************************************************************************/
1343 ACPI_PHYSICAL_ADDRESS Address
,
1352 /******************************************************************************
1354 * FUNCTION: AcpiOsSignal
1356 * PARAMETERS: Function - ACPI CA signal function code
1357 * Info - Pointer to function-dependent structure
1361 * DESCRIPTION: Miscellaneous functions. Example implementation only.
1363 *****************************************************************************/
1373 case ACPI_SIGNAL_FATAL
:
1377 case ACPI_SIGNAL_BREAKPOINT
:
1390 /******************************************************************************
1392 * FUNCTION: Local cache interfaces
1394 * DESCRIPTION: Implements cache interfaces via malloc/free for testing
1397 *****************************************************************************/
1399 #ifndef ACPI_USE_LOCAL_CACHE
1406 ACPI_CACHE_T
**ReturnCache
)
1408 ACPI_MEMORY_LIST
*NewCache
;
1411 NewCache
= malloc (sizeof (ACPI_MEMORY_LIST
));
1414 return (AE_NO_MEMORY
);
1417 memset (NewCache
, 0, sizeof (ACPI_MEMORY_LIST
));
1418 NewCache
->ListName
= CacheName
;
1419 NewCache
->ObjectSize
= ObjectSize
;
1420 NewCache
->MaxDepth
= MaxDepth
;
1422 *ReturnCache
= (ACPI_CACHE_T
) NewCache
;
1428 ACPI_CACHE_T
*Cache
)
1436 ACPI_CACHE_T
*Cache
)
1442 AcpiOsAcquireObject (
1443 ACPI_CACHE_T
*Cache
)
1447 NewObject
= malloc (((ACPI_MEMORY_LIST
*) Cache
)->ObjectSize
);
1448 memset (NewObject
, 0, ((ACPI_MEMORY_LIST
*) Cache
)->ObjectSize
);
1454 AcpiOsReleaseObject (
1455 ACPI_CACHE_T
*Cache
,
1462 #endif /* ACPI_USE_LOCAL_CACHE */
1465 /* Optional multi-thread support */
1467 #ifndef ACPI_SINGLE_THREADED
1468 /******************************************************************************
1470 * FUNCTION: AcpiOsGetThreadId
1474 * RETURN: Id of the running thread
1476 * DESCRIPTION: Get the Id of the current (running) thread
1478 *****************************************************************************/
1486 /* Ensure ID is never 0 */
1488 ThreadId
= GetCurrentThreadId ();
1489 return ((ACPI_THREAD_ID
) (ThreadId
+ 1));
1493 /******************************************************************************
1495 * FUNCTION: AcpiOsExecute
1497 * PARAMETERS: Type - Type of execution
1498 * Function - Address of the function to execute
1499 * Context - Passed as a parameter to the function
1503 * DESCRIPTION: Execute a new thread
1505 *****************************************************************************/
1509 ACPI_EXECUTE_TYPE Type
,
1510 ACPI_OSD_EXEC_CALLBACK Function
,
1514 _beginthread (Function
, (unsigned) 0, Context
);
1518 #endif /* ACPI_SINGLE_THREADED */
1521 /******************************************************************************
1523 * FUNCTION: AcpiOsWaitEventsComplete
1529 * DESCRIPTION: Wait for all asynchronous events to complete. This
1530 * implementation does nothing.
1532 *****************************************************************************/
1535 AcpiOsWaitEventsComplete (