diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-03-19 17:16:00 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-03-28 11:02:07 +0300 |
commit | d11c79cd977443defe4260beec976fad29719eaf (patch) | |
tree | 7c3cfb19ecac01e346ea477adbebc889a9146f4a /lib | |
parent | cb78a482314e8e3c7f423bb13fc50bbd50c59b13 (diff) | |
download | opensbi-d11c79cd977443defe4260beec976fad29719eaf.tar.xz |
lib: sbi_emulate_csr: Remove scratch and hartid parameter
We remove scratch and hartid parameter from various functions
for CSR emulation because we can always get current HART id
and current scratch pointer using just one CSR access.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sbi/sbi_emulate_csr.c | 15 | ||||
-rw-r--r-- | lib/sbi/sbi_illegal_insn.c | 5 |
2 files changed, 11 insertions, 9 deletions
diff --git a/lib/sbi/sbi_emulate_csr.c b/lib/sbi/sbi_emulate_csr.c index dbb36cb..41c92df 100644 --- a/lib/sbi/sbi_emulate_csr.c +++ b/lib/sbi/sbi_emulate_csr.c @@ -13,14 +13,16 @@ #include <sbi/sbi_console.h> #include <sbi/sbi_emulate_csr.h> #include <sbi/sbi_error.h> +#include <sbi/sbi_scratch.h> #include <sbi/sbi_timer.h> #include <sbi/sbi_trap.h> -int sbi_emulate_csr_read(int csr_num, u32 hartid, struct sbi_trap_regs *regs, - struct sbi_scratch *scratch, ulong *csr_val) +int sbi_emulate_csr_read(int csr_num, struct sbi_trap_regs *regs, + ulong *csr_val) { int ret = 0; ulong cen = -1UL; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); ulong prev_mode = (regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT; #if __riscv_xlen == 32 bool virt = (regs->mstatusH & MSTATUSH_MPV) ? TRUE : FALSE; @@ -111,15 +113,16 @@ int sbi_emulate_csr_read(int csr_num, u32 hartid, struct sbi_trap_regs *regs, if (ret) sbi_dprintf(scratch, "%s: hartid%d: invalid csr_num=0x%x\n", - __func__, hartid, csr_num); + __func__, current_hartid(), csr_num); return ret; } -int sbi_emulate_csr_write(int csr_num, u32 hartid, struct sbi_trap_regs *regs, - struct sbi_scratch *scratch, ulong csr_val) +int sbi_emulate_csr_write(int csr_num, struct sbi_trap_regs *regs, + ulong csr_val) { int ret = 0; + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); ulong prev_mode = (regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT; #if __riscv_xlen == 32 bool virt = (regs->mstatusH & MSTATUSH_MPV) ? TRUE : FALSE; @@ -179,7 +182,7 @@ int sbi_emulate_csr_write(int csr_num, u32 hartid, struct sbi_trap_regs *regs, if (ret) sbi_dprintf(scratch, "%s: hartid%d: invalid csr_num=0x%x\n", - __func__, hartid, csr_num); + __func__, current_hartid(), csr_num); return ret; } diff --git a/lib/sbi/sbi_illegal_insn.c b/lib/sbi/sbi_illegal_insn.c index a374fa2..980b7dd 100644 --- a/lib/sbi/sbi_illegal_insn.c +++ b/lib/sbi/sbi_illegal_insn.c @@ -57,7 +57,7 @@ static int system_opcode_insn(ulong insn, u32 hartid, ulong mcause, return truly_illegal_insn(insn, hartid, mcause, regs, scratch); - if (sbi_emulate_csr_read(csr_num, hartid, regs, scratch, &csr_val)) + if (sbi_emulate_csr_read(csr_num, regs, &csr_val)) return truly_illegal_insn(insn, hartid, mcause, regs, scratch); @@ -87,8 +87,7 @@ static int system_opcode_insn(ulong insn, u32 hartid, ulong mcause, return truly_illegal_insn(insn, hartid, mcause, regs, scratch); }; - if (do_write && sbi_emulate_csr_write(csr_num, hartid, regs, - scratch, new_csr_val)) + if (do_write && sbi_emulate_csr_write(csr_num, regs, new_csr_val)) return truly_illegal_insn(insn, hartid, mcause, regs, scratch); SET_RD(insn, regs, csr_val); |