Skip to content

Commit

Permalink
add Srnmi support to ocaml_emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed Jan 28, 2024
1 parent 5d253a8 commit b810e84
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ocaml_emulator/platform.ml
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,14 @@ let init arch elf_file =
in ( write_rom 0 rom;
get_slice_int (cur_arch_bitwidth (), rom_base, Big_int.zero)
)

(* Srnmi - resumable NMI *)
let rnmi_exc_trap_vector() = arch_bits_of_int !P.config_srnmi_exc_trap_vec
let rnmi_int_trap_vector() = arch_bits_of_int !P.config_srnmi_int_trap_vec
let is_rnmi_pending = ref true

let rnmi_pending nmie =
let was_rnmi_pending = !is_rnmi_pending in
if was_rnmi_pending && nmie
then is_rnmi_pending := false;
was_rnmi_pending && nmie
7 changes: 7 additions & 0 deletions ocaml_emulator/platform_impl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ let show_bytes s =
let dump_dts arch = show_bytes (make_dts arch)
let dump_dtb arch = show_bytes (bytes_to_string (make_dtb (make_dts arch)))

(* Smrnmi : Resumable NMI *)
let config_srnmi_exc_trap_vec = ref (Int.(0))
let config_srnmi_int_trap_vec = ref (Int.(0))
let set_srnmi_exc_trap_vec v = config_srnmi_exc_trap_vec := v
let set_srnmi_int_trap_vec v = config_srnmi_int_trap_vec := v


(*
let save_string_to_file s fname =
let out = open_out fname in
Expand Down
8 changes: 7 additions & 1 deletion ocaml_emulator/riscv_ocaml_sim.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ let options = Arg.align ([("-dump-dts",
" requested isa");
("-with-dtc",
Arg.String PI.set_dtc,
" full path to dtc to use")
" full path to dtc to use");
("-srnmi_int_trap_vec",
Arg.Int PI.set_srnmi_int_trap_vec,
" configure RNMI interrupt trap vector");
("-srnmi_exc_trap_vec",
Arg.Int PI.set_srnmi_exc_trap_vec,
" configure RNMI exception trap vector")
])

let usage_msg = "RISC-V platform options:"
Expand Down

0 comments on commit b810e84

Please sign in to comment.