semihosting: reorganize semihosting commands
[fw/openocd] / src / target / riscv / asm.h
1 #ifndef TARGET__RISCV__ASM_H
2 #define TARGET__RISCV__ASM_H
3
4 #include "riscv.h"
5
6 /*** Version-independent functions that we don't want in the main address space. ***/
7
8 static uint32_t load(const struct target *target, unsigned int rd,
9                 unsigned int base, uint16_t offset) __attribute__ ((unused));
10 static uint32_t load(const struct target *target, unsigned int rd,
11                 unsigned int base, uint16_t offset)
12 {
13         switch (riscv_xlen(target)) {
14                 case 32:
15                         return lw(rd, base, offset);
16                 case 64:
17                         return ld(rd, base, offset);
18         }
19         assert(0);
20         return 0; /* Silence -Werror=return-type */
21 }
22
23 static uint32_t store(const struct target *target, unsigned int src,
24                 unsigned int base, uint16_t offset) __attribute__ ((unused));
25 static uint32_t store(const struct target *target, unsigned int src,
26                 unsigned int base, uint16_t offset)
27 {
28         switch (riscv_xlen(target)) {
29                 case 32:
30                         return sw(src, base, offset);
31                 case 64:
32                         return sd(src, base, offset);
33         }
34         assert(0);
35         return 0; /* Silence -Werror=return-type */
36 }
37
38 #endif