static ACPI_STATUS LsAmlListingWalk ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { UINT8 FileByte; UINT32 i; UINT32 FileId = (UINT32) ACPI_TO_INTEGER (Context); LsWriteNodeToListing (Op, FileId); if (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DATA) { /* Buffer is a resource template, don't dump the data all at once */ return (AE_OK); } /* Write the hex bytes to the listing file(s) (if requested) */ for (i = 0; i < Op->Asl.FinalAmlLength; i++) { if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1))) { FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ); AslAbort (); } LsWriteListingHexBytes (&FileByte, 1, FileId); } return (AE_OK); }
void DtWriteTableToListing ( void) { UINT8 *Buffer; if (!Gbl_ListingFlag) { return; } /* Read the entire table from the output file */ Buffer = UtLocalCalloc (Gbl_TableLength); FlSeekFile (ASL_FILE_AML_OUTPUT, 0); FlReadFile (ASL_FILE_AML_OUTPUT, Buffer, Gbl_TableLength); /* Dump the raw table data */ AcpiOsRedirectOutput (Gbl_Files[ASL_FILE_LISTING_OUTPUT].Handle); AcpiOsPrintf ("\n%s: Length %d (0x%X)\n\n", ACPI_RAW_TABLE_DATA_HEADER, Gbl_TableLength, Gbl_TableLength); AcpiUtDumpBuffer2 (Buffer, Gbl_TableLength, DB_BYTE_DISPLAY); AcpiOsRedirectOutput (stdout); }
static void LsDoHexOutputC ( 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); }
static void CmFlushSourceCode ( void) { char Buffer; while (FlReadFile (ASL_FILE_INPUT, &Buffer, 1) != AE_ERROR) { AslInsertLineBuffer ((int) Buffer); } AslResetCurrentLineBuffer (); }
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); }
UINT32 LsWriteOneSourceLine ( UINT32 FileId) { UINT8 FileByte; UINT32 Column = 0; UINT32 Index = 16; BOOLEAN StartOfLine = FALSE; BOOLEAN ProcessLongLine = FALSE; Gbl_SourceLine++; Gbl_ListingNode->LineNumber++; /* Ignore lines that are completely blank (but count the line above) */ if (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) != AE_OK) { return (0); } if (FileByte == '\n') { return (1); } /* * This is a non-empty line, we will print the entire line with * the line number and possibly other prefixes and transforms. */ /* Line prefixes for special files, C and ASM output */ if (FileId == ASL_FILE_C_SOURCE_OUTPUT) { FlPrintFile (FileId, " *"); } if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) { FlPrintFile (FileId, "; "); } if (Gbl_HasIncludeFiles) { /* * This file contains "include" statements, print the current * filename and line number within the current file */ FlPrintFile (FileId, "%12s %5d%s", Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber, ASL_LISTING_LINE_PREFIX); } else { /* No include files, just print the line number */ FlPrintFile (FileId, "%8u%s", Gbl_SourceLine, ASL_LISTING_LINE_PREFIX); } /* Read the rest of this line (up to a newline or EOF) */ do { if (FileId == ASL_FILE_C_SOURCE_OUTPUT) { if (FileByte == '/') { FileByte = '*'; } } /* Split long input lines for readability in the listing */ Column++; if (Column >= 128) { if (!ProcessLongLine) { if ((FileByte != '}') && (FileByte != '{')) { goto WriteByte; } ProcessLongLine = TRUE; } if (FileByte == '{') { FlPrintFile (FileId, "\n%*s{\n", Index, " "); StartOfLine = TRUE; Index += 4; continue; } else if (FileByte == '}') { if (!StartOfLine) { FlPrintFile (FileId, "\n"); } StartOfLine = TRUE; Index -= 4; FlPrintFile (FileId, "%*s}\n", Index, " "); continue; } /* Ignore spaces/tabs at the start of line */ else if ((FileByte == ' ') && StartOfLine) { continue; } else if (StartOfLine) { StartOfLine = FALSE; FlPrintFile (FileId, "%*s", Index, " "); } WriteByte: FlWriteFile (FileId, &FileByte, 1); if (FileByte == '\n') { /* * This line has been completed. * Check if an error occurred on this source line during the compile. * If so, we print the error message after the source line. */ LsCheckException (Gbl_SourceLine, FileId); return (1); } } else { FlWriteFile (FileId, &FileByte, 1); if (FileByte == '\n') { /* * This line has been completed. * Check if an error occurred on this source line during the compile. * If so, we print the error message after the source line. */ LsCheckException (Gbl_SourceLine, FileId); return (1); } } } while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK); /* EOF on the input file was reached */ return (0); }
static UINT32 LsWriteOneSourceLine ( UINT32 FileId) { UINT8 FileByte; Gbl_SourceLine++; Gbl_ListingNode->LineNumber++; if (FileId == ASL_FILE_C_SOURCE_OUTPUT) { FlPrintFile (FileId, " *"); } if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) { FlPrintFile (FileId, "; "); } if (Gbl_HasIncludeFiles) { /* * This file contains "include" statements, print the current * filename and line number within the current file */ FlPrintFile (FileId, "%12s %5d....", Gbl_ListingNode->Filename, Gbl_ListingNode->LineNumber); } else { /* No include files, just print the line number */ FlPrintFile (FileId, "%8d....", Gbl_SourceLine); } /* Read one line (up to a newline or EOF) */ while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK) { if (FileId == ASL_FILE_C_SOURCE_OUTPUT) { if (FileByte == '/') { FileByte = '*'; } } FlWriteFile (FileId, &FileByte, 1); if (FileByte == '\n') { /* * Check if an error occurred on this source line during the compile. * If so, we print the error message after the source line. */ LsCheckException (Gbl_SourceLine, FileId); return (1); } } /* EOF on the input file was reached */ return (0); }
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); }