Skip to content

Commit 0a65ab1

Browse files
authored
Add unratified Smclic, Ssclic, Smclicshv extensions
Spec: https://github.com/riscv/riscv-fast-interrupt Tests: riscv-non-isa/riscv-arch-test#436
1 parent 0edd11e commit 0a65ab1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ocaml_emulator/platform.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ let dram_size () = arch_bits_of_int64 !P.dram_size_ref
102102
let clint_base () = arch_bits_of_int64 P.clint_base
103103
let clint_size () = arch_bits_of_int64 P.clint_size
104104

105+
let clic_base () = arch_bits_of_int64 P.clic_base
106+
let clic_size () = arch_bits_of_int64 P.clic_size
107+
105108
let insns_per_tick () = Big_int.of_int P.insns_per_tick
106109

107110
let htif_tohost () =
@@ -165,6 +168,7 @@ let init arch elf_file =
165168

166169
print_platform (Printf.sprintf "\nRegistered htif_tohost at 0x%Lx.\n" (Big_int.to_int64 (Elf.elf_tohost ())));
167170
print_platform (Printf.sprintf "Registered clint at 0x%Lx (size 0x%Lx).\n%!" P.clint_base P.clint_size);
171+
print_platform (Printf.sprintf "Registered clic at 0x%Lx (size 0x%Lx).\n%!" P.clic_base P.clic_size);
168172

169173
let start_pc = Elf.Big_int.to_int64 (Elf.elf_entry ()) in
170174
let rom = make_rom arch start_pc in

ocaml_emulator/platform_impl.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ let reset_vec_int arch start_pc = [
5353
let dram_base = 0x80000000L;; (* Spike::DRAM_BASE *)
5454
let clint_base = 0x02000000L;; (* Spike::CLINT_BASE *)
5555
let clint_size = 0x000c0000L;; (* Spike::CLINT_SIZE *)
56+
let clic_base = 0x04000000L;; (* Spike::MCLIC_BASE *)
57+
let clic_size = 0x000c0000L;; (* Spike::CLIC_SIZE *)
5658
let rom_base = 0x00001000L;; (* Spike::DEFAULT_RSTVEC *)
5759

5860
let dram_size_ref = ref (Int64.(shift_left 64L 20))
@@ -108,6 +110,12 @@ let spike_dts isa_spec mmu_spec cpu_hz insns_per_rtc_tick mems =
108110
^ " reg = <0x" ^ Printf.sprintf "%Lx" Int64.(shift_right_logical clint_base 32) ^ " 0x" ^ Printf.sprintf "%Lx" Int64.(logand clint_base 0xffffffffL)
109111
^ " 0x" ^ Printf.sprintf "%Lx" Int64.(shift_right_logical clint_size 32) ^ " 0x" ^ Printf.sprintf "%Lx" Int64.(logand clint_size 0xffffffffL) ^ ">;\n"
110112
^ " };\n"
113+
^ " clic@" ^ Printf.sprintf "%Lx" clic_base ^ " {\n"
114+
^ " compatible = \"riscv,clic0\";\n"
115+
^ " interrupts-extended = <&CPU0_intc 3 &CPU0_intc 7 >;\n"
116+
^ " reg = <0x" ^ Printf.sprintf "%Lx" Int64.(shift_right_logical clic_base 32) ^ " 0x" ^ Printf.sprintf "%Lx" Int64.(logand clic_base 0xffffffffL)
117+
^ " 0x" ^ Printf.sprintf "%Lx" Int64.(shift_right_logical clic_size 32) ^ " 0x" ^ Printf.sprintf "%Lx" Int64.(logand clic_size 0xffffffffL) ^ ">;\n"
118+
^ " };\n"
111119
^ " };\n"
112120
^ " htif {\n"
113121
^ " compatible = \"ucb,htif0\";\n"

0 commit comments

Comments
 (0)