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:
Clément Léger
2024-10-18 10:40:03 +02:00
committed by Anup Patel
parent daa282573f
commit 80656bdb1d
6 changed files with 13 additions and 8 deletions

View File

@@ -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) {