Skip to content

Commit b8e1e8e

Browse files
committed
Introduce ENABLE_ON_TEST
The MMU test suite relies on rv32emu's syscall function instead of its syscall table, unlike the Linux kernel. Therefore, use the ON_TEST macro to distinguish between the Linux kernel and MMU test suite as the emulation target.
1 parent d3c493d commit b8e1e8e

File tree

5 files changed

+23
-7
lines changed

5 files changed

+23
-7
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
- name: MMU test
7272
run: |
7373
make -C tests/system/mmu/
74-
make distclean && make ENABLE_USE_ELF=1 ENABLE_SYSTEM=1 mmu-test -j$(nproc)
74+
make distclean && make ENABLE_ON_TEST=1 ENABLE_USE_ELF=1 ENABLE_SYSTEM=1 mmu-test -j$(nproc)
7575
- name: gdbstub test
7676
run: |
7777
make distclean && make ENABLE_GDBSTUB=1 gdbstub-test -j$(nproc)

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ ifeq ($(call has, USE_ELF), 1)
2020
DEFINE_USE_ELF := -DUSE_ELF
2121
endif
2222

23+
# The MMU test suite relies on rv32emu's syscall function instead of
24+
# its syscall table, unlike the Linux kernel. Therefore, use the
25+
# ON_TEST macro to distinguish between the Linux kernel and MMU test
26+
# suite as the emulation target.
27+
ENABLE_ON_TEST ?= 0
28+
ifeq ($(call has, ON_TEST), 1)
29+
DEFINE_ON_TEST := -DON_TEST
30+
endif
31+
2332
ENABLE_SYSTEM ?= 0
2433
$(call set-feature, SYSTEM)
2534

@@ -251,7 +260,7 @@ endif
251260

252261
$(OUT)/%.o: src/%.c $(deps_emcc)
253262
$(VECHO) " CC\t$@\n"
254-
$(Q)$(CC) $(DEFINE_USE_ELF) -o $@ $(CFLAGS) $(CFLAGS_emcc) -c -MMD -MF $@.d $<
263+
$(Q)$(CC) $(DEFINE_USE_ELF) $(DEFINE_ON_TEST) -o $@ $(CFLAGS) $(CFLAGS_emcc) -c -MMD -MF $@.d $<
255264

256265
$(BIN): $(OBJS) $(DEV_OBJS)
257266
$(VECHO) " LD\t$@\n"

src/devices/uart.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
* "LICENSE" for information on usage and redistribution of this file.
44
*/
55

6+
#include <assert.h>
67
#include <errno.h>
78
#include <poll.h>
89
#include <stdio.h>
910
#include <stdlib.h>
1011
#include <string.h>
1112
#include <unistd.h>
12-
#include <assert.h>
13-
14-
/* Emulate 8250 (plain, without loopback mode support) */
1513

1614
#include "uart.h"
1715

16+
/* Emulate 8250 (plain, without loopback mode support) */
17+
1818
#define U8250_INT_THRE 1
1919

2020
void u8250_update_interrupts(u8250_state_t *uart)

src/emulate.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,15 @@ void ebreak_handler(riscv_t *rv)
12031203
void ecall_handler(riscv_t *rv)
12041204
{
12051205
assert(rv);
1206-
#if RV32_HAS(SYSTEM)
1206+
1207+
/*
1208+
* FIXME: MMU test suite rely on rv32emu syscall instead of its own syscall
1209+
* table
1210+
*/
1211+
#if defined(ON_TEST)
1212+
rv->PC += 4;
1213+
syscall_handler(rv);
1214+
#elif RV32_HAS(SYSTEM)
12071215
if (rv->priv_mode == RV_PRIV_U_MODE) {
12081216
SET_CAUSE_AND_TVAL_THEN_TRAP(rv, ECALL_U, 0);
12091217
} else if (rv->priv_mode ==

src/t2c_template.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ T2C_OP(sfencevma, { __UNREACHABLE; })
373373

374374
#if RV32_HAS(Zifencei)
375375
T2C_OP(fencei, { __UNREACHABLE; })
376-
T2C_OP(fence, { __UNREACHABLE; })
377376
#endif
378377

379378
#if RV32_HAS(Zicsr)

0 commit comments

Comments
 (0)