Commit f19c3b42 authored by Clément Léger's avatar Clément Léger Committed by Palmer Dabbelt

riscv: remove unused functions in traps_misaligned.c

Replace macros by the only two function calls that are done from this
file, store_u8() and load_u8().
Signed-off-by: default avatarClément Léger <cleger@rivosinc.com>
Link: https://lore.kernel.org/r/20231004151405.521596-2-cleger@rivosinc.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 0bb80ecc
...@@ -151,51 +151,19 @@ ...@@ -151,51 +151,19 @@
#define PRECISION_S 0 #define PRECISION_S 0
#define PRECISION_D 1 #define PRECISION_D 1
#define DECLARE_UNPRIVILEGED_LOAD_FUNCTION(type, insn) \ static inline u8 load_u8(const u8 *addr)
static inline type load_##type(const type *addr) \ {
{ \ u8 val;
type val; \
asm (#insn " %0, %1" \
: "=&r" (val) : "m" (*addr)); \
return val; \
}
#define DECLARE_UNPRIVILEGED_STORE_FUNCTION(type, insn) \ asm volatile("lbu %0, %1" : "=&r" (val) : "m" (*addr));
static inline void store_##type(type *addr, type val) \
{ \
asm volatile (#insn " %0, %1\n" \
: : "r" (val), "m" (*addr)); \
}
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u8, lbu) return val;
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u16, lhu)
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(s8, lb)
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(s16, lh)
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(s32, lw)
DECLARE_UNPRIVILEGED_STORE_FUNCTION(u8, sb)
DECLARE_UNPRIVILEGED_STORE_FUNCTION(u16, sh)
DECLARE_UNPRIVILEGED_STORE_FUNCTION(u32, sw)
#if defined(CONFIG_64BIT)
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u32, lwu)
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u64, ld)
DECLARE_UNPRIVILEGED_STORE_FUNCTION(u64, sd)
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(ulong, ld)
#else
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(u32, lw)
DECLARE_UNPRIVILEGED_LOAD_FUNCTION(ulong, lw)
static inline u64 load_u64(const u64 *addr)
{
return load_u32((u32 *)addr)
+ ((u64)load_u32((u32 *)addr + 1) << 32);
} }
static inline void store_u64(u64 *addr, u64 val) static inline void store_u8(u8 *addr, u8 val)
{ {
store_u32((u32 *)addr, val); asm volatile ("sb %0, %1\n" : : "r" (val), "m" (*addr));
store_u32((u32 *)addr + 1, val >> 32);
} }
#endif
static inline ulong get_insn(ulong mepc) static inline ulong get_insn(ulong mepc)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment