aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorFrancis Rowe <info@gluglug.org.uk>2014-12-22 11:23:41 +0000
committerFrancis Rowe <info@gluglug.org.uk>2014-12-22 11:23:41 +0000
commitdf462c2336dd90af9b55b61cbac8c75efc98e07a (patch)
tree1dd77780eb2faed3520a97361451222ecb0c1bad /resources
parent970ab39a7f36089b8e5030412767c1a720099e81 (diff)
downloadlibrebootfr-df462c2336dd90af9b55b61cbac8c75efc98e07a.tar.gz
librebootfr-df462c2336dd90af9b55b61cbac8c75efc98e07a.zip
ich9deblob: make it possible to calculate checksum of backup gbe
Diffstat (limited to 'resources')
-rw-r--r--resources/utilities/ich9deblob/ich9deblob.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/resources/utilities/ich9deblob/ich9deblob.c b/resources/utilities/ich9deblob/ich9deblob.c
index a2819bfd..5c493587 100644
--- a/resources/utilities/ich9deblob/ich9deblob.c
+++ b/resources/utilities/ich9deblob/ich9deblob.c
@@ -53,7 +53,7 @@
// The 2nd one is a "backup", but we don't know when it's used. perhaps it's used when the checksum on the first one does not match?
// gbe checksum related functions
-unsigned short GetChecksum(char* buffer, unsigned short desiredValue); // for GBe region (checksum calculation)
+unsigned short GetChecksum(char* buffer, unsigned short desiredValue, char isBackup); // for GBe region (checksum calculation)
unsigned short GetRegionWord(int i, char* buffer); // used for getting each word needed to calculate said checksum
int main(int argc, char *argv[])
@@ -242,6 +242,8 @@ int main(int argc, char *argv[])
printf("\ndeblobbed descriptor successfully created: deblobbed_descriptor.bin \n");
+ // -------------------------------------------------------------------------------------
+
// calculate the 0x3F'th 16-bit uint to make the desired final checksum for GBe
// observed values (from actual factory.rom dumps) 0xBABA 0x3ABA 0x34BA. spec defined as 0xBABA.
// theoretically, this could be any l33t speak variation of BABA, eg 3434 or BA34, and so on, but this is untested. so far.
@@ -249,24 +251,33 @@ int main(int argc, char *argv[])
// maybe only the 8 least significant bits are checked? or something deeper than that
// it will need to be tested if those gbe regions that use something other than baba
// will also work with the checksum changed to match baba (per datasheets)
- unsigned short gbeCalculatedChecksum = GetChecksum(gbeBuffer, 0xBABA);
+ unsigned short gbeCalculatedChecksum = GetChecksum(gbeBuffer, 0xBABA, 0);
// get the actual 0x3F'th 16-bit uint that was already in the supplied (pre-compiled) region data
unsigned short gbeChecksum = GetRegionWord(0x3F, gbeBuffer); // from the original factory.rom
-
- printf("\ncalculated Gbe checksum: 0x%hx actual GBe checksum: 0x%hx\n", gbeCalculatedChecksum, gbeChecksum);
+ printf("\noriginal Gbe (main): calculated Gbe checksum: 0x%hx and actual GBe checksum: 0x%hx\n", gbeCalculatedChecksum, gbeChecksum);
+
+ // same as above, but for 2nd region ("backup") in gbe
+ gbeCalculatedChecksum = GetChecksum(gbeBuffer, 0xBABA, 1);
+ // get the actual 0x3F'th 16-bit uint that was already in the supplied (pre-compiled) region data
+ gbeChecksum = GetRegionWord(0x3F+(0x1000>>1), gbeBuffer);
+ printf("original Gbe (backup) calculated Gbe checksum: 0x%hx and actual GBe checksum: 0x%hx\n", gbeCalculatedChecksum, gbeChecksum);
return 0;
}
// checksum calculation for gbe region (algorithm based on datasheet)
-unsigned short GetChecksum(char* regionData, unsigned short desiredValue)
+unsigned short GetChecksum(char* regionData, unsigned short desiredValue, char isBackup)
{
unsigned short regionWord;
unsigned short checksum = 0;
+ // if isBackup is true, use 2nd gbe region ("backup" region)
+ unsigned short offset = 0;
+ if (isBackup) offset = 0x1000>>1; // this function uses *word* not *byte* indexes.
+
int i;
for (i = 0; i < 0x3F; i++) {
- regionWord = GetRegionWord(i, regionData);
+ regionWord = GetRegionWord(i+offset, regionData);
checksum += regionWord;
}
checksum = desiredValue - checksum;