opcodes.h opcodes_attr.h decode_insn.h execute_insn.h disasm_insn.h constants.c: crunch_isa.py Instructions.def
python3 crunch_isa.py
+ecall.h: ecall_nums.h opcodes.h insn.h core.h
+
ecall_nums.h: make_ecall_tbl.py
python3 make_ecall_tbl.py
#include "arith.h"
#include "caveat.h"
+#include "ecall.h"
#include "opcodes.h"
#include "insn.h"
#include "shmfifo.h"
#include "core.h"
#include "riscv-opc.h"
-#include "ecall_nums.h"
//#define DEBUG
cpu->reg[10].l, cpu->reg[11].l, cpu->reg[12].l, cpu->reg[13].l, cpu->reg[14].l, cpu->reg[15].l);
abort();
}
- long sysnum = rv_to_host[rvnum].sysnum;
+ struct ecall_entry const *entry = ecall_entry(rvnum);
+ long sysnum = entry->number;
+ char const *name = entry->name;
#ifdef DEBUG
fprintf(stderr, "%10ld: %s[%ld:%ld](%lx, %lx, %lx, %lx, %lx, %lx)", cpu->counter.insn_executed-previous,
- rv_to_host[rvnum].name, rvnum, sysnum,
+ name, rvnum, sysnum,
cpu->reg[10].l, cpu->reg[11].l, cpu->reg[12].l, cpu->reg[13].l, cpu->reg[14].l, cpu->reg[15].l);
previous = cpu->counter.insn_executed;
#endif
- switch (sysnum) {
+ switch (entry->number) {
case -1:
goto no_mapping;
case -2:
- fprintf(stderr, "RISCV-V system call %s(#%ld) not supported on host system\n", rv_to_host[rvnum].name, sysnum);
+ fprintf(stderr, "RISCV-V system call %s(#%ld) not supported on host system\n", name, sysnum);
abort();
#if 0
--- /dev/null
+#pragma once
+
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/time.h>
+
+struct ecall_entry {
+ long number;
+ char const *name;
+};
+
+#include "opcodes.h"
+#include "insn.h"
+#include "core.h"
+
+#include "ecall_nums.h"
+
+static inline struct ecall_entry const *
+ecall_entry(long id) {
+ return &rv_to_host[id];
+}
+
+static inline long
+ecall_idargs(struct core_t const *cpu, long arguments[6]) {
+ arguments[0] = cpu->reg[10].l;
+ arguments[1] = cpu->reg[11].l;
+ arguments[2] = cpu->reg[12].l;
+ arguments[3] = cpu->reg[13].l;
+ arguments[4] = cpu->reg[14].l;
+ arguments[5] = cpu->reg[15].l;
+
+ return cpu->reg[17].l;
+}