From 2963434601864065b528655f77b280a73f3cb2b5 Mon Sep 17 00:00:00 2001 From: Wojciech Sipak Date: Tue, 5 Nov 2024 10:54:28 +0100 Subject: [PATCH] fix machine_external_ints test --- testbench/asm/machine_external_ints.s | 5 ++++- testbench/asm/tb.h | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/testbench/asm/machine_external_ints.s b/testbench/asm/machine_external_ints.s index 31a2fdd8057..7b73cf5254e 100644 --- a/testbench/asm/machine_external_ints.s +++ b/testbench/asm/machine_external_ints.s @@ -1,7 +1,9 @@ #include "common.s" machine_software_interrupt: + // put expected mcause in x4 la x4, 0x80000003 + // put expected mscause in x5 li x5, 0x0 // enable software interrupt li x2, 0x8 @@ -10,6 +12,7 @@ machine_software_interrupt: li x2, TRIGGER_SOFT_INT li x3, STDOUT sw x2, 0(x3) + li x12, 0x8 j fail_if_not_serviced machine_timer_interrupt: @@ -27,4 +30,4 @@ machine_timer_interrupt: main: call machine_software_interrupt call machine_timer_interrupt - j _finish \ No newline at end of file + j _finish diff --git a/testbench/asm/tb.h b/testbench/asm/tb.h index 38ac5deed16..b3deeed4476 100644 --- a/testbench/asm/tb.h +++ b/testbench/asm/tb.h @@ -1,9 +1,20 @@ #define STDOUT 0xd0580000 -#define TRIGGER_NMI 0x80 +/* TODO remove this. It's not supported by the testbench mailbox logic */ #define LOAD_NMI_ADDR 0x81 -#define TRIGGER_DBUS_FAULT 0x82 -#define TRIGGER_IBUS_FAULT 0x83 -#define TRIGGER_SOFT_INT 0x84 -#define TRIGGER_TIMER_INT 0x85 -#define TRIGGER_EXT_INT1 0x86 \ No newline at end of file +/* helper macros that define messages to be written to `STDOUT` to trigger and clear interrupts */ + +#define CLEAR 0x82 +#define TRIGGER 0x83 + +#define NMI_INT (1<<8) +#define TIMER_INT (1<<9) +#define SOFT_INT (1<<10) + +#define TRIGGER_NMI_INT (TRIGGER | NMI_INT) +#define TRIGGER_TIMER_INT (TRIGGER | TIMER_INT) +#define TRIGGER_SOFT_INT (TRIGGER | SOFT_INT) + +#define CLEAR_NMI_INT (CLEAR | NMI_INT) +#define CLEAR_TIMER_INT (CLEAR | TIMER_INT) +#define CLEAR_SOFT_INT (CLEAR | SOFT_INT)