aboutsummaryrefslogtreecommitdiff
path: root/libflash/ecc.c
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2015-03-03 17:21:29 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-03-05 15:00:52 +1100
commite62b82ba6a2d8b23f72d22873295e1a1fe53357f (patch)
tree5611b4e10761eb968fc191255d1d4949c3b98608 /libflash/ecc.c
parente03082b84c387c936bd0b1639776eed5549df889 (diff)
downloadskiboot-e62b82ba6a2d8b23f72d22873295e1a1fe53357f.zip
skiboot-e62b82ba6a2d8b23f72d22873295e1a1fe53357f.tar.gz
skiboot-e62b82ba6a2d8b23f72d22873295e1a1fe53357f.tar.bz2
libflash: endian fixups for ecc.c
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@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libflash/ecc.c')
-rw-r--r--libflash/ecc.c13
1 files 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;