bootrom: follow SBI (a0=hartid, a1=dtb)
This commit is contained in:
@ -5,8 +5,11 @@ OBJCOPY=riscv64-unknown-elf-objcopy
|
||||
|
||||
all: $(bootrom_img)
|
||||
|
||||
%.img: %.elf
|
||||
$(OBJCOPY) -O binary --change-addresses=-0x1000 --only-section .text $< $@
|
||||
%.img: %.bin
|
||||
dd if=$< of=$@ bs=128 count=1
|
||||
|
||||
%.bin: %.elf
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
|
||||
%.elf: %.S linker.ld
|
||||
$(GCC) -Tlinker.ld $< -nostdlib -static -o $@
|
||||
$(GCC) -Tlinker.ld $< -nostdlib -static -Wl,--no-gc-sections -o $@
|
||||
|
@ -1,13 +1,19 @@
|
||||
.text
|
||||
.global _start
|
||||
.section .text.start, "ax", @progbits
|
||||
.globl _start
|
||||
_start:
|
||||
// This boot ROM doesn't know about any boot devices, so it just spins,
|
||||
// waiting for the debugger to load a program and change the PC.
|
||||
j _start // reset vector
|
||||
.word 0 // reserved
|
||||
.word 0 // reserved
|
||||
.word 0 // pointer to config string
|
||||
.word 0 // default trap vector
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
la s0, DRAM_BASE
|
||||
csrr a0, mhartid
|
||||
la a1, _dtb
|
||||
jr s0
|
||||
|
||||
.section .text.hang, "ax", @progbits
|
||||
.globl _hang
|
||||
_hang:
|
||||
wfi
|
||||
j _hang
|
||||
|
||||
.section .rodata.dtb, "a", @progbits
|
||||
.globl _dtb
|
||||
.align 5, 0
|
||||
_dtb:
|
||||
.ascii "DTB goes here"
|
||||
|
BIN
bootrom/bootrom.img
Executable file → Normal file
BIN
bootrom/bootrom.img
Executable file → Normal file
Binary file not shown.
@ -1,5 +1,12 @@
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x1000;
|
||||
.text : { *(.text) }
|
||||
DRAM_BASE = 0x80000000;
|
||||
ROM_BASE = 0x1000;
|
||||
|
||||
. = ROM_BASE;
|
||||
.text.start : { *(.text.start) }
|
||||
. = ROM_BASE + 0x40;
|
||||
.text.hang : { *(.text.hang) }
|
||||
. = ROM_BASE + 0x80;
|
||||
.rodata.dtb : { *(.rodata.dtb) }
|
||||
}
|
||||
|
Reference in New Issue
Block a user