diff options
Diffstat (limited to 'resources/utilities/ich9deblob')
-rw-r--r-- | resources/utilities/ich9deblob/ich9deblob.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/resources/utilities/ich9deblob/ich9deblob.c b/resources/utilities/ich9deblob/ich9deblob.c index bd980b9..f99b4a4 100644 --- a/resources/utilities/ich9deblob/ich9deblob.c +++ b/resources/utilities/ich9deblob/ich9deblob.c @@ -61,26 +61,11 @@ unsigned short gbeGetChecksumFrom4kStruct(struct GBEREGIONRECORD_4K gbeStruct4k, unsigned short gbeGetChecksumFrom8kBuffer(char* buffer, unsigned short desiredValue, char isBackup); // for GBe region (checksum calculation) unsigned short gbeGetRegionWordFrom8kBuffer(int i, char* buffer); // used for getting each word needed to calculate said checksum struct DESCRIPTORREGIONRECORD deblobbedFromFactory(struct DESCRIPTORREGIONRECORD factoryDescriptorStruct, int romSize); - -// Basically, this should only return true on non-x86 machines -int structSizesIncorrect(struct DESCRIPTORREGIONRECORD descriptorDummy, struct GBEREGIONRECORD_8K gbe8kDummy) { - unsigned int descriptorRegionStructSize = sizeof(descriptorDummy); - unsigned int gbeRegion8kStructSize = sizeof(gbe8kDummy); - // check compiler bit-packs in a compatible way. basically, it is expected that this code will be used on x86 - if (DESCRIPTORREGIONSIZE != descriptorRegionStructSize){ - printf("\nerror: compiler incompatibility: descriptor struct length is %i bytes (should be %i)\n", descriptorRegionStructSize, DESCRIPTORREGIONSIZE); - return 1; - } - if (GBEREGIONSIZE != gbeRegion8kStructSize){ - printf("\nerror: compiler incompatibility: gbe struct length is %i bytes (should be %i)\n", gbeRegion8kStructSize, GBEREGIONSIZE); - return 1; - } - return 0; -} +int structSizesIncorrect(struct DESCRIPTORREGIONRECORD descriptorDummy, struct GBEREGIONRECORD_8K gbe8kDummy); +int systemIsBigEndian(); int main(int argc, char *argv[]) { - // descriptor region. Will have actual descriptor mapped to it (from the factory.rom dump) // and then it will be modified (deblobbed) to remove the ME/AMT struct DESCRIPTORREGIONRECORD factoryDescriptorStruct; @@ -90,15 +75,9 @@ int main(int argc, char *argv[]) struct GBEREGIONRECORD_8K factoryGbeStruct8k; struct GBEREGIONRECORD_8K deblobbedGbeStruct8k; + // Compatibility checks. This version of ich9deblob is not yet porable. if (structSizesIncorrect(factoryDescriptorStruct, factoryGbeStruct8k)) return 1; - - // endianness check. big endian forced to fail - unsigned short steak = 0xBEEF; - unsigned char *grill = (char*)&steak; - if (*grill==0xBE) { - printf("\nunsigned short 0xBEEF: first byte should be EF, but it's BE. Your system is big endian, and unsupported (only little endian is tested)\n"); - return 1; - } + if (systemIsBigEndian()) return 1; // ----------------------------------------------------------------------------------------------- @@ -288,6 +267,33 @@ int main(int argc, char *argv[]) return 0; } +// Basically, this should only return true on non-x86 machines +int structSizesIncorrect(struct DESCRIPTORREGIONRECORD descriptorDummy, struct GBEREGIONRECORD_8K gbe8kDummy) { + unsigned int descriptorRegionStructSize = sizeof(descriptorDummy); + unsigned int gbeRegion8kStructSize = sizeof(gbe8kDummy); + // check compiler bit-packs in a compatible way. basically, it is expected that this code will be used on x86 + if (DESCRIPTORREGIONSIZE != descriptorRegionStructSize){ + printf("\nerror: compiler incompatibility: descriptor struct length is %i bytes (should be %i)\n", descriptorRegionStructSize, DESCRIPTORREGIONSIZE); + return 1; + } + if (GBEREGIONSIZE != gbeRegion8kStructSize){ + printf("\nerror: compiler incompatibility: gbe struct length is %i bytes (should be %i)\n", gbeRegion8kStructSize, GBEREGIONSIZE); + return 1; + } + return 0; +} + +int systemIsBigEndian() { + // endianness check. big endian forced to fail + unsigned short steak = 0xBEEF; + unsigned char *grill = (char*)&steak; + if (*grill==0xBE) { + printf("\nunsigned short 0xBEEF: first byte should be EF, but it's BE. Your system is big endian, and unsupported (only little endian is tested)\n"); + return 1; + } + return 0; +} + // Modify the flash descriptor, to remove the ME/AMT, and disable all other regions // Only Flash Descriptor, Gbe and BIOS regions (BIOS region fills romSize-12k) are left. // Tested on ThinkPad X200 and X200S. X200T and other GM45 targets may also work. |