decode_insn.h
disasm_insn.h
execute_insn.h
-ecall_nums.h
+ecall.h
opcodes.h
opcodes_attr.h
.PHONY: clean
clean:
- rm -f decode_insn.h disasm_insn.h execute_insn.h ecall_nums.h opcodes.h opcodes_attr.h *.o *~ ./#*#
+ rm -f decode_insn.h disasm_insn.h execute_insn.h ecall.h opcodes.h opcodes_attr.h *.o *~ ./#*#
rm -rf build
$(cobj): $(incf)
$B/slow_sim.o $B/fast_sim.o: sim_body.h execute_insn.h caveat_fp.h core.h
-$B/ecall.o: core.h ecall_nums.h
+$B/ecall.o: core.h ecall.h
$B/insn.o: decode_insn.h disasm_insn.h
$B/trace.o: fifo.h
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
+ecall.h: opcodes.h insn.h core.h
+ echo -n > $@
+ echo '#include <stdio.h>' >> $@
+ echo '#include <stdint.h>' >> $@
+ echo '#include <sys/time.h>' >> $@
+ echo '#include "opcodes.h"' >> $@
+ echo '#include "insn.h"' >> $@
+ echo '#include "core.h"' >> $@
+ python3 -m openpower.syscalls ecall riscv64 amd64 >> $@
+++ /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_fetch(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;
-}
-
-static inline void
-ecall_store(long const arguments[6], struct core_t *cpu)
-{
- cpu->reg[10].l = arguments[0];
- cpu->reg[11].l = arguments[1];
- cpu->reg[12].l = arguments[2];
- cpu->reg[13].l = arguments[3];
- cpu->reg[14].l = arguments[4];
- cpu->reg[15].l = arguments[5];
-}
+++ /dev/null
-#
-# Copyright (c) 2020 Peter Hsu. All Rights Reserved. See LICENCE file for details.
-#
-
-import re
-import os
-
-PKpattern = re.compile(r'#define\s+SYS_(\S+)\s+(\d+)')
-RVpattern = re.compile(r'#define\s+TARGET_NR_(\S+)\s+(\d+)')
-
-# Algorith is we make table of RISC-V system call names and record
-# their numbers, create a C file of names, include the host x86
-# 'asm/unistd_64.h' file to get the correct mapping.
-
-ecall = {}
-enames = {}
-highest = -1
-rv = open('../include/pk-syscall.h', 'r')
-for line in rv:
- m = PKpattern.match(line)
- if m:
- name, num = m.groups()
- num = int(num)
- ecall[num] = name
- enames[name] = num
- highest = max(num, highest)
-rv.close()
-
-rv = open('../include/syscall64_nr.h', 'r')
-for line in rv:
- m = RVpattern.match(line)
- if m:
- name, num = m.groups()
- num = int(num)
- if num in ecall and name != ecall[num]:
- print('libc {:s} override pk {:s} ecall'.format(name, ecall[num]))
- ecall[num] = name
- enames[name] = num
- highest = max(num, highest)
-
-en = open('ecall_nums.h', 'w')
-en.write("#pragma once\n")
-
-for name in sorted(enames.keys()):
- en.write('#ifndef __NR_{:s}\n'.format(name))
- en.write('#define __NR_{:s} -2\n'.format(name))
- en.write('#endif\n')
-
-en.write("""\n
-static struct ecall_entry const rv_to_host[] = {
-""")
-
-for n in range(0, highest+1):
- if n in ecall:
- name = ecall[n]
- en.write(' /* {:5d} */ {{ __NR_{:s}, "{:s}" }},\n'.format(n, name, name))
- else:
- en.write(' /* {:5d} */ {{ -1, 0 }},\n'.format(n))
-
-en.write('};\n\n')
-en.write('const int rv_syscall_entries = {:d};\n\n'.format(highest+1))
-en.close()