summaryrefslogtreecommitdiffstats
path: root/resources/utilities/ich9deblob/src
diff options
context:
space:
mode:
Diffstat (limited to 'resources/utilities/ich9deblob/src')
-rw-r--r--resources/utilities/ich9deblob/src/gbe/gbe.c34
-rw-r--r--resources/utilities/ich9deblob/src/gbe/gbe.h3
2 files changed, 8 insertions, 29 deletions
diff --git a/resources/utilities/ich9deblob/src/gbe/gbe.c b/resources/utilities/ich9deblob/src/gbe/gbe.c
index 5f4cffc..9a7f44f 100644
--- a/resources/utilities/ich9deblob/src/gbe/gbe.c
+++ b/resources/utilities/ich9deblob/src/gbe/gbe.c
@@ -32,42 +32,22 @@
* ---------------------------------------------------------------------
*/
-/* Read a 16-bit unsigned int from a supplied region buffer */
-uint16_t gbeGetRegionWordFrom8kBuffer(int wordOffset, uint8_t* regionData)
-{
- int byteOffset = wordOffset << 1;
-
- uint16_t* regionDataWordAddress = (uint16_t*)(regionData+byteOffset);
- uint16_t regionWord = *regionDataWordAddress;
-
- return regionWord;
-}
-
/* gbe checksum calculation (algorithm based on datasheet) */
-uint16_t gbeGetChecksumFrom8kBuffer(uint8_t* regionData, uint16_t desiredValue, int byteOffset)
+uint16_t gbeGetChecksumFrom8kBuffer(uint16_t* regionData, uint16_t desiredValue, int gbeRegionBase)
{
- int i;
- int wordOffset = byteOffset >> 1;
-
- uint16_t regionWord; /* store words here for adding to checksum */
- uint16_t checksum = 0; /* this gbe's checksum */
+ int wordOffset;
+ uint16_t total = 0;
- for (i = 0; i < 0x3F; i++) {
- regionWord = gbeGetRegionWordFrom8kBuffer(i+wordOffset, regionData);
- checksum += regionWord;
- }
- checksum = desiredValue - checksum;
+ for (wordOffset = 0; wordOffset < 0x3F; wordOffset++)
+ total += regionData[wordOffset + (gbeRegionBase>>1)];
- return checksum;
+ return desiredValue - total;
}
/* checksum calculation for 4k gbe struct (algorithm based on datasheet) */
uint16_t gbeGetChecksumFrom4kStruct(struct GBEREGIONRECORD_4K gbeStruct4k, uint16_t desiredValue)
{
- uint8_t gbeBuffer4k[GBEREGIONSIZE_4K];
- memcpy(&gbeBuffer4k, &gbeStruct4k, GBEREGIONSIZE_4K);
-
- return gbeGetChecksumFrom8kBuffer(gbeBuffer4k, desiredValue, 0);
+ return gbeGetChecksumFrom8kBuffer((uint16_t*)&gbeStruct4k, desiredValue, 0);
}
/* modify the gbe region extracted from a factory.rom dump */
diff --git a/resources/utilities/ich9deblob/src/gbe/gbe.h b/resources/utilities/ich9deblob/src/gbe/gbe.h
index 68b9ed7..ff620c4 100644
--- a/resources/utilities/ich9deblob/src/gbe/gbe.h
+++ b/resources/utilities/ich9deblob/src/gbe/gbe.h
@@ -424,8 +424,7 @@ struct GBEREGIONRECORD_8K {
* ---------------------------------------------------------------------
*/
-uint16_t gbeGetRegionWordFrom8kBuffer(int wordOffset, uint8_t* regionData);
-uint16_t gbeGetChecksumFrom8kBuffer(uint8_t* regionData, uint16_t desiredValue, int byteOffset);
+uint16_t gbeGetChecksumFrom8kBuffer(uint16_t* regionData, uint16_t desiredValue, int gbeRegionBase);
uint16_t gbeGetChecksumFrom4kStruct(struct GBEREGIONRECORD_4K gbeStruct4k, uint16_t desiredValue);
struct GBEREGIONRECORD_8K deblobbedGbeStructFromFactory(struct GBEREGIONRECORD_8K factoryGbeStruct8k);
int notCreatedHFileForGbeCFile(char* outFileName, char* cFileName);