diff options
author | Tim Hutt <timothy.hutt@codasip.com> | 2024-02-02 11:56:55 +0000 |
---|---|---|
committer | Bill McSpadden <bill@riscv.org> | 2024-02-05 11:22:09 -0600 |
commit | 4de2bff12d967d91dd064e4a49e25ca4785f25e3 (patch) | |
tree | b106b03932811b9f35c4ac025a89c6f47862dc8f /ocaml_emulator | |
parent | d5e89a71e3a84495c1b88a7749c25fd6b9da684b (diff) | |
download | sail-riscv-4de2bff12d967d91dd064e4a49e25ca4785f25e3.zip sail-riscv-4de2bff12d967d91dd064e4a49e25ca4785f25e3.tar.gz sail-riscv-4de2bff12d967d91dd064e4a49e25ca4785f25e3.tar.bz2 |
Improve PMP support
This implements a lot of missing functionality for PMPs.
* Support 64 PMPs as well as 0 and 16.
* Support setting PMP grain
* Return correct address bits on read (some read as 0 or 1 depending on the grain and match type)
* Unlock PMPs on reset
* Implement pmpcfg WARL legalisation
Co-authored-by: Ben Fletcher <benjamin.fletcher@codasip.com>
Diffstat (limited to 'ocaml_emulator')
-rw-r--r-- | ocaml_emulator/platform.ml | 9 | ||||
-rw-r--r-- | ocaml_emulator/riscv_ocaml_sim.ml | 9 |
2 files changed, 13 insertions, 5 deletions
diff --git a/ocaml_emulator/platform.ml b/ocaml_emulator/platform.ml index e4dbfeb..a8bde44 100644 --- a/ocaml_emulator/platform.ml +++ b/ocaml_emulator/platform.ml @@ -10,9 +10,13 @@ let config_enable_writable_misa = ref true let config_enable_dirty_update = ref false let config_enable_misaligned_access = ref false let config_mtval_has_illegal_inst_bits = ref false -let config_enable_pmp = ref false let config_enable_writable_fiom = ref true let config_enable_vext = ref true +let config_pmp_count = ref Big_int.zero +let config_pmp_grain = ref Big_int.zero + +let set_config_pmp_count x = config_pmp_count := Big_int.of_int x +let set_config_pmp_grain x = config_pmp_grain := Big_int.of_int x let platform_arch = ref P.RV64 @@ -84,9 +88,10 @@ let enable_vext () = !config_enable_vext let enable_dirty_update () = !config_enable_dirty_update let enable_misaligned_access () = !config_enable_misaligned_access let mtval_has_illegal_inst_bits () = !config_mtval_has_illegal_inst_bits -let enable_pmp () = !config_enable_pmp let enable_zfinx () = false let enable_writable_fiom () = !config_enable_writable_fiom +let pmp_count () = !config_pmp_count +let pmp_grain () = !config_pmp_grain let rom_base () = arch_bits_of_int64 P.rom_base let rom_size () = arch_bits_of_int !rom_size_ref diff --git a/ocaml_emulator/riscv_ocaml_sim.ml b/ocaml_emulator/riscv_ocaml_sim.ml index c151d69..03887b7 100644 --- a/ocaml_emulator/riscv_ocaml_sim.ml +++ b/ocaml_emulator/riscv_ocaml_sim.ml @@ -41,9 +41,12 @@ let options = Arg.align ([("-dump-dts", ("-enable-misaligned-access", Arg.Set P.config_enable_misaligned_access, " enable misaligned accesses without M-mode traps"); - ("-enable-pmp", - Arg.Set P.config_enable_pmp, - " enable PMP support"); + ("-pmp-count", + Arg.Int P.set_config_pmp_count, + " number of supported PMPs (0, 16, 64)"); + ("-pmp-grain", + Arg.Int P.set_config_pmp_grain, + " exponent of granularity of PMP addresses (G in the spec)"); ("-enable-next", Arg.Set P.config_enable_next, " enable N extension"); |