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

📄 asllisting.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 3 页
字号:
 *              FileId          - ID of current listing file * * RETURN:      None. * * DESCRIPTION: Write "a node" to the listing file.  This means to *              1) Write out all of the source text associated with the node *              2) Write out all of the AML bytes associated with the node *              3) Write any compiler exceptions associated with the node * ******************************************************************************/static voidLsWriteNodeToListing (    ACPI_PARSE_OBJECT       *Op,    UINT32                  FileId){    const ACPI_OPCODE_INFO  *OpInfo;    UINT32                  OpClass;    char                    *Pathname;    UINT32                  Length;    UINT32                  i;    OpInfo  = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);    OpClass = OpInfo->Class;    /* TBD: clean this up with a single flag that says:     * I start a named output block     */    if (FileId == ASL_FILE_C_SOURCE_OUTPUT)    {        switch (Op->Asl.ParseOpcode)        {        case PARSEOP_DEFINITIONBLOCK:        case PARSEOP_METHODCALL:        case PARSEOP_INCLUDE:        case PARSEOP_INCLUDE_END:        case PARSEOP_DEFAULT_ARG:            break;        default:            switch (OpClass)            {            case AML_CLASS_NAMED_OBJECT:                switch (Op->Asl.AmlOpcode)                {                case AML_SCOPE_OP:                case AML_ALIAS_OP:                    break;                default:                    if (Op->Asl.ExternalName)                    {                        LsFlushListingBuffer (FileId);                        FlPrintFile (FileId, "    };\n");                    }                    break;                }                break;            default:                /* Don't care about other objects */                break;            }            break;        }    }    /* These cases do not have a corresponding AML opcode */    switch (Op->Asl.ParseOpcode)    {    case PARSEOP_DEFINITIONBLOCK:        LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);        /* Use the table Signature and TableId to build a unique name */        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)        {            FlPrintFile (FileId,                "%s_%s_Header \\\n",                Gbl_TableSignature, Gbl_TableId);        }        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)        {            FlPrintFile (FileId,                "    unsigned char    %s_%s_Header [] =\n    {\n",                Gbl_TableSignature, Gbl_TableId);        }        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)        {            FlPrintFile (FileId,                "extrn %s_%s_Header : byte\n",                Gbl_TableSignature, Gbl_TableId);        }        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)        {            FlPrintFile (FileId,                "extern unsigned char    %s_%s_Header [];\n",                Gbl_TableSignature, Gbl_TableId);        }        return;    case PARSEOP_METHODCALL:        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,            FileId);        return;    case PARSEOP_INCLUDE:        /* Flush everything up to and including the include source line */        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,            FileId);        /* Create a new listing node and push it */        LsPushNode (Op->Asl.Child->Asl.Value.String);        return;    case PARSEOP_INCLUDE_END:        /* Flush out the rest of the include file */        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,            FileId);        /* Pop off this listing node and go back to the parent file */        (void) LsPopNode ();        return;    case PARSEOP_DEFAULT_ARG:        if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)        {            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine,                FileId);        }        return;    default:        /* All other opcodes have an AML opcode */        break;    }    /*     * Otherwise, we look at the AML opcode because we can     * switch on the opcode type, getting an entire class     * at once     */    switch (OpClass)    {    case AML_CLASS_ARGUMENT:       /* argument type only */    case AML_CLASS_INTERNAL:        break;    case AML_CLASS_NAMED_OBJECT:        switch (Op->Asl.AmlOpcode)        {        case AML_FIELD_OP:        case AML_INDEX_FIELD_OP:        case AML_BANK_FIELD_OP:            /*             * For fields, we want to dump all the AML after the             * entire definition             */            LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,                FileId);            break;        case AML_NAME_OP:            if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)            {                LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,                    FileId);            }            else            {                /*                 * For fields, we want to dump all the AML after the                 * entire definition                 */                LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,                    FileId);            }            break;        default:            LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,                FileId);            break;        }        switch (Op->Asl.AmlOpcode)        {        case AML_SCOPE_OP:        case AML_ALIAS_OP:            /* These opcodes do not declare a new object, ignore them */            break;        default:            /* All other named object opcodes come here */            switch (FileId)            {            case ASL_FILE_ASM_SOURCE_OUTPUT:            case ASL_FILE_C_SOURCE_OUTPUT:            case ASL_FILE_ASM_INCLUDE_OUTPUT:            case ASL_FILE_C_INCLUDE_OUTPUT:                /*                 * For named objects, we will create a valid symbol so that the                 * AML code can be referenced from C or ASM                 */                if (Op->Asl.ExternalName)                {                    /* Get the full pathname associated with this node */                    Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);                    Length = strlen (Pathname);                    if (Length >= 4)                    {                        /* Convert all dots in the path to underscores */                        for (i = 0; i < Length; i++)                        {                            if (Pathname[i] == '.')                            {                                Pathname[i] = '_';                            }                        }                        /* Create the appropriate symbol in the output file */                        if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)                        {                            FlPrintFile (FileId,                                "%s_%s_%s  \\\n",                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);                        }                        if (FileId == ASL_FILE_C_SOURCE_OUTPUT)                        {                            FlPrintFile (FileId,                                "    unsigned char    %s_%s_%s [] =\n    {\n",                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);                        }                        if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT)                        {                            FlPrintFile (FileId,                                "extrn %s_%s_%s : byte\n",                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);                        }                        if (FileId == ASL_FILE_C_INCLUDE_OUTPUT)                        {                            FlPrintFile (FileId,                                "extern unsigned char    %s_%s_%s [];\n",                                Gbl_TableSignature, Gbl_TableId, &Pathname[1]);                        }                    }                    ACPI_FREE (Pathname);                }                break;            default:                /* Nothing to do for listing file */                break;            }        }        break;    case AML_CLASS_EXECUTE:    case AML_CLASS_CREATE:    default:        if ((Op->Asl.ParseOpcode == PARSEOP_BUFFER) &&            (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC))        {            return;        }        LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,            FileId);        break;    case AML_CLASS_UNKNOWN:        break;    }}/******************************************************************************* * * FUNCTION:    LsDoHexOutput * * PARAMETERS:  None * * RETURN:      None. * * DESCRIPTION: Create the hex output file. * ******************************************************************************/voidLsDoHexOutput (    void){    switch (Gbl_HexOutputFlag)    {    case HEX_OUTPUT_C:        LsDoHexOutputC ();        break;    case HEX_OUTPUT_ASM:        LsDoHexOutputAsm ();        break;    default:        /* No other output types supported */        break;    }}/******************************************************************************* * * FUNCTION:    LsDoHexOutputC * * PARAMETERS:  None * * RETURN:      None. * * DESCRIPTION: Create the hex output file.  This is the same data as the AML *              output file, but formatted into hex/ascii bytes suitable for *              inclusion into a C source file. * ******************************************************************************/static voidLsDoHexOutputC (    void){    UINT32                  j;    UINT8                   FileByte[HEX_TABLE_LINE_SIZE];    UINT8                   Buffer[4];    UINT32                  Offset = 0;    FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n *\n */\n");    FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] =\n{\n");    /* Start at the beginning of the AML file */    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);    /* Process all AML bytes in the AML file */    j = 0;    while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)    {        if (j == 0)        {            FlPrintFile (ASL_FILE_HEX_OUTPUT, "    ");        }        /* Convert each AML byte to hex */        UtConvertByteToHex (FileByte[j], Buffer);        FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);        FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");        /* An occasional linefeed improves readability */        Offset++;        j++;        if (j >= HEX_TABLE_LINE_SIZE)        {            /* End of line, emit the ascii dump of the entire line */            FlPrintFile (ASL_FILE_HEX_OUTPUT,                "  /* %8.8X", Offset - HEX_TABLE_LINE_SIZE);            /* Write the ASCII character associated with each of the bytes */            LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT,                HEX_TABLE_LINE_SIZE, FileByte);            FlPrintFile (ASL_FILE_HEX_OUTPUT, " */\n");            /* Start new line */            j = 0;        }    }    FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n};\n");    FlCloseFile (ASL_FILE_HEX_OUTPUT);}/******************************************************************************* * * FUNCTION:    LsDoHexOutputAsm * * PARAMETERS:  None * * RETURN:      None. * * DESCRIPTION: Create the hex output file.  This is the same data as the AML *              output file, but formatted into hex/ascii bytes suitable for *              inclusion into a ASM source file. * ******************************************************************************/static voidLsDoHexOutputAsm (    void){    UINT32                  j;    UINT8                   FileByte[HEX_TABLE_LINE_SIZE];    UINT8                   Buffer[4];    UINT32                  Offset = 0;    BOOLEAN                 DoComma = FALSE;    FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n;\n");    /* Start at the beginning of the AML file */    FlSeekFile (ASL_FILE_AML_OUTPUT, 0);    /* Process all AML bytes in the AML file */    j = 0;    while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte[j], 1) == AE_OK)    {        if (j == 0)        {            FlPrintFile (ASL_FILE_HEX_OUTPUT, "  db  ");        }        else if (DoComma)        {            FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");            DoComma = FALSE;        }        /* Convert each AML byte to hex */        UtConvertByteToAsmHex (FileByte[j], Buffer);        FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4);        /* An occasional linefeed improves readability */        Offset++;        j++;        if (j >= HEX_TABLE_LINE_SIZE)        {            FlPrintFile (ASL_FILE_HEX_OUTPUT,                "  ;%8.8X", Offset - HEX_TABLE_LINE_SIZE);            /* Write the ASCII character associated with each of the bytes */            LsDumpAscii (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte);            FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");            j = 0;        }        else        {            DoComma = TRUE;        }    }    FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");    FlCloseFile (ASL_FILE_HEX_OUTPUT);}

⌨️ 快捷键说明

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