mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 05:42:43 +00:00 
			
		
		
		
	 247109cee6
			
		
	
	
		247109cee6
		
	
	
	
	
		
			
			Until now the kernel was always executing with SP_EL0, as this made the initial dropping to EL1 a bit easier. This commit changes this behaviour to use the corresponding SP_ELx for each exception level. To make sure that the execution of the C++ code can continue, the current stack pointer is copied into the corresponding SP_ELx just before dropping an exception level.
		
			
				
	
	
		
			39 lines
		
	
	
	
		
			877 B
		
	
	
	
		
			ArmAsm
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
	
		
			877 B
		
	
	
	
		
			ArmAsm
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Nico Weber <thakis@chromium.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| // In a specially-named text section so that the linker script can put it first in .text.
 | |
| .section ".text.first"
 | |
| 
 | |
| .global start
 | |
| .type start, @function
 | |
| start:
 | |
|   // Let only core 0 continue, put other cores to sleep.
 | |
|   mrs x13, MPIDR_EL1
 | |
|   and x13, x13, 0xff
 | |
|   cbnz x13, halt
 | |
| 
 | |
|   // Let stack start before .text for now.
 | |
|   // 512 kiB (0x80000) of stack are probably not sufficient, especially once we give the other cores some stack too,
 | |
|   // but for now it's ok.
 | |
|   adrp x14, start
 | |
|   add x14, x14, :lo12:start
 | |
|   mov sp, x14
 | |
| 
 | |
|   // Clear BSS.
 | |
|   adrp x14, start_of_bss
 | |
|   add x14, x14, :lo12:start_of_bss
 | |
|   ldr x15, =size_of_bss_divided_by_8
 | |
| Lbss_clear_loop:
 | |
|   str xzr, [x14], #8
 | |
|   subs x15, x15, #1
 | |
|   bne Lbss_clear_loop
 | |
| 
 | |
|   b pre_init
 | |
| 
 | |
| halt:
 | |
|   msr daifset, #2
 | |
|   wfi
 | |
|   b halt
 |