mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00

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>
36 lines
807 B
C
36 lines
807 B
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
*/
|
|
|
|
#ifndef __SBI_TRAP_LDST_H__
|
|
#define __SBI_TRAP_LDST_H__
|
|
|
|
#include <sbi/sbi_types.h>
|
|
#include <sbi/sbi_trap.h>
|
|
|
|
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);
|
|
|
|
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
|