From 5ff75cb1f5135e7f04328e82418f8e3519ecf526 Mon Sep 17 00:00:00 2001 From: Francis Rowe Date: Mon, 22 Dec 2014 15:00:15 -0500 Subject: ich9deblob: refactor variable names to top of the main function --- (limited to 'resources') diff --git a/resources/utilities/ich9deblob/ich9deblob.c b/resources/utilities/ich9deblob/ich9deblob.c index 2c7e983..32c2f1f 100644 --- a/resources/utilities/ich9deblob/ich9deblob.c +++ b/resources/utilities/ich9deblob/ich9deblob.c @@ -68,15 +68,38 @@ struct GBEREGIONRECORD_8K deblobbedGbeStructFromFactory(struct GBEREGIONRECORD_8 int main(int argc, char *argv[]) { - // descriptor region. Will have actual descriptor mapped to it (from the factory.rom dump) + // descriptor region. Will have an actual descriptor struct mapped to it (from the factory.rom dump) // and then it will be modified (deblobbed) to remove the ME/AMT + char factoryDescriptorBuffer[DESCRIPTORREGIONSIZE]; struct DESCRIPTORREGIONRECORD factoryDescriptorStruct; + char deblobbedDescriptorBuffer[DESCRIPTORREGIONSIZE]; struct DESCRIPTORREGIONRECORD deblobbedDescriptorStruct; + // gbe region. Well have actual gbe buffer mapped to it (from the factory.rom dump) // and then it will be modified to correct the main region + char factoryGbeBuffer8k[GBEREGIONSIZE]; struct GBEREGIONRECORD_8K factoryGbeStruct8k; + char deblobbedGbeBuffer8k[GBEREGIONSIZE]; struct GBEREGIONRECORD_8K deblobbedGbeStruct8k; + // Used to store the location of the Gbe + // region inside the factory.rom image. + unsigned int factoryGbeRegionLocation; + + // These are used later to present the user + // before-after Gbe checksums when modifying the gbe region + unsigned short gbeCalculatedChecksum; + unsigned short gbeChecksum; + + // names of the files that this utility will handle + char* factoryRomFilename = "factory.rom"; // user-supplied factory.bin dump (original firmware) + char* deblobbedDescriptorFilename = "deblobbed_descriptor.bin"; // descriptor+gbe: to be dd'd to beginning of a libreboot image + + // Used when reading the factory.rom to extract descriptor/gbe regions + unsigned int bufferLength; + + // ----------------------------------------------------------------------------------------------- + // Compatibility checks. This version of ich9deblob is not yet porable. if (structSizesIncorrect(factoryDescriptorStruct, factoryGbeStruct8k)) return 1; if (systemIsBigEndian()) return 1; @@ -84,13 +107,6 @@ int main(int argc, char *argv[]) if (structMembersWrongOrder()) return 1; // ----------------------------------------------------------------------------------------------- - - // files that this utility will handle - - // supplied by user, dumped from their machine before flashing libreboot - char* factoryRomFilename = "factory.rom"; - // name of the file that this utility will create (deblobbed descriptor+gbe) - char* deblobbedDescriptorFilename = "deblobbed_descriptor.bin"; // Open factory.rom, needed for extracting descriptor and gbe // ----------------------------------------------- @@ -105,16 +121,11 @@ int main(int argc, char *argv[]) // ----------------------------------------------- // Get the descriptor region dump from the factory.rom - - // Create empty descriptor buffer (populated below) - char factoryDescriptorBuffer[DESCRIPTORREGIONSIZE]; - // Extract the descriptor region from the factory.rom dump // (goes in factoryDescriptorBuffer variable) - unsigned int readLen; - readLen = fread(factoryDescriptorBuffer, sizeof(char), DESCRIPTORREGIONSIZE, fp); - if (DESCRIPTORREGIONSIZE != readLen) // + bufferLength = fread(factoryDescriptorBuffer, sizeof(char), DESCRIPTORREGIONSIZE, fp); + if (DESCRIPTORREGIONSIZE != bufferLength) // { - printf("\nerror: could not read descriptor from factory.rom (%i) bytes read\n", readLen); + printf("\nerror: could not read descriptor from factory.rom (%i) bytes read\n", bufferLength); return 1; } printf("\ndescriptor region read successfully\n"); @@ -136,18 +147,16 @@ int main(int argc, char *argv[]) // (it will be moved to the beginning of the flash, after the descriptor region) // note for example, factoryGbeRegionLocation is set to <