diff options
Diffstat (limited to 'os_specific/service_layers/oswinxf.c')
| -rw-r--r-- | os_specific/service_layers/oswinxf.c | 312 |
1 files changed, 179 insertions, 133 deletions
diff --git a/os_specific/service_layers/oswinxf.c b/os_specific/service_layers/oswinxf.c index cf19603ec2808..2ad82369414ea 100644 --- a/os_specific/service_layers/oswinxf.c +++ b/os_specific/service_layers/oswinxf.c @@ -137,24 +137,17 @@ ACPI_MODULE_NAME ("oswinxf") -/* Semaphore information structure */ - -typedef struct acpi_os_semaphore_info -{ - UINT16 MaxUnits; - UINT16 CurrentUnits; - void *OsHandle; - -} ACPI_OS_SEMAPHORE_INFO; - -/* Need enough semaphores to run the large aslts suite */ +extern FILE *AcpiGbl_DebugFile; +extern BOOLEAN AcpiGbl_DebugTimeout; -#define ACPI_OS_MAX_SEMAPHORES 256 +FILE *AcpiGbl_OutputFile; +UINT64 TimerFrequency; +char TableName[ACPI_NAME_SIZE + 1]; -ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES]; +#define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */ -/* Upcalls to AcpiExec */ +/* Upcalls to application */ ACPI_PHYSICAL_ADDRESS AeLocalGetRootPointer ( @@ -170,14 +163,28 @@ OsGetTable ( char *Signature); -extern FILE *AcpiGbl_DebugFile; -extern BOOLEAN AcpiGbl_DebugTimeout; +/* + * Real semaphores are only used for a multi-threaded application + */ +#ifndef ACPI_SINGLE_THREADED -FILE *AcpiGbl_OutputFile; -UINT64 TimerFrequency; -char TableName[ACPI_NAME_SIZE + 1]; +/* Semaphore information structure */ -#define ACPI_OS_DEBUG_TIMEOUT 30000 /* 30 seconds */ +typedef struct acpi_os_semaphore_info +{ + UINT16 MaxUnits; + UINT16 CurrentUnits; + void *OsHandle; + +} ACPI_OS_SEMAPHORE_INFO; + +/* Need enough semaphores to run the large aslts suite */ + +#define ACPI_OS_MAX_SEMAPHORES 256 + +ACPI_OS_SEMAPHORE_INFO AcpiGbl_Semaphores[ACPI_OS_MAX_SEMAPHORES]; + +#endif /* ACPI_SINGLE_THREADED */ /****************************************************************************** @@ -186,16 +193,17 @@ char TableName[ACPI_NAME_SIZE + 1]; * * PARAMETERS: None * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Nothing to do for windows * *****************************************************************************/ ACPI_STATUS -AcpiOsTerminate (void) +AcpiOsTerminate ( + void) { - return AE_OK; + return (AE_OK); } @@ -212,16 +220,19 @@ AcpiOsTerminate (void) *****************************************************************************/ ACPI_STATUS -AcpiOsInitialize (void) +AcpiOsInitialize ( + void) { LARGE_INTEGER LocalTimerFrequency; - AcpiGbl_OutputFile = stdout; - +#ifndef ACPI_SINGLE_THREADED /* Clear the semaphore info array */ memset (AcpiGbl_Semaphores, 0x00, sizeof (AcpiGbl_Semaphores)); +#endif + + AcpiGbl_OutputFile = stdout; /* Get the timer frequency for use in AcpiOsGetTimer */ @@ -233,7 +244,7 @@ AcpiOsInitialize (void) TimerFrequency = LocalTimerFrequency.QuadPart; } - return AE_OK; + return (AE_OK); } @@ -262,10 +273,10 @@ AcpiOsGetRootPointer ( * * FUNCTION: AcpiOsPredefinedOverride * - * PARAMETERS: InitVal - Initial value of the predefined object - * NewVal - The new value for the object + * PARAMETERS: InitVal - Initial value of the predefined object + * NewVal - The new value for the object * - * RETURN: Status, pointer to value. Null pointer returned if not + * RETURN: Status, pointer to value. Null pointer returned if not * overriding. * * DESCRIPTION: Allow the OS to override predefined names @@ -292,10 +303,10 @@ AcpiOsPredefinedOverride ( * * FUNCTION: AcpiOsTableOverride * - * PARAMETERS: ExistingTable - Header of current table (probably firmware) - * NewTable - Where an entire new table is returned. + * PARAMETERS: ExistingTable - Header of current table (probably firmware) + * NewTable - Where an entire new table is returned. * - * RETURN: Status, pointer to new table. Null pointer returned if no + * RETURN: Status, pointer to new table. Null pointer returned if no * table is available to override * * DESCRIPTION: Return a different version of a table if one is available @@ -460,7 +471,7 @@ AcpiOsRedirectOutput ( * * FUNCTION: AcpiOsPrintf * - * PARAMETERS: fmt, ... Standard printf format + * PARAMETERS: Fmt, ... - Standard printf format * * RETURN: None * @@ -489,8 +500,8 @@ AcpiOsPrintf ( * * FUNCTION: AcpiOsVprintf * - * PARAMETERS: fmt Standard printf format - * args Argument list + * PARAMETERS: Fmt - Standard printf format + * Args - Argument list * * RETURN: None * @@ -539,8 +550,7 @@ AcpiOsVprintf ( * * FUNCTION: AcpiOsGetLine * - * PARAMETERS: fmt Standard printf format - * args Argument list + * PARAMETERS: Buffer - Where to store the line * * RETURN: Actual bytes read * @@ -581,10 +591,10 @@ AcpiOsGetLine ( * * FUNCTION: AcpiOsMapMemory * - * PARAMETERS: where Physical address of memory to be mapped - * length How much memory to map + * PARAMETERS: Where - Physical address of memory to be mapped + * Length - How much memory to map * - * RETURN: Pointer to mapped memory. Null on error. + * RETURN: Pointer to mapped memory. Null on error. * * DESCRIPTION: Map physical memory into caller's address space * @@ -592,11 +602,11 @@ AcpiOsGetLine ( void * AcpiOsMapMemory ( - ACPI_PHYSICAL_ADDRESS where, - ACPI_SIZE length) + ACPI_PHYSICAL_ADDRESS Where, + ACPI_SIZE Length) { - return (ACPI_TO_POINTER ((ACPI_SIZE) where)); + return (ACPI_TO_POINTER ((ACPI_SIZE) Where)); } @@ -604,20 +614,20 @@ AcpiOsMapMemory ( * * FUNCTION: AcpiOsUnmapMemory * - * PARAMETERS: where Logical address of memory to be unmapped - * length How much memory to unmap + * PARAMETERS: Where - Logical address of memory to be unmapped + * Length - How much memory to unmap * * RETURN: None. * - * DESCRIPTION: Delete a previously created mapping. Where and Length must + * DESCRIPTION: Delete a previously created mapping. Where and Length must * correspond to a previous mapping exactly. * *****************************************************************************/ void AcpiOsUnmapMemory ( - void *where, - ACPI_SIZE length) + void *Where, + ACPI_SIZE Length) { return; @@ -628,24 +638,24 @@ AcpiOsUnmapMemory ( * * FUNCTION: AcpiOsAllocate * - * PARAMETERS: Size Amount to allocate, in bytes + * PARAMETERS: Size - Amount to allocate, in bytes * - * RETURN: Pointer to the new allocation. Null on error. + * RETURN: Pointer to the new allocation. Null on error. * - * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. + * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. * *****************************************************************************/ void * AcpiOsAllocate ( - ACPI_SIZE size) + ACPI_SIZE Size) { void *Mem; - Mem = (void *) malloc ((size_t) size); + Mem = (void *) malloc ((size_t) Size); - return Mem; + return (Mem); } @@ -653,7 +663,7 @@ AcpiOsAllocate ( * * FUNCTION: AcpiOsFree * - * PARAMETERS: mem Pointer to previously allocated memory + * PARAMETERS: Mem - Pointer to previously allocated memory * * RETURN: None. * @@ -670,6 +680,52 @@ AcpiOsFree ( } +#ifdef ACPI_SINGLE_THREADED +/****************************************************************************** + * + * FUNCTION: Semaphore stub functions + * + * DESCRIPTION: Stub functions used for single-thread applications that do + * not require semaphore synchronization. Full implementations + * of these functions appear after the stubs. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_HANDLE *OutHandle) +{ + *OutHandle = (ACPI_HANDLE) 1; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_HANDLE Handle) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units, + UINT16 Timeout) +{ + return (AE_OK); +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + return (AE_OK); +} + +#else /****************************************************************************** * * FUNCTION: AcpiOsCreateSemaphore @@ -690,12 +746,10 @@ AcpiOsCreateSemaphore ( UINT32 InitialUnits, ACPI_SEMAPHORE *OutHandle) { -#ifdef _MULTI_THREADED void *Mutex; UINT32 i; ACPI_FUNCTION_NAME (OsCreateSemaphore); -#endif if (MaxUnits == ACPI_UINT32_MAX) @@ -710,11 +764,9 @@ AcpiOsCreateSemaphore ( if (InitialUnits > MaxUnits) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } -#ifdef _MULTI_THREADED - /* Find an empty slot */ for (i = 0; i < ACPI_OS_MAX_SEMAPHORES; i++) @@ -728,7 +780,7 @@ AcpiOsCreateSemaphore ( { ACPI_EXCEPTION ((AE_INFO, AE_LIMIT, "Reached max semaphores (%u), could not create", ACPI_OS_MAX_SEMAPHORES)); - return AE_LIMIT; + return (AE_LIMIT); } /* Create an OS semaphore */ @@ -737,7 +789,7 @@ AcpiOsCreateSemaphore ( if (!Mutex) { ACPI_ERROR ((AE_INFO, "Could not create semaphore")); - return AE_NO_MEMORY; + return (AE_NO_MEMORY); } AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits; @@ -748,9 +800,7 @@ AcpiOsCreateSemaphore ( i, MaxUnits, InitialUnits, Mutex)); *OutHandle = (void *) i; -#endif - - return AE_OK; + return (AE_OK); } @@ -776,17 +826,12 @@ AcpiOsDeleteSemaphore ( if ((Index >= ACPI_OS_MAX_SEMAPHORES) || !AcpiGbl_Semaphores[Index].OsHandle) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } - -#ifdef _MULTI_THREADED - CloseHandle (AcpiGbl_Semaphores[Index].OsHandle); AcpiGbl_Semaphores[Index].OsHandle = NULL; -#endif - - return AE_OK; + return (AE_OK); } @@ -810,7 +855,6 @@ AcpiOsWaitSemaphore ( UINT32 Units, UINT16 Timeout) { -#ifdef _MULTI_THREADED UINT32 Index = (UINT32) Handle; UINT32 WaitStatus; UINT32 OsTimeout = Timeout; @@ -822,13 +866,13 @@ AcpiOsWaitSemaphore ( if ((Index >= ACPI_OS_MAX_SEMAPHORES) || !AcpiGbl_Semaphores[Index].OsHandle) { - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (Units > 1) { printf ("WaitSemaphore: Attempt to receive %u units\n", Units); - return AE_NOT_IMPLEMENTED; + return (AE_NOT_IMPLEMENTED); } if (Timeout == ACPI_WAIT_FOREVER) @@ -857,7 +901,7 @@ AcpiOsWaitSemaphore ( "Debug timeout on semaphore 0x%04X (%ums)\n", Index, ACPI_OS_DEBUG_TIMEOUT)); } - return AE_TIME; + return (AE_TIME); } if (AcpiGbl_Semaphores[Index].CurrentUnits == 0) @@ -865,13 +909,11 @@ AcpiOsWaitSemaphore ( ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout 0x%X, OS_Status 0x%X", AcpiUtGetMutexName (Index), Timeout, WaitStatus)); - return AE_OK; + return (AE_OK); } AcpiGbl_Semaphores[Index].CurrentUnits--; -#endif - - return AE_OK; + return (AE_OK); } @@ -893,8 +935,6 @@ AcpiOsSignalSemaphore ( ACPI_SEMAPHORE Handle, UINT32 Units) { -#ifdef _MULTI_THREADED - UINT32 Index = (UINT32) Handle; @@ -904,19 +944,19 @@ AcpiOsSignalSemaphore ( if (Index >= ACPI_OS_MAX_SEMAPHORES) { printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index); - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (!AcpiGbl_Semaphores[Index].OsHandle) { printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index); - return AE_BAD_PARAMETER; + return (AE_BAD_PARAMETER); } if (Units > 1) { printf ("SignalSemaphore: Attempt to signal %u units, Index %2.2X\n", Units, Index); - return AE_NOT_IMPLEMENTED; + return (AE_NOT_IMPLEMENTED); } if ((AcpiGbl_Semaphores[Index].CurrentUnits + 1) > @@ -933,13 +973,19 @@ AcpiOsSignalSemaphore ( AcpiGbl_Semaphores[Index].CurrentUnits++; ReleaseSemaphore (AcpiGbl_Semaphores[Index].OsHandle, Units, NULL); -#endif - return (AE_OK); } +#endif /* ACPI_SINGLE_THREADED */ -/* Spinlock interfaces, just implement with a semaphore */ + +/****************************************************************************** + * + * FUNCTION: Spinlock interfaces + * + * DESCRIPTION: Map these interfaces to semaphore interfaces + * + *****************************************************************************/ ACPI_STATUS AcpiOsCreateLock ( @@ -1012,13 +1058,13 @@ AcpiOsReleaseMutex ( * * FUNCTION: AcpiOsInstallInterruptHandler * - * PARAMETERS: InterruptNumber Level handler should respond to. - * Isr Address of the ACPI interrupt handler - * ExceptPtr Where status is returned + * PARAMETERS: InterruptNumber - Level handler should respond to. + * ServiceRoutine - Address of the ACPI interrupt handler + * Context - User context * * RETURN: Handle to the newly installed handler. * - * DESCRIPTION: Install an interrupt handler. Used to install the ACPI + * DESCRIPTION: Install an interrupt handler. Used to install the ACPI * OS-independent handler. * *****************************************************************************/ @@ -1030,7 +1076,7 @@ AcpiOsInstallInterruptHandler ( void *Context) { - return AE_OK; + return (AE_OK); } @@ -1038,7 +1084,7 @@ AcpiOsInstallInterruptHandler ( * * FUNCTION: AcpiOsRemoveInterruptHandler * - * PARAMETERS: Handle Returned when handler was installed + * PARAMETERS: Handle - Returned when handler was installed * * RETURN: Status * @@ -1052,7 +1098,7 @@ AcpiOsRemoveInterruptHandler ( ACPI_OSD_HANDLER ServiceRoutine) { - return AE_OK; + return (AE_OK); } @@ -1085,9 +1131,9 @@ AcpiOsGetThreadId ( * * FUNCTION: AcpiOsExecute * - * PARAMETERS: Type - Type of execution - * Function - Address of the function to execute - * Context - Passed as a parameter to the function + * PARAMETERS: Type - Type of execution + * Function - Address of the function to execute + * Context - Passed as a parameter to the function * * RETURN: Status * @@ -1102,11 +1148,11 @@ AcpiOsExecute ( void *Context) { -#ifdef _MULTI_THREADED +#ifndef ACPI_SINGLE_THREADED _beginthread (Function, (unsigned) 0, Context); #endif - return 0; + return (0); } @@ -1114,9 +1160,9 @@ AcpiOsExecute ( * * FUNCTION: AcpiOsStall * - * PARAMETERS: microseconds To sleep + * PARAMETERS: Microseconds - Time to stall * - * RETURN: Blocks until sleep is completed. + * RETURN: None. Blocks until stall is completed. * * DESCRIPTION: Sleep at microsecond granularity * @@ -1124,10 +1170,10 @@ AcpiOsExecute ( void AcpiOsStall ( - UINT32 microseconds) + UINT32 Microseconds) { - Sleep ((microseconds / 1000) + 1); + Sleep ((Microseconds / 1000) + 1); return; } @@ -1136,9 +1182,9 @@ AcpiOsStall ( * * FUNCTION: AcpiOsSleep * - * PARAMETERS: milliseconds To sleep + * PARAMETERS: Milliseconds - Time to sleep * - * RETURN: Blocks until sleep is completed. + * RETURN: None. Blocks until sleep is completed. * * DESCRIPTION: Sleep at millisecond granularity * @@ -1146,12 +1192,12 @@ AcpiOsStall ( void AcpiOsSleep ( - UINT64 milliseconds) + UINT64 Milliseconds) { /* Add 10ms to account for clock tick granularity */ - Sleep (((unsigned long) milliseconds) + 10); + Sleep (((unsigned long) Milliseconds) + 10); return; } @@ -1160,10 +1206,10 @@ AcpiOsSleep ( * * FUNCTION: AcpiOsReadPciConfiguration * - * PARAMETERS: PciId Seg/Bus/Dev - * Register Device Register - * Value Buffer where value is placed - * Width Number of bits + * PARAMETERS: PciId - Seg/Bus/Dev + * Register - Device Register + * Value - Buffer where value is placed + * Width - Number of bits * * RETURN: Status * @@ -1187,12 +1233,12 @@ AcpiOsReadPciConfiguration ( * * FUNCTION: AcpiOsWritePciConfiguration * - * PARAMETERS: PciId Seg/Bus/Dev - * Register Device Register - * Value Value to be written - * Width Number of bits + * PARAMETERS: PciId - Seg/Bus/Dev + * Register - Device Register + * Value - Value to be written + * Width - Number of bits * - * RETURN: Status. + * RETURN: Status * * DESCRIPTION: Write data to PCI configuration space * @@ -1214,9 +1260,9 @@ AcpiOsWritePciConfiguration ( * * FUNCTION: AcpiOsReadPort * - * PARAMETERS: Address Address of I/O port/register to read - * Value Where value is placed - * Width Number of bits + * PARAMETERS: Address - Address of I/O port/register to read + * Value - Where value is placed + * Width - Number of bits * * RETURN: Value read from port * @@ -1257,9 +1303,9 @@ AcpiOsReadPort ( * * FUNCTION: AcpiOsWritePort * - * PARAMETERS: Address Address of I/O port/register to write - * Value Value to write - * Width Number of bits + * PARAMETERS: Address - Address of I/O port/register to write + * Value - Value to write + * Width - Number of bits * * RETURN: None * @@ -1282,11 +1328,11 @@ AcpiOsWritePort ( * * FUNCTION: AcpiOsReadMemory * - * PARAMETERS: Address Physical Memory Address to read - * Value Where value is placed - * Width Number of bits + * PARAMETERS: Address - Physical Memory Address to read + * Value - Where value is placed + * Width - Number of bits * - * RETURN: Value read from physical memory address. Always returned + * RETURN: Value read from physical memory address. Always returned * as a 32-bit integer, regardless of the read width. * * DESCRIPTION: Read data from a physical memory address @@ -1321,9 +1367,9 @@ AcpiOsReadMemory ( * * FUNCTION: AcpiOsWriteMemory * - * PARAMETERS: Address Physical Memory Address to write - * Value Value to write - * Width Number of bits + * PARAMETERS: Address - Physical Memory Address to write + * Value - Value to write + * Width - Number of bits * * RETURN: None * @@ -1346,8 +1392,8 @@ AcpiOsWriteMemory ( * * FUNCTION: AcpiOsSignal * - * PARAMETERS: Function ACPI CA signal function code - * Info Pointer to function-dependent structure + * PARAMETERS: Function - ACPI CA signal function code + * Info - Pointer to function-dependent structure * * RETURN: Status * |
