util/amdfwtool: Correct fletcher32 algorithm
Change the fletcher32 checksum calculation to match PSP and AGESA implementations. The symptom of the failure has only been noted in Picasso's BIOS Directory Table, when a BIOS binary image of different sizes were passed to amdfwtool. The PSP halts the boot process with the bad BDT checksum, and if allowed to continue, AGESA asserts later due to a failed BDT verification. This version has been verified to produce the same result as found at https://en.wikipedia.org/wiki/Fletcher%27s_checksum. TEST=Build apu2, bettong, grunt and verify before/after amdfw.rom is unchanged. Change-Id: I2ba2c49a70aa81c15acaab0be6b4c95e7891234f Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/34574 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
dffa781558
commit
b85ddc5d44
|
@ -148,17 +148,15 @@ static uint32_t fletcher32(const void *data, int length)
|
||||||
c0 = 0xFFFF;
|
c0 = 0xFFFF;
|
||||||
c1 = 0xFFFF;
|
c1 = 0xFFFF;
|
||||||
|
|
||||||
for (index = 0; index < length; index++) {
|
while (length) {
|
||||||
/*
|
index = length >= 359 ? 359 : length;
|
||||||
* Ignore the contents of the checksum field.
|
length -= index;
|
||||||
*/
|
do {
|
||||||
c0 += *(pptr++);
|
c0 += *(pptr++);
|
||||||
c1 += c0;
|
c1 += c0;
|
||||||
if ((index % 360) == 0) {
|
} while (--index);
|
||||||
/* Sums[0,1] mod 64K + overflow */
|
c0 = (c0 & 0xFFFF) + (c0 >> 16);
|
||||||
c0 = (c0 & 0xFFFF) + (c0 >> 16);
|
c1 = (c1 & 0xFFFF) + (c1 >> 16);
|
||||||
c1 = (c1 & 0xFFFF) + (c1 >> 16);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sums[0,1] mod 64K + overflow */
|
/* Sums[0,1] mod 64K + overflow */
|
||||||
|
|
Loading…
Reference in New Issue