📄 osdosxf.c
字号:
memcpy (New, ".4lX", 4); New += 4; Fmt += 3; continue; } if (!ACPI_STRNCMP (Fmt, ".2X", 3)) { memcpy (New, ".2lX", 4); New += 4; Fmt += 3; continue; } if (!ACPI_STRNCMP (Fmt, "2X", 2)) { memcpy (New, "2lX", 3); New += 3; Fmt += 2; continue; } if (!ACPI_STRNCMP (Fmt, "02X", 2)) { memcpy (New, "02lX", 4); New += 4; Fmt += 3; continue; } *New++ = *Fmt++; } *New = 0;}/****************************************************************************** * * FUNCTION: AcpiOsRedirectOutput * * PARAMETERS: Destination - An open file handle/pointer * * RETURN: None * * DESCRIPTION: Causes redirect of AcpiOsPrintf and AcpiOsVprintf * *****************************************************************************/voidAcpiOsRedirectOutput ( void *Destination){ AcpiGbl_OutputFile = Destination;}/****************************************************************************** * * FUNCTION: AcpiOsPrintf * * PARAMETERS: fmt, ... Standard printf format * * RETURN: None * * DESCRIPTION: Formatted output * *****************************************************************************/void ACPI_INTERNAL_VAR_XFACEAcpiOsPrintf ( const char *Fmt, ...){ va_list Args; va_start (Args, Fmt); AcpiOsVprintf (Fmt, Args); va_end (Args); return;}/****************************************************************************** * * FUNCTION: AcpiOsVprintf * * PARAMETERS: fmt Standard printf format * args Argument list * * RETURN: None * * DESCRIPTION: Formatted output with argument list pointer * *****************************************************************************/voidAcpiOsVprintf ( const char *Fmt, va_list Args){ INT32 Count = 0; UINT8 Flags; AcpiOslDoFormat (Fmt); Flags = AcpiGbl_DbOutputFlags; if (Flags & ACPI_DB_REDIRECTABLE_OUTPUT) { /* Output is directable to either a file (if open) or the console */ if (AcpiGbl_DebugFile) { /* Output file is open, send the output there */ Count = vfprintf (AcpiGbl_DebugFile, NewFmt, Args); } else { /* No redirection, send output to console (once only!) */ Flags |= ACPI_DB_CONSOLE_OUTPUT; } } if (Flags & ACPI_DB_CONSOLE_OUTPUT) { Count = vfprintf (AcpiGbl_OutputFile, NewFmt, Args); } return;}/****************************************************************************** * * FUNCTION: AcpiOsGetLine * * PARAMETERS: fmt Standard printf format * args Argument list * * RETURN: Actual bytes read * * DESCRIPTION: Formatted input with argument list pointer * *****************************************************************************/UINT32AcpiOsGetLine ( char *Buffer){ UINT8 Temp; UINT32 i; for (i = 0; ; i++) { scanf ("%1c", &Temp); if (!Temp || Temp == '\n') { break; } Buffer [i] = Temp; } /* Null terminate the buffer */ Buffer [i] = 0; /* Return the number of bytes in the string */ return (i);}/****************************************************************************** * * FUNCTION: AcpiOsMapMemory * * PARAMETERS: where Physical address of memory to be mapped * length How much memory to map * there Logical address of mapped memory * * RETURN: Pointer to mapped memory. Null on error. * * DESCRIPTION: Map physical memory into caller's address space * *****************************************************************************/ACPI_STATUSAcpiOsMapMemory ( ACPI_PHYSICAL_ADDRESS where, ACPI_SIZE length, void **there){ *there = where; return AE_OK;}/****************************************************************************** * * FUNCTION: AcpiOsUnmapMemory * * 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 * correspond to a previous mapping exactly. * *****************************************************************************/voidAcpiOsUnmapMemory ( void *where, ACPI_SIZE length){ return;}/****************************************************************************** * * FUNCTION: AcpiOsAllocate * * PARAMETERS: Size Amount to allocate, in bytes * * RETURN: Pointer to the new allocation. Null on error. * * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS. * *****************************************************************************/UINT32 TotalAllocations;UINT32 TotalSize;void *AcpiOsAllocate ( ACPI_SIZE size){ void *Mem; Mem = (void *) malloc ((size_t) size); if (!Mem) { ACPI_ERROR ((AE_INFO, "Could not allocate memory of size %X\n (total allocations/size, %X/%X)", (UINT32) size, TotalAllocations, TotalSize)); } TotalAllocations++; TotalSize += size; return Mem;}/****************************************************************************** * * FUNCTION: AcpiOsFree * * PARAMETERS: mem Pointer to previously allocated memory * * RETURN: None. * * DESCRIPTION: Free memory allocated via AcpiOsAllocate * *****************************************************************************/voidAcpiOsFree ( char *mem){ free ((void *) mem);}/****************************************************************************** * * FUNCTION: AcpiOsCreateSemaphore * * PARAMETERS: InitialUnits - Units to be assigned to the new semaphore * OutHandle - Where a handle will be returned * * RETURN: Status * * DESCRIPTION: Create an OS semaphore * *****************************************************************************/ACPI_STATUSAcpiOsCreateSemaphore ( UINT32 MaxUnits, UINT32 InitialUnits, ACPI_HANDLE *OutHandle){ DOS_SEMAPHORE *Sem; Sem = AcpiOsAllocate (sizeof (DOS_SEMAPHORE)); if (!Sem) { return (AE_NO_MEMORY); } Sem->Units = InitialUnits; *OutHandle = Sem; return AE_OK;}/****************************************************************************** * * FUNCTION: AcpiOsDeleteSemaphore * * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore * * RETURN: Status * * DESCRIPTION: Delete an OS semaphore * *****************************************************************************/ACPI_STATUSAcpiOsDeleteSemaphore ( ACPI_HANDLE Handle){ if (!Handle) { return AE_BAD_PARAMETER; } AcpiOsFree (Handle); return AE_OK;}/****************************************************************************** * * FUNCTION: AcpiOsWaitSemaphore * * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore * Units - How many units to wait for * Timeout - How long to wait * * RETURN: Status * * DESCRIPTION: Wait for units * *****************************************************************************/ACPI_STATUSAcpiOsWaitSemaphore ( ACPI_HANDLE Handle, UINT32 Units, UINT16 Timeout){ DOS_SEMAPHORE *Sem; if (!Handle) { return AE_BAD_PARAMETER; } Sem = Handle; if (Sem->Units) { Sem->Units--; return AE_OK; } return AE_TIME;}/****************************************************************************** * * FUNCTION: AcpiOsSignalSemaphore * * PARAMETERS: Handle - Handle returned by AcpiOsCreateSemaphore * Units - Number of units to send * * RETURN: Status * * DESCRIPTION: Send units * *****************************************************************************/ACPI_STATUSAcpiOsSignalSemaphore ( ACPI_HANDLE Handle, UINT32 Units){ DOS_SEMAPHORE *Sem; if (!Handle) { return AE_BAD_PARAMETER; } Sem = Handle; Sem->Units++; return AE_OK;}ACPI_STATUSAcpiOsCreateLock ( ACPI_SPINLOCK *OutHandle);{ return (AcpiOsCreateSemaphore (1, 1, OutHandle));}voidAcpiOsDeleteLock ( ACPI_SPINLOCK Handle){ AcpiOsDeleteSemaphore (Handle);}ACPI_CPU_FLAGSAcpiOsAcquireLock ( ACPI_SPINLOCK Handle){ AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); return (0);}voidAcpiOsReleaseLock ( ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags){ AcpiOsSignalSemaphore (Handle, 1);}/****************************************************************************** * * FUNCTION: AcpiOsInstallInterruptHandler * * PARAMETERS: InterruptNumber Level handler should respond to. * Isr Address of the ACPI interrupt handler
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -