5 #include <arch/exception.h>
9 #if defined(__riscv_flen)
10 #if __riscv_flen >= 32
11 extern void read_f32(
int regnum,
uint32_t *v);
12 extern void write_f32(
int regnum,
uint32_t *v);
14 #if __riscv_flen >= 64
15 extern void read_f64(
int regnum,
uint64_t *v);
16 extern void write_f64(
int regnum,
uint64_t *v);
47 #if __riscv_xlen == 128
48 { 0x00002000, 0x0000e003, 2, 7, 8, 0, 1, 16, 1},
50 { 0x00002000, 0x0000e003, 2, 7, 8, 1, 1, 8, 0},
52 { 0x00004000, 0x0000e003, 2, 7, 8, 0, 1, 4, 1},
53 #if __riscv_xlen == 32
54 { 0x00006000, 0x0000e003, 2, 7, 8, 1, 1, 4, 0},
56 { 0x00006000, 0x0000e003, 2, 7, 8, 0, 1, 8, 1},
59 #if __riscv_xlen == 128
60 { 0x0000a000, 0x0000e003, 2, 7, 8, 0, 0, 16, 0},
62 { 0x0000a000, 0x0000e003, 2, 7, 8, 1, 0, 8, 0},
64 { 0x0000c000, 0x0000e003, 2, 7, 8, 0, 0, 4, 0},
65 #if __riscv_xlen == 32
66 { 0x0000e000, 0x0000e003, 2, 7, 8, 1, 0, 4, 0},
68 { 0x0000e000, 0x0000e003, 2, 7, 8, 0, 0, 8, 0},
71 #if __riscv_xlen == 128
72 { 0x00002002, 0x0000e003, 7, 15, 0, 0, 1, 16, 1},
74 { 0x00002002, 0x0000e003, 7, 15, 0, 1, 1, 8, 0},
76 { 0x00004002, 0x0000e003, 7, 15, 0, 0, 1, 4, 1},
77 #if __riscv_xlen == 32
78 { 0x00006002, 0x0000e003, 7, 15, 0, 1, 1, 4, 0},
80 { 0x00006002, 0x0000e003, 7, 15, 0, 0, 1, 8, 1},
83 #if __riscv_xlen == 128
84 { 0x0000a002, 0x0000e003, 2, 15, 0, 0, 0, 16, 0},
86 { 0x0000a002, 0x0000e003, 2, 15, 0, 1, 0, 8, 0},
88 { 0x0000c002, 0x0000e003, 2, 15, 0, 0, 0, 4, 0},
89 #if __riscv_xlen == 32
90 { 0x0000e002, 0x0000e003, 2, 15, 0, 1, 0, 4, 0},
92 { 0x0000e002, 0x0000e003, 2, 15, 0, 0, 0, 8, 0},
95 { 0x00000003, 0x0000707f, 7, 15, 0, 0, 1, 1, 1},
96 { 0x00001003, 0x0000707f, 7, 15, 0, 0, 1, 2, 1},
97 { 0x00002003, 0x0000707f, 7, 15, 0, 0, 1, 4, 1},
99 { 0x00003003, 0x0000707f, 7, 15, 0, 0, 1, 8, 1},
101 { 0x00004003, 0x0000707f, 7, 15, 0, 0, 1, 1, 0},
102 { 0x00005003, 0x0000707f, 7, 15, 0, 0, 1, 2, 0},
103 { 0x00006003, 0x0000707f, 7, 15, 0, 0, 1, 4, 0},
105 { 0x00000023, 0x0000707f, 20, 15, 0, 0, 0, 1, 0},
106 { 0x00001023, 0x0000707f, 20, 15, 0, 0, 0, 2, 0},
107 { 0x00002023, 0x0000707f, 20, 15, 0, 0, 0, 4, 0},
108 #if __riscv_xlen > 32
109 { 0x00003023, 0x0000707f, 20, 15, 0, 0, 0, 8, 0},
112 #if defined(__riscv_flen)
113 #if __riscv_flen >= 32
114 { 0x00002007, 0x0000707f, 7, 15, 0, 1, 1, 4, 0},
115 { 0x00003007, 0x0000707f, 7, 15, 0, 1, 1, 8, 0},
118 #if __riscv_flen >= 64
119 { 0x00002027, 0x0000707f, 20, 15, 0, 1, 0, 4, 0},
120 { 0x00003027, 0x0000707f, 20, 15, 0, 1, 0, 8, 0},
190 for (
int i = 0; i < match->
width; i++) {
192 buff.
b[i] = mprv_read_u8(
addr);
197 if (buff.
v >> (8 * match->
width - 1))
198 buff.
v |= -1 << (8 * match->
width);
203 #if defined(__riscv_flen)
204 #if __riscv_flen >= 32
206 if (match->
width == 4) {
207 write_f32(regnum, buff.
w);
211 #if __riscv_flen >= 64
213 if (match->
width == 8) {
214 write_f64(regnum, buff.
d);
222 tf->
gpr[regnum] = buff.
v;
230 #if defined(__riscv_flen)
231 #if __riscv_flen >= 32
232 if (match->
width == 4) {
233 read_f32(regnum, buff.
w);
237 #if __riscv_flen >= 64
238 if (match->
width == 8) {
239 read_f64(regnum, buff.
d);
247 buff.
v = tf->
gpr[regnum];
252 for (
int i = 0; i < match->
width; i++) {
254 mprv_write_u8(
addr, buff.
b[i]);
259 write_csr(mepc, read_csr(mepc) + insn_size);
static struct memory_instruction_info insn_info[]
static struct memory_instruction_info * match_instruction(uintptr_t insn)
static int fetch_16bit_instruction(uintptr_t vaddr, uintptr_t *insn, int *size)
static int fetch_32bit_instruction(uintptr_t vaddr, uintptr_t *insn, int *size)
void handle_misaligned(trapframe *tf)
unsigned long long uint64_t
unsigned int reg_addition
#define EXTRACT_FIELD(val, which)