Skip to content

Commit

Permalink
Merge branch 'sysprog21:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
chiangkd authored Jul 20, 2024
2 parents c88e165 + 24f5c80 commit bc42531
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ semu
Image
ext4.img
rootfs.cpio

# intermediate
riscv-harts.dtsi
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,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
Expand Down
2 changes: 0 additions & 2 deletions clint.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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,
Expand All @@ -94,5 +93,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;
}
17 changes: 9 additions & 8 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,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)
{
Expand Down Expand Up @@ -491,7 +491,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; \
Expand All @@ -501,7 +501,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)
{
Expand Down Expand Up @@ -552,10 +552,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);
Expand Down
4 changes: 2 additions & 2 deletions mk/external.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit bc42531

Please sign in to comment.