diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-12-26 19:02:07 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-12-26 19:09:43 -0500 |
commit | 466b619e95908dc073b78413f0d0d0b1cb97e4b5 (patch) | |
tree | 2b3a47fc43dab9497495d232fd6769945db63aff /sim/bfin/dv-bfin_otp.c | |
parent | b72dd4c228d71b44e487ff2c53c0d2883653bce7 (diff) | |
download | gdb-466b619e95908dc073b78413f0d0d0b1cb97e4b5.zip gdb-466b619e95908dc073b78413f0d0d0b1cb97e4b5.tar.gz gdb-466b619e95908dc073b78413f0d0d0b1cb97e4b5.tar.bz2 |
sim: bfin: push down mmr address/size checks
The bfin port is using the WITH_DEVICES framework for two reasons:
- get access to the cpu making the request (if available)
- check the alignment & size for core & system MMRs
We addressed the first part with commit dea10706e9159ba6e94eab4c25010f3,
and we handle the second part with this commit. Arguably this is more
correct too because trying to do bad reads/writes directly (when devices
support is disabled) often results in bad memory accesses.
As part of this clean up, we also adjust all of the existing logic that
would reject invalid accesses: the code was relying on the checks never
returning, but that's not the case when things like gdb (via the user's
commands) are making the requests. Thus we'd still end up with bad mem
accesses, or sometimes gdb being hung due to while(1) loops.
Now we can connect (most of) these models into any address and have them
work correctly.
Diffstat (limited to 'sim/bfin/dv-bfin_otp.c')
-rw-r--r-- | sim/bfin/dv-bfin_otp.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/sim/bfin/dv-bfin_otp.c b/sim/bfin/dv-bfin_otp.c index 52bcf47..4a20eb1 100644 --- a/sim/bfin/dv-bfin_otp.c +++ b/sim/bfin/dv-bfin_otp.c @@ -104,6 +104,10 @@ bfin_otp_io_write_buffer (struct hw *me, const void *source, int space, bu32 *value32p; void *valuep; + /* Invalid access mode is higher priority than missing register. */ + if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, true)) + return 0; + if (nr_bytes == 4) value = dv_load_4 (source); else @@ -122,7 +126,8 @@ bfin_otp_io_write_buffer (struct hw *me, const void *source, int space, { int page; - dv_bfin_mmr_require_16 (me, addr, nr_bytes, true); + if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true)) + return 0; /* XXX: Seems like these bits aren't writable. */ *value16p = value & 0x39FF; @@ -142,12 +147,14 @@ bfin_otp_io_write_buffer (struct hw *me, const void *source, int space, break; } case mmr_offset(ben): - dv_bfin_mmr_require_16 (me, addr, nr_bytes, true); + if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true)) + return 0; /* XXX: All bits seem to be writable. */ *value16p = value; break; case mmr_offset(status): - dv_bfin_mmr_require_16 (me, addr, nr_bytes, true); + if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true)) + return 0; /* XXX: All bits seem to be W1C. */ dv_w1c_2 (value16p, value, -1); break; @@ -156,12 +163,13 @@ bfin_otp_io_write_buffer (struct hw *me, const void *source, int space, case mmr_offset(data1): case mmr_offset(data2): case mmr_offset(data3): - dv_bfin_mmr_require_32 (me, addr, nr_bytes, true); + if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, true)) + return 0; *value32p = value; break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, true); - break; + return 0; } return nr_bytes; @@ -177,6 +185,10 @@ bfin_otp_io_read_buffer (struct hw *me, void *dest, int space, bu32 *value32p; void *valuep; + /* Invalid access mode is higher priority than missing register. */ + if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, false)) + return 0; + mmr_off = addr - otp->base; valuep = (void *)((unsigned long)otp + mmr_base() + mmr_off); value16p = valuep; @@ -189,7 +201,8 @@ bfin_otp_io_read_buffer (struct hw *me, void *dest, int space, case mmr_offset(control): case mmr_offset(ben): case mmr_offset(status): - dv_bfin_mmr_require_16 (me, addr, nr_bytes, false); + if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false)) + return 0; dv_store_2 (dest, *value16p); break; case mmr_offset(timing): @@ -197,12 +210,13 @@ bfin_otp_io_read_buffer (struct hw *me, void *dest, int space, case mmr_offset(data1): case mmr_offset(data2): case mmr_offset(data3): - dv_bfin_mmr_require_32 (me, addr, nr_bytes, false); + if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false)) + return 0; dv_store_4 (dest, *value32p); break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); - break; + return 0; } return nr_bytes; |