2023-12-20 16:20:42 +00:00
|
|
|
#ifndef ARCH_H__
|
|
|
|
#define ARCH_H__
|
2024-07-25 08:47:29 +00:00
|
|
|
#include <stdint.h>
|
2023-12-20 16:20:42 +00:00
|
|
|
|
|
|
|
#ifdef __riscv_e
|
|
|
|
#define NR_REGS 16
|
|
|
|
#else
|
|
|
|
#define NR_REGS 32
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct Context {
|
|
|
|
// TODO: fix the order of these members to match trap.S
|
2024-07-25 08:47:29 +00:00
|
|
|
uintptr_t gpr[NR_REGS];
|
|
|
|
uintptr_t mcause, mstatus, mepc;
|
2023-12-20 16:20:42 +00:00
|
|
|
void *pdir;
|
|
|
|
};
|
|
|
|
|
2024-07-25 08:47:29 +00:00
|
|
|
enum Cause { CauseEnvironmentCallFromMMode = 11 };
|
|
|
|
|
2023-12-20 16:20:42 +00:00
|
|
|
#ifdef __riscv_e
|
|
|
|
#define GPR1 gpr[15] // a5
|
|
|
|
#else
|
|
|
|
#define GPR1 gpr[17] // a7
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GPR2 gpr[0]
|
|
|
|
#define GPR3 gpr[0]
|
|
|
|
#define GPR4 gpr[0]
|
|
|
|
#define GPRx gpr[0]
|
|
|
|
|
|
|
|
#endif
|