ARM Interrupt Structure

  • ARM 아키텍처의 경우 x86아키텍처와는 다르게 Interrupt를 Exception의 일종으로 받아들인다.
  • 즉, IDT, IVT가 아닌, Exception Vector Table이 있고, Interrupt 타입인 Exception이 들어오면 어떤 Interrupt인지 그때 확인한 후에 적절한 handler를 실행시켜주어야 한다.

index

Interrupt

ARM Interrupt Structure

https://www.geeksforgeeks.org/arm-interrupt-structure/

GIC

https://wiki.osdev.org/Generic_Interrupt_Controller_versions_3_and_4

Interrupt Types

Interrupt Trigger Types

Link to original

Exception Levels

Exception Levels

Exception Levels

  • EL3
    • Highest privilege level is typically used for so called Secure Monitor
    • EL3 firmware typically implements the Power State Coordination Interface (PSCI) for the lower ELs to use
    • EL3 firmware typically involved into trusted boot
  • EL2
    • Targets the virtualization use-case
    • EL at which hypervisors normally use for virtualization purposes.
  • EL1
    • Privileged parts of the OS kernels use
  • EL0
    • Most unprivileged level
    • Runs most unprivileged codes (userspace application, userspace drivers, etc).

Reference

Link to original

Exception Handling

https://developer.arm.com/documentation/dui0471/m/handling-processor-exceptions/exception-handling-process https://developer.arm.com/documentation/100933/0100/Exception-handling https://developer.arm.com/documentation/den0024/a/AArch64-Exception-Handling/Interrupt-handling

Exception Vector

Exception Vector Table

AArch64 Exception Vector Table

ARMv7 Exception Vector Table

OffsetVectorMode
0x00ResetSupervisor
0x04Undefined InstructionUndefined
0x08Supervisor CallSupervisor
0x0CPrefetch AbortAbort
0x10Data AbortAbort
0x14Not UsedNA
0x18IRQ InterruptIRQ
0x1CFIQ InterruptFIQ

ARMv8 Exception Vector Table

AddressException TypeDescription
VBAR_ELn +0x000SynchronousCurrent EL with SP0
+0x080IRQ/vIRQ^
+0x100FIQ/vFIQ^
+0x180SError/vSError^
+0x200SynchronousCurrent EL with SPx
+0x280IRQ/vIRQ^
+0x300FIQ/vFIQ^
+0x380SError/vSError^
+0x400SynchronousLower EL using AArch64
+0x480IRQ/vIRQ^
+0x500FIQ/vFIQ^
+0x580SError/vSError^
+0x600SynchronousLower EL using AArch32
+0x680IRQ/vIRQ^
+0x700FIQ/vFIQ^
+0x780SError/vSError^
Link to original

Reference

Link to original

Enable & Disable Interrupt

  • Enable interrupt: asm!("msr DAIFClr, #0xf", options(nomem, nostack));
    • MSR DAIFSet, <Xt>: DAIF |= Xt (OR).. 1인 자릿수의 bit 1로 (마스킹하는거)
    • MSR DAIFClr, <Xt>: DAIF &= ~Xt (NAND).. 1인 자릿수의 bit 0으로 (마스킹 안하는거)
  • Disable interrupt: asm!("msr DAIFClr, #0xf", options(nomem, nostack));

DAIF

DAIF: Interrupt Mask Bits

Allows access to the interrupt mask bits. https://developer.arm.com/documentation/ddi0601/2023-12/AArch64-Registers/DAIF—Interrupt-Mask-Bits

D bit[9]

Debug Whether to mask Watchpoint, Breakpoint, Software Step exceptions targeted at the current Exception Level When the target Exception level of debug exception is higher than the current Exception level, the exception will not be masked by D Defaults to 1 on warm reset

DMeaning
0not masked
1masked

A bit[8]

SError(SystemError) Exception mask bit Defaults to 1 on warm reset

AMeaning
0Exception not masked
1Exception masked

I bit[7]

IRQ mask bit Defaults to 1 on warm reset

IMeaning
0Exception not masked
1Exception masked

F bit[6]

FIQ mask bit Defaults to 1 on warm reset

FMeaning
0Exception not masked
1Exception masked
Link to original

Registers used to configure Coretex-M Exceptions

https://interrupt.memfault.com/blog/arm-cortex-m-exceptions-and-nvic