aboutsummaryrefslogtreecommitdiff
path: root/src/baremetal/start_aarch64.S
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /src/baremetal/start_aarch64.S
a
Diffstat (limited to 'src/baremetal/start_aarch64.S')
-rw-r--r--src/baremetal/start_aarch64.S38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/baremetal/start_aarch64.S b/src/baremetal/start_aarch64.S
new file mode 100644
index 0000000..36b2752
--- /dev/null
+++ b/src/baremetal/start_aarch64.S
@@ -0,0 +1,38 @@
+/* AArch64 virt. Drop EL2 to EL1 if we came up there, enable SIMD
+ (the compiler copies the genome with q registers), then stack, bss, C. */
+.section .text.init
+.global _start
+_start:
+ mrs x0, CurrentEL
+ lsr x0, x0, #2
+ cmp x0, #2
+ b.ne 1f
+ mov x0, #(1 << 31) /* EL1 is AArch64 */
+ msr HCR_EL2, x0
+ mrs x0, CPTR_EL2
+ bic x0, x0, #(1 << 10) /* do not trap SIMD to EL2 */
+ msr CPTR_EL2, x0
+ mov x0, #0x3c5 /* EL1h, interrupts masked */
+ msr SPSR_EL2, x0
+ adr x0, 1f
+ msr ELR_EL2, x0
+ eret
+1:
+ mrs x0, CPACR_EL1
+ orr x0, x0, #(3 << 20) /* FPEN: SIMD does not trap */
+ msr CPACR_EL1, x0
+ isb
+ ldr x0, =_stack_top
+ mov sp, x0
+ ldr x0, =_sbss
+ ldr x1, =_ebss
+2:
+ cmp x0, x1
+ b.hs 3f
+ str xzr, [x0], #8
+ b 2b
+3:
+ bl bare_main
+4:
+ wfe
+ b 4b