aboutsummaryrefslogtreecommitdiff
path: root/resources/utilities/ich9deblob/src/gbe
diff options
context:
space:
mode:
authorFrancis Rowe <info@gluglug.org.uk>2014-12-28 17:33:50 +0000
committerFrancis Rowe <info@gluglug.org.uk>2014-12-28 17:33:50 +0000
commit4ff5a94eb974a783081ee358966b2022aaf1fb20 (patch)
tree242d67dcfcf3fb4f1f9f0f06097757ec707a7520 /resources/utilities/ich9deblob/src/gbe
parent779f26c4b48b792873438d99526ebe51c9db2565 (diff)
downloadlibrebootfr-4ff5a94eb974a783081ee358966b2022aaf1fb20.tar.gz
librebootfr-4ff5a94eb974a783081ee358966b2022aaf1fb20.zip
ich9deblob: added ich9gen utility
This can generate the descriptor+gbe images from scratch, without the need for a factory.bin dump.
Diffstat (limited to 'resources/utilities/ich9deblob/src/gbe')
-rw-r--r--resources/utilities/ich9deblob/src/gbe/gbe.c353
-rw-r--r--resources/utilities/ich9deblob/src/gbe/gbe.h16
2 files changed, 361 insertions, 8 deletions
diff --git a/resources/utilities/ich9deblob/src/gbe/gbe.c b/resources/utilities/ich9deblob/src/gbe/gbe.c
index b41b0dbe..12b8d990 100644
--- a/resources/utilities/ich9deblob/src/gbe/gbe.c
+++ b/resources/utilities/ich9deblob/src/gbe/gbe.c
@@ -94,12 +94,19 @@ struct GBEREGIONRECORD_8K deblobbedGbeStructFromFactory(struct GBEREGIONRECORD_8
* (for later chipsets) do. Maybe these are "reserved". Or maybe they are just junk.
*
* We really don't know. Blanking them with 0xFF seems harmless, though (nothing important seems broken).
+ *
+ * http://www.intel.co.uk/content/dam/doc/application-note/82573-nvm-map-appl-note.pdf
+ * That is a datasheet for a later chipset. Word 40H-53H seems (as per this datasheet) to be for AMT.
+ * Since libreboot disables and removes ME/AMT, it makes sense that blanking out words 40h to 53h
+ * has no effect on functionality, since ME/AMT is already removed (assuming that 40-53 is really for AMT).
*/
for(i = 0; i < sizeof(deblobbedGbeStruct8k.backup.padding); i++) {
deblobbedGbeStruct8k.backup.padding[i] = 0xFF; /* FF is correct. In the struct, this is a char buffer. */
- }
+ } /* We really only need to do this for words 40h-53h, but let's just nuke the whole lot. It's all 0xFF anyway. */
+ /* Fix the checksum */
deblobbedGbeStruct8k.backup.checkSum = gbeGetChecksumFrom4kStruct(deblobbedGbeStruct8k.backup, GBECHECKSUMTOTAL);
+ /* Main Gbe region on X200 (as shipped by Lenovo) is broken. Fix it by over-writing it with the contents of Gbe/Backup */
memcpy(&deblobbedGbeStruct8k.main, &deblobbedGbeStruct8k.backup, GBEREGIONSIZE_4K);
return deblobbedGbeStruct8k;
@@ -107,6 +114,350 @@ struct GBEREGIONRECORD_8K deblobbedGbeStructFromFactory(struct GBEREGIONRECORD_8
/*
* ---------------------------------------------------------------------
+ * C code generator (self-writing code)
+ * ---------------------------------------------------------------------
+ */
+
+/*
+ * Generate a C (.h) header file for the C source file made by notCreatedCFileFromGbeStruct4k()
+ *
+ * Output it to a file.
+ */
+int notCreatedHFileForGbeCFile(char* outFileName, char* cFileName)
+{
+ remove(outFileName); /* Remove the old file before continuing */
+
+ /* Open the file that will be written to */
+ FILE* fp = fopen(outFileName, "w+");
+
+ /* ------------------------------ */
+
+ fprintf(fp, "/* %s: generated C code from ich9deblob */\n", outFileName);
+ fprintf(fp, "/* .h header file for the gbe-generating C code (%s) */\n\n", cFileName);
+
+ fprintf(fp, "#ifndef ICH9GEN_MKGBE_H\n");
+ fprintf(fp, "#define ICH9GEN_MKGBE_H\n\n");
+
+ fprintf(fp, "#include <stdio.h>\n");
+ fprintf(fp, "#include <string.h>\n");
+ fprintf(fp, "#include \"../gbe/gbe.h\"\n\n");
+
+ fprintf(fp, "struct GBEREGIONRECORD_4K generatedGbeStruct4k();\n");
+ fprintf(fp, "struct GBEREGIONRECORD_8K generatedGbeStruct8k();\n\n");
+
+ fprintf(fp, "#endif\n");
+
+ /* ------------------------------ */
+
+ fclose(fp); /* Always close the file when done. */
+
+ return 0;
+}
+/*
+ * Generate a C source file that initializes the same data from a given
+ * 4KiB Gbe data structure.
+ *
+ * It will simply copy the 4KiB struct at the end to make a full 8KiB struct.
+ * So just pass a working 4KiB Gbe struct here and you're good to go.
+ *
+ * Output it to a file.
+ */
+int notCreatedCFileFromGbeStruct4k(struct GBEREGIONRECORD_4K gbeStruct4k, char* outFileName, char* headerFileName)
+{
+ int i;
+ int paddingSize;
+ int paddingIdentical;
+
+ remove(outFileName); /* Remove the old file before continuing */
+
+ /* Open the file that will be written to */
+ FILE* fp = fopen(outFileName, "w+");
+
+ /* ------------------------------ */
+
+ fprintf(fp, "/* %s: generated C code from ich9deblob */\n", outFileName);
+ fprintf(fp, "/* .c source file for the gbe-generating C code */\n\n");
+
+ fprintf(fp, "#include \"%s\"\n\n", headerFileName);
+
+ fprintf(fp, "/* Generate a 4KiB Gbe struct, with default values. */\n");
+ fprintf(fp, "/* Read ../gbe/gbe.h for an explanation of the default values used here */\n\n");
+
+ fprintf(fp, "struct GBEREGIONRECORD_4K generatedGbeStruct4k()\n");
+ fprintf(fp, "{\n");
+ fprintf(fp, " int i;\n");
+ fprintf(fp, " struct GBEREGIONRECORD_4K gbeStruct4k;\n");
+ fprintf(fp, "\n");
+ /* Words 00h to 02h: MAC Address */
+ fprintf(fp, " /* MAC address (words 00h to 02h) */\n");
+ for (i = 0; i < 6; i++) {
+ fprintf(fp, " gbeStruct4k.macAddress[%d] = 0x%02x;\n", i, gbeStruct4k.macAddress[i]);
+ }
+ fprintf(fp, "\n");
+ /* Word 03h (Reserved) */
+ fprintf(fp, " /* Word 03h (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord03h.reserved1_0 = 0x%02x;\n", gbeStruct4k.reservedWord03h.reserved1_0);
+ fprintf(fp, " gbeStruct4k.reservedWord03h.reserved1_1 = 0x%01x;\n", gbeStruct4k.reservedWord03h.reserved1_1);
+ fprintf(fp, " gbeStruct4k.reservedWord03h.ibaLom = 0x%01x;\n", gbeStruct4k.reservedWord03h.ibaLom);
+ fprintf(fp, " gbeStruct4k.reservedWord03h.reserved2 = 0x%01x;\n", gbeStruct4k.reservedWord03h.reserved2);
+ fprintf(fp, "\n");
+ /* Word 04h (Reserved) */
+ fprintf(fp, " /* Word 04h (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord04h = 0x%04x;\n", gbeStruct4k.reservedWord04h);
+ fprintf(fp, "\n");
+ /* Word 05h (Image Version Information) */
+ fprintf(fp, " /* Word 05h (Image Version Information) */\n");
+ fprintf(fp, " gbeStruct4k.imageVersionInformation = 0x%04x;\n", gbeStruct4k.imageVersionInformation);
+ fprintf(fp, "\n");
+ /* Words 06h and 07h (Reserved) */
+ fprintf(fp, " /* Words 06h and 07h (Reserved) */\n");
+ for (i = 0; i < 2; i++) {
+ fprintf(fp, " gbeStruct4k.reservedWords06h07h[%d] = 0x%04x;\n", i, gbeStruct4k.reservedWords06h07h[i]);
+ }
+ fprintf(fp, "\n");
+ /* Words 08h and 09h (PBA Low and PBA High) */
+ fprintf(fp, " /* Word 08h and 09h (PBA Low and PBA High) */\n");
+ fprintf(fp, " gbeStruct4k.pbaLow = 0x%04x;\n", gbeStruct4k.pbaLow);
+ fprintf(fp, " gbeStruct4k.pbaHigh = 0x%04x;\n", gbeStruct4k.pbaHigh);
+ fprintf(fp, "\n");
+ /* Word 0Ah (PCI Initialization Control Word) */
+ fprintf(fp, " /* Word 0Ah (PCI Initialization Control Word) */\n");
+ fprintf(fp, " gbeStruct4k.pciInitializationControlWord.loadVendorDeviceId = 0x%01x;\n", gbeStruct4k.pciInitializationControlWord.loadVendorDeviceId);
+ fprintf(fp, " gbeStruct4k.pciInitializationControlWord.loadSubsystemId = 0x%01x;\n", gbeStruct4k.pciInitializationControlWord.loadSubsystemId);
+ fprintf(fp, " gbeStruct4k.pciInitializationControlWord.reserved1 = 0x%01x;\n", gbeStruct4k.pciInitializationControlWord.reserved1);
+ fprintf(fp, " gbeStruct4k.pciInitializationControlWord.reserved2 = 0x%01x;\n", gbeStruct4k.pciInitializationControlWord.reserved2);
+ fprintf(fp, " gbeStruct4k.pciInitializationControlWord.pmEnable = 0x%01x;\n", gbeStruct4k.pciInitializationControlWord.pmEnable);
+ fprintf(fp, " gbeStruct4k.pciInitializationControlWord.auxPwr = 0x%01x;\n", gbeStruct4k.pciInitializationControlWord.auxPwr);
+ fprintf(fp, " gbeStruct4k.pciInitializationControlWord.reserved3 = 0x%01x;\n", gbeStruct4k.pciInitializationControlWord.reserved3);
+ fprintf(fp, " gbeStruct4k.pciInitializationControlWord.reserved4 = 0x%01x;\n", gbeStruct4k.pciInitializationControlWord.reserved4);
+ fprintf(fp, "\n");
+ /* Word 0Bh (Subsystem ID) */
+ fprintf(fp, " /* Word 0Bh (Subsystem ID) */\n");
+ fprintf(fp, " gbeStruct4k.subsystemId = 0x%04x;\n", gbeStruct4k.subsystemId);
+ fprintf(fp, "\n");
+ /* Word 0Ch (Subsystem Vendor ID) */
+ fprintf(fp, " /* Word 0Ch (Subsystem Vendor ID) */\n");
+ fprintf(fp, " gbeStruct4k.subsystemVendorId = 0x%04x;\n", gbeStruct4k.subsystemVendorId);
+ fprintf(fp, "\n");
+ /* Word 0Dh (Device ID) */
+ fprintf(fp, " /* Word 0Dh (Device ID) */\n");
+ fprintf(fp, " gbeStruct4k.deviceId = 0x%04x;\n", gbeStruct4k.deviceId);
+ fprintf(fp, "\n");
+ /* Word 0Eh (Vendor ID) */
+ fprintf(fp, " /* Word 0Eh (Vendor ID) */\n");
+ fprintf(fp, " gbeStruct4k.vendorId = 0x%04x;\n", gbeStruct4k.vendorId);
+ fprintf(fp, "\n");
+ /* Word 0Fh (Device Revision ID) */
+ fprintf(fp, " /* Word 0Fh (Device Revision ID) */\n");
+ fprintf(fp, " gbeStruct4k.deviceRevId = 0x%04x;\n", gbeStruct4k.deviceRevId);
+ fprintf(fp, "\n");
+ /* Word 10h (LAN Power Consumption) */
+ fprintf(fp, " /* Word 10h (LAN Power Consumption) */\n");
+ fprintf(fp, " gbeStruct4k.lanPowerConsumption.lanD3Power = 0x%02x;\n", gbeStruct4k.lanPowerConsumption.lanD3Power);
+ fprintf(fp, " gbeStruct4k.lanPowerConsumption.reserved = 0x%01x;\n", gbeStruct4k.lanPowerConsumption.reserved);
+ fprintf(fp, " gbeStruct4k.lanPowerConsumption.lanD0Power = 0x%02x;\n", gbeStruct4k.lanPowerConsumption.lanD0Power);
+ fprintf(fp, "\n");
+ /* Words 11h and 12h (Reserved) */
+ fprintf(fp, " /* Words 11h and 12h (Reserved) */\n");
+ for (i = 0; i < 2; i++) {
+ fprintf(fp, " gbeStruct4k.reservedWords11h12h[%d] = 0x%04x;\n", i, gbeStruct4k.reservedWords11h12h[i]);
+ }
+ fprintf(fp, "\n");
+ /* Word 13h (Shared Initialization Control Word) */
+ fprintf(fp, " /* Word 13h (Shared Initialization Control Word) */\n");
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.reserved1 = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.reserved1);
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.forceDuplex = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.forceDuplex);
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.forceSpeedEnable = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.forceSpeedEnable);
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.reserved2_0 = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.reserved2_0);
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.reserved2_1 = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.reserved2_1);
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.phyPowerDownEnable = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.phyPowerDownEnable);
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.reserved3 = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.reserved3);
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.reserved4 = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.reserved4);
+ fprintf(fp, " gbeStruct4k.sharedInitializationControlWord.sign = 0x%01x;\n", gbeStruct4k.sharedInitializationControlWord.sign);
+ fprintf(fp, "\n");
+ /* Word 14h (Extended Configuration Control Word 1) */
+ fprintf(fp, " /* Word 14h (Extended Configuration Control Word 1) */\n");
+ fprintf(fp, " gbeStruct4k.extendedConfigurationControlWord1.extendedConfigurationPointer = 0x%03x;\n", gbeStruct4k.extendedConfigurationControlWord1.extendedConfigurationPointer);
+ fprintf(fp, " gbeStruct4k.extendedConfigurationControlWord1.oemWriteEnable = 0x%01x;\n", gbeStruct4k.extendedConfigurationControlWord1.oemWriteEnable);
+ fprintf(fp, " gbeStruct4k.extendedConfigurationControlWord1.reserved1 = 0x%01x;\n", gbeStruct4k.extendedConfigurationControlWord1.reserved1);
+ fprintf(fp, " gbeStruct4k.extendedConfigurationControlWord1.reserved2 = 0x%01x;\n", gbeStruct4k.extendedConfigurationControlWord1.reserved2);
+ fprintf(fp, " gbeStruct4k.extendedConfigurationControlWord1.reserved3 = 0x%01x;\n", gbeStruct4k.extendedConfigurationControlWord1.reserved3);
+ fprintf(fp, "\n");
+ /* Word 15h (Extended Configuration Control Word 2) */
+ fprintf(fp, " /* Word 15h (Extended Configuration Control Word 2) */\n");
+ fprintf(fp, " gbeStruct4k.extendedConfigurationControlWord2.reserved = 0x%02x;\n", gbeStruct4k.extendedConfigurationControlWord2.reserved);
+ fprintf(fp, " gbeStruct4k.extendedConfigurationControlWord2.extendedPhyLength = 0x%02x;\n", gbeStruct4k.extendedConfigurationControlWord2.extendedPhyLength);
+ fprintf(fp, "\n");
+ /* Word 16h (Extended Configuration Control Word 3) */
+ fprintf(fp, " /* Word 16h (Extended Configuration Control Word 3) */\n");
+ fprintf(fp, " gbeStruct4k.extendedConfigurationControlWord3 = 0x%04x;\n", gbeStruct4k.extendedConfigurationControlWord3);
+ fprintf(fp, "\n");
+ /* Word 17h (LED 1 Configuration and Power Management) */
+ fprintf(fp, " /* Word 17h (LED 1 Configuration and Power Management) */\n");
+ fprintf(fp, " gbeStruct4k.ledCtl1.led1Mode = 0x%01x;\n", gbeStruct4k.ledCtl1.led1Mode);
+ fprintf(fp, " gbeStruct4k.ledCtl1.reserved1 = 0x%01x;\n", gbeStruct4k.ledCtl1.reserved1);
+ fprintf(fp, " gbeStruct4k.ledCtl1.led1BlinkMode = 0x%01x;\n", gbeStruct4k.ledCtl1.led1BlinkMode);
+ fprintf(fp, " gbeStruct4k.ledCtl1.led1Invert = 0x%01x;\n", gbeStruct4k.ledCtl1.led1Invert);
+ fprintf(fp, " gbeStruct4k.ledCtl1.led1Blink = 0x%01x;\n", gbeStruct4k.ledCtl1.led1Blink);
+ fprintf(fp, " gbeStruct4k.ledCtl1.reserved2 = 0x%01x;\n", gbeStruct4k.ledCtl1.reserved2);
+ fprintf(fp, " gbeStruct4k.ledCtl1.lpluEnable = 0x%01x;\n", gbeStruct4k.ledCtl1.lpluEnable);
+ fprintf(fp, " gbeStruct4k.ledCtl1.lpluEnableNonD0a = 0x%01x;\n", gbeStruct4k.ledCtl1.lpluEnableNonD0a);
+ fprintf(fp, " gbeStruct4k.ledCtl1.gbeDisableNonD0a = 0x%01x;\n", gbeStruct4k.ledCtl1.gbeDisableNonD0a);
+ fprintf(fp, " gbeStruct4k.ledCtl1.reserved3 = 0x%01x;\n", gbeStruct4k.ledCtl1.reserved3);
+ fprintf(fp, " gbeStruct4k.ledCtl1.gbeDisable = 0x%01x;\n", gbeStruct4k.ledCtl1.gbeDisable);
+ fprintf(fp, " gbeStruct4k.ledCtl1.reserved4 = 0x%01x;\n", gbeStruct4k.ledCtl1.reserved4);
+ fprintf(fp, "\n");
+ /* Word 18h (LED 0 and 2 Configuration Defaults) */
+ fprintf(fp, " /* Word 18h (LED 0 and 2 Configuration Defaults) */\n");
+ fprintf(fp, " gbeStruct4k.ledCtl02.led0Mode = 0x%01x;\n", gbeStruct4k.ledCtl02.led0Mode);
+ fprintf(fp, " gbeStruct4k.ledCtl02.reserved1 = 0x%01x;\n", gbeStruct4k.ledCtl02.reserved1);
+ fprintf(fp, " gbeStruct4k.ledCtl02.led0BlinkMode = 0x%01x;\n", gbeStruct4k.ledCtl02.led0BlinkMode);
+ fprintf(fp, " gbeStruct4k.ledCtl02.led0Invert = 0x%01x;\n", gbeStruct4k.ledCtl02.led0Invert);
+ fprintf(fp, " gbeStruct4k.ledCtl02.led0Blink = 0x%01x;\n", gbeStruct4k.ledCtl02.led0Blink);
+ fprintf(fp, " gbeStruct4k.ledCtl02.led2Mode = 0x%01x;\n", gbeStruct4k.ledCtl02.led2Mode);
+ fprintf(fp, " gbeStruct4k.ledCtl02.reserved2 = 0x%01x;\n", gbeStruct4k.ledCtl02.reserved2);
+ fprintf(fp, " gbeStruct4k.ledCtl02.led2BlinkMode = 0x%01x;\n", gbeStruct4k.ledCtl02.led2BlinkMode);
+ fprintf(fp, " gbeStruct4k.ledCtl02.led2Invert = 0x%01x;\n", gbeStruct4k.ledCtl02.led2Invert);
+ fprintf(fp, " gbeStruct4k.ledCtl02.led2Blink = 0x%01x;\n", gbeStruct4k.ledCtl02.led2Blink);
+ fprintf(fp, "\n");
+ /* Word 19h (Reserved) */
+ fprintf(fp, " /* Word 19h (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord19h = 0x%04x;\n", gbeStruct4k.reservedWord19h);
+ fprintf(fp, "\n");
+ /* Word 1Ah (Reserved) */
+ fprintf(fp, " /* Word 1Ah (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord1Ah = 0x%04x;\n", gbeStruct4k.reservedWord1Ah);
+ fprintf(fp, "\n");
+ /* Word 1Bh (Reserved) */
+ fprintf(fp, " /* Word 1Bh (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord1Bh = 0x%04x;\n", gbeStruct4k.reservedWord1Bh);
+ fprintf(fp, "\n");
+ /* Word 1Ch (Reserved) */
+ fprintf(fp, " /* Word 1Ch (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord1Ch = 0x%04x;\n", gbeStruct4k.reservedWord1Ch);
+ fprintf(fp, "\n");
+ /* Word 1Dh (Reserved) */
+ fprintf(fp, " /* Word 1Dh (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord1Dh = 0x%04x;\n", gbeStruct4k.reservedWord1Dh);
+ fprintf(fp, "\n");
+ /* Word 1Eh (Device ID for Intel 82567LM gigabit ethernet controller) */
+ fprintf(fp, " /* Word 1Eh (Device ID for Intel 82567LM gigabit ethernet controller) */\n");
+ fprintf(fp, " gbeStruct4k._82567lmDeviceId = 0x%04x;\n", gbeStruct4k._82567lmDeviceId);
+ fprintf(fp, "\n");
+ /* Word 1Fh (Device ID for Intel 82567LF gigabit ethernet controller) */
+ fprintf(fp, " /* Word 1Fh (Device ID for Intel 82567LF gigabit ethernet controller) */\n");
+ fprintf(fp, " gbeStruct4k._82567lfDeviceId = 0x%04x;\n", gbeStruct4k._82567lfDeviceId);
+ fprintf(fp, "\n");
+ /* Word 20h (Reserved) */
+ fprintf(fp, " /* Word 20h (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord20h = 0x%04x;\n", gbeStruct4k.reservedWord20h);
+ fprintf(fp, "\n");
+ /* Word 21h (Device ID for Intel 82567V gigabit ethernet controller) */
+ fprintf(fp, " /* Word 21h (Device ID for Intel 82567V gigabit ethernet controller) */\n");
+ fprintf(fp, " gbeStruct4k._82567vDeviceId = 0x%04x;\n", gbeStruct4k._82567vDeviceId);
+ fprintf(fp, "\n");
+ /* Word 22h (Reserved) */
+ fprintf(fp, " /* Word 22h (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord22h = 0x%04x;\n", gbeStruct4k.reservedWord22h);
+ fprintf(fp, "\n");
+ /* Word 23h (Reserved) */
+ fprintf(fp, " /* Word 23h (Reserved) */\n");
+ fprintf(fp, " gbeStruct4k.reservedWord23h = 0x%04x;\n", gbeStruct4k.reservedWord23h);
+ fprintf(fp, "\n");
+ /* Words 24h to 2Fh (Reserved) */
+ fprintf(fp, " /* Words 24h to 2Fh (Reserved) */\n");
+ for (i = 0; i < 12; i++) {
+ fprintf(fp, " gbeStruct4k.reservedWords24to2Fh[%d] = 0x%04x;\n", i, gbeStruct4k.reservedWords24to2Fh[i]);
+ }
+ fprintf(fp, "\n");
+ /* Words 30h to 3Eh (PXE Software Region) */
+ fprintf(fp, " /* Words 30h to 3Eh (PXE Software Region) */\n");
+ fprintf(fp, " /* Boot Agent Main Setup Options (Word 30h) */\n");
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.protocolSelect = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.protocolSelect);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.reserved1 = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.reserved1);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.defaultBootSelection = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.defaultBootSelection);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.reserved2 = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.reserved2);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.promptTime = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.promptTime);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.displaySetupMessage = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.displaySetupMessage);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.reserved3 = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.reserved3);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.forceSpeed = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.forceSpeed);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.forceFullDuplex = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.forceFullDuplex);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.reserved4 = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.reserved4);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.efiPresence = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.efiPresence);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.pxePresence = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentMainSetupOptions.pxePresence);
+ fprintf(fp, " /* Boot Agent Configuration Customization Options (Word 31h) */\n");
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableSetupMenu = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableSetupMenu);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableTitleMessage = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableTitleMessage);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableProtocolSelect = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableProtocolSelect);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableBootSelection = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableBootSelection);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableLegacyWakeupSupport = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableLegacyWakeupSupport);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableFlashUpdate = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.disableFlashUpdate);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.reserved1 = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.reserved1);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.ibaBootOrderSetupMode = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.ibaBootOrderSetupMode);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.reserved2 = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.reserved2);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.signature = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions31h.signature);
+ fprintf(fp, " /* Boot Agent Configuration Customization Options (Word 32h) */\n");
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions32h.buildNumber = 0x%02x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions32h.buildNumber);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions32h.minorVersionNumber = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions32h.minorVersionNumber);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions32h.majorVersionNumber = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.bootAgentConfigurationCustomizationOptions32h.majorVersionNumber);
+ fprintf(fp, " /* IBA Capabilities (Word 33h) */\n");
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.baseCodePresent = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.baseCodePresent);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.undiCapabilityPresent = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.undiCapabilityPresent);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.reserved1 = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.reserved1);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.efiUndiCapabilityPresent = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.efiUndiCapabilityPresent);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.reserved2_0 = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.reserved2_0);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.reserved2_1 = 0x%02x;\n", gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.reserved2_1);
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.signature = 0x%01x;\n", gbeStruct4k.pxeSoftwareRegion.ibaCapabilities.signature);
+ fprintf(fp, " /* Padding (Words 34h to 3Eh) */\n");
+ for (i = 0; i < 11; i++) {
+ fprintf(fp, " gbeStruct4k.pxeSoftwareRegion.paddingWords34hTo3Eh[%d] = 0x%04x;\n", i, gbeStruct4k.pxeSoftwareRegion.paddingWords34hTo3Eh[i]);
+ }
+ fprintf(fp, "\n");
+ /* Word 3Fh (Checksum) */
+ fprintf(fp, " /* Word 3Fh (Checksum) */\n");
+ fprintf(fp, " gbeStruct4k.checkSum = 0x%04x;\n", gbeStruct4k.checkSum);
+ fprintf(fp, "\n");
+ /* The rest of Gbe is just padding */
+ paddingSize = sizeof(gbeStruct4k.padding);
+ paddingIdentical = 1; /* Assume that it's all 0xFF, then try to disprove it */
+ for (i = 0; i < paddingSize; i++) { /* check whether contents differ */
+ if (gbeStruct4k.padding[i] != 0xFF) {
+ paddingIdentical = 0;
+ break;
+ }
+ }
+ if (!paddingIdentical) {
+ fprintf(fp, " /* The rest of Gbe (word 40h or byte 80h onwards) is just padding */\n");
+ for (i = 0; i < paddingSize; i++) { /* contents are not all 0xFF, just spit them all out one by one */
+ fprintf(fp, " gbeStruct4k.padding[%d] = 0x%02x;\n", i, gbeStruct4k.padding[i]);
+ }
+ } else { /* contents are all 0xFF. Generate a small for loop that sets them all to 0xFF */
+ fprintf(fp, " /* The rest of Gbe (word 40h or byte 80h onwards) is just padding (0xFF) */\n");
+ fprintf(fp, " for (i = 0; i < %d; i++) {\n", paddingSize);
+ fprintf(fp, " gbeStruct4k.padding[i] = 0xFF;\n");
+ fprintf(fp, " }\n");
+ }
+ fprintf(fp, "\n");
+ fprintf(fp, " return gbeStruct4k;\n");
+ fprintf(fp, "}\n\n");
+
+ fprintf(fp, "struct GBEREGIONRECORD_8K generatedGbeStruct8k()\n");
+ fprintf(fp, "{\n");
+ fprintf(fp, " struct GBEREGIONRECORD_8K gbeStruct8k;\n");
+ fprintf(fp, " gbeStruct8k.main = generatedGbeStruct4k();\n");
+ fprintf(fp, " memcpy(&gbeStruct8k.backup, &gbeStruct8k.main, GBEREGIONSIZE_4K);\n");
+ fprintf(fp, " return gbeStruct8k;\n");
+ fprintf(fp, "}\n\n");
+
+ /* ------------------------------ */
+
+ fclose(fp); /* Always close the file when done. */
+
+ return 0;
+}
+
+/*
+ * ---------------------------------------------------------------------
* Debugging functions:
* ---------------------------------------------------------------------
*/
diff --git a/resources/utilities/ich9deblob/src/gbe/gbe.h b/resources/utilities/ich9deblob/src/gbe/gbe.h
index 5422374c..7ba59e27 100644
--- a/resources/utilities/ich9deblob/src/gbe/gbe.h
+++ b/resources/utilities/ich9deblob/src/gbe/gbe.h
@@ -164,8 +164,8 @@ struct LED_CTL_1 {
unsigned char led1Invert : 1; /* initial value of LED1_IVRT field. 0 = led1 has active low output, 1 is high active output. Default is 0 according to datasheet and deblobbed_descriptor.bin */
unsigned char led1Blink : 1; /* 1 = led1 blinks, 0 = it does not. default 0 according to datasheet, but it's 1 in deblobbed_descriptor.bin */
unsigned char reserved2 : 1; /* Reserved. should be 1 according to datasheet and deblobbed_descriptor.bin */
- unsigned char lpluEnable : 1; /* Low Power Link Up. Enable links at lowest supported speed by both link partners in all power states. 1=enabled(all power states), 0=disabled. Default is 0 according to datasheet and 1 according to deblobbed_descriptor.bin */
- unsigned char lpluEnableNonD0a : 1; /* Low Power Link up (non-D0a states). Same as above but only for non-D0a states. default is 1 according to datasheet but 0 in deblobbed_descriptor.bin */
+ unsigned char lpluEnable : 1; /* Low Power Link Up. Enable links at lowest supported speed by both link partners in all power states. 1=enabled(all power states), 0=disabled. Default is 0 according to datasheet and deblobbed_descriptor.bin */
+ unsigned char lpluEnableNonD0a : 1; /* Low Power Link up (non-D0a states). Same as above but only for non-D0a states. default is 1 according to and deblobbed_descriptor.bin */
unsigned char gbeDisableNonD0a : 1; /* If set to 1, disable gigabit speeds in non-D0a power states. Must be 1 (according to datasheet) because GbE is not supported in Sx mode. It's also set to 1 in deblobbed_descriptor.bin */
unsigned char reserved3 : 2; /* Reserved. Datasheet says both bits should be 0 (confirmed in deblobbed_descriptor.bin) */
unsigned char gbeDisable : 1; /* When 1, gigabit speeds are disabled in all power states including D0a. Default is 0 according to datasheet and deblobbed_descriptor.bin */
@@ -250,7 +250,7 @@ struct GBE_PXE_BOOT_AGENT_CONFIGURATION_CUSTOMIZATION_OPTIONS_32H {
/* least significant bits */
unsigned char buildNumber : 8; /* PXE boot agent build number. default is 28 (hex). deblobbed_descriptor.bin says 18 (hex) */
unsigned char minorVersionNumber : 4; /* PXE boot agent minor number. default is 2 (hex). deblobbed_descriptor.bin says 3 (hex) */
- unsigned char majorVersionNumber : 4; /* PXE boot agent makor number. default is F (hex). deblobbed_descriptor.bin says 1 (hex) */
+ unsigned char majorVersionNumber : 4; /* PXE boot agent major number. default is F (hex). deblobbed_descriptor.bin says 1 (hex) */
/* most significant bits */
/* This whole data structure is pointless, since libreboot doesn't (read: won't)
@@ -293,9 +293,9 @@ struct GBE_PXE_SOFTWARE_REGION {
struct GBEREGIONRECORD_4K {
unsigned char macAddress[6]; /* Word 00 to 02 */
struct GBE_RESERVED_WORD_03H reservedWord03h; /* Reserved word 03. */
- unsigned short reservedWord04h; /* Reserved word 04: set it to 0xFFFF (according to datasheet) */
+ unsigned short reservedWord04h; /* Reserved word 04: set it to 0xFFFF (according to datasheet and deblobbed_descriptor.bin) */
unsigned short imageVersionInformation; /* Reserved word 05: 83 10 (little endian) in my deblobbed_descriptor.bin. Set this to 0x1083 (in C, assuming little endian byte order). "cannot be changed" according to datasheet */
- unsigned short reservedWords06h07h[2]; /* Reserved words 06-07: set both to 0xFFFF (according to datasheet) */
+ unsigned short reservedWords06h07h[2]; /* Reserved words 06-07: set both to 0xFFFF (according to datasheet and deblobbed_descriptor.bin) */
/*
* Word 08 and 09 (pba low and pba high):
@@ -312,8 +312,8 @@ struct GBEREGIONRECORD_4K {
*
* Setting it to FF FF FF FF should be fine, according to the datasheet.
*/
- unsigned short pbaLow; /* Word 08. Set it to 0x1008. */
- unsigned short pbaHigh; /* Word 09. Set it to 0xFFFF. */
+ unsigned short pbaLow; /* Word 08. Set it to 0x1008 (according to deblobbed_descriptor.bin). */
+ unsigned short pbaHigh; /* Word 09. Set it to 0xFFFF (according to deblobbed_descriptor.bin). */
/* Word 0A */
struct GBE_PCI_INITIALIZATION_CONTROL_WORD pciInitializationControlWord;
@@ -426,6 +426,8 @@ unsigned short gbeGetRegionWordFrom8kBuffer(int index, char* regionData);
unsigned short gbeGetChecksumFrom8kBuffer(char* regionData, unsigned short desiredValue, int byteOffset);
unsigned short gbeGetChecksumFrom4kStruct(struct GBEREGIONRECORD_4K gbeStruct4k, unsigned short desiredValue);
struct GBEREGIONRECORD_8K deblobbedGbeStructFromFactory(struct GBEREGIONRECORD_8K factoryGbeStruct8k);
+int notCreatedHFileForGbeCFile(char* outFileName, char* cFileName);
+int notCreatedCFileFromGbeStruct4k(struct GBEREGIONRECORD_4K gbeStruct4k, char* outFileName, char* headerFileName);
void printGbeChecksumDataFromStruct4k(struct GBEREGIONRECORD_4K gbeStruct4k, char* romName, char* regionName);
void printGbeChecksumDataFromStruct8k(struct GBEREGIONRECORD_8K gbeStruct8k, char* romName);