summaryrefslogtreecommitdiffstats
path: root/resources/utilities/ich9deblob
diff options
context:
space:
mode:
Diffstat (limited to 'resources/utilities/ich9deblob')
-rw-r--r--resources/utilities/ich9deblob/gbe/gbe.c17
-rw-r--r--resources/utilities/ich9deblob/gbe/gbe.h2
2 files changed, 9 insertions, 10 deletions
diff --git a/resources/utilities/ich9deblob/gbe/gbe.c b/resources/utilities/ich9deblob/gbe/gbe.c
index b1c55dd..d566906 100644
--- a/resources/utilities/ich9deblob/gbe/gbe.c
+++ b/resources/utilities/ich9deblob/gbe/gbe.c
@@ -45,22 +45,21 @@ unsigned short gbeGetRegionWordFrom8kBuffer(int index, char* regionData)
* checksum calculation for 8k gbe region (algorithm based on datasheet)
* also works for 4k buffers, so long as isBackup remains false
*/
-unsigned short gbeGetChecksumFrom8kBuffer(char* regionData, unsigned short desiredValue, char isBackup)
+unsigned short gbeGetChecksumFrom8kBuffer(char* regionData, unsigned short desiredValue, int byteOffset)
{
int i;
- unsigned short regionWord; /* store words here for adding to checksum */
- unsigned short checksum = 0; /* this gbe's checksum */
- unsigned short offset = 0; /* in bytes, from the start of the gbe region. */
-
/*
- * if isBackup is true, use 2nd gbe region ("backup" region)
- * this function uses *word* not *byte* indexes, hence the bit shift.
+ * byteOffset defines the byte address where the gbe begins in the buffer "regionData".
+ * However, this function works with 16-bit words. Shift the byte offset to the right for the word (16-bit) offset.
*/
- if (isBackup) offset = GBEREGIONSIZE_4K>>1;
+ int wordOffset = byteOffset >> 1;
+
+ unsigned short regionWord; /* store words here for adding to checksum */
+ unsigned short checksum = 0; /* this gbe's checksum */
for (i = 0; i < 0x3F; i++) {
- regionWord = gbeGetRegionWordFrom8kBuffer(i+offset, regionData);
+ regionWord = gbeGetRegionWordFrom8kBuffer(i+wordOffset, regionData);
checksum += regionWord;
}
checksum = desiredValue - checksum;
diff --git a/resources/utilities/ich9deblob/gbe/gbe.h b/resources/utilities/ich9deblob/gbe/gbe.h
index 9647d80..d0ad649 100644
--- a/resources/utilities/ich9deblob/gbe/gbe.h
+++ b/resources/utilities/ich9deblob/gbe/gbe.h
@@ -82,7 +82,7 @@ struct GBEREGIONRECORD_8K {
*/
unsigned short gbeGetRegionWordFrom8kBuffer(int index, char* regionData);
-unsigned short gbeGetChecksumFrom8kBuffer(char* regionData, unsigned short desiredValue, char isBackup);
+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);