diff options
| author | Clément Léger <[email protected]> | 2024-10-18 10:40:02 +0200 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2024-10-25 23:52:51 +0530 |
| commit | daa282573ffac0f295de7631c98840668f20a568 (patch) | |
| tree | 3de7a726113d69a316316abb2ccc71cc684968ec /include | |
| parent | b919daf4958281b94fd2e03e23874b97b4908fc5 (diff) | |
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 <[email protected]>
Reviewed-by: Samuel Holland <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/sbi/sbi_trap.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h index f7c170e6..b0c47ce5 100644 --- a/include/sbi/sbi_trap.h +++ b/include/sbi/sbi_trap.h @@ -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); |
