Files
mkrtos-real/mkrtos_knl/arch/aarch64/aarch64_qemu/entry.S
2024-03-31 16:06:11 +00:00

119 lines
2.3 KiB
ArmAsm
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <asm/sysregs.h>
#include <asm_config.h>
.section .rodata
.align 3
.globl string1
string1:
.string "Booting at EL"
/* 8字节对齐否则会出错*/
.align 3
.globl sp_addr
.section ".data.boot"
sp_addr:
.quad per_cpu_stack + THREAD_BLOCK_SIZE - 8 - PT_REGS_SIZE //pt regs is 320 bytes.
.align 3
.globl cpio_images
.section ".data.boot"
cpio_images:
.quad 0 //pt regs is 320 bytes.
.align 3
.global cpu_jump_addr
.section ".data.boot"
cpu_jump_addr:
.zero (32) //TODO: cpu_num*MWORD_BYTES
.align 3
.global per_cpu_stack_addr
.section ".data.boot"
per_cpu_stack_addr:
.zero (32) //TODO: cpu_num*MWORD_BYTES
.section ".text.boot"
.globl _start
_start:
msr daifset, #0xf //
mov x9, x0
#ifdef CONFIG_DEBUG_ON_EARLY_ASM
/* init uart and print the string*/
bl __init_uart
#endif
mrs x5, CurrentEL
cmp x5, #CurrentEL_EL3
b.eq el3_entry //el3
b el2_entry
el3_entry:
#ifdef CONFIG_DEBUG_ON_EARLY_ASM
bl print_el
#endif
ldr x0, =SCTLR_EL2_VALUE_MMU_DISABLED
msr sctlr_el2, x0
ldr x0, =(1<<31)|(1<<4)|(1<<29)
msr hcr_el2, x0
ldr x0, =((1UL) | (1UL<<7) | (1UL<<8) | (1UL<<10))
msr scr_el3, x0
ldr x0, =SPSR_EL2
msr spsr_el3, x0
adr x0, el2_entry
msr elr_el3, x0
eret
el2_entry: //el2
/* Generic timers. */
//mrs x0, cnthctl_el2
//orr x0, x0, #3 // Enable EL1 physical timers
//msr cnthctl_el2, x0
//msr cntvoff_el2, xzr // Clear virtual offset
mrs x0, cpacr_el1
orr x0, x0, 0x3 << 20
msr cpacr_el1, x0
/* 设置异常向量表基地址到vbar寄存器 */
ldr x5, =vectors
msr vbar_el2, x5
isb
//
mrs x0, mpidr_el1 // id
and x0, x0,#0xFF // Check processor id
cbz x0, master // Hang for all non-primary CPU
//spin table
ldr x1, = cpu_jump_addr
lsl x2, x0, MWORD_SHIFT
spin_jump:
ldr x3, [x1, x2]
cbz x3, spin_jump
ldr x4, = per_cpu_stack_addr
ldr x4, [x4, x2] //sp
mov sp, x4 //cpusp
br x3
b .
master:
ldr x0, = cpio_images
str x9, [x0, #0]
/* set sp to top of init_task_union */
ldr x8, =sp_addr
ldr x9, [x8]
mov sp, x9
bl boot_mapping
proc_hang:
b proc_hang // should never come here
.globl jump_kenel_main
jump_kenel_main:
ldr x1, = start_kernel
br x1
b .