mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00
lib: sbi: factorize previous mode computation
Previous privilege mode retrieval from mstatus is done at different places, factorize it rather than copy/pasting it again. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
This commit is contained in:

committed by
Anup Patel

parent
daa282573f
commit
80656bdb1d
@@ -52,7 +52,7 @@ static int system_opcode_insn(ulong insn, struct sbi_trap_regs *regs)
|
||||
int rs1_num = GET_RS1_NUM(insn);
|
||||
ulong rs1_val = GET_RS1(insn, regs);
|
||||
int csr_num = GET_CSR_NUM((u32)insn);
|
||||
ulong prev_mode = (regs->mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT;
|
||||
ulong prev_mode = sbi_mstatus_prev_mode(regs->mstatus);
|
||||
ulong csr_val, new_csr_val;
|
||||
|
||||
if (prev_mode == PRV_M) {
|
||||
|
Reference in New Issue
Block a user