static void LsGenerateListing ( UINT32 FileId) { UINT32 WalkMode = ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_DB_SEPARATELY; /* Start at the beginning of both the source and AML files */ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); FlSeekFile (ASL_FILE_AML_OUTPUT, 0); AslGbl_SourceLine = 0; AslGbl_CurrentHexColumn = 0; LsPushNode (AslGbl_Files[ASL_FILE_INPUT].Filename); if (FileId == ASL_FILE_C_OFFSET_OUTPUT) { AslGbl_CurrentAmlOffset = 0; /* Offset table file has a special header and footer */ LsDoOffsetTableHeader (FileId); TrWalkParseTree (AslGbl_CurrentDB, WalkMode, LsAmlOffsetWalk, NULL, (void *) ACPI_TO_POINTER (FileId)); LsDoOffsetTableFooter (FileId); return; } /* Process all parse nodes */ TrWalkParseTree (AslGbl_CurrentDB, WalkMode, LsAmlListingWalk, NULL, (void *) ACPI_TO_POINTER (FileId)); /* Final processing */ LsFinishSourceListing (FileId); }
void CgGenerateAmlOutput ( void) { DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n"); /* Generate the AML output file */ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); Gbl_SourceLine = 0; Gbl_NextError = Gbl_ErrorLog; TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL); CgCloseTable (); }
void CgGenerateAmlOutput ( void) { /* Generate the AML output file */ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); Gbl_SourceLine = 0; Gbl_NextError = Gbl_ErrorLog; TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL); DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2); CgCloseTable (); }
void DtWriteFieldToListing ( UINT8 *Buffer, DT_FIELD *Field, UINT32 Length) { UINT8 FileByte; if (!Gbl_ListingFlag || !Field) { return; } /* Dump the original source line */ FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Input: "); FlSeekFile (ASL_FILE_INPUT, Field->ByteOffset); while (FlReadFile (ASL_FILE_INPUT, &FileByte, 1) == AE_OK) { FlWriteFile (ASL_FILE_LISTING_OUTPUT, &FileByte, 1); if (FileByte == '\n') { break; } } /* Dump the line as parsed and represented internally */ FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %.64s", Field->Column-4, Field->Name, Field->Value); if (strlen (Field->Value) > 64) { FlPrintFile (ASL_FILE_LISTING_OUTPUT, "...Additional data, length 0x%X\n", strlen (Field->Value)); } FlPrintFile (ASL_FILE_LISTING_OUTPUT, "\n"); /* Dump the hex data that will be output for this field */ DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length); }
void CgGenerateAmlOutput ( void) { DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n"); /* Generate the AML output file */ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); Gbl_SourceLine = 0; Gbl_NextError = Gbl_ErrorLog; TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL); DbgPrint (ASL_TREE_OUTPUT, "%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr" " Parent Child Next Flags AcTyp Final Col L# EL# LL# ELL#\n", 76, " "); CgCloseTable (); }
int CmDoAslMiddleAndBackEnd ( void) { UINT8 Event; ACPI_STATUS Status; /* Interpret and generate all compile-time constants */ Event = UtBeginEvent ("Constant folding via AML interpreter"); DbgPrint (ASL_DEBUG_OUTPUT, "Interpreting compile-time constant expressions\n\n"); if (AslGbl_FoldConstants) { TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlConstantWalk, NULL); } else { DbgPrint (ASL_PARSE_OUTPUT, " Optional folding disabled\n"); } UtEndEvent (Event); /* Update AML opcodes if necessary, after constant folding */ Event = UtBeginEvent ("Updating AML opcodes after constant folding"); DbgPrint (ASL_DEBUG_OUTPUT, "Updating AML opcodes after constant folding\n\n"); TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeUpdateWalk, NULL); UtEndEvent (Event); /* Calculate all AML package lengths */ Event = UtBeginEvent ("Generate AML package lengths"); DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n"); TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); UtEndEvent (Event); if (AslGbl_ParseOnlyFlag) { AePrintErrorLog (ASL_FILE_STDERR); UtDisplaySummary (ASL_FILE_STDERR); if (AslGbl_DebugFlag) { /* Print error summary to the stdout also */ AePrintErrorLog (ASL_FILE_STDOUT); UtDisplaySummary (ASL_FILE_STDOUT); } return (0); } /* * Create an internal namespace and use it as a symbol table */ /* Namespace loading */ Event = UtBeginEvent ("Create ACPI Namespace"); DbgPrint (ASL_DEBUG_OUTPUT, "Creating ACPI Namespace\n\n"); Status = LdLoadNamespace (AslGbl_ParseTreeRoot); UtEndEvent (Event); if (ACPI_FAILURE (Status)) { return (-1); } /* Namespace cross-reference */ AslGbl_NamespaceEvent = UtBeginEvent ( "Cross reference parse tree and Namespace"); DbgPrint (ASL_DEBUG_OUTPUT, "Cross referencing namespace\n\n"); Status = XfCrossReferenceNamespace (); if (ACPI_FAILURE (Status)) { return (-1); } /* Namespace - Check for non-referenced objects */ LkFindUnreferencedObjects (); UtEndEvent (AslGbl_NamespaceEvent); /* Resolve External Declarations */ Event = UtBeginEvent ("Resolve all Externals"); DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n"); if (AslGbl_DoExternalsInPlace) { TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, ExAmlExternalWalkBegin, NULL, NULL); } else { TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL); } UtEndEvent (Event); /* * Semantic analysis. This can happen only after the * namespace has been loaded and cross-referenced. * * part one - check control methods */ Event = UtBeginEvent ("Analyze control method return types"); AslGbl_AnalysisWalkInfo.MethodStack = NULL; DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method analysis\n\n"); if (AslGbl_CrossReferenceOutput) { OtPrintHeaders ("Part 1: Object Reference Map " "(Object references from within each control method)"); } TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE, MtMethodAnalysisWalkBegin, MtMethodAnalysisWalkEnd, &AslGbl_AnalysisWalkInfo); UtEndEvent (Event); /* Generate the object cross-reference file if requested */ Event = UtBeginEvent ("Generate cross-reference file"); OtCreateXrefFile (); UtEndEvent (Event); /* Semantic error checking part two - typing of method returns */ Event = UtBeginEvent ("Determine object types returned by methods"); DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Method typing\n\n"); TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, AnMethodTypingWalkEnd, NULL); UtEndEvent (Event); /* Semantic error checking part three - operand type checking */ Event = UtBeginEvent ("Analyze AML operand types"); DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - Operand type checking\n\n"); if (AslGbl_DoTypechecking) { TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, AnOperandTypecheckWalkEnd, &AslGbl_AnalysisWalkInfo); } UtEndEvent (Event); /* Semantic error checking part four - other miscellaneous checks */ Event = UtBeginEvent ("Miscellaneous analysis"); DbgPrint (ASL_DEBUG_OUTPUT, "Semantic analysis - miscellaneous\n\n"); TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD, AnOtherSemanticAnalysisWalkBegin, NULL, &AslGbl_AnalysisWalkInfo); UtEndEvent (Event); /* * ASL-/ASL+ converter: Gbl_ParseTreeRoot->CommentList contains the * very last comment of a given ASL file because it's the last constructed * node during compilation. We take the very last comment and save it in a * global for it to be used by the disassembler. */ if (AcpiGbl_CaptureComments) { AcpiGbl_LastListHead = AslGbl_ParseTreeRoot->Asl.CommentList; AslGbl_ParseTreeRoot->Asl.CommentList = NULL; } /* Calculate all AML package lengths */ Event = UtBeginEvent ("Finish AML package length generation"); DbgPrint (ASL_DEBUG_OUTPUT, "Generating Package lengths\n\n"); TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL); TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); UtEndEvent (Event); /* Code generation - emit the AML */ Event = UtBeginEvent ("Generate AML code and write output files"); DbgPrint (ASL_DEBUG_OUTPUT, "Writing AML byte code\n\n"); AslGbl_CurrentDB = AslGbl_ParseTreeRoot->Asl.Child; while (AslGbl_CurrentDB) { switch (FlSwitchFileSet(AslGbl_CurrentDB->Asl.Filename)) { case SWITCH_TO_DIFFERENT_FILE: /* * Reset these parameters when definition blocks belong in * different files. If they belong in the same file, there is * no need to reset these parameters */ FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0); AslGbl_SourceLine = 0; AslGbl_NextError = AslGbl_ErrorLog; /* fall-through */ case SWITCH_TO_SAME_FILE: CgGenerateAmlOutput (); CmDoOutputFiles (); AslGbl_CurrentDB = AslGbl_CurrentDB->Asl.Next; break; default: /* FILE_NOT_FOUND */ /* The requested file could not be found. Get out of here */ AslGbl_CurrentDB = NULL; break; } } UtEndEvent (Event); Event = UtBeginEvent ("Write optional output files"); UtEndEvent (Event); return (0); }
static void HxDoHexOutputAsm ( void) { UINT8 FileData[HEX_TABLE_LINE_SIZE]; UINT32 LineLength; UINT32 Offset = 0; UINT32 AmlFileSize; UINT32 i; /* Get AML size, seek back to start */ AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); FlSeekFile (ASL_FILE_AML_OUTPUT, 0); FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n"); FlPrintFile (ASL_FILE_HEX_OUTPUT, "; AML code block contains 0x%X bytes\n;\n", AmlFileSize); while (Offset < AmlFileSize) { /* Read enough bytes needed for one output line */ LineLength = HxReadAmlOutputFile (FileData); if (!LineLength) { break; } FlPrintFile (ASL_FILE_HEX_OUTPUT, " db "); for (i = 0; i < LineLength; i++) { /* * Print each hex byte. * Add a comma until the last byte of the line */ FlPrintFile (ASL_FILE_HEX_OUTPUT, "0%2.2Xh", FileData[i]); if ((i + 1) < LineLength) { FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); } } FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); /* Add fill spaces if needed for last line */ if (LineLength < HEX_TABLE_LINE_SIZE) { FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); } /* Emit the offset and ascii dump for the entire line */ FlPrintFile (ASL_FILE_HEX_OUTPUT, " ; %8.8X", Offset); LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); Offset += LineLength; } FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n"); }
static void HxDoHexOutputAsl ( void) { UINT8 FileData[HEX_TABLE_LINE_SIZE]; UINT32 LineLength; UINT32 Offset = 0; UINT32 AmlFileSize; UINT32 i; /* Get AML size, seek back to start */ AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT); FlSeekFile (ASL_FILE_AML_OUTPUT, 0); FlPrintFile (ASL_FILE_HEX_OUTPUT, " * ASL source code output\n"); FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n", AmlFileSize); FlPrintFile (ASL_FILE_HEX_OUTPUT, " Name (BUF1, Buffer()\n {\n"); while (Offset < AmlFileSize) { /* Read enough bytes needed for one output line */ LineLength = HxReadAmlOutputFile (FileData); if (!LineLength) { break; } FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); for (i = 0; i < LineLength; i++) { /* * Print each hex byte. * Add a comma until the very last byte of the AML file * (Some C compilers complain about a trailing comma) */ FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]); if ((Offset + i + 1) < AmlFileSize) { FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); } else { FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); } } /* Add fill spaces if needed for last line */ if (LineLength < HEX_TABLE_LINE_SIZE) { FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s", 5 * (HEX_TABLE_LINE_SIZE - LineLength), " "); } /* Emit the offset and ascii dump for the entire line */ FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset); LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData); FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n", HEX_TABLE_LINE_SIZE - LineLength + 1, " "); Offset += LineLength; } FlPrintFile (ASL_FILE_HEX_OUTPUT, " })\n"); }
static void LsDoHexOutputAsm ( 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); }