gem5  v22.1.0.0
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 
38 #include "arch/arm/interrupts.hh"
39 
40 #include "arch/arm/system.hh"
41 
42 namespace gem5
43 {
44 
45 bool
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)
90  mask = INT_MASK_M;
91  else {
92  if (!is_secure && (el == EL0 || el == EL1))
93  mask = INT_MASK_T;
94  else
95  mask = INT_MASK_M;
96  }
97  } else {
98  // SCR IRQ == 1
99  if ((!is_secure) &&
100  (hcr_mask_override_bit ||
101  (!scr_fwaw_bit && !hcr_mask_override_bit)))
102  mask = INT_MASK_T;
103  else
104  mask = INT_MASK_M;
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)
114  mask = INT_MASK_P;
115  else
116  mask = INT_MASK_M;
117  } else {
118  if (el == EL3)
119  mask = INT_MASK_T;
120  else if (is_secure || el == EL2)
121  mask = INT_MASK_M;
122  else
123  mask = INT_MASK_T;
124  }
125  } else {
126  // SCR RW == 1
127  if (!hcr_mask_override_bit) {
128  if (el == EL3 || el == EL2)
129  mask = INT_MASK_P;
130  else
131  mask = INT_MASK_M;
132  } else {
133  if (el == EL3)
134  mask = INT_MASK_P;
135  else if (is_secure || el == EL2)
136  mask = INT_MASK_M;
137  else
138  mask = INT_MASK_T;
139  }
140  }
141  } else {
142  // SCR IRQ == 1
143  if (el == EL3)
144  mask = INT_MASK_M;
145  else
146  mask = INT_MASK_T;
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:184
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:178
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:598
@ MISCREG_CPSR
Definition: misc.hh:65
@ 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....
int64 int_type
Definition: sc_nbdefs.hh:206

Generated on Wed Dec 21 2022 10:22:24 for gem5 by doxygen 1.9.1