gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pl330.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 
30 #include <cctype>
31 
32 #include "params/FastModelPL330.hh"
33 #include "sim/core.hh"
34 
35 namespace FastModel
36 {
37 
38 PL330::PL330(const FastModelPL330Params &params,
40  scx_evs_PL330(_name), clockPeriod(params.clock),
41  dma(amba_m, params.name + ".dma", -1),
42  pioS(amba_s, params.name + ".pio_s", -1),
43  pioNs(amba_s_ns, params.name + ".pio_ns", -1),
44  irqAbortReceiver("irq_abort_receiver")
45 {
46  set_parameter("pl330.fifo_size", params.fifo_size);
47  set_parameter("pl330.max_transfer", params.max_transfer);
48  set_parameter("pl330.generate_clear", params.generate_clear);
49  set_parameter("pl330.activate_delay", params.activate_delay);
50  set_parameter("pl330.revision", params.revision);
51  set_parameter("pl330.p_max_irqs", params.max_irqs);
52  set_parameter("pl330.p_buffer_depth", params.buffer_depth);
53  set_parameter("pl330.p_lsq_read_size", params.lsq_read_size);
54  set_parameter("pl330.p_lsq_write_size", params.lsq_write_size);
55  set_parameter("pl330.p_read_issuing_capability",
56  params.read_issuing_capability);
57  set_parameter("pl330.p_write_issuing_capability",
58  params.write_issuing_capability);
59  set_parameter("pl330.p_axi_bus_width_param", params.axi_bus_width);
60  set_parameter("pl330.p_cache_line_words", params.cache_line_words);
61  set_parameter("pl330.p_cache_lines", params.cache_lines);
62  set_parameter("pl330.p_max_channels", params.max_channels);
63  set_parameter("pl330.p_controller_nsecure", params.controller_nsecure);
64  set_parameter("pl330.p_irq_nsecure", params.irq_nsecure);
65  set_parameter("pl330.p_periph_nsecure", params.periph_nsecure);
66  set_parameter("pl330.p_controller_boots", params.controller_boots);
67  set_parameter("pl330.p_reset_pc", params.reset_pc);
68  set_parameter("pl330.p_max_periph", params.max_periph);
69  set_parameter("pl330.p_perip_request_acceptance_0",
70  params.perip_request_acceptance_0);
71  set_parameter("pl330.p_perip_request_acceptance_1",
72  params.perip_request_acceptance_1);
73  set_parameter("pl330.p_perip_request_acceptance_2",
74  params.perip_request_acceptance_2);
75  set_parameter("pl330.p_perip_request_acceptance_3",
76  params.perip_request_acceptance_3);
77  set_parameter("pl330.p_perip_request_acceptance_4",
78  params.perip_request_acceptance_4);
79  set_parameter("pl330.p_perip_request_acceptance_5",
80  params.perip_request_acceptance_5);
81  set_parameter("pl330.p_perip_request_acceptance_6",
82  params.perip_request_acceptance_6);
83  set_parameter("pl330.p_perip_request_acceptance_7",
84  params.perip_request_acceptance_7);
85  set_parameter("pl330.p_perip_request_acceptance_8",
86  params.perip_request_acceptance_8);
87  set_parameter("pl330.p_perip_request_acceptance_9",
88  params.perip_request_acceptance_9);
89  set_parameter("pl330.p_perip_request_acceptance_10",
90  params.perip_request_acceptance_10);
91  set_parameter("pl330.p_perip_request_acceptance_11",
92  params.perip_request_acceptance_11);
93  set_parameter("pl330.p_perip_request_acceptance_12",
94  params.perip_request_acceptance_12);
95  set_parameter("pl330.p_perip_request_acceptance_13",
96  params.perip_request_acceptance_13);
97  set_parameter("pl330.p_perip_request_acceptance_14",
98  params.perip_request_acceptance_14);
99  set_parameter("pl330.p_perip_request_acceptance_15",
100  params.perip_request_acceptance_15);
101  set_parameter("pl330.p_perip_request_acceptance_16",
102  params.perip_request_acceptance_16);
103  set_parameter("pl330.p_perip_request_acceptance_17",
104  params.perip_request_acceptance_17);
105  set_parameter("pl330.p_perip_request_acceptance_18",
106  params.perip_request_acceptance_18);
107  set_parameter("pl330.p_perip_request_acceptance_19",
108  params.perip_request_acceptance_19);
109  set_parameter("pl330.p_perip_request_acceptance_20",
110  params.perip_request_acceptance_20);
111  set_parameter("pl330.p_perip_request_acceptance_21",
112  params.perip_request_acceptance_21);
113  set_parameter("pl330.p_perip_request_acceptance_22",
114  params.perip_request_acceptance_22);
115  set_parameter("pl330.p_perip_request_acceptance_23",
116  params.perip_request_acceptance_23);
117  set_parameter("pl330.p_perip_request_acceptance_24",
118  params.perip_request_acceptance_24);
119  set_parameter("pl330.p_perip_request_acceptance_25",
120  params.perip_request_acceptance_25);
121  set_parameter("pl330.p_perip_request_acceptance_26",
122  params.perip_request_acceptance_26);
123  set_parameter("pl330.p_perip_request_acceptance_27",
124  params.perip_request_acceptance_27);
125  set_parameter("pl330.p_perip_request_acceptance_28",
126  params.perip_request_acceptance_28);
127  set_parameter("pl330.p_perip_request_acceptance_29",
128  params.perip_request_acceptance_29);
129  set_parameter("pl330.p_perip_request_acceptance_30",
130  params.perip_request_acceptance_30);
131  set_parameter("pl330.p_perip_request_acceptance_31",
132  params.perip_request_acceptance_31);
133 
134  // Plumb up the mechanism which lets us set the clock rate inside the EVS.
135  clockRateControl.bind(this->clock_rate_s);
136 
137  // Allocate all the source pins for each interrupt port.
138  allocateIrq(0, params.port_irq_0_connection_count);
139  allocateIrq(1, params.port_irq_1_connection_count);
140  allocateIrq(2, params.port_irq_2_connection_count);
141  allocateIrq(3, params.port_irq_3_connection_count);
142  allocateIrq(4, params.port_irq_4_connection_count);
143  allocateIrq(5, params.port_irq_5_connection_count);
144  allocateIrq(6, params.port_irq_6_connection_count);
145  allocateIrq(7, params.port_irq_7_connection_count);
146  allocateIrq(8, params.port_irq_8_connection_count);
147  allocateIrq(9, params.port_irq_9_connection_count);
148  allocateIrq(10, params.port_irq_10_connection_count);
149  allocateIrq(11, params.port_irq_11_connection_count);
150  allocateIrq(12, params.port_irq_12_connection_count);
151  allocateIrq(13, params.port_irq_13_connection_count);
152  allocateIrq(14, params.port_irq_14_connection_count);
153  allocateIrq(15, params.port_irq_15_connection_count);
154  allocateIrq(16, params.port_irq_16_connection_count);
155  allocateIrq(17, params.port_irq_17_connection_count);
156  allocateIrq(18, params.port_irq_18_connection_count);
157  allocateIrq(19, params.port_irq_19_connection_count);
158  allocateIrq(20, params.port_irq_20_connection_count);
159  allocateIrq(21, params.port_irq_21_connection_count);
160  allocateIrq(22, params.port_irq_22_connection_count);
161  allocateIrq(23, params.port_irq_23_connection_count);
162  allocateIrq(24, params.port_irq_24_connection_count);
163  allocateIrq(25, params.port_irq_25_connection_count);
164  allocateIrq(26, params.port_irq_26_connection_count);
165  allocateIrq(27, params.port_irq_27_connection_count);
166  allocateIrq(28, params.port_irq_28_connection_count);
167  allocateIrq(29, params.port_irq_29_connection_count);
168  allocateIrq(30, params.port_irq_30_connection_count);
169  allocateIrq(31, params.port_irq_31_connection_count);
170 
171  // Plumb the interrupts from inside the EVS to any external sinks.
172  for (int i = 0; i < 32; i++) {
173  // Create a receiver to receive interrupts from the EVS.
174  irqReceiver.emplace_back(
175  new SignalReceiver(csprintf("irq_receiver[%d]", i)));
176 
177  // Attach the receiver to the socket coming out of the EVS.
178  irq[i].bind(irqReceiver[i]->signal_in);
179 
180  // Set up a handler for when the signal changes state.
181  auto on_change = [&port = irqPort[i]](bool status)
182  {
183  // Loop through all the connections and propogate the signal.
184  for (auto &pin: port)
185  status ? pin->raise() : pin->lower();
186  };
187 
188  // Install the handler.
189  irqReceiver[i]->onChange(on_change);
190  }
191 
192  // Set up the abort IRQ pins.
193  for (int i = 0; i < params.port_irq_abort_connection_count; i++) {
194  irqAbortPort.emplace_back(new IntSourcePin<PL330>(
195  csprintf("%s.irq_abort_master_port[%d]", name(), i),
196  i, this));
197  }
198 
199  // Attach the receiver (already set up) to the EVS.
200  irq_abort.bind(irqAbortReceiver.signal_in);
201 
202  // Set up a handler.
203  auto abort_change = [this](bool status) {
204  for (auto &pin: irqAbortPort)
205  status ? pin->raise() : pin->lower();
206  };
207 
208  // And install it.
209  irqAbortReceiver.onChange(abort_change);
210 }
211 
212 void
214 {
215  for (int i = 0; i < count; i++) {
216  irqPort[idx].emplace_back(new IntSourcePin<PL330>(
217  csprintf("%s.irq_master_port[%d][%d]", name(), idx, i),
218  i, this));
219  }
220 }
221 
222 ::Port &
223 PL330::gem5_getPort(const std::string &if_name, int idx)
224 {
225  if (if_name == "dma") {
226  return dma;
227  } else if (if_name == "pio_s") {
228  return pioS;
229  } else if (if_name == "pio_ns") {
230  return pioNs;
231  } else if (if_name.substr(0, 4) == "irq_") {
232  auto suffix = if_name.substr(4);
233 
234  if (suffix == "abort")
235  return *irqAbortPort.at(idx);
236 
237  // Existing functions like stoull, and to_number which uses it, skip
238  // leading whitespace and ignore non-numeric characters at the end of
239  // the string. We're going to be more picky than that.
240  int port = -1;
241  if (suffix.size() == 1 && isdigit(suffix[0])) {
242  port = suffix[0] - '0';
243  } else if (suffix.size() == 2 && isdigit(suffix[0]) &&
244  isdigit(suffix[1])) {
245  port = (suffix[1] - '0') * 10 + (suffix[0] - '0');
246  }
247  if (port != -1 && port < irqPort.size())
248  return *irqPort[port].at(idx);
249  }
250 
251  return scx_evs_PL330::gem5_getPort(if_name, idx);
252 }
253 
254 void
256 {
257  // Set the clock rate using the divider inside the EVS.
259 }
260 
261 } // namespace FastModel
ArmISA::status
Bitfield< 5, 0 > status
Definition: miscregs_types.hh:417
FastModel::SignalReceiver::signal_in
amba_pv::signal_slave_export< bool > signal_in
Definition: signal_receiver.hh:51
FastModel::PL330::irqAbortReceiver
SignalReceiver irqAbortReceiver
Definition: pl330.hh:68
FastModel::PL330::start_of_simulation
void start_of_simulation() override
Definition: pl330.cc:255
FastModel::PL330::irqAbortPort
std::vector< std::unique_ptr< IntSource > > irqAbortPort
Definition: pl330.hh:67
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
pl330.hh
IntSourcePin
Definition: intpin.hh:109
X86ISA::count
count
Definition: misc.hh:703
FastModel::PL330::PL330
PL330(const FastModelPL330Params &params, sc_core::sc_module_name _name)
Definition: pl330.cc:38
FastModel::PL330::dma
AmbaInitiator dma
Definition: pl330.hh:57
FastModel::PL330::irqPort
std::array< std::vector< std::unique_ptr< IntSource > >, 32 > irqPort
Definition: pl330.hh:64
FastModel::PL330::pioS
AmbaTarget pioS
Definition: pl330.hh:58
FastModel::SignalReceiver
Definition: signal_receiver.hh:41
FastModel::PL330::pioNs
AmbaTarget pioNs
Definition: pl330.hh:58
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
FastModel::PL330::allocateIrq
void allocateIrq(int idx, int count)
Definition: pl330.cc:213
SimClock::Int::s
Tick s
second
Definition: core.cc:59
sc_core::sc_module_name
Definition: sc_module_name.hh:41
FastModel::PL330::clockPeriod
Tick clockPeriod
Definition: pl330.hh:55
core.hh
name
const std::string & name()
Definition: trace.cc:48
FastModel::SignalReceiver::onChange
void onChange(OnChangeFunc func)
Definition: signal_receiver.hh:64
ArmISA::irq
Bitfield< 1 > irq
Definition: miscregs_types.hh:327
FastModel::PL330::clockRateControl
ClockRateControlInitiatorSocket clockRateControl
Definition: pl330.hh:60
FastModel
Definition: amba_from_tlm_bridge.cc:32
tlm::tlm_base_initiator_socket::bind
virtual void bind(base_target_socket_type &s)
Definition: initiator_socket.hh:121
ArmISA::at
Bitfield< 35, 32 > at
Definition: miscregs_types.hh:151
FastModel::PL330::irqReceiver
std::vector< std::unique_ptr< SignalReceiver > > irqReceiver
Definition: pl330.hh:65
FastModel::PL330::gem5_getPort
::Port & gem5_getPort(const std::string &if_name, int idx=-1) override
Definition: pl330.cc:223
csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:158

Generated on Tue Mar 23 2021 19:41:19 for gem5 by doxygen 1.8.17