
* Question
How does the ARM processor hardware respond to the following process when an abort occurs (assuming the interrupt is not masked)?
* Answer
When an abort occurs in an ARM processor (assuming the interrupt is not masked), the hardware follows a defined sequence to handle the abort. The process varies slightly depending on whether the abort is a prefetch abort or a data abort, but the general steps are as follows:
1. Interrupt Detection
The ARM processor detects an abort exception, which can happen under two primary conditions:
– Prefetch Abort: Occurs when the processor attempts to fetch an instruction at an invalid memory address or encounters an access permission fault.
– Data Abort: Occurs when the processor tries to access an invalid memory location or violates memory access permissions during data access.
2. Mode Change
The processor switches to the appropriate exception mode:
– Prefetch Abort: Switches to Abort mode with the instruction address that caused the abort.
– Data Abort: Switches to Abort mode with the data address causing the issue.
3. Save the Program State
– Current Program Counter (PC): The PC is saved in the Link Register (LR_abt) associated with the Abort mode.
– For a prefetch abort, the PC value points to the next instruction, so correction may be required.
– For a data abort, the PC typically points to the instruction causing the abort.
– CPSR (Current Program Status Register): The CPSR is saved into the Saved Program Status Register (SPSR_abt) of the Abort mode. This allows the processor to restore the previous state after handling the exception.
4. Disable IRQs
Interrupts are disabled by setting the IRQ disable bit in the CPSR to prevent other interrupts from interfering while handling the abort exception.
5. Vector to the Abort Handler
The PC is set to the exception vector address corresponding to the abort type:
– Prefetch Abort Vector: Address `0x0000000C`
– Data Abort Vector: Address `0x00000010`
The processor begins executing the exception handler code located at this address.
6. Exception Handling by Software
The software exception handler will typically:
– Determine the cause of the abort by inspecting relevant system registers (e.g., Fault Status Registers or Fault Address Registers).
– Decide how to handle the fault (e.g., recover from it, terminate the offending process, or reset the system).
7. Returning from the Exception
Once the exception is handled:
– The CPSR is restored from the SPSR_abt.
– The PC is restored to the instruction address saved in the LR_abt (adjusted if necessary).
– Execution resumes, either retrying the aborted instruction or skipping it, depending on the handler’s logic.
Key Hardware Mechanisms
– Vector Table: Provides the entry point for the abort exception handler.
– Abort Mode Registers: Specific registers, including `LR_abt` and `SPSR_abt`, are used to store the state during the exception.
– Fault Status Registers: Provide information about the type and cause of the fault.
This structured response ensures that the ARM processor can isolate the issue, prevent further corruption, and enable software to handle the exception in a controlled manner.
COMMENTS