forked from Mirrors/opensbi
lib: sbi: factorize previous virtualization mode read from regs
The same pattern is used at multiple places to verify in which mode the exception was actually taken. Factorize it. 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
b919daf495
commit
daa282573f
@@ -236,6 +236,15 @@ static inline unsigned long sbi_regs_gva(const struct sbi_trap_regs *regs)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline bool sbi_regs_from_virt(const struct sbi_trap_regs *regs)
|
||||
{
|
||||
#if __riscv_xlen == 32
|
||||
return (regs->mstatusH & MSTATUSH_MPV) ? true : false;
|
||||
#else
|
||||
return (regs->mstatus & MSTATUS_MPV) ? true : false;
|
||||
#endif
|
||||
}
|
||||
|
||||
int sbi_trap_redirect(struct sbi_trap_regs *regs,
|
||||
const struct sbi_trap_info *trap);
|
||||
|
||||
|
Reference in New Issue
Block a user