diff options
Diffstat (limited to 'src/start.s')
-rw-r--r-- | src/start.s | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/start.s b/src/start.s index 0fd2a5f..b142397 100644 --- a/src/start.s +++ b/src/start.s | |||
@@ -3,8 +3,33 @@ | |||
3 | .global _start | 3 | .global _start |
4 | 4 | ||
5 | _start: | 5 | _start: |
6 | ldr r3, =main | 6 | // Stop all cores except one. |
7 | blx r3 | 7 | mrs x0, mpidr_el1 |
8 | and x0, x0, #0xFF | ||
9 | cbz x0, master | ||
10 | b halt | ||
11 | |||
12 | // Helper function to clear x1 bytes starting at the x0 memory address. | ||
13 | memzero: | ||
14 | str xzr, [x0], #8 | ||
15 | subs x1, x1, #8 | ||
16 | b.gt memzero | ||
17 | ret | ||
18 | |||
19 | master: | ||
20 | // Clear bss. | ||
21 | ldr x0, =__bss_start | ||
22 | ldr x1, =__bss_size | ||
23 | sub x1, x1, x0 | ||
24 | bl memzero | ||
25 | |||
26 | // Set stack before our code. | ||
27 | ldr x0, =_start | ||
28 | mov sp, x0 | ||
29 | |||
30 | // Start C code, should not return. | ||
31 | bl main | ||
32 | b halt | ||
8 | 33 | ||
9 | halt: | 34 | halt: |
10 | wfe | 35 | wfe |