Browse over 10,000 Electronics Projects

The ARM1 processor’s flags, reverse engineered

The ARM1 processor’s flags, reverse engineered

The mode and interrupt flags

This section discusses the M0 and M1 (processor mode) flags and the I and F (interrupt) flags.
The behavior of these flags is different in several ways from the condition code flags, and their circuitry is significantly different.

The four modes of the ARM1 are:

M1 M0 Mode
0 0 User
0 1 Fast Interrupt (FIRQ)
1 0 Interrupt (IRQ)
1 1 Supervisor (SVC)

 

When an exception trap occurs, the trap logic directs the flag circuitry to switch the mode. An interrupt switches to Interrupt mode, a fast interrupt switches to Fast Interrupt mode, and any other exception (reset, undefined instruction, memory abort, etc) switches to Supervisor mode. The trap logic indicates the new mode through the signals psrbank1 and psrbank0:

 

Exception psrbank1 psrbank0
Fast Interrupt 0 1
Interrupt 1 0
Reset 1 1
Other 0 0

 

Note that the psrbank values don’t exactly match the M0/M1 values.
The psrbank values pass through a few gates in the mode control logic to generate newM1 and newM0 which are stored into the flags.

As the schematic shows, control signal oldstatus causes the flags to keep their old value, while newstatus loads the new value when a fault occurs.
The newstatus signal is generated from instruction decode signal pla2_banken, which is activated during a SWI (software interrupt) instruction, coprocessor instruction (causing an undefined instruction fault), or an interrupt. It is blocked by the abort signal. Otherwise oldstatus is activated. Both signals can only be active during clock phase Φ1.



Advertisement1


Schematic of the status flags in the ARM1 processor: Mode 0 and 1, Interrupt, and Fast interrupt.

Schematic of the status flags in the ARM1 processor: Mode 0 and 1, Interrupt, and Fast interrupt.

The other multiplexer signals are psr_t0, which loads the flags from the ALU bus, and psr_t1, which uses the value from the previous multiplexer.
Both signals can be active only during clock phase Φ2, so the two multiplexers alternate.
The psr_t0 signal is the same as writeflags used by the condition flags, except it is blocked if the mode flags indicate user mode.
This is how the ARM1 prevents the mode and status flags from being updated in User mode (which is necessary for security). The psr_t1 signal is the opposite of psr_t0 (not exactly inverted since both are low during Φ1).

Moving on to the interrupt flags, any fault causes the I flag to be set (preventing an interrupt while the fault is being handled).
This is accomplished by the 1 input to the I register multiplexer.
The F flag is set (blocking fast interrupts) on reset and when a fast interrupt occurs. The schematic shows that F will be set if psrbank0 is high, and keeps its old value otherwise (via the OR gate). Since psrbank0 is high for fast interrupts and reset, the desired behavior is obtained.

Pages: 1 2 3 4 5 6 7 8 9 10 11

 


Top