Skip to content

Commit

Permalink
Change RISC-V Addresses. NuttX for Ox64 boots a tiny bit
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Jan 15, 2024
1 parent 4678ed5 commit 8100f25
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions riscv_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ typedef struct RISCVMachine {
int virtio_count;
} RISCVMachine;

#define LOW_RAM_SIZE 0x00010000 /* 64KB */
#define RAM_BASE_ADDR 0x80000000
#define CLINT_BASE_ADDR 0x02000000
#define CLINT_SIZE 0x000c0000
#define LOW_RAM_SIZE 0x00010000 // TODO: 64KB at 0x0
#define RAM_BASE_ADDR 0x50200000
#define CLINT_BASE_ADDR 0x02000000 // TODO: Unused
#define CLINT_SIZE 0x000c0000 // TODO: Unused
#define DEFAULT_HTIF_BASE_ADDR 0x40008000
#define VIRTIO_BASE_ADDR 0x40010000
#define VIRTIO_SIZE 0x1000
#define VIRTIO_IRQ 1
#define PLIC_BASE_ADDR 0x40100000
#define PLIC_BASE_ADDR 0xe0000000ul
#define PLIC_SIZE 0x00400000
#define FRAMEBUFFER_BASE_ADDR 0x41000000

Expand Down Expand Up @@ -253,7 +253,7 @@ static void plic_update_mip(RISCVMachine *s)
}
}

#define PLIC_HART_BASE 0x200000
#define PLIC_HART_BASE 0x201000 // Hart 0 S-Mode Priority Threshold
#define PLIC_HART_SIZE 0x1000

static uint32_t plic_read(void *opaque, uint32_t offset, int size_log2)
Expand Down Expand Up @@ -860,10 +860,10 @@ static void copy_bios(RISCVMachine *s, const uint8_t *buf, int buf_len,
RAM_BASE_ADDR + initrd_base,
initrd_size);

/* jump_addr = 0x80000000 */
/* jump_addr = RAM_BASE_ADDR */

q = (uint32_t *)(ram_ptr + 0x1000);
q[0] = 0x297 + 0x80000000 - 0x1000; /* auipc t0, jump_addr */
q[0] = 0x297 + RAM_BASE_ADDR - 0x1000; /* auipc t0, jump_addr */
q[1] = 0x597; /* auipc a1, dtb */
q[2] = 0x58593 + ((fdt_addr - 4) << 20); /* addi a1, a1, dtb */
q[3] = 0xf1402573; /* csrr a0, mhartid */
Expand Down

0 comments on commit 8100f25

Please sign in to comment.