[Skiboot] [PATCH 2/2] libflash: endian fixups for ecc.c
Cyril Bur
cyril.bur at au1.ibm.com
Tue Mar 3 17:21:29 AEDT 2015
The flash is in big endian and the ecc code must be aware of this when
performing ecc checks on a little endian cpu.
Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
libflash/ecc.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libflash/ecc.c b/libflash/ecc.c
index 2fca0fa..61084cc 100644
--- a/libflash/ecc.c
+++ b/libflash/ecc.c
@@ -18,6 +18,8 @@
#include <stdint.h>
+#include <ccan/endian/endian.h>
+
#include "libflash.h"
#include "ecc.h"
@@ -141,7 +143,7 @@ static uint8_t eccverify(uint64_t data, uint8_t ecc)
*/
uint8_t eccmemcpy(uint64_t *dst, uint64_t *src, uint32_t len)
{
- uint64_t *data;
+ beint64_t *data;
uint8_t *ecc;
uint32_t i;
uint8_t badbit;
@@ -157,20 +159,21 @@ uint8_t eccmemcpy(uint64_t *dst, uint64_t *src, uint32_t len)
len >>= 3;
for (i = 0; i < len; i++) {
- data = (uint64_t *)((uint8_t *)src + i*9);
+ data = (beint64_t *)((uint8_t *)src + i * 9);
ecc = (uint8_t *)data + 8;
- badbit = eccverify(*data, *ecc);
+ badbit = eccverify(be64_to_cpu(*data), *ecc);
if (badbit == UE) {
FL_ERR("ECC: uncorrectable error: %016lx %02x\n",
- (long unsigned int)*data, *ecc);
+ (long unsigned int)be64_to_cpu(*data), *ecc);
return badbit;
}
*dst = *data;
if (badbit <= UE)
FL_INF("ECC: correctable error: %i\n", badbit);
if (badbit < 64)
- *dst = *data ^ (1ul << (63 - badbit));
+ *dst = (uint64_t)cpu_to_be64(be64_to_cpu(*data) ^
+ (1ul << (63 - badbit)));
dst++;
}
return GD;
--
1.9.1
More information about the Skiboot
mailing list