⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oswinxf.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************** * * FUNCTION:    AcpiOsReadable * * PARAMETERS:  Pointer             - Area to be verified *              Length              - Size of area * * RETURN:      TRUE if readable for entire length * * DESCRIPTION: Verify that a pointer is valid for reading * *****************************************************************************/BOOLEANAcpiOsReadable (    void                    *Pointer,    ACPI_SIZE               Length){    return ((BOOLEAN) !IsBadReadPtr (Pointer, Length));}/****************************************************************************** * * FUNCTION:    AcpiOsWritable * * PARAMETERS:  Pointer             - Area to be verified *              Length              - Size of area * * RETURN:      TRUE if writable for entire length * * DESCRIPTION: Verify that a pointer is valid for writing * *****************************************************************************/BOOLEANAcpiOsWritable (    void                    *Pointer,    ACPI_SIZE               Length){    return ((BOOLEAN) !IsBadWritePtr (Pointer, Length));}/****************************************************************************** * * 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;    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, Fmt, 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, Fmt, 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){    char                    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 * * RETURN:      Pointer to mapped memory.  Null on error. * * DESCRIPTION: Map physical memory into caller's address space * *****************************************************************************/void *AcpiOsMapMemory (    ACPI_PHYSICAL_ADDRESS   where,    ACPI_SIZE               length){    return (ACPI_TO_POINTER ((ACPI_NATIVE_UINT) where));}/****************************************************************************** * * 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. * *****************************************************************************/void *AcpiOsAllocate (    ACPI_SIZE               size){    void                    *Mem;    Mem = (void *) malloc ((size_t) size);    return Mem;}/****************************************************************************** * * FUNCTION:    AcpiOsFree * * PARAMETERS:  mem                 Pointer to previously allocated memory * * RETURN:      None. * * DESCRIPTION: Free memory allocated via AcpiOsAllocate * *****************************************************************************/voidAcpiOsFree (    void                    *Mem){    free (Mem);}/****************************************************************************** * * FUNCTION:    AcpiOsCreateSemaphore * * PARAMETERS:  MaxUnits            - Maximum units that can be sent *              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_SEMAPHORE      *OutHandle){#ifdef _MULTI_THREADED    void                *Mutex;    UINT32              i;    ACPI_FUNCTION_NAME (OsCreateSemaphore);#endif    if (MaxUnits == ACPI_UINT32_MAX)    {        MaxUnits = 255;    }    if (InitialUnits == ACPI_UINT32_MAX)    {        InitialUnits = MaxUnits;    }    if (InitialUnits > MaxUnits)    {        return AE_BAD_PARAMETER;    }#ifdef _MULTI_THREADED    /* Find an empty slot */    for (i = 0; i < NUM_SEMAPHORES; i++)    {        if (!AcpiGbl_Semaphores[i].OsHandle)        {            break;        }    }    if (i >= NUM_SEMAPHORES)    {        return AE_LIMIT;    }    /* Create an OS semaphore */    Mutex = CreateSemaphore (NULL, InitialUnits, MaxUnits, NULL);    if (!Mutex)    {        ACPI_ERROR ((AE_INFO, "Could not create semaphore"));        return AE_NO_MEMORY;    }    AcpiGbl_Semaphores[i].MaxUnits = (UINT16) MaxUnits;    AcpiGbl_Semaphores[i].CurrentUnits = (UINT16) InitialUnits;    AcpiGbl_Semaphores[i].OsHandle = Mutex;    ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Handle=%d, Max=%d, Current=%d, OsHandle=%p\n",            i, MaxUnits, InitialUnits, Mutex));    *OutHandle = (void *) i;#endif    return AE_OK;}/****************************************************************************** * * FUNCTION:    AcpiOsDeleteSemaphore * * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore * * RETURN:      Status * * DESCRIPTION: Delete an OS semaphore * *****************************************************************************/ACPI_STATUSAcpiOsDeleteSemaphore (    ACPI_SEMAPHORE      Handle){    UINT32              Index = (UINT32) Handle;    if ((Index >= NUM_SEMAPHORES) ||        !AcpiGbl_Semaphores[Index].OsHandle)    {        return AE_BAD_PARAMETER;    }#ifdef _MULTI_THREADED    CloseHandle (AcpiGbl_Semaphores[Index].OsHandle);    AcpiGbl_Semaphores[Index].OsHandle = NULL;#endif    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_SEMAPHORE      Handle,    UINT32              Units,    UINT16              Timeout){#ifdef _MULTI_THREADED    UINT32              Index = (UINT32) Handle;    UINT32              WaitStatus;    UINT32              OsTimeout = Timeout;    ACPI_FUNCTION_ENTRY ();    if ((Index >= NUM_SEMAPHORES) ||        !AcpiGbl_Semaphores[Index].OsHandle)    {        return AE_BAD_PARAMETER;    }    if (Units > 1)    {        printf ("WaitSemaphore: Attempt to receive %d units\n", Units);        return AE_NOT_IMPLEMENTED;    }/* TBD: Make this a command line option so that we can catch * synchronization deadlocks *    if (Timeout == INFINITE)        Timeout = 400000;*/    if (Timeout == ACPI_WAIT_FOREVER)    {        OsTimeout = INFINITE;    }    else    {        /* Add 10ms to account for clock tick granularity */        OsTimeout += 10;    }    WaitStatus = WaitForSingleObject (AcpiGbl_Semaphores[Index].OsHandle, OsTimeout);    if (WaitStatus == WAIT_TIMEOUT)    {/* Make optional -- wait of 0 is used to detect if unit is available        ACPI_ERROR ((AE_INFO, "Timeout on semaphore %d",            Handle));*/        return AE_TIME;    }    if (AcpiGbl_Semaphores[Index].CurrentUnits == 0)    {        ACPI_ERROR ((AE_INFO, "%s - No unit received. Timeout %X, OSstatus 0x%X",            AcpiUtGetMutexName (Index), Timeout, WaitStatus));        return AE_OK;    }    AcpiGbl_Semaphores[Index].CurrentUnits--;#endif    return AE_OK;}/****************************************************************************** * * FUNCTION:    AcpiOsSignalSemaphore * * PARAMETERS:  Handle              - Handle returned by AcpiOsCreateSemaphore *              Units               - Number of units to send * * RETURN:      Status * * DESCRIPTION: Send units * *****************************************************************************/ACPI_STATUSAcpiOsSignalSemaphore (    ACPI_SEMAPHORE      Handle,    UINT32              Units){#ifdef _MULTI_THREADED    UINT32              Index = (UINT32) Handle;    ACPI_FUNCTION_ENTRY ();    if (Index >= NUM_SEMAPHORES)    {        printf ("SignalSemaphore: Index/Handle out of range: %2.2X\n", Index);        return AE_BAD_PARAMETER;    }    if (!AcpiGbl_Semaphores[Index].OsHandle)    {        printf ("SignalSemaphore: Null OS handle, Index %2.2X\n", Index);        return AE_BAD_PARAMETER;    }    if (Units > 1)    {        printf ("SignalSemaphore: Attempt to signal %d units, Index %2.2X\n", Units, Index);        return AE_NOT_IMPLEMENTED;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -