From b15a36139fcedd4d6f83f929d1558577d034c5c1 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Thu, 18 Jul 2024 13:31:08 +0800 Subject: [PATCH 1/4] Do not track the generated riscv-harts.dtsi --- .gitignore | 3 +++ Makefile | 1 + 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 58e9e7e..b56a9aa 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ semu Image ext4.img rootfs.cpio + +# intermediate +riscv-harts.dtsi diff --git a/Makefile b/Makefile index 3b81bf2..caaab7d 100644 --- a/Makefile +++ b/Makefile @@ -98,6 +98,7 @@ clean: $(Q)$(RM) $(BIN) $(OBJS) $(deps) distclean: clean + $(Q)$(RM) riscv-harts.dtsi $(Q)$(RM) minimal.dtb $(Q)$(RM) Image rootfs.cpio $(Q)$(RM) ext4.img From 3a1bbd4f012882c366b5c2ce63e138db1d8dde21 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Thu, 18 Jul 2024 13:34:07 +0800 Subject: [PATCH 2/4] Update checksum for prebuilt Linux image Now, the kernel image is SMP aware. --- mk/external.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mk/external.mk b/mk/external.mk index 68a83c8..65499b4 100644 --- a/mk/external.mk +++ b/mk/external.mk @@ -8,12 +8,12 @@ COMMON_URL = https://github.com/sysprog21/semu/raw/blob # kernel KERNEL_DATA_URL = $(COMMON_URL)/Image.bz2 KERNEL_DATA = Image -KERNEL_DATA_SHA1 = 75cf702d3f9781bc5848de5dc758141bbec75d26 +KERNEL_DATA_SHA1 = a1fb94ff9d47d833759a2ff5d912858faa125a6c # initrd INITRD_DATA_URL = $(COMMON_URL)/rootfs.cpio.bz2 INITRD_DATA = rootfs.cpio -INITRD_DATA_SHA1 = 61b38be3eff25a9fab3a8db4eb119b0145bb5f65 +INITRD_DATA_SHA1 = 3b3fd7131b5e27cbb6675145cbfeccfcedcb867f define download $($(T)_DATA): From ffefe18ac96e5c30fc1afafd378a96f56ae26f7c Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Thu, 18 Jul 2024 13:42:20 +0800 Subject: [PATCH 3/4] Apply editorial changes --- main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 9e20690..2e011c6 100644 --- a/main.c +++ b/main.c @@ -382,14 +382,14 @@ static void handle_sbi_ecall(hart_t *hart) hart->error = ERR_NONE; } -#define MAPPER_SIZE 4 +#define N_MAPPERS 4 struct mapper { char *addr; uint32_t size; }; -static struct mapper mapper[MAPPER_SIZE] = {0}; +static struct mapper mapper[N_MAPPERS] = {0}; static int map_index = 0; static void unmap_files(void) { @@ -498,7 +498,7 @@ static void handle_options(int argc, #define INIT_HART(hart, emu, id) \ - ({ \ + do { \ hart->priv = emu; \ hart->mhartid = id; \ hart->mem_fetch = mem_fetch; \ @@ -508,7 +508,7 @@ static void handle_options(int argc, hart->s_mode = true; \ hart->hsm_status = SBI_HSM_STATE_STOPPED; \ vm_init(hart); \ - }) + } while (0) static int semu_start(int argc, char **argv) { @@ -558,10 +558,11 @@ static int semu_start(int argc, char **argv) /* Hook for unmapping files */ atexit(unmap_files); - /* Set up RISC-V hart */ - vm_t vm; - vm.n_hart = hart_count; - vm.hart = malloc(sizeof(hart_t *) * vm.n_hart); + /* Set up RISC-V harts */ + vm_t vm = { + .n_hart = hart_count, + .hart = malloc(sizeof(hart_t *) * vm.n_hart), + }; for (uint32_t i = 0; i < vm.n_hart; i++) { hart_t *newhart = malloc(sizeof(hart_t)); INIT_HART(newhart, &emu, i); From 24f5c80a7593a1039a1211bd2736c567b8d465b0 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Thu, 18 Jul 2024 13:53:41 +0800 Subject: [PATCH 4/4] Remove unintended return statements --- clint.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/clint.c b/clint.c index 874f16e..f5560f6 100644 --- a/clint.c +++ b/clint.c @@ -80,7 +80,6 @@ void clint_read(hart_t *vm, if (!clint_reg_read(clint, addr, value)) vm_set_exception(vm, RV_EXC_LOAD_FAULT, vm->exc_val); *value = (*value) >> (RV_MEM_SW - width); - return; } void clint_write(hart_t *vm, @@ -91,5 +90,4 @@ void clint_write(hart_t *vm, { if (!clint_reg_write(clint, addr, value >> (RV_MEM_SW - width))) vm_set_exception(vm, RV_EXC_STORE_FAULT, vm->exc_val); - return; }