Skip to content

Commit 3cd4460

Browse files
committed
Refine input
1 parent 5b7fcbd commit 3cd4460

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ CFLAGS = -std=gnu99 -O2 -Wall -Wextra
1111
CFLAGS += -Wno-unused-label
1212
CFLAGS += -include src/common.h
1313

14+
# In the system test suite, the executable is an ELF file.
15+
# However, the Linux kernel emulation includes the Image, DT, and
16+
# root filesystem (rootfs). Therefore, the test suite needs this
17+
# flag to load the ELF and differentiate it from the kernel emulation.
18+
USE_ELF ?= 0
19+
1420
ENABLE_SYSTEM ?= 0
1521
$(call set-feature, SYSTEM)
1622

src/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,14 @@ int main(int argc, char **args)
225225
.cycle_per_step = CYCLE_PER_STEP,
226226
.allow_misalign = opt_misaligned,
227227
};
228-
#if RV32_HAS(SYSTEM)
229-
assert(attr.data.system);
230-
attr.data.system->kernel = "build/Image"; /* FIXME: hardcoded */
231-
attr.data.system->initrd = "build/rootfs.cpio"; /* FIXME: hardcoded */
232-
attr.data.system->dtb = "build/minimal.dtb"; /* FIXME: hardcoded */
233-
#else
228+
#if defined(USE_ELF)
234229
assert(attr.data.user);
235230
attr.data.user->elf_program = opt_prog_name;
231+
#elif RV32_HAS(SYSTEM)
232+
assert(attr.data.system);
233+
attr.data.system->kernel = "build/Image"; /* FIXME: hardcoded */
234+
attr.data.system->initrd = "build/rootfs.cpio";/* FIXME: hardcoded */
235+
attr.data.system->dtb = "build/minimal.dtb";/* FIXME: hardcoded */
236236
#endif
237237

238238
/* create the RISC-V runtime */

src/riscv.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ riscv_t *rv_create(riscv_user_t rv_attr)
306306

307307
elf_delete(elf);
308308

309+
#if RV32_HAS(SYSTEM)
310+
/* install the MMU I/O handlers */
311+
memcpy(&rv->io, &mmu_io, sizeof(riscv_io_t));
312+
#else
309313
/* install the I/O handlers */
310314
const riscv_io_t io = {
311315
/* memory read interface */
@@ -327,8 +331,9 @@ riscv_t *rv_create(riscv_user_t rv_attr)
327331
.on_trap = trap_handler,
328332
};
329333
memcpy(&rv->io, &io, sizeof(riscv_io_t));
334+
#endif /* RV32_HAS(SYSTEM) */
330335
}
331-
#if RV32_HAS(SYSTEM)
336+
#if RV32_HAS(SYSTEM) && !defined(USE_ELF)
332337
else {
333338
/* *-----------------------------------------*
334339
* | Memory layout |

0 commit comments

Comments
 (0)