aboutsummaryrefslogtreecommitdiffstats
path: root/src/start.s
blob: 8f8ca2fa2b4f99237ef0efdfe0d27209e5a5a910 (plain)
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
.section ".text.boot"

.global _start
_start:
    // Stop all cores except one.
    mrs     x0, mpidr_el1
    and     x0, x0, #0xFF
    cbz     x0, master
    b       halt

// Helper function to clear x1 bytes starting at the x0 memory address.
.globl memzero64
memzero64:
    mov     x2, x1
    lsr     x2, x2, #3
    cbz     x2, memzero64_ret
memzero64_loop:
	str     xzr, [x0], #8
	subs    x2, x2, #1
	b.gt    memzero64_loop
memzero64_ret:
	ret

// Helper function wait for N cycles before returning.
.globl delay
delay:
    subs    x0, x0, #1
    bne     delay
    ret

master:
    // Set the stack memory location. Since the stack grows towards zero we set
    // the stack pointer to the end of the .stack memory section.
    ldr     x0, =__stack_end
    mov     sp, x0

    // Start C code, should not return.
    bl      main
    b       halt

halt:
    wfe
    b       halt