Hardware vectors, like their software counterparts (Software Vectors), contain an address of a routine that will be called in specific situations. Hardware vectors are called when a privileged mode is entered or when a hardware error occurs. These conditions are known as exceptions.
Each vector will usually hold an address of a routine that will deal with the exception. Each vector has a different priority which is used to determine the order in which exceptions should be handled (if there are simultaneous exceptions).
The ARM processor handles exceptions by:
The following table list each of the different hardware vectors.
Offset | Name |
---|---|
&00 | Reset |
&04 | Undefined instruction |
&08 | SWI |
&0C | Prefetch abort |
&10 | Data abort |
&14 | Address Exception |
&18 | IRQ |
&1C | FIQ |
The offset given in the table above is relative to the vector base address. Under RISC OS this will either be &0 or &FFFF0000, as indicated by the flag returned in bit 20 of OS_PlatformFeatures 0.
This vector is used to specify that the computer is reset. The ARM processor can be reset by pulling its RESET pin HIGH. When RESET goes LOW again, the following will occur:
This vector is called when the ARM processor attempts to execute an instruction that is unknown. If a co-processor (software of hardware) is present on the system such as a floating point emulator, the ARM will pass it onto it (when the co-processor is ready). Any instruction still unknown is passed on, and this vector is called.
The ARM processor will:
This vector is called when a SWI instruction is issued. It contains an address of the routine used by RISC OS to decode the SWI number. Due to the importance of this vector it is strongly recommended not to replace it.
The ARM processor will:
This vector is called when an illegal attempt to prefetch an instruction has been detected. The cause of this could be:
The ARM processor will:
This vector is called when an illegal attempt to fetch data has been detected. The cause of this could be:
The ARM processor will:
This vector is deprecated on 32-bit ARM processors, and no longer of any use.
This vector is called when an interrupt request is received by the ARM processor.
The ARM processor will:
The FIQ vector is called when a Fast Interrupt Request is received by the ARM processor. The FIQ vector is entered in FIQ mode.
The ARM processor will:
Each vector has a different priority which is used to determine the order in which exceptions should be handled (if there are simultaneous exceptions). We list the hardware vectors in order of priority.
Vector | Priority |
---|---|
Reset | 1 (highest priority) |
Data abort, Address exception | 2 |
FIQ | 3 |
IRQ | 4 |
Prefetch abort | 5 |
Undefined instruction, SWI | 6 (lowest priority) |
The original ARM processor could only access 26-bit addresses, but with the introduction of the ARM v3 architecture, full 32-bit addressing was made possible. The ARM processor included backwards compatibility by supporting both 26-bit and 32-bit processor modes.
On these new CPUs the processor vectors are typically entered in 32-bit CPU modes rather than 26-bit. In order to provide compatibility with existing software, 26-bit versions of RISC OS install a set of pre-veneers on the hardware vectors which switch to the relevant 26-bit CPU mode before calling the vector handler. The only exception is the FIQ vector, which cannot support a pre-veneer due to the way the FIQ claim/release mechanism works under RISC OS.
Under RISC OS 5 all software is expected to be running in 32-bit mode, and so pre-veneers are no longer required.
To claim a vector, you use OS_ClaimProcessorVector. You pass it the address of the replacement handler routine, which is installed on the vector. The address of the previous routine will be returned to you, so that your handler routine can use it to pass on a call if necessary. On older versions of RISC OS (pre-RISC OS 3.5) it is necessary to patch the processor vectors directly. If your code needs to pass on to the previous claimant then care will be needed to make sure you decode the old handler instruction correctly (typically it will either be a branch instruction or a PC-relative LDR of the PC)
Note that the FIQ vector cannot be claimed using OS_ClaimProcessorVector. Instead, Service_ClaimFIQ or Service_ClaimFIQinBackground must be used, on all versions of RISC OS.