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    X1 Value: Pointer to ARMV8 core data
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
54      The function arguments are as follows:
55      magic: register x0
56      pointer: register x1
57    */
58
59    /* branch to the C function */
60    b boot_bsp_init
61
62
63
64/* Calling the initialization function for the APP cores.
65
66   void boot_app_init(lpaddr_t context);
67
68   Register x0 holds the pointer to the context (ARMv8 core data).
69   We need to extract the stack pointer from the context and set it
70   before we branch off to the C function
71 */
72
73boot_entry_psci:
74    ldr x1, [x0, #OFFSETOF_COREDATA_KERNEL_STACK]
75    mov sp, x1
76    b boot_app_init
77    wfi
78
79
80boot_entry_parking:
81    /*
82        we are using the remainder of the OS use part of the parking frame for
83        the stack
84     */
85    add sp, x0, #2032
86    b boot_app_init
87    wfi
88
89/* Error return required to drop to lower execution levels */
90eret:
91    eret
92
93
94