1/*
2 * Copyright (c) 2010, 2012-2013 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 135 unchanged lines hidden (view full) ---

144 SCR scr = tc->readMiscReg(MISCREG_SCR);
145
146 bool isHypMode = cpsr.mode == MODE_HYP;
147 bool isSecure = inSecureState(scr, cpsr);
148 bool allowVIrq = !cpsr.i && hcr.imo && !isSecure && !isHypMode;
149 bool allowVFiq = !cpsr.f && hcr.fmo && !isSecure && !isHypMode;
150 bool allowVAbort = !cpsr.a && hcr.amo && !isSecure && !isHypMode;
151
152 if ( !(intStatus || (hcr.vi && allowVIrq) || (hcr.vf && allowVFiq) ||
153 (hcr.va && allowVAbort)) )
154 return false;
155
156 bool take_irq = takeInt(tc, INT_IRQ);
157 bool take_fiq = takeInt(tc, INT_FIQ);
158 bool take_ea = takeInt(tc, INT_ABT);
159
160 return ((interrupts[INT_IRQ] && take_irq) ||
161 (interrupts[INT_FIQ] && take_fiq) ||
162 (interrupts[INT_ABT] && take_ea) ||
163 ((interrupts[INT_VIRT_IRQ] || hcr.vi) && allowVIrq) ||

--- 56 unchanged lines hidden (view full) ---

220 panic("Interrupt number out of range.\n");
221
222 return interrupts[interrupt];
223 }
224
225 Fault
226 getInterrupt(ThreadContext *tc)
227 {
228 assert(checkInterrupts(tc));
229
230 HCR hcr = tc->readMiscReg(MISCREG_HCR);
231 CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
232 SCR scr = tc->readMiscReg(MISCREG_SCR);
233
234 // Calculate a few temp vars so we can work out if there's a pending
235 // virtual interrupt, and if its allowed to happen
236 // ARM ARM Issue C section B1.9.9, B1.9.11, and B1.9.13
237 bool isHypMode = cpsr.mode == MODE_HYP;
238 bool isSecure = inSecureState(scr, cpsr);
239 bool allowVIrq = !cpsr.i && hcr.imo && !isSecure && !isHypMode;
240 bool allowVFiq = !cpsr.f && hcr.fmo && !isSecure && !isHypMode;
241 bool allowVAbort = !cpsr.a && hcr.amo && !isSecure && !isHypMode;
242
237 if ( !(intStatus || (hcr.vi && allowVIrq) || (hcr.vf && allowVFiq) ||
238 (hcr.va && allowVAbort)) )
239 return NoFault;
240
243 bool take_irq = takeInt(tc, INT_IRQ);
244 bool take_fiq = takeInt(tc, INT_FIQ);
245 bool take_ea = takeInt(tc, INT_ABT);
246
245
247 if (interrupts[INT_IRQ] && take_irq)
248 return std::make_shared<Interrupt>();
249 if ((interrupts[INT_VIRT_IRQ] || hcr.vi) && allowVIrq)
250 return std::make_shared<VirtualInterrupt>();
251 if (interrupts[INT_FIQ] && take_fiq)
252 return std::make_shared<FastInterrupt>();
253 if ((interrupts[INT_VIRT_FIQ] || hcr.vf) && allowVFiq)
254 return std::make_shared<VirtualFastInterrupt>();

--- 37 unchanged lines hidden ---