gem5  v22.1.0.0
evs.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
29 
32 #include "base/logging.hh"
33 #include "dev/arm/base_gic.hh"
34 #include "sim/core.hh"
36 
37 namespace gem5
38 {
39 
40 GEM5_DEPRECATED_NAMESPACE(FastModel, fastmodel);
41 namespace fastmodel
42 {
43 
44 template <class Types>
45 void
47 {
48  clockRateControl->set_mul_div(sim_clock::as_int::s, clk_period);
49 }
50 
51 template <class Types>
52 void
54 {
55  periphClockRateControl->set_mul_div(sys_counter_frq, 1);
56 }
57 
58 template <class Types>
59 void
61 {
62  gem5CpuCluster = dynamic_cast<CortexA76Cluster *>(cluster);
63  panic_if(!gem5CpuCluster, "Cluster should be of type CortexA76Cluster");
64 }
65 
66 template <class Types>
67 void
69 {
70  this->rvbaraddr[core]->set_state(0, addr);
71 }
72 
73 template <class Types>
74 void
76 {
77  // Reset all cores.
78  for (auto &poweron_reset : this->poweron_reset) {
79  poweron_reset->signal_out.set_state(0, true);
80  poweron_reset->signal_out.set_state(0, false);
81  }
82  // Reset DSU.
83  this->top_reset.signal_out.set_state(0, true);
84  this->top_reset.signal_out.set_state(0, false);
85  // Reset debug APB.
86  this->dbg_reset.signal_out.set_state(0, true);
87  this->dbg_reset.signal_out.set_state(0, false);
88 }
89 
90 template <class Types>
92  const sc_core::sc_module_name &mod_name, const Params &p) :
93  Base(mod_name),
94  amba(Base::amba, p.name + ".amba", -1),
95  top_reset(p.name + ".top_reset", 0),
96  dbg_reset(p.name + ".dbg_reset", 0),
97  model_reset(p.name + ".model_reset", -1, this),
98  params(p)
99 {
100  for (int i = 0; i < CoreCount; i++) {
101  redist.emplace_back(new TlmGicTarget(this->redistributor[i],
102  csprintf("%s.redistributor[%d]", name(), i), i));
103  cnthpirq.emplace_back(new SignalReceiver(csprintf("cnthpirq[%d]", i)));
104  cnthvirq.emplace_back(new SignalReceiver(csprintf("cnthvirq[%d]", i)));
105  cntpsirq.emplace_back(new SignalReceiver(csprintf("cntpsirq[%d]", i)));
106  cntvirq.emplace_back(new SignalReceiver(csprintf("cntvirq[%d]", i)));
107  commirq.emplace_back(new SignalReceiver(csprintf("commirq[%d]", i)));
108  ctidbgirq.emplace_back(
109  new SignalReceiver(csprintf("ctidbgirq[%d]", i)));
110  pmuirq.emplace_back(new SignalReceiver(csprintf("pmuirq[%d]", i)));
111  vcpumntirq.emplace_back(
112  new SignalReceiver(csprintf("vcpumntirq[%d]", i)));
113  cntpnsirq.emplace_back(
114  new SignalReceiver(csprintf("cntpnsirq[%d]", i)));
115  rvbaraddr.emplace_back(new SignalInitiator<uint64_t>(
116  csprintf("rvbaraddr[%d]", i).c_str()));
117  core_reset.emplace_back(
118  new SignalSender(csprintf("core_reset[%d]", i), 0));
119  poweron_reset.emplace_back(
120  new SignalSender(csprintf("poweron_reset[%d]", i), 0));
121 
122  Base::cnthpirq[i].bind(cnthpirq[i]->signal_in);
123  Base::cnthvirq[i].bind(cnthvirq[i]->signal_in);
124  Base::cntpsirq[i].bind(cntpsirq[i]->signal_in);
125  Base::cntvirq[i].bind(cntvirq[i]->signal_in);
126  Base::commirq[i].bind(commirq[i]->signal_in);
127  Base::ctidbgirq[i].bind(ctidbgirq[i]->signal_in);
128  Base::pmuirq[i].bind(pmuirq[i]->signal_in);
129  Base::vcpumntirq[i].bind(vcpumntirq[i]->signal_in);
130  Base::cntpnsirq[i].bind(cntpnsirq[i]->signal_in);
131  rvbaraddr[i]->bind(Base::rvbaraddr[i]);
132  core_reset[i]->signal_out.bind(Base::core_reset[i]);
133  poweron_reset[i]->signal_out.bind(Base::poweron_reset[i]);
134  }
135 
136  top_reset.signal_out.bind(Base::top_reset);
137  dbg_reset.signal_out.bind(Base::dbg_reset);
138 
139  clockRateControl.bind(this->clock_rate_s);
140  periphClockRateControl.bind(this->periph_clock_rate_s);
141 }
142 
143 template <class Types>
144 void
146 {
147  auto *trans = sc_gem5::packet2payload(pkt);
148  panic_if(Base::amba->transport_dbg(*trans) != trans->get_data_length(),
149  "Didn't send entire functional packet!");
150  trans->release();
151 }
152 
153 template <class Types>
154 void
156 {
157  Base::before_end_of_elaboration();
158 
159  auto set_on_change = [this](
160  SignalReceiver &recv, ArmInterruptPinGen *gen, int num)
161  {
162  auto *pin = gen->get(gem5CpuCluster->getCore(num)->getContext(0));
163  auto handler = [pin](bool status)
164  {
165  status ? pin->raise() : pin->clear();
166  };
167  recv.onChange(handler);
168  };
169 
170  for (int i = 0; i < CoreCount; i++) {
171  set_on_change(*cnthpirq[i], gem5CpuCluster->params().cnthpirq, i);
172  set_on_change(*cnthvirq[i], gem5CpuCluster->params().cnthvirq, i);
173  set_on_change(*cntpsirq[i], gem5CpuCluster->params().cntpsirq, i);
174  set_on_change(*cntvirq[i], gem5CpuCluster->params().cntvirq, i);
175  set_on_change(*commirq[i], gem5CpuCluster->params().commirq, i);
176  set_on_change(*ctidbgirq[i], gem5CpuCluster->params().ctidbgirq, i);
177  set_on_change(*pmuirq[i], gem5CpuCluster->params().pmuirq, i);
178  set_on_change(*vcpumntirq[i], gem5CpuCluster->params().vcpumntirq, i);
179  set_on_change(*cntpnsirq[i], gem5CpuCluster->params().cntpnsirq, i);
180  }
181 }
182 
183 template <class Types>
184 Port &
185 ScxEvsCortexA76<Types>::gem5_getPort(const std::string &if_name, int idx)
186 {
187  if (if_name == "redistributor")
188  return *redist.at(idx);
189  else if (if_name == "core_reset")
190  return *core_reset.at(idx);
191  else if (if_name == "poweron_reset")
192  return *poweron_reset.at(idx);
193  else if (if_name == "amba")
194  return amba;
195  else if (if_name == "top_reset")
196  return top_reset;
197  else if (if_name == "dbg_reset")
198  return dbg_reset;
199  else if (if_name == "model_reset")
200  return model_reset;
201  else
202  return Base::gem5_getPort(if_name, idx);
203 }
204 
209 
210 } // namespace fastmodel
211 } // namespace gem5
Base class for ARM GIC implementations.
This SimObject is instantiated in the python world and serves as an ArmInterruptPin generator.
Definition: base_gic.hh:145
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
Abstract superclass for simulation objects.
Definition: sim_object.hh:148
std::vector< std::unique_ptr< SignalReceiver > > cntvirq
Definition: evs.hh:88
typename Types::Base Base
Definition: evs.hh:66
amba_pv::signal_master_port< T > SignalInitiator
Definition: evs.hh:80
std::vector< std::unique_ptr< SignalReceiver > > cntpnsirq
Definition: evs.hh:93
std::vector< std::unique_ptr< SignalReceiver > > pmuirq
Definition: evs.hh:91
sc_gem5::TlmTargetBaseWrapper< 64, svp_gicv3_comms::gicv3_comms_fw_if, svp_gicv3_comms::gicv3_comms_bw_if, 1, sc_core::SC_ONE_OR_MORE_BOUND > TlmGicTarget
Definition: evs.hh:77
void setResetAddr(int core, Addr addr, bool secure) override
Definition: evs.cc:68
std::vector< std::unique_ptr< SignalInitiator< uint64_t > > > rvbaraddr
Definition: evs.hh:94
static const int CoreCount
Definition: evs.hh:65
void setCluster(SimObject *cluster) override
Definition: evs.cc:60
std::vector< std::unique_ptr< TlmGicTarget > > redist
Definition: evs.hh:83
std::vector< std::unique_ptr< SignalSender > > poweron_reset
Definition: evs.hh:96
std::vector< std::unique_ptr< SignalReceiver > > cnthpirq
Definition: evs.hh:85
std::vector< std::unique_ptr< SignalReceiver > > ctidbgirq
Definition: evs.hh:90
std::vector< std::unique_ptr< SignalSender > > core_reset
Definition: evs.hh:95
std::vector< std::unique_ptr< SignalReceiver > > cnthvirq
Definition: evs.hh:86
void before_end_of_elaboration() override
Definition: evs.cc:155
typename Types::Params Params
Definition: evs.hh:67
ClockRateControlInitiatorSocket clockRateControl
Definition: evs.hh:71
ClockRateControlInitiatorSocket periphClockRateControl
Definition: evs.hh:72
ScxEvsCortexA76(const Params &p)
Definition: evs.hh:109
void setClkPeriod(Tick clk_period) override
Definition: evs.cc:46
void sendFunc(PacketPtr pkt) override
Definition: evs.cc:145
std::vector< std::unique_ptr< SignalReceiver > > cntpsirq
Definition: evs.hh:87
std::vector< std::unique_ptr< SignalReceiver > > vcpumntirq
Definition: evs.hh:92
std::vector< std::unique_ptr< SignalReceiver > > commirq
Definition: evs.hh:89
Port & gem5_getPort(const std::string &if_name, int idx) override
Definition: evs.cc:185
void setSysCounterFrq(uint64_t sys_counter_frq) override
Definition: evs.cc:53
void onChange(OnChangeFunc func)
amba_pv::signal_master_port< bool > signal_out
virtual void bind(base_target_socket_type &s)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
Bitfield< 7 > i
Definition: misc_types.hh:67
Bitfield< 5, 0 > status
Definition: misc_types.hh:429
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
Tick s
second
Definition: core.cc:68
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
uint64_t Tick
Tick count type.
Definition: types.hh:58
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
tlm::tlm_generic_payload * packet2payload(PacketPtr packet)
Convert a gem5 packet to TLM payload by copying all the relevant information to new payload.
Definition: gem5_to_tlm.cc:131
const std::string & name()
Definition: trace.cc:49

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