diff options
author | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2019-03-06 16:35:52 -0800 |
---|---|---|
committer | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2019-03-06 16:35:52 -0800 |
commit | 50968b4df7a356eb1e1f53192a4f1c62ce05d057 (patch) | |
tree | deea824d6384289d3bf40696da4310a2930cfa01 | |
parent | 7b2a230ab8cdbf0bee2225c71880b1a71e13c0b7 (diff) | |
download | sail-riscv-50968b4df7a356eb1e1f53192a4f1c62ce05d057.zip sail-riscv-50968b4df7a356eb1e1f53192a4f1c62ce05d057.tar.gz sail-riscv-50968b4df7a356eb1e1f53192a4f1c62ce05d057.tar.bz2 |
Fix RV32 reservation checks in C emulator. Also reduce default ram to 64MB.
-rw-r--r-- | c_emulator/riscv_platform.c | 18 | ||||
-rw-r--r-- | c_emulator/riscv_platform_impl.c | 2 |
2 files changed, 15 insertions, 5 deletions
diff --git a/c_emulator/riscv_platform.c b/c_emulator/riscv_platform.c index e3c85a8..d1b1f6e 100644 --- a/c_emulator/riscv_platform.c +++ b/c_emulator/riscv_platform.c @@ -2,6 +2,7 @@ #include "rts.h" #include "riscv_prelude.h" #include "riscv_platform_impl.h" +#include "riscv_sail.h" /* This file contains the definitions of the C externs of Sail model. */ @@ -46,12 +47,21 @@ unit load_reservation(mach_bits addr) bool speculate_conditional(unit u) { return true; } +static mach_bits check_mask(void) +{ + return (zxlen_val == 32) ? 0x00000000FFFFFFFF : -1; +} + bool match_reservation(mach_bits addr) -{ /* - fprintf(stderr, "reservation(%c): %0" PRIx64 ", key=%0" PRIx64 "\n", - reservation_valid ? 'v' : 'i', reservation, addr); +{ + mach_bits mask = check_mask(); + bool ret = reservation_valid && (reservation & mask) == (addr & mask); + /* + fprintf(stderr, "reservation(%c): %0" PRIx64 ", key=%0" PRIx64 ": %s\n", + reservation_valid ? 'v' : 'i', reservation, addr, ret ? "ok" : "fail"); */ - return reservation_valid && reservation == addr; + + return ret; } unit cancel_reservation(unit u) diff --git a/c_emulator/riscv_platform_impl.c b/c_emulator/riscv_platform_impl.c index 04a661c..ed32979 100644 --- a/c_emulator/riscv_platform_impl.c +++ b/c_emulator/riscv_platform_impl.c @@ -9,7 +9,7 @@ bool rv_enable_misaligned = false; bool rv_mtval_has_illegal_inst_bits = false; uint64_t rv_ram_base = UINT64_C(0x80000000); -uint64_t rv_ram_size = UINT64_C(0x80000000); +uint64_t rv_ram_size = UINT64_C(0x4000000); uint64_t rv_rom_base = UINT64_C(0x1000); uint64_t rv_rom_size = UINT64_C(0x100); |