1
2/*
3 * Copyright (c) 2017 ETH Zurich.
4 * All rights reserved.
5 *
6 * This file is distributed under the terms in the attached LICENSE file.
7 * If you do not find this file, copies can be found by writing to:
8 * ETH Zurich D-INFK, Universitaetstr 6, CH-8092 Zurich. Attn: Systems Group.
9 */
10
11#define ASM_FILE 1
12
13#ifndef ASM_FILE
14#define ASM_FILE 1
15#endif
16#include <multiboot2.h>
17#include <asmoffsets.h>
18
19
20.text
21
22.global eret, boot_entry_bsp, boot_entry_psci, boot_entry_parking
23
24.type boot_entry_bsp, @function
25.type boot_entry_psci, @function
26.type boot_entry_parking, @function
27
28/*
29    This is the kernel entry point. We distinguish between how and who booted
30    us. In the following, an enumeration of possible boot modes. In all cases,
31    we use register X0 as a distinction.
32
33    EFI Boot:
34    Started by: UEFI (hagfish)
35    X0 Value: MULTIBOOT2_BOOTLOADER_MAGIC
36
37
38    PSCI Boot:
39    Started by: Running kernel
40    X0 Value: Pointer to ARMv8 core data
41
42    Parking Protocol Boot:
43    Started by: Running kernel
44    X0 Value: Pointer to ARMv8 core data
45 */
46
47
48boot_entry_bsp:
49     /* Calling the boot initialization function for the BSP core.
50
51      void boot_bsp_init(uint32_t magic,
52                         lpaddr_t pointer,
53                         lpaddr_t kernel_stack_top)
54
55      The function arguments are as follows:
56      magic: register x0
57      pointer: register x1
58      kernel_stack_top: register x2
59    */
60
61    /* store the stack pointer at x2 */
62    mov x2, sp
63
64    /* branch to the C function */
65    b boot_bsp_init
66
67
68
69/* Calling the initialization function for the APP cores.
70
71   void boot_app_init(lpaddr_t context);
72
73   Register x0 holds the pointer to the context (ARMv8 core data).
74   We need to extract the stack pointer from the context and set it
75   before we branch off to the C function
76 */
77
78boot_entry_psci:
79    ldr x1, [x0, #OFFSETOF_COREDATA_KERNEL_STACK]
80    mov sp, x1
81    b boot_app_init
82    wfi
83
84
85boot_entry_parking:
86    /*
87        we are using the remainder of the OS use part of the parking frame for
88        the stack
89     */
90    add sp, x0, #2032
91    b boot_app_init
92    wfi
93
94/* Error return required to drop to lower execution levels */
95eret:
96    eret
97
98
99