gem5  v20.1.0.0
base_gic.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, 2017-2018 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 "dev/arm/base_gic.hh"
39 
40 #include "cpu/thread_context.hh"
41 #include "dev/arm/realview.hh"
42 #include "params/ArmInterruptPin.hh"
43 #include "params/ArmPPI.hh"
44 #include "params/ArmSPI.hh"
45 #include "params/BaseGic.hh"
46 
48  : PioDevice(p),
49  platform(p->platform)
50 {
51  RealView *const rv(dynamic_cast<RealView*>(p->platform));
52  // The platform keeps track of the GIC that is hooked up to the
53  // system. Due to quirks in gem5's configuration system, the
54  // platform can't take a GIC as parameter. Instead, we need to
55  // register with the platform when a new GIC is created. If we
56  // can't find a platform, something is seriously wrong.
57  fatal_if(!rv, "GIC model can't register with platform code");
58  rv->setGic(this);
59 }
60 
62 {
63 }
64 
65 void
67 {
69  getSystem()->setGIC(this);
70 }
71 
72 const BaseGic::Params *
74 {
75  return dynamic_cast<const Params *>(_params);
76 }
77 
78 ArmInterruptPinGen::ArmInterruptPinGen(const ArmInterruptPinParams *p)
79  : SimObject(p)
80 {
81 }
82 
83 ArmSPIGen::ArmSPIGen(const ArmSPIParams *p)
84  : ArmInterruptPinGen(p), pin(new ArmSPI(p->platform, p->num))
85 {
86 }
87 
90 {
91  return pin;
92 }
93 
94 ArmPPIGen::ArmPPIGen(const ArmPPIParams *p)
96 {
97 }
98 
101 {
102  panic_if(!tc, "Invalid Thread Context\n");
103  ContextID cid = tc->contextId();
104 
105  auto pin_it = pins.find(cid);
106 
107  if (pin_it != pins.end()) {
108  // PPI Pin Already generated
109  return pin_it->second;
110  } else {
111  // Generate PPI Pin
112  auto p = static_cast<const ArmPPIParams *>(_params);
113  ArmPPI *pin = new ArmPPI(p->platform, tc, p->num);
114 
115  pins.insert({cid, pin});
116 
117  return pin;
118  }
119 }
120 
122  Platform *_platform, ThreadContext *tc, uint32_t int_num)
123  : threadContext(tc), platform(dynamic_cast<RealView*>(_platform)),
124  intNum(int_num), _active(false)
125 {
126  fatal_if(!platform, "Interrupt not connected to a RealView platform");
127 }
128 
129 void
131 {
133  "InterruptLine::setThreadContext called twice\n");
134 
135  threadContext = tc;
136 }
137 
138 ContextID
140 {
141  panic_if(!threadContext, "Per-context interrupt triggered without a " \
142  "call to InterruptLine::setThreadContext.\n");
143  return threadContext->contextId();
144 }
145 
146 void
148 {
150 }
151 
152 void
154 {
156 }
157 
159  Platform *_platform, uint32_t int_num)
160  : ArmInterruptPin(_platform, nullptr, int_num)
161 {
162 }
163 
164 void
166 {
167  _active = true;
169 }
170 
171 void
173 {
174  _active = false;
176 }
177 
179  Platform *_platform, ThreadContext *tc, uint32_t int_num)
180  : ArmInterruptPin(_platform, tc, int_num)
181 {
182 }
183 
184 void
186 {
187  _active = true;
189 }
190 
191 void
193 {
194  _active = false;
196 }
197 
198 ArmSPIGen *
199 ArmSPIParams::create()
200 {
201  return new ArmSPIGen(this);
202 }
203 
204 ArmPPIGen *
205 ArmPPIParams::create()
206 {
207  return new ArmPPIGen(this);
208 }
ArmSPI::raise
void raise() override
Signal an interrupt.
Definition: base_gic.cc:165
BaseGic::Params
BaseGicParams Params
Definition: base_gic.hh:65
ArmSPI::ArmSPI
ArmSPI(Platform *platform, uint32_t int_num)
Definition: base_gic.cc:158
ArmPPIGen
Private Peripheral Interrupt Generator Since PPIs are banked in the GIC, this class is capable of gen...
Definition: base_gic.hh:163
ArmSPI::clear
void clear() override
Clear a signalled interrupt.
Definition: base_gic.cc:172
ArmSPIGen::ArmSPIGen
ArmSPIGen(const ArmSPIParams *p)
Definition: base_gic.cc:83
RealView
Definition: realview.hh:57
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:797
PioDevice::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: io_device.cc:56
ArmPPIGen::pins
std::unordered_map< ContextID, ArmPPI * > pins
Definition: base_gic.hh:170
RealView::setGic
void setGic(BaseGic *_gic)
Give platform a pointer to interrupt controller.
Definition: realview.hh:81
ArmInterruptPin::setThreadContext
void setThreadContext(ThreadContext *tc)
Set the thread context owning this interrupt.
Definition: base_gic.cc:130
ContextID
int ContextID
Globally unique thread context ID.
Definition: types.hh:231
base_gic.hh
ArmPPIGen::get
ArmInterruptPin * get(ThreadContext *tc=nullptr) override
Definition: base_gic.cc:100
ArmInterruptPin::_active
bool _active
True if interrupt pin is active, false otherwise.
Definition: base_gic.hh:230
realview.hh
RealView::gic
BaseGic * gic
Definition: realview.hh:63
ArmInterruptPin::intNum
const uint32_t intNum
Interrupt number to generate.
Definition: base_gic.hh:227
BaseGic::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base_gic.cc:66
ArmSPIGen::get
ArmInterruptPin * get(ThreadContext *tc=nullptr) override
Definition: base_gic.cc:89
ArmSPIGen
Shared Peripheral Interrupt Generator It is capable of generating one interrupt only: it maintains a ...
Definition: base_gic.hh:148
cp
Definition: cprintf.cc:40
PioDevice
This device is the base class which all devices senstive to an address range inherit from.
Definition: io_device.hh:99
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
ArmInterruptPin::targetContext
ContextID targetContext() const
Get the target context ID of this interrupt.
Definition: base_gic.cc:139
ArmInterruptPin::ArmInterruptPin
ArmInterruptPin(Platform *platform, ThreadContext *tc, uint32_t int_num)
Definition: base_gic.cc:121
ArmInterruptPinGen
This SimObject is instantiated in the python world and serves as an ArmInterruptPin generator.
Definition: base_gic.hh:135
ArmPPI::clear
void clear() override
Clear a signalled interrupt.
Definition: base_gic.cc:192
ThreadContext::contextId
virtual ContextID contextId() const =0
ArmInterruptPinGen::ArmInterruptPinGen
ArmInterruptPinGen(const ArmInterruptPinParams *p)
Definition: base_gic.cc:78
Platform
Definition: platform.hh:49
ArmInterruptPin::threadContext
const ThreadContext * threadContext
Pointer to the thread context that owns this interrupt in case it is a thread-/CPU-private interrupt.
Definition: base_gic.hh:221
BaseGic::clearPPInt
virtual void clearPPInt(uint32_t num, uint32_t cpu)=0
ArmInterruptPin::platform
RealView *const platform
Arm platform to use for interrupt generation.
Definition: base_gic.hh:224
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:790
BaseGic::sendInt
virtual void sendInt(uint32_t num)=0
Post an interrupt from a device that is connected to the GIC.
BaseGic::~BaseGic
virtual ~BaseGic()
Definition: base_gic.cc:61
BaseGic::clearInt
virtual void clearInt(uint32_t num)=0
Clear an interrupt from a device that is connected to the GIC.
BaseGic::BaseGic
BaseGic(const Params *p)
Definition: base_gic.cc:47
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:197
SimObject::_params
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
ArmSPIGen::pin
ArmSPI * pin
Definition: base_gic.hh:155
ArmSystem::setGIC
void setGIC(BaseGic *gic)
Sets the pointer to the GIC.
Definition: system.hh:185
ArmInterruptPin
Generic representation of an Arm interrupt pin.
Definition: base_gic.hh:176
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
BaseGic::getSystem
ArmSystem * getSystem() const
Definition: base_gic.hh:104
BaseGic::params
const Params * params() const
Definition: base_gic.cc:73
ArmPPI::raise
void raise() override
Signal an interrupt.
Definition: base_gic.cc:185
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
BaseGic::sendPPInt
virtual void sendPPInt(uint32_t num, uint32_t cpu)=0
Interface call for private peripheral interrupts.
fatal_if
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:219
ArmPPIGen::ArmPPIGen
ArmPPIGen(const ArmPPIParams *p)
Definition: base_gic.cc:94
CheckpointIn
Definition: serialize.hh:67
ArmInterruptPin::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: base_gic.cc:147
ArmSPI
Definition: base_gic.hh:233
ArmPPI
Definition: base_gic.hh:244
ArmInterruptPin::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: base_gic.cc:153
ArmPPI::ArmPPI
ArmPPI(Platform *platform, ThreadContext *tc, uint32_t int_num)
Definition: base_gic.cc:178
thread_context.hh
SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:92

Generated on Wed Sep 30 2020 14:02:10 for gem5 by doxygen 1.8.17