fix riscv-tests and add flag for exit call

This commit is contained in:
Stefan 2021-08-17 09:36:49 +02:00
parent cb6d05178b
commit 30bd88dbbf
3 changed files with 21 additions and 16 deletions

View File

@ -10,6 +10,8 @@
#include "trap.h" #include "trap.h"
#include "csr.h" #include "csr.h"
static bool allow_ecall_exit = false;
#define AS_SIGNED(val) (*(int32_t*)&val) #define AS_SIGNED(val) (*(int32_t*)&val)
#define AS_UNSIGNED(val) (*(uint*)&val) #define AS_UNSIGNED(val) (*(uint*)&val)
const uint ZERO = 0; const uint ZERO = 0;
@ -203,12 +205,12 @@ DEF(ebreak, FormatEmpty, { // system
SINGLE_STEP=1; SINGLE_STEP=1;
}) })
DEF(ecall, FormatEmpty, { // system DEF(ecall, FormatEmpty, { // system
/* if (cpu->xreg[17] == 93) { */ if (allow_ecall_exit && cpu->xreg[17] == 93) {
/* // EXIT CALL */ // EXIT CALL
/* uint status = cpu->xreg[10] >> 1; */ uint status = cpu->xreg[10] >> 1;
/* printf("ecall EXIT = %d (0x%x)\n", status, status); */ printf("ecall EXIT = %d (0x%x)\n", status, status);
/* exit(status); */ exit(status);
/* } */ }
ret->trap.en = true; ret->trap.en = true;
ret->trap.value = cpu->pc; ret->trap.value = cpu->pc;

View File

@ -58,7 +58,7 @@ uint8_t* get_mmap_ptr(const char* filename) {
} }
void usage() { void usage() {
printf("Usage: rvc (-e <ELF binary>|-b <raw binary>) [-d <device tree binary>] [-i <initramfs>] [-v (0|1|2|3|4)] [-s] [-t]\n"); printf("Usage: rvc (-e <ELF binary>|-b <raw binary>) [-d <device tree binary>] [-i <initramfs>] [-v (0|1|2|3|4)] [-s] [-t] [-x]\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -92,9 +92,12 @@ int main(int argc, char *argv[]) {
int c; int c;
bool trace = false; bool trace = false;
while ((c = getopt (argc, argv, "e:b:d:v:i:st")) != -1) { while ((c = getopt (argc, argv, "e:b:d:v:i:stx")) != -1) {
switch (c) switch (c)
{ {
case 'x':
allow_ecall_exit = true;
break;
case 'e': case 'e':
elf = optarg; elf = optarg;
break; break;
@ -163,7 +166,7 @@ int main(int argc, char *argv[]) {
setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdin, NULL, _IONBF, 0);
buf_off(); buf_off();
// LIMITER // LIMITER (set to high number to ignore)
const unsigned long restr = 200000*1000; const unsigned long restr = 200000*1000;
unsigned long cur = 0; unsigned long cur = 0;
unsigned long t = time(NULL); unsigned long t = time(NULL);
@ -204,13 +207,13 @@ int main(int argc, char *argv[]) {
/* printf("else if (cpu.clock == %d && arb != 0x%08x) ARB_FAIL\n", cpu.clock, arb_f); */ /* printf("else if (cpu.clock == %d && arb != 0x%08x) ARB_FAIL\n", cpu.clock, arb_f); */
/* } */ /* } */
if (cpu.pc == 0x80000118) { /* if (cpu.pc == 0x80000118) { */
/* if (cpu.clock == 6350505) { // divergence: 6350908 */ /* if (cpu.clock == 6350505) { // divergence: 6350908 */
/* if (cpu.clock == 6400000) { */ /* if (cpu.clock == 6400000) { */
printf("BREAKPOINT HIT\n"); /* printf("BREAKPOINT HIT\n"); */
SINGLE_STEP = 1; /* SINGLE_STEP = 1; */
VERBOSE = 4; /* VERBOSE = 4; */
} /* } */
if (VERBOSE >= 4) if (VERBOSE >= 4)
cpu_dump(&cpu); cpu_dump(&cpu);

View File

@ -19,8 +19,8 @@ function run_test {
popd popd
echo "Running: ./rvc -e \"./riscv-tests/isa/$1\" -v 1" echo "Running: ./rvc -x -e \"./riscv-tests/isa/$1\" -v 1"
timeout 5s ./rvc -e "./riscv-tests/isa/$1" -v 1 ./rvc -x -e "./riscv-tests/isa/$1" -v 1
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
echo "Test failed!" echo "Test failed!"