summaryrefslogtreecommitdiffstats
path: root/resources/utilities/ich9deblob/src/gbe
diff options
context:
space:
mode:
authorFrancis Rowe <info@gluglug.org.uk>2015-01-10 19:27:17 (EST)
committer Francis Rowe <info@gluglug.org.uk>2015-01-10 19:41:55 (EST)
commit2e909117e9733070a23d4164ba7c30b2f8d825a9 (patch)
tree2d18ec9256d8555e71a0a53eaebe9c60daa5e163 /resources/utilities/ich9deblob/src/gbe
parentd21f6ee04804f7d3e6f45edb5ba52563f1005575 (diff)
downloadlibreboot-2e909117e9733070a23d4164ba7c30b2f8d825a9.zip
libreboot-2e909117e9733070a23d4164ba7c30b2f8d825a9.tar.gz
libreboot-2e909117e9733070a23d4164ba7c30b2f8d825a9.tar.bz2
ich9deblob/ich9gen: get word function: make it actually readable
Diffstat (limited to 'resources/utilities/ich9deblob/src/gbe')
-rw-r--r--resources/utilities/ich9deblob/src/gbe/gbe.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/resources/utilities/ich9deblob/src/gbe/gbe.c b/resources/utilities/ich9deblob/src/gbe/gbe.c
index baefec8..5f4cffc 100644
--- a/resources/utilities/ich9deblob/src/gbe/gbe.c
+++ b/resources/utilities/ich9deblob/src/gbe/gbe.c
@@ -35,20 +35,18 @@
/* Read a 16-bit unsigned int from a supplied region buffer */
uint16_t gbeGetRegionWordFrom8kBuffer(int wordOffset, uint8_t* regionData)
{
- return *((uint16_t*)(regionData + (wordOffset << 1)));
+ int byteOffset = wordOffset << 1;
+
+ uint16_t* regionDataWordAddress = (uint16_t*)(regionData+byteOffset);
+ uint16_t regionWord = *regionDataWordAddress;
+
+ return regionWord;
}
-/*
- * gbe checksum calculation (algorithm based on datasheet)
- */
+/* gbe checksum calculation (algorithm based on datasheet) */
uint16_t gbeGetChecksumFrom8kBuffer(uint8_t* regionData, uint16_t desiredValue, int byteOffset)
{
int i;
-
- /*
- * 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.
- */
int wordOffset = byteOffset >> 1;
uint16_t regionWord; /* store words here for adding to checksum */
@@ -59,6 +57,7 @@ uint16_t gbeGetChecksumFrom8kBuffer(uint8_t* regionData, uint16_t desiredValue,
checksum += regionWord;
}
checksum = desiredValue - checksum;
+
return checksum;
}
@@ -67,6 +66,7 @@ uint16_t gbeGetChecksumFrom4kStruct(struct GBEREGIONRECORD_4K gbeStruct4k, uint1
{
uint8_t gbeBuffer4k[GBEREGIONSIZE_4K];
memcpy(&gbeBuffer4k, &gbeStruct4k, GBEREGIONSIZE_4K);
+
return gbeGetChecksumFrom8kBuffer(gbeBuffer4k, desiredValue, 0);
}