gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
interrupts.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Authors: Steve Reinhardt
29  * Kevin Lim
30  */
31 
32 #ifndef __ARCH_ALPHA_INTERRUPT_HH__
33 #define __ARCH_ALPHA_INTERRUPT_HH__
34 
35 #include <memory>
36 
37 #include "arch/alpha/faults.hh"
38 #include "arch/alpha/isa_traits.hh"
39 #include "base/compiler.hh"
40 #include "base/trace.hh"
41 #include "cpu/thread_context.hh"
42 #include "debug/Flow.hh"
43 #include "debug/Interrupt.hh"
44 #include "params/AlphaInterrupts.hh"
45 #include "sim/sim_object.hh"
46 
47 namespace AlphaISA {
48 
49 class Interrupts : public SimObject
50 {
51  private:
52  bool newInfoSet;
53  int newIpl;
56 
57  protected:
59  uint64_t intstatus;
60 
61  public:
62  typedef AlphaInterruptsParams Params;
63 
64  const Params *
65  params() const
66  {
67  return dynamic_cast<const Params *>(_params);
68  }
69 
70  Interrupts(Params * p) : SimObject(p), cpu(NULL)
71  {
72  memset(interrupts, 0, sizeof(interrupts));
73  intstatus = 0;
74  newInfoSet = false;
75  }
76 
77  void
78  setCPU(BaseCPU * _cpu)
79  {
80  cpu = _cpu;
81  }
82 
83  void
84  post(int int_num, int index)
85  {
86  DPRINTF(Interrupt, "Interrupt %d:%d posted\n", int_num, index);
87 
88  if (int_num < 0 || int_num >= NumInterruptLevels)
89  panic("int_num out of bounds\n");
90 
91  if (index < 0 || index >= (int)sizeof(uint64_t) * 8)
92  panic("int_num out of bounds\n");
93 
94  interrupts[int_num] |= 1 << index;
95  intstatus |= (ULL(1) << int_num);
96  }
97 
98  void
99  clear(int int_num, int index)
100  {
101  DPRINTF(Interrupt, "Interrupt %d:%d cleared\n", int_num, index);
102 
103  if (int_num < 0 || int_num >= NumInterruptLevels)
104  panic("int_num out of bounds\n");
105 
106  if (index < 0 || index >= (int)sizeof(uint64_t) * 8)
107  panic("int_num out of bounds\n");
108 
109  interrupts[int_num] &= ~(1 << index);
110  if (interrupts[int_num] == 0)
111  intstatus &= ~(ULL(1) << int_num);
112  }
113 
114  void
116  {
117  DPRINTF(Interrupt, "Interrupts all cleared\n");
118 
119  memset(interrupts, 0, sizeof(interrupts));
120  intstatus = 0;
121  }
122 
123  void
125  {
128  }
129 
130  void
132  {
135  }
136 
137  bool
139  {
140  if (intstatus == 0)
141  return false;
142 
143  if (tc->pcState().pc() & 0x3)
144  return false;
145 
147  panic("asynchronous traps not implemented\n");
148 
149  uint64_t ipl = 0;
150  uint64_t summary = 0;
151 
152  if (tc->readMiscRegNoEffect(IPR_SIRR)) {
153  for (uint64_t i = INTLEVEL_SOFTWARE_MIN;
154  i < INTLEVEL_SOFTWARE_MAX; i++) {
155  if (tc->readMiscRegNoEffect(IPR_SIRR) & (ULL(1) << i)) {
156  // See table 4-19 of 21164 hardware reference
157  ipl = (i - INTLEVEL_SOFTWARE_MIN) + 1;
158  summary |= (ULL(1) << i);
159  }
160  }
161  }
162 
163  for (uint64_t i = INTLEVEL_EXTERNAL_MIN; i < INTLEVEL_EXTERNAL_MAX;
164  i++) {
165  if (intstatus & (ULL(1) << i)) {
166  // See table 4-19 of 21164 hardware reference
167  ipl = i;
168  summary |= (ULL(1) << i);
169  }
170  }
171 
172  return ipl && ipl > tc->readMiscRegNoEffect(IPR_IPLR);
173  }
174 
175  Fault
177  {
178  assert(checkInterrupts(tc));
179 
180  uint64_t ipl = 0;
181  uint64_t summary = 0;
182  if (tc->readMiscRegNoEffect(IPR_SIRR)) {
183  for (uint64_t i = INTLEVEL_SOFTWARE_MIN;
184  i < INTLEVEL_SOFTWARE_MAX; i++) {
185  if (tc->readMiscRegNoEffect(IPR_SIRR) & (ULL(1) << i)) {
186  // See table 4-19 of 21164 hardware reference
187  ipl = (i - INTLEVEL_SOFTWARE_MIN) + 1;
188  summary |= (ULL(1) << i);
189  }
190  }
191  }
192 
193  for (uint64_t i = INTLEVEL_EXTERNAL_MIN; i < INTLEVEL_EXTERNAL_MAX;
194  i++) {
195  if (intstatus & (ULL(1) << i)) {
196  // See table 4-19 of 21164 hardware reference
197  ipl = i;
198  summary |= (ULL(1) << i);
199  }
200  }
201 
202  newIpl = ipl;
203  newSummary = summary;
204  newInfoSet = true;
205  DPRINTF(Flow, "Interrupt! IPLR=%d ipl=%d summary=%x\n",
206  tc->readMiscRegNoEffect(IPR_IPLR), ipl, summary);
207 
208  return std::make_shared<InterruptFault>();
209  }
210 
211  void
213  {
214  assert(newInfoSet);
217  newInfoSet = false;
218  }
219 };
220 
221 } // namespace AlphaISA
222 
223 #endif // __ARCH_ALPHA_INTERRUPT_HH__
224 
bool checkInterrupts(ThreadContext *tc) const
Definition: interrupts.hh:138
#define DPRINTF(x,...)
Definition: trace.hh:212
void unserialize(CheckpointIn &cp)
Unserialize an object.
Definition: interrupts.hh:131
Bitfield< 30, 0 > index
Bitfield< 7 > i
Definition: miscregs.hh:1378
#define panic(...)
Definition: misc.hh:153
void updateIntrInfo(ThreadContext *tc)
Definition: interrupts.hh:212
virtual MiscReg readMiscRegNoEffect(int misc_reg) const =0
virtual TheISA::PCState pcState()=0
ThreadContext is the external interface to all thread state for anything outside of the CPU...
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:145
void post(int int_num, int index)
Definition: interrupts.hh:84
#define SERIALIZE_ARRAY(member, size)
Definition: serialize.hh:158
void setCPU(BaseCPU *_cpu)
Definition: interrupts.hh:78
#define ULL(N)
uint64_t constant
Definition: types.hh:50
Fault getInterrupt(ThreadContext *tc)
Definition: interrupts.hh:176
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:143
#define UNSERIALIZE_ARRAY(member, size)
Definition: serialize.hh:161
Interrupts(Params *p)
Definition: interrupts.hh:70
std::ostream CheckpointOut
Definition: serialize.hh:67
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:107
uint64_t interrupts[NumInterruptLevels]
Definition: interrupts.hh:58
void serialize(CheckpointOut &cp) const
Serialize an object.
Definition: interrupts.hh:124
AlphaInterruptsParams Params
Definition: interrupts.hh:62
const Params * params() const
Definition: interrupts.hh:65
Bitfield< 15, 10 > ipl
virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val)=0
Bitfield< 0 > p
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
Abstract superclass for simulation objects.
Definition: sim_object.hh:94
void clear(int int_num, int index)
Definition: interrupts.hh:99

Generated on Fri Jun 9 2017 13:03:34 for gem5 by doxygen 1.8.6