diff options
Diffstat (limited to 'boards/qemu-virt')
-rw-r--r-- | boards/qemu-virt/qemu-virt.ld | 9 | ||||
-rw-r--r-- | boards/qemu-virt/qemu-virt.s | 36 |
2 files changed, 40 insertions, 5 deletions
diff --git a/boards/qemu-virt/qemu-virt.ld b/boards/qemu-virt/qemu-virt.ld index 1fd3c22..41b4b40 100644 --- a/boards/qemu-virt/qemu-virt.ld +++ b/boards/qemu-virt/qemu-virt.ld @@ -10,12 +10,14 @@ SECTIONS { *(.text .text.*) } . = ALIGN(0x1000); + PROVIDE(kernel_rx_end = .); .rodata : { *(.srodata .srodata.*) . = ALIGN(16); *(.rodata .rodata.*) } . = ALIGN(0x1000); + PROVIDE(kernel_ro_end = .); .data : { *(.sdata .sdata.*) . = ALIGN(16); @@ -28,6 +30,13 @@ SECTIONS { *(.bss .bss.*) } . = ALIGN(0x1000); + PROVIDE(kernel_rw_end = .); + .trampoline_page : { + PROVIDE(trampoline_start = .); + *(.trampoline_page) + . = trampoline_start + 0x1000; + } + . = ALIGN(0x1000); .hart0_initial_stack : { PROVIDE(hart0_initial_stack = .); . += 0x1000; diff --git a/boards/qemu-virt/qemu-virt.s b/boards/qemu-virt/qemu-virt.s index f0599da..36ccee0 100644 --- a/boards/qemu-virt/qemu-virt.s +++ b/boards/qemu-virt/qemu-virt.s @@ -71,17 +71,36 @@ _start: .type hart0_full_boot, STT_FUNC hart0_full_boot: - ## Set up hart0's stack. - la sp, hart0_initial_stack_top + ## Set up hart0's stack, leaving room for the EarlyBootAddrs. + la sp, hart0_initial_stack_top - 9 * 8 - ## Write a canary to hart0's stack. + ## Write a canary to the bottom of hart0's stack. li t0, 0xdead0bad0defaced la t1, hart0_initial_stack sd t0, (t1) + ## Store the DeviceTree and the appropriate addresses into the + ## EarlyBootAddrs. + sd a1, (0 * 8)(sp) + la t0, kernel_start + sd t0, (1 * 8)(sp) + la t0, kernel_end + sd t0, (2 * 8)(sp) + la t0, kernel_rx_end + sd t0, (3 * 8)(sp) + la t0, kernel_ro_end + sd t0, (4 * 8)(sp) + la t0, kernel_rw_end + sd t0, (5 * 8)(sp) + sd t1, (6 * 8)(sp) # This is still hart0_initial_stack from above. + la t0, hart0_initial_stack_top + sd t0, (7 * 8)(sp) + la t0, trampoline_start + sd t0, (8 * 8)(sp) + ## Call hart0_early_boot, passing it the DeviceTree we received and ## getting back the address of a stack to switch to. - mv a0, a1 + mv a0, sp call hart0_early_boot ## Switch to the returned stack. @@ -99,7 +118,14 @@ hart0_full_boot: .type wait_for_hart0, STT_FUNC wait_for_hart0: - # TODO + ## TODO wfi j wait_for_hart0 .size wait_for_hart0, . - wait_for_hart0 + +.section .trampoline_page + +trap_handler: + ## TODO + wfi + j trap_handler |