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