aboutsummaryrefslogtreecommitdiff
path: root/src/baremetal/start_aarch64.S
blob: 36b27528862c8b119ea6e34c6966ea1dbc72312d (plain) (blame)
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
/* 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