summaryrefslogtreecommitdiffstats
path: root/libpdbg
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2017-05-19 07:34:00 +1000
committerAlistair Popple <alistair@popple.id.au>2017-05-19 07:34:00 +1000
commitd4f73e9be6356279fc02be62b42b6bd35bff4717 (patch)
tree36540764c7d7ec39b822fbca84dfa288b7b0e439 /libpdbg
parent3c8aee3e1d38a470451929c9b3499b85928cb241 (diff)
downloadpdbg-d4f73e9be6356279fc02be62b42b6bd35bff4717.tar.gz
pdbg-d4f73e9be6356279fc02be62b42b6bd35bff4717.zip
Reads and writes to the FSI bus are in bus-endian format, so we need to
convert. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'libpdbg')
-rw-r--r--libpdbg/kernel.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libpdbg/kernel.c b/libpdbg/kernel.c
index 6f16310..b5b42da 100644
--- a/libpdbg/kernel.c
+++ b/libpdbg/kernel.c
@@ -37,7 +37,7 @@ int fsi_fd;
static int kernel_fsi_getcfam(struct fsi *fsi, uint32_t addr64, uint32_t *value)
{
int rc;
- uint32_t addr = (addr64 & 0x7ffc00) | ((addr64 & 0x3ff) << 2);
+ uint32_t tmp, addr = (addr64 & 0x7ffc00) | ((addr64 & 0x3ff) << 2);
rc = lseek(fsi_fd, addr, SEEK_SET);
if (rc < 0) {
@@ -45,7 +45,7 @@ static int kernel_fsi_getcfam(struct fsi *fsi, uint32_t addr64, uint32_t *value)
return errno;
}
- rc = read(fsi_fd, value, 4);
+ rc = read(fsi_fd, &tmp, 4);
if (rc < 0) {
if ((addr64 & 0xfff) != 0xc09)
/* We expect reads of 0xc09 to occasionally
@@ -54,6 +54,7 @@ static int kernel_fsi_getcfam(struct fsi *fsi, uint32_t addr64, uint32_t *value)
warn("Failed to read from 0x%08x (%016llx)", (uint32_t)addr, addr64);
return errno;
}
+ *value = be32toh(tmp);
return 0;
}
@@ -61,7 +62,7 @@ static int kernel_fsi_getcfam(struct fsi *fsi, uint32_t addr64, uint32_t *value)
static int kernel_fsi_putcfam(struct fsi *fsi, uint32_t addr64, uint32_t data)
{
int rc;
- uint32_t addr = (addr64 & 0x7ffc00) | ((addr64 & 0x3ff) << 2);
+ uint32_t tmp, addr = (addr64 & 0x7ffc00) | ((addr64 & 0x3ff) << 2);
rc = lseek(fsi_fd, addr, SEEK_SET);
if (rc < 0) {
@@ -69,7 +70,8 @@ static int kernel_fsi_putcfam(struct fsi *fsi, uint32_t addr64, uint32_t data)
return errno;
}
- rc = write(fsi_fd, &data, 4);
+ tmp = htobe32(data);
+ rc = write(fsi_fd, &tmp, 4);
if (rc < 0) {
warn("Failed to write to 0x%08x (%016llx)", addr, addr64);
return errno;
OpenPOWER on IntegriCloud