summaryrefslogtreecommitdiff
path: root/Kernel/Arch/aarch64/boot.S
blob: ac4796f61680864a9b647d319cfd000631663d8d (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
/*
 * Copyright (c) 2021, Nico Weber <thakis@chromium.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

// In a specially-named text section so that the linker script can put it first in .text.
.section ".text.first"

.global start
.type start, @function
start:
  // Let only core 0 continue, put other cores to sleep.
  mrs x13, MPIDR_EL1
  and x13, x13, 0xff
  cbnz x13, halt

  // Let stack start before .text for now.
  // 512 kiB (0x80000) of stack are probably not sufficient, especially once we give the other cores some stack too,
  // but for now it's ok.
  msr SPSel, #0   //Use the same SP as we descend into EL1
  adrp x14, start
  add x14, x14, :lo12:start
  mov sp, x14

  // Clear BSS.
  adrp x14, start_of_bss
  add x14, x14, :lo12:start_of_bss
  ldr x15, =size_of_bss_divided_by_8
Lbss_clear_loop:
  str xzr, [x14], #8
  subs x15, x15, #1
  bne Lbss_clear_loop

  b init

halt:
  msr daifset, #2
  wfi
  b halt