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/sbi/sbi_emulate_csr.c | |
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/sbi/sbi_emulate_csr.c')
-rw-r--r-- | lib/sbi/sbi_emulate_csr.c | 15 |
1 files changed, 9 insertions, 6 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; } |