05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The System Level Programmers’ Model<br />

If CPSR.I == 0 <strong>and</strong> SCTLR.FI == 1, IRQ exceptions can be taken. In this case IRQ exception entry<br />

is precise to an instruction boundary, except that some of the effects of the instruction that follows<br />

that boundary might have occurred. These effects are restricted to those that can be repeated<br />

idempotently <strong>and</strong> without breaking the rules in Single-copy atomicity on page A3-27. Examples of<br />

such effects are:<br />

— changing the value of a register that the instruction writes but does not read<br />

— performing an access to Normal memory.<br />

Note<br />

This relaxation of the normal definition of a precise asynchronous exception permits interrupts to<br />

occur during the execution of instructions that change register or memory values, while only<br />

requiring the implementation to restore those register values that are needed to correctly re-execute<br />

the instruction after the preferred exception return. LDM <strong>and</strong> STM are examples of such instructions.<br />

The following pseudocode describes how this exception is taken:<br />

// TakeIRQException()<br />

// ==================<br />

TakeIRQException()<br />

// Determine return information. SPSR is to be the current CPSR, <strong>and</strong> LR is to be the<br />

// current PC minus 0 for Thumb or 4 for <strong>ARM</strong>, to change the PC offsets of 4 or 8<br />

// respectively from the address of the current instruction into the required address<br />

// of the instruction boundary at which the interrupt occurred plus 4. For this<br />

// purpose, the PC <strong>and</strong> CPSR are considered to have already moved on to their values<br />

// for the instruction following that boundary.<br />

new_lr_value = if CPSR.T == ‘1’ then PC else PC-4;<br />

new_spsr_value = CPSR;<br />

// Determine whether IRQs are trapped to Monitor mode.<br />

trap_to_monitor = HaveSecurityExt() && SCR.IRQ == ‘1’;<br />

// Enter IRQ (‘10010’) or Monitor (‘10110’) mode, <strong>and</strong> ensure Secure state if initially<br />

// in Monitor mode. This affects the banked versions of various registers accessed<br />

// later in the code.<br />

if CPSR.M == ‘10110’ then SCR.NS = ‘0’;<br />

CPSR.M = if trap_to_monitor then ‘10110’ else ‘10010’;<br />

// Write return information to registers, <strong>and</strong> make further CPSR changes: IRQs disabled,<br />

// other interrupts disabled if appropriate, IT state reset, instruction set <strong>and</strong><br />

// endianness to SCTLR-configured values.<br />

SPSR[] = new_spsr_value;<br />

R[14] = new_lr_value;<br />

CPSR.I = ‘1’;<br />

if trap_to_monitor then<br />

CPSR.F = ‘1’; CPSR.A = ‘1’;<br />

else<br />

if !HaveSecurityExt() || SCR.NS == ‘0’ || SCR.AW == ‘1’ then CPSR.A = ‘1’;<br />

CPSR.IT = ‘00000000’;<br />

CPSR.J = ‘0’; CPSR.T = SCTLR.TE; // TE=0: <strong>ARM</strong>, TE=1: Thumb<br />

CPSR.E = SCTLR.EE; // EE=0: little-endian, EE=1: big-endian<br />

<strong>ARM</strong> DDI 0406B Copyright © 1996-1998, 2000, 2004-2008 <strong>ARM</strong> Limited. All rights reserved. B1-59

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!