gem5 v23.0.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
interrupts.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009, 2012-2013, 2016, 2019 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
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met: redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer;
18 * redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution;
21 * neither the name of the copyright holders nor the names of its
22 * contributors may be used to endorse or promote products derived from
23 * this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
39
40#include "arch/arm/system.hh"
41
42namespace gem5
43{
44
45bool
47{
48 // Table G1-17~19 of ARM V8 ARM
50 bool highest_el_is_64 = ArmSystem::highestELIs64(tc);
51
52 CPSR cpsr = tc->readMiscReg(MISCREG_CPSR);
53 SCR scr = tc->readMiscReg(MISCREG_SCR_EL3);;
54 HCR hcr = tc->readMiscReg(MISCREG_HCR_EL2);
56 bool cpsr_mask_bit, scr_routing_bit, scr_fwaw_bit, hcr_mask_override_bit;
57 bool is_secure = isSecure(tc);
58
59 switch(int_type) {
60 case INT_FIQ:
61 cpsr_mask_bit = cpsr.f;
62 scr_routing_bit = scr.fiq;
63 scr_fwaw_bit = scr.fw;
64 hcr_mask_override_bit = hcr.fmo;
65 break;
66 case INT_IRQ:
67 cpsr_mask_bit = cpsr.i;
68 scr_routing_bit = scr.irq;
69 scr_fwaw_bit = 1;
70 hcr_mask_override_bit = hcr.imo;
71 break;
72 case INT_ABT:
73 cpsr_mask_bit = cpsr.a;
74 scr_routing_bit = scr.ea;
75 scr_fwaw_bit = scr.aw;
76 hcr_mask_override_bit = hcr.amo;
77 break;
78 default:
79 panic("Unhandled interrupt type!");
80 }
81
82 if (hcr.tge)
83 hcr_mask_override_bit = 1;
84
85 if (!highest_el_is_64) {
86 // AArch32
87 if (!scr_routing_bit) {
88 // SCR IRQ == 0
89 if (!hcr_mask_override_bit)
91 else {
92 if (!is_secure && (el == EL0 || el == EL1))
94 else
96 }
97 } else {
98 // SCR IRQ == 1
99 if ((!is_secure) &&
100 (hcr_mask_override_bit ||
101 (!scr_fwaw_bit && !hcr_mask_override_bit)))
103 else
105 }
106 } else {
107 // AArch64
108 if (!scr_routing_bit) {
109 // SCR IRQ == 0
110 if (!scr.rw) {
111 // SCR RW == 0
112 if (!hcr_mask_override_bit) {
113 if (el == EL3)
115 else
117 } else {
118 if (el == EL3)
120 else if (is_secure || el == EL2)
122 else
124 }
125 } else {
126 // SCR RW == 1
127 if (!hcr_mask_override_bit) {
128 if (el == EL3 || el == EL2)
130 else
132 } else {
133 if (el == EL3)
135 else if (is_secure || el == EL2)
137 else
139 }
140 }
141 } else {
142 // SCR IRQ == 1
143 if (el == EL3)
145 else
147 }
148 }
149
150 return ((mask == INT_MASK_T) ||
151 ((mask == INT_MASK_M) && !cpsr_mask_bit)) &&
152 (mask != INT_MASK_P);
153}
154
155} // namespace gem5
bool takeInt(InterruptTypes int_type) const
Definition interrupts.cc:46
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8)
Definition system.hh:187
ThreadContext * tc
Definition interrupts.hh:44
virtual RegVal readMiscReg(RegIndex misc_reg)=0
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
ExceptionLevel currEL(const ThreadContext *tc)
Returns the current Exception Level (EL) of the provided ThreadContext.
Definition utility.cc:124
bool isSecure(ThreadContext *tc)
Definition utility.cc:74
@ MISCREG_SCR_EL3
Definition misc.hh:599
@ MISCREG_CPSR
Definition misc.hh:66
@ MISCREG_HCR_EL2
Definition misc.hh:591
Bitfield< 3, 2 > el
Definition misc_types.hh:73
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....

Generated on Mon Jul 10 2023 15:31:58 for gem5 by doxygen 1.9.7