feat: make compatible with openperf
This commit is contained in:
parent
a7b830fedd
commit
5fee5aad38
79 changed files with 3943 additions and 274 deletions
|
@ -2,6 +2,7 @@
|
|||
#define __AMDEV_H__
|
||||
|
||||
// **MAY SUBJECT TO CHANGE IN THE FUTURE**
|
||||
#include <am.h>
|
||||
|
||||
#define AM_DEVREG(id, reg, perm, ...) \
|
||||
enum { AM_##reg = (id) }; \
|
||||
|
|
|
@ -11,34 +11,15 @@ struct Context {
|
|||
uintptr_t ksp;
|
||||
void *vm_head;
|
||||
ucontext_t uc;
|
||||
#ifdef __x86_64__
|
||||
// skip the red zone of the stack frame, see the amd64 ABI manual for details
|
||||
uint8_t redzone[128];
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define GPR1 uc.uc_mcontext.gregs[REG_RDI]
|
||||
#define GPR2 uc.uc_mcontext.gregs[REG_RSI]
|
||||
#define GPR3 uc.uc_mcontext.gregs[REG_RDX]
|
||||
#define GPR4 uc.uc_mcontext.gregs[REG_RCX]
|
||||
#define GPRx uc.uc_mcontext.gregs[REG_RAX]
|
||||
#elif defined(__aarch64__)
|
||||
#define GPR1 uc.uc_mcontext.regs[0]
|
||||
#define GPR2 uc.uc_mcontext.regs[1]
|
||||
#define GPR3 uc.uc_mcontext.regs[2]
|
||||
#define GPR4 uc.uc_mcontext.regs[3]
|
||||
#define GPRx uc.uc_mcontext.regs[0]
|
||||
#elif defined(__riscv)
|
||||
// FIXME: may be wrong
|
||||
#define GPR1 uc.uc_mcontext.__gregs[REG_A0]
|
||||
#define GPR2 uc.uc_mcontext.__gregs[REG_A0+1]
|
||||
#define GPR3 uc.uc_mcontext.__gregs[REG_A0+2]
|
||||
#define GPR4 uc.uc_mcontext.__gregs[REG_A0+3]
|
||||
#define GPRx uc.uc_mcontext.__gregs[REG_A0+4]
|
||||
#else
|
||||
#error Unsupported architecture
|
||||
#endif
|
||||
|
||||
#undef __USE_GNU
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef ARCH_H__
|
||||
#define ARCH_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#ifdef __riscv_e
|
||||
#define NR_REGS 16
|
||||
#else
|
||||
|
@ -8,9 +9,12 @@
|
|||
#endif
|
||||
|
||||
struct Context {
|
||||
// TODO: fix the order of these members to match trap.S
|
||||
uintptr_t mepc, mcause, gpr[NR_REGS], mstatus;
|
||||
void *pdir;
|
||||
//The order of these members should match trap.S, pay attention to pdir.
|
||||
uintptr_t gpr[NR_REGS];
|
||||
uintptr_t mcause;
|
||||
uintptr_t mstatus;
|
||||
uintptr_t mepc;
|
||||
void *pdir;
|
||||
};
|
||||
|
||||
#ifdef __riscv_e
|
||||
|
@ -19,9 +23,9 @@ struct Context {
|
|||
#define GPR1 gpr[17] // a7
|
||||
#endif
|
||||
|
||||
#define GPR2 gpr[0]
|
||||
#define GPR3 gpr[0]
|
||||
#define GPR4 gpr[0]
|
||||
#define GPRx gpr[0]
|
||||
#define GPR2 gpr[10] //a0
|
||||
#define GPR3 gpr[11] //a1
|
||||
#define GPR4 gpr[12] //a2
|
||||
#define GPRx gpr[10] //a0, return value
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue