diff options
author | Bo Gan <ganboing@gmail.com> | 2024-03-05 18:35:38 -0800 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2024-03-11 10:50:39 +0530 |
commit | 4c112650bbb0611de4939c749e2a34c8168e09f7 (patch) | |
tree | 3d14f806a2cc3993bbdeec3224a87ae5d9a123a5 /include | |
parent | 9221fe58d1e65d0a1b6f62098c814994ce04dd5d (diff) | |
download | opensbi-4c112650bbb0611de4939c749e2a34c8168e09f7.zip opensbi-4c112650bbb0611de4939c749e2a34c8168e09f7.tar.gz opensbi-4c112650bbb0611de4939c749e2a34c8168e09f7.tar.bz2 |
lib: sbi: abstract out insn decoding to unify mem fault handlers
This patch abstracts out the instruction decoding part of misaligned ld/st
fault handlers, so it can be reused by ld/st access fault handlers.
Also Added lb/lbu/sb decoding. (previously unreachable by misaligned fault)
sbi_trap_emulate_load/store is now the common handler which takes a `emu`
parameter that is responsible for emulating the misaligned or access fault.
The `emu` callback is expected to fixup the fault, and based on the return
code of `emu`, sbi_trap_emulate_load/store will:
r/wlen => the fixup is successful and regs/mepc needs to be updated.
0 => the fixup is successful, but regs/mepc should be left untouched
(this is usually used if `emu` does `sbi_trap_redirect`)
-err => failed, sbi_trap_error will be called
For now, load/store access faults are blindly redirected. It will be
enhanced in the following patches.
Signed-off-by: Bo Gan <ganboing@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/sbi/sbi_trap_ldst.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/sbi/sbi_trap_ldst.h b/include/sbi/sbi_trap_ldst.h index 5f0ed92..9cab4e4 100644 --- a/include/sbi/sbi_trap_ldst.h +++ b/include/sbi/sbi_trap_ldst.h @@ -13,7 +13,12 @@ #include <sbi/sbi_types.h> #include <sbi/sbi_trap.h> -struct sbi_trap_regs; +union sbi_ldst_data { + u64 data_u64; + u32 data_u32; + u8 data_bytes[8]; + ulong data_ulong; +}; int sbi_misaligned_load_handler(struct sbi_trap_regs *regs, const struct sbi_trap_info *orig_trap); @@ -21,4 +26,10 @@ int sbi_misaligned_load_handler(struct sbi_trap_regs *regs, int sbi_misaligned_store_handler(struct sbi_trap_regs *regs, const struct sbi_trap_info *orig_trap); +int sbi_load_access_handler(struct sbi_trap_regs *regs, + const struct sbi_trap_info *orig_trap); + +int sbi_store_access_handler(struct sbi_trap_regs *regs, + const struct sbi_trap_info *orig_trap); + #endif |