mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-25 07:41:42 +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
@@ -245,6 +245,11 @@ static inline bool sbi_regs_from_virt(const struct sbi_trap_regs *regs)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int sbi_mstatus_prev_mode(unsigned long mstatus)
|
||||
{
|
||||
return (mstatus & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT;
|
||||
}
|
||||
|
||||
int sbi_trap_redirect(struct sbi_trap_regs *regs,
|
||||
const struct sbi_trap_info *trap);
|
||||
|
||||
|
Reference in New Issue
Block a user