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 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"); }
void LsFlushListingBuffer ( UINT32 FileId) { UINT32 i; if (Gbl_CurrentHexColumn == 0) { return; } /* Write the hex bytes */ switch (FileId) { case ASL_FILE_LISTING_OUTPUT: for (i = 0; i < Gbl_CurrentHexColumn; i++) { FlPrintFile (FileId, "%2.2X ", Gbl_AmlBuffer[i]); } for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 3); i++) { FlWriteFile (FileId, ".", 1); } /* Write the ASCII character associated with each of the bytes */ LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); break; case ASL_FILE_ASM_SOURCE_OUTPUT: for (i = 0; i < Gbl_CurrentHexColumn; i++) { if (i > 0) { FlPrintFile (FileId, ","); } FlPrintFile (FileId, "0%2.2Xh", Gbl_AmlBuffer[i]); } for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++) { FlWriteFile (FileId, " ", 1); } FlPrintFile (FileId, " ;%8.8X", Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); /* Write the ASCII character associated with each of the bytes */ LsDumpAscii (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); break; case ASL_FILE_C_SOURCE_OUTPUT: for (i = 0; i < Gbl_CurrentHexColumn; i++) { FlPrintFile (FileId, "0x%2.2X,", Gbl_AmlBuffer[i]); } /* Pad hex output with spaces if line is shorter than max line size */ for (i = 0; i < ((HEX_LISTING_LINE_SIZE - Gbl_CurrentHexColumn) * 5); i++) { FlWriteFile (FileId, " ", 1); } /* AML offset for the start of the line */ FlPrintFile (FileId, " /* %8.8X", Gbl_CurrentAmlOffset - Gbl_CurrentHexColumn); /* Write the ASCII character associated with each of the bytes */ LsDumpAsciiInComment (FileId, Gbl_CurrentHexColumn, Gbl_AmlBuffer); FlPrintFile (FileId, " */"); break; default: /* No other types supported */ return; } FlPrintFile (FileId, "\n"); Gbl_CurrentHexColumn = 0; Gbl_HexBytesWereWritten = TRUE; }