/* 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