-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.S
More file actions
46 lines (37 loc) · 933 Bytes
/
boot.S
File metadata and controls
46 lines (37 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Copyright (c) 2025, Rye Stahle-Smith
December 2nd, 2025 - boot.S
Description: Bare-metal RISC-V bootloader that initializes machine mode, sets up trap vectors, prepares stack state, prints boot messages, and jumps into the kernel. */
.section .text
.globl _start
.align 4
_start:
# Set stack pointer to top of RAM
la sp, _stack_start
li t1, 0
csrw medeleg, t1
csrw mideleg, t1
# Initialize trap vectors
la t0, trap_vector
csrw mtvec, t0
csrw stvec, t0
la a0, boot_msg
call print_str
# Jump to kernel main
call kernel_main
hang:
wfi
j hang
.section .rodata
boot_msg:
.ascii "(bootloader) Booting...\n\0"
/* Trap trampoline (M-mode entry) - forward to trap_vector label */
.section .text
.globl trap
trap:
j trap_vector
/* Stack section */
.section .bss
.align 16
stack:
.space 16384 # 16 KiB stack
_stack_start: