• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved.
3 *
4 * UniProton is licensed under Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *          http://license.coscl.org.cn/MulanPSL2
8 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11 * See the Mulan PSL v2 for more details.
12 * Create: 2022-11-22
13 * Description: GUEST启动处理。
14 */
15#include "prt_buildef.h"
16#include "prt_asm_arm_external.h"
17
18DAIF_MASK = 0x1C0       // disable Abort, IRQ, FIQ
19
20.macro REG_INIT  xreg
21    mov \xreg, #0
22.endm
23
24
25    .global  __os_sys_sp_end
26    .global  g_cfgPrimaryCore
27    .global  g_gicCoreMap
28    .global  OsResetVector
29    .global  OsBssInit
30    .global  InitSystemSp
31    .global  OsVectorTable
32
33    .type   __os_sys_sp_end, object
34    .type   g_cfgPrimaryCore, object
35    .type   g_gicCoreMap, object
36    .type   OsResetVector, function
37    .type   OsBssInit, function
38
39    .section .text.startup, "ax"
40OsResetVector:
41OsVectTblInit:
42    LDR x0, =OsVectorTable
43    MSR VBAR_EL1, X0
44
45OsGeneralRegsInit:  // The X30 general-purpose register is used as the procedure call link register
46    REG_INIT x0
47    REG_INIT x1
48    REG_INIT x2
49    REG_INIT x3
50    REG_INIT x4
51    REG_INIT x5
52    REG_INIT x6
53    REG_INIT x7
54    REG_INIT x8
55    REG_INIT x9
56    REG_INIT x10
57    REG_INIT x11
58    REG_INIT x12
59    REG_INIT x13
60    REG_INIT x14
61    REG_INIT x15
62    REG_INIT x16
63    REG_INIT x17
64    REG_INIT x18
65    REG_INIT x19
66    REG_INIT x20
67    REG_INIT x21
68    REG_INIT x22
69    REG_INIT x23
70    REG_INIT x24
71    REG_INIT x25
72    REG_INIT x26
73    REG_INIT x27
74    REG_INIT x28
75    REG_INIT x29
76
77OsStackBssInit:
78    LDR x0, =__os_sys_sp_end
79    BIC sp, x0, #0xf                /* 16-byte alignment for ABI compliance */
80    BL  OsBssInit
81    BL  InitSystemSp
82    B   OsCoreMapInit
83
84OsCoreMapInit:
85    MRS x1, mpidr_el1 // 读取CoreMap
86    LDR x2, =g_gicCoreMap
87    STR x1, [x2]
88
89OsPrimaryMain: /* OsPrimaryMain函数主核调用 */
90    BL PRT_HardBootInit /* 用户调用的第一个函数钩子,用户在此处完成Seed随机数生成 */
91    /* Notes:X9存g_memCanaryRdm地址,X10存__stack_chk_guard地址,w11存g_memCanaryRdm的值 U32类型 */
92    /* __stack_chk_guard赋值后 g_memCanaryRdm 以及 w11都会被销毁 */
93#if defined(OS_OPTION_GUARD_STACK)
94    InitChkGuardRnd x9, x10, w11 /* RND 写入 StackChkGuard */
95#endif
96
97OsEnterMain:
98    BL      main
99
100    MOV     x2, DAIF_MASK
101    MSR     DAIF, x2
102
103EXITLOOP:
104    B EXITLOOP
105
106    .text
107