diff options
| author | Prashanth Mundkur | 2018-11-29 09:06:35 -0800 |
|---|---|---|
| committer | Prashanth Mundkur | 2018-11-29 09:52:36 -0800 |
| commit | 6797b018523d0acf82b570e9417d6d91c18dd69f (patch) | |
| tree | 108080fae9e41e1cc6a3f3ab6a9234b06f1e50f3 /riscv | |
| parent | 35eff0805dffe8d006d390bdaebac1b8d4b0a61d (diff) | |
RISC-V: implement WFI in the platform model.
The initial implementation tries to optimize for simulator execution, especially for OS boots.
Diffstat (limited to 'riscv')
| -rw-r--r-- | riscv/riscv.sail | 4 | ||||
| -rw-r--r-- | riscv/riscv_platform.sail | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/riscv/riscv.sail b/riscv/riscv.sail index c8fcdbab..37553299 100644 --- a/riscv/riscv.sail +++ b/riscv/riscv.sail @@ -724,10 +724,10 @@ mapping clause encdec = WFI() <-> 0b000100000101 @ 0b00000 @ 0b000 @ 0b00000 @ 0 function clause execute WFI() = match cur_privilege { - Machine => true, + Machine => { platform_wfi(); true }, Supervisor => if mstatus.TW() == true then { handle_illegal(); false } - else true, + else { platform_wfi(); true }, User => { handle_illegal(); false } } diff --git a/riscv/riscv_platform.sail b/riscv/riscv_platform.sail index c878f2a7..aee72e47 100644 --- a/riscv/riscv_platform.sail +++ b/riscv/riscv_platform.sail @@ -281,3 +281,15 @@ function handle_illegal() -> unit = { excinfo = info }; nextPC = handle_exception(cur_privilege, CTL_TRAP(t), PC) } + +/* Platform-specific wait-for-interrupt */ + +function platform_wfi() -> unit = { + /* speed execution by getting the timer to fire at the next instruction, + * since we currently don't have any other devices raising interrupts. + */ + if mtime <_u mtimecmp then { + mtime = mtimecmp; + mcycle = mtimecmp; + } +}
\ No newline at end of file |
