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

Generated on Tue Sep 21 2021 12:24:29 for gem5 by doxygen 1.8.17