Changes in boot/arch/arm64/src/asm.S [95b7d4df:84176f3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/arch/arm64/src/asm.S
r95b7d4df r84176f3 33 33 .section BOOTSTRAP 34 34 35 #define DIRECTORY_ENTRIES 1636 37 35 /* MS-DOS stub */ 38 36 msdos_stub: … … 53 51 .long 0 /* Number of symbols */ 54 52 .short sec_table - opt_header /* Size of optional header */ 55 /* 56 * Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE | 57 * IMAGE_FILE_LARGE_ADDRESS_AWARE 58 */ 53 /* Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE | 54 * IMAGE_FILE_LARGE_ADDRESS_AWARE */ 59 55 .short 0x22 60 56 … … 91 87 .quad 0 /* Size of heap commit */ 92 88 .long 0 /* Loader flags */ 93 .long DIRECTORY_ENTRIES /* Number of RVA and sizes */ 94 .space DIRECTORY_ENTRIES * 8 /* Directory entries */ 89 .long 0 /* Number of RVA and sizes */ 95 90 96 91 sec_table: 97 92 .ascii ".text\x0\x0\x0" /* Name */ 98 93 .long payload_end - start /* Virtual size */ 99 94 .long start - msdos_stub /* Virtual address */ … … 104 99 .short 0 /* Number of relocations */ 105 100 .short 0 /* Number of line numbers */ 106 /* 107 * Characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | 108 * IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE 109 */ 101 /* Characteristics = IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | 102 * IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE */ 110 103 .long 0xe0000020 111 104 112 /** Boot loader entry point113 *114 * @param x0 UEFI image handle.115 * @param x1 Pointer to the UEFI system table.116 *117 */118 105 SYMBOL(start) 119 106 .hidden start 120 107 121 108 /* 122 * Stay on the UEFI stack. Its size is at least 128 KiB, plenty for this 109 * Parameters: 110 * x0 is the image handle. 111 * x1 is a pointer to the UEFI system table. 112 */ 113 114 /* 115 * Stay on the UEFI stack. Its size is at least 128 kB, plenty for this 123 116 * boot loader. 124 117 */ … … 135 128 add x1, x1, #:lo12:_DYNAMIC 136 129 bl self_relocate 137 cbnz x0, __uefi_exit 138 139 /* 140 * Flush the instruction cache of the relocated boot loader image. 141 */ 142 adr x0, msdos_stub 143 adrp x1, payload_end 144 sub x1, x1, x0 145 bl smc_coherence 130 cbnz x0, 0f 146 131 147 132 /* … … 153 138 bl bootstrap 154 139 155 __uefi_exit:156 157 140 0: 141 ldp x29, x30, [sp], #32 142 ret 158 143 159 144 FUNCTION_BEGIN(halt) … … 163 148 FUNCTION_END(halt) 164 149 165 /** Flush instruction caches166 *167 * @param x0 Starting address of the flushing.168 * @param x1 Number of bytes to flush.169 *170 */171 FUNCTION_BEGIN(smc_coherence)172 .hidden smc_coherence173 174 /* Initialize loop */175 mov x9, x0176 mov x10, xzr177 178 __dc_loop:179 /* Data or Unified Cache Line Clean */180 dc cvau, x9181 add x9, x9, #4182 add x10, x10, #4183 cmp x10, x1184 blo __dc_loop185 186 dsb ish187 188 /* Initialize loop */189 mov x9, x0190 mov x10, xzr191 192 __ic_loop:193 /* Instruction Cache Line Invalidate */194 ic ivau, x9195 add x9, x9, #4196 add x10, x10, #4197 cmp x10, x1198 blo __ic_loop199 200 dsb ish201 isb202 ret203 FUNCTION_END(smc_coherence)204 205 /** Flush data caches206 *207 * @param x0 Starting address of the flushing.208 * @param x1 Number of bytes to flush.209 *210 */211 FUNCTION_BEGIN(dcache_flush)212 .hidden dcache_flush213 214 mov x9, x0215 mov x10, xzr216 217 __dc_flush_loop:218 /* Data or Unified Cache Line Clean */219 dc cvau, x9220 add x9, x9, #4221 add x10, x10, #4222 cmp x10, x1223 blo __dc_flush_loop224 225 dsb ish226 isb227 ret228 FUNCTION_END(dcache_flush)229 230 /** Kernel entry231 *232 * @param x0 Kernel entry point.233 * @param x1 Pointer to the bootinfo structure.234 *235 */236 150 FUNCTION_BEGIN(jump_to_kernel) 237 151 .hidden jump_to_kernel 238 152 239 mrs x9, CurrentEL 240 lsr x9, x9, 2 153 /* 154 * Parameters: 155 * x0 is kernel entry point. 156 * x1 is pointer to the bootinfo structure. 157 */ 241 158 242 cmp x9, #3 243 b.eq __el3 159 /* Disable MMU (removes the identity mapping provided by UEFI). */ 160 mrs x2, sctlr_el1 161 bic x2, x2, #SCTLR_M_FLAG 162 msr sctlr_el1, x2 163 isb 244 164 245 cmp x9, #2 246 b.eq __el2 247 248 cmp x9, #1 249 b.eq __el1 250 251 b halt 252 253 __el3: 254 msr sctlr_el2, xzr 255 msr hcr_el2, xzr 256 isb 257 258 /* EL2 is AArch64, EL1 is Non-secure World */ 259 mov x9, #(1 << 10) 260 orr x9, x9, #(1 << 0) 261 msr scr_el3, x9 262 isb 263 264 /* EL2h */ 265 mov x9, #0x9 266 msr spsr_el3, x9 267 isb 268 269 adr x9, __el2 270 msr elr_el3, x9 271 isb 272 273 /* Switch to EL2 */ 274 eret 275 276 __el2: 277 msr sctlr_el1, xzr 278 isb 279 280 /* EL1 is AArch64 */ 281 mov x9, #(1 << 31) 282 msr hcr_el2, x9 283 isb 284 285 /* EL1h */ 286 mov x9, #0x5 287 msr spsr_el2, x9 288 isb 289 290 adr x9, __el1 291 msr elr_el2, x9 292 isb 293 294 /* Switch to EL1 */ 295 eret 296 297 __el1: 298 /* Do not trap on FPU instructions */ 299 mrs x9, cpacr_el1 300 orr x9, x9, #(3 << 20) 301 msr cpacr_el1, x9 302 dmb ish 303 304 /* Disable MMU (removes the identity mapping provided by UEFI) */ 305 mrs x9, sctlr_el1 306 bic x9, x9, #SCTLR_M_FLAG 307 msr sctlr_el1, x9 308 isb 309 310 br x0 165 br x0 311 166 FUNCTION_END(jump_to_kernel)
Note:
See TracChangeset
for help on using the changeset viewer.