20230826 step03 获取当前异常等级 CurrentEL

发布时间 2023-08-26 16:44:08作者: 杨大茄子

  armV8-A  架构文档的  C5.2.1

 在EL0不可用,EL1时。。。。。,返回值前60bits 和后2bits都为0

修改一下boot.S

// The entry point is in its own section ".text.boot".
.section ".text.boot"

// The symbol "_start" is the kernel's entry point, make it global.
.global _start

// Entry point for the main core.
_start:
        MRS X5,CurrentEL        //read current  Exception level.EL, bits [3:2]
        LSR X5,X5,2     //Shift out two 0 at the tail

// Hang forever in a loop.
hang_forever:
        wfe                   // Allow the CPU to go to low-power mode.
        b hang_forever

  make

make run-gdb

new teminal:  make gdb

读取内存

  反汇编

  si   step instruction, i r 查看寄存器;这里可以看到EL等于2,当前为EL2