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

📄 dmbuffer.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 2 页
字号:
{    UINT8                   *ByteData;    UINT32                  ByteCount;    UINT32                  WordCount;    ACPI_PARSE_OBJECT       *SizeOp;    ACPI_PARSE_OBJECT       *NextOp;    ACPI_NATIVE_UINT        i;    /* Buffer size is the buffer argument */    SizeOp = Op->Common.Value.Arg;    /* Next, the initializer byte list to examine */    NextOp = SizeOp->Common.Next;    if (!NextOp)    {        return (FALSE);    }    /* Extract the byte list info */    ByteData = NextOp->Named.Data;    ByteCount = (UINT32) NextOp->Common.Value.Integer;    WordCount = ACPI_DIV_2 (ByteCount);    /*     * Unicode string must have an even number of bytes and last     * word must be zero     */    if ((!ByteCount)     ||         (ByteCount < 4) ||         (ByteCount & 1) ||        ((UINT16 *) (void *) ByteData)[WordCount - 1] != 0)    {        return (FALSE);    }    /* For each word, 1st byte must be ascii, 2nd byte must be zero */    for (i = 0; i < (ByteCount - 2); i += 2)    {        if ((!ACPI_IS_PRINT (ByteData[i])) ||            (ByteData[i + 1] != 0))        {            return (FALSE);        }    }    /* Ignore the Size argument in the disassembly of this buffer op */    SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;    return (TRUE);}/******************************************************************************* * * FUNCTION:    AcpiDmIsStringBuffer * * PARAMETERS:  Op              - Buffer Object to be examined * * RETURN:      TRUE if buffer contains a ASCII string, FALSE otherwise * * DESCRIPTION: Determine if a buffer Op contains a ASCII string * ******************************************************************************/BOOLEANAcpiDmIsStringBuffer (    ACPI_PARSE_OBJECT       *Op){    UINT8                   *ByteData;    UINT32                  ByteCount;    ACPI_PARSE_OBJECT       *SizeOp;    ACPI_PARSE_OBJECT       *NextOp;    UINT32                  i;    /* Buffer size is the buffer argument */    SizeOp = Op->Common.Value.Arg;    /* Next, the initializer byte list to examine */    NextOp = SizeOp->Common.Next;    if (!NextOp)    {        return (FALSE);    }    /* Extract the byte list info */    ByteData = NextOp->Named.Data;    ByteCount = (UINT32) NextOp->Common.Value.Integer;    /* Last byte must be the null terminator */    if ((!ByteCount)     ||         (ByteCount < 2) ||         (ByteData[ByteCount-1] != 0))    {        return (FALSE);    }    for (i = 0; i < (ByteCount - 1); i++)    {        /* TBD: allow some escapes (non-ascii chars).         * they will be handled in the string output routine         */        if (!ACPI_IS_PRINT (ByteData[i]))        {            return (FALSE);        }    }    return (TRUE);}/******************************************************************************* * * FUNCTION:    AcpiDmUnicode * * PARAMETERS:  Op              - Byte List op containing Unicode string * * RETURN:      None * * DESCRIPTION: Dump Unicode string as a standard ASCII string.  (Remove *              the extra zero bytes). * ******************************************************************************/static voidAcpiDmUnicode (    ACPI_PARSE_OBJECT       *Op){    UINT16                  *WordData;    UINT32                  WordCount;    UINT32                  i;    /* Extract the buffer info as a WORD buffer */    WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);    WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));    AcpiOsPrintf ("\"");    /* Write every other byte as an ASCII character */    for (i = 0; i < (WordCount - 1); i++)    {        AcpiOsPrintf ("%c", (int) WordData[i]);    }    AcpiOsPrintf ("\")");}/******************************************************************************* * * FUNCTION:    AcpiDmIsEisaId * * PARAMETERS:  Op              - Op to be examined * * RETURN:      None * * DESCRIPTION: Determine if an Op can be converted to an EisaId. * ******************************************************************************/voidAcpiDmIsEisaId (    ACPI_PARSE_OBJECT       *Op){    UINT32                  Name;    UINT32                  BigEndianId;    ACPI_PARSE_OBJECT       *NextOp;    ACPI_NATIVE_UINT        i;    UINT32                  Prefix[3];    /* Get the NameSegment */    Name = AcpiPsGetName (Op);    if (!Name)    {        return;    }    /* We are looking for _HID */    if (!ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID))    {        return;    }    /* The parameter must be either a word or a dword */    NextOp = AcpiPsGetDepthNext (NULL, Op);    if ((NextOp->Common.AmlOpcode != AML_DWORD_OP) &&        (NextOp->Common.AmlOpcode != AML_WORD_OP))    {        return;    }    /* Swap from little-endian to big-endian to simplify conversion */    BigEndianId = AcpiUtDwordByteSwap ((UINT32) NextOp->Common.Value.Integer);    /* Create the 3 leading ASCII letters */    Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40;    Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40;    Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40;    /* Verify that all 3 are ascii and alpha */    for (i = 0; i < 3; i++)    {        if (!ACPI_IS_ASCII (Prefix[i]) ||            !ACPI_IS_ALPHA (Prefix[i]))        {            return;        }    }    /* OK - mark this node as convertable to an EISA ID */    NextOp->Common.DisasmOpcode = ACPI_DASM_EISAID;}/******************************************************************************* * * FUNCTION:    AcpiDmEisaId * * PARAMETERS:  EncodedId       - Raw encoded EISA ID. * * RETURN:      None * * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String. * ******************************************************************************/voidAcpiDmEisaId (    UINT32                  EncodedId){    UINT32                  BigEndianId;    /* Swap from little-endian to big-endian to simplify conversion */    BigEndianId = AcpiUtDwordByteSwap (EncodedId);    /* Split to form "AAANNNN" string */    AcpiOsPrintf ("EisaId (\"%c%c%c%4.4X\")",        /* Three Alpha characters (AAA), 5 bits each */        (int) ((BigEndianId >> 26) & 0x1F) + 0x40,        (int) ((BigEndianId >> 21) & 0x1F) + 0x40,        (int) ((BigEndianId >> 16) & 0x1F) + 0x40,        /* Numeric part (NNNN) is simply the lower 16 bits */        (UINT32) (BigEndianId & 0xFFFF));}#endif

⌨️ 快捷键说明

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