blob: 25631cb09a26436e0e0ecc95ff66c8975aba6dce [file] [log] [blame]
Andrew Walbran15068b02022-03-22 15:57:34 +00001/*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17.macro adr_l, reg:req, sym:req
18 adrp \reg, \sym
19 add \reg, \reg, :lo12:\sym
20.endm
21
22/**
23 * This is a generic entry point for an image. It carries out the operations
24 * required to prepare the loaded image to be run. Specifically, it zeroes the
25 * bss section using registers x25 and above, prepares the stack, enables
26 * floating point, and sets up the exception vector.
27 */
28.section .init.entry, "ax"
29.global entry
30entry:
31 /* Disable trapping floating point access in EL1. */
32 mrs x30, cpacr_el1
33 orr x30, x30, #(0x3 << 20)
34 msr cpacr_el1, x30
35 isb
36
37 /* Zero out the bss section. */
38 adr_l x29, bss_begin
39 adr_l x30, bss_end
400: cmp x29, x30
41 b.hs 1f
42 stp xzr, xzr, [x29], #16
43 b 0b
44
451: /* Prepare the stack. */
46 adr x30, boot_stack_end
47 mov sp, x30
48
49 /* Call into Rust code. */
50 bl main
51
52 /* Loop forever waiting for interrupts. */
532: wfi
54 b 2b