在 AArch64 架构中,异常优先级是高度优先的,因此具有更高优先级的异常将优先处理。可以使用以下示例代码来更改 AArch64 异常优先级:
void __attribute__((interrupt("ABORT"))) my_abort_handler(void) {
// Abort exception handling code here
}
void __attribute__((interrupt("FIQ"))) my_fiq_handler(void) {
// FIQ exception handling code here
}
void __attribute__((interrupt("IRQ"))) my_irq_handler(void) {
// IRQ exception handling code here
}
void __attribute__((interrupt("UNDEF"))) my_undef_handler(void) {
// Undefined instruction exception handling code here
}
在上面的代码中,每个异常都有一个优先级标识符,例如“FIQ”和“IRQ”。通过定义优先级,在异常发生时,具有较高优先级的异常将优先处理。在此示例中,Abort 异常具有最高优先级,因为它是使用“ABORT”优先级标识符定义的。然后是 FIQ 异常,使用“FIQ”标识符定义; IRQ 异常使用“IRQ”标识符定义,最后是 Undefined 异常,使用“UNDEF”标识符定义。这种定义顺序确定了 AArch64 异常的优先级序列。