gic_v3.cc (13623:fa728033d933) gic_v3.cc (13756:12aa26df8c2f)
1/*
2 * Copyright (c) 2018 Metempsy Technology Consulting
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;

--- 31 unchanged lines hidden (view full) ---

40#include "mem/packet.hh"
41#include "mem/packet_access.hh"
42
43Gicv3::Gicv3(const Params * p)
44 : BaseGic(p)
45{
46}
47
1/*
2 * Copyright (c) 2018 Metempsy Technology Consulting
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;

--- 31 unchanged lines hidden (view full) ---

40#include "mem/packet.hh"
41#include "mem/packet_access.hh"
42
43Gicv3::Gicv3(const Params * p)
44 : BaseGic(p)
45{
46}
47
48Gicv3::~Gicv3()
49{
50}
51
52void
53Gicv3::init()
54{
55 distRange = RangeSize(params()->dist_addr,
56 Gicv3Distributor::ADDR_RANGE_SIZE - 1);
57 redistRange = RangeSize(params()->redist_addr,
58 Gicv3Redistributor::ADDR_RANGE_SIZE * sys->numContexts() - 1);
59 addrRanges = {distRange, redistRange};

--- 47 unchanged lines hidden (view full) ---

107 Addr daddr = addr - redistRange.start();
108 uint32_t redistributor_id =
109 daddr / Gicv3Redistributor::ADDR_RANGE_SIZE;
110 daddr = daddr % Gicv3Redistributor::ADDR_RANGE_SIZE;
111 panic_if(redistributor_id >= redistributors.size(),
112 "Invalid redistributor_id!");
113 panic_if(!redistributors[redistributor_id], "Redistributor is null!");
114 resp = redistributors[redistributor_id]->read(daddr, size,
48void
49Gicv3::init()
50{
51 distRange = RangeSize(params()->dist_addr,
52 Gicv3Distributor::ADDR_RANGE_SIZE - 1);
53 redistRange = RangeSize(params()->redist_addr,
54 Gicv3Redistributor::ADDR_RANGE_SIZE * sys->numContexts() - 1);
55 addrRanges = {distRange, redistRange};

--- 47 unchanged lines hidden (view full) ---

103 Addr daddr = addr - redistRange.start();
104 uint32_t redistributor_id =
105 daddr / Gicv3Redistributor::ADDR_RANGE_SIZE;
106 daddr = daddr % Gicv3Redistributor::ADDR_RANGE_SIZE;
107 panic_if(redistributor_id >= redistributors.size(),
108 "Invalid redistributor_id!");
109 panic_if(!redistributors[redistributor_id], "Redistributor is null!");
110 resp = redistributors[redistributor_id]->read(daddr, size,
115 is_secure_access);
111 is_secure_access);
116 delay = params()->redist_pio_delay;
117 DPRINTF(GIC, "Gicv3::read(): (redistributor %d) context_id %d "
118 "register %#x size %d is_secure_access %d (value %#x)\n",
119 redistributor_id, pkt->req->contextId(), daddr, size,
120 is_secure_access, resp);
121 } else {
122 panic("Gicv3::read(): unknown address %#x\n", addr);
123 }

--- 50 unchanged lines hidden (view full) ---

174 panic_if(int_id >= Gicv3::INTID_SECURE, "Invalid SPI!");
175 DPRINTF(Interrupt, "Gicv3::sendInt(): received SPI %d\n", int_id);
176 distributor->sendInt(int_id);
177}
178
179void
180Gicv3::clearInt(uint32_t number)
181{
112 delay = params()->redist_pio_delay;
113 DPRINTF(GIC, "Gicv3::read(): (redistributor %d) context_id %d "
114 "register %#x size %d is_secure_access %d (value %#x)\n",
115 redistributor_id, pkt->req->contextId(), daddr, size,
116 is_secure_access, resp);
117 } else {
118 panic("Gicv3::read(): unknown address %#x\n", addr);
119 }

--- 50 unchanged lines hidden (view full) ---

170 panic_if(int_id >= Gicv3::INTID_SECURE, "Invalid SPI!");
171 DPRINTF(Interrupt, "Gicv3::sendInt(): received SPI %d\n", int_id);
172 distributor->sendInt(int_id);
173}
174
175void
176Gicv3::clearInt(uint32_t number)
177{
182 distributor->intDeasserted(number);
178 distributor->deassertSPI(number);
183}
184
185void
186Gicv3::sendPPInt(uint32_t int_id, uint32_t cpu)
187{
188 panic_if(cpu >= redistributors.size(), "Invalid cpuID sending PPI!");
189 panic_if(int_id < Gicv3::SGI_MAX, "Invalid PPI!");
190 panic_if(int_id >= Gicv3::SGI_MAX + Gicv3::PPI_MAX, "Invalid PPI!");

--- 5 unchanged lines hidden (view full) ---

196void
197Gicv3::clearPPInt(uint32_t num, uint32_t cpu)
198{
199}
200
201void
202Gicv3::postInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
203{
179}
180
181void
182Gicv3::sendPPInt(uint32_t int_id, uint32_t cpu)
183{
184 panic_if(cpu >= redistributors.size(), "Invalid cpuID sending PPI!");
185 panic_if(int_id < Gicv3::SGI_MAX, "Invalid PPI!");
186 panic_if(int_id >= Gicv3::SGI_MAX + Gicv3::PPI_MAX, "Invalid PPI!");

--- 5 unchanged lines hidden (view full) ---

192void
193Gicv3::clearPPInt(uint32_t num, uint32_t cpu)
194{
195}
196
197void
198Gicv3::postInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
199{
204 postDelayedInt(cpu, int_type);
200 platform->intrctrl->post(cpu, int_type, 0);
205}
206
207void
208Gicv3::deassertInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
209{
210 platform->intrctrl->clear(cpu, int_type, 0);
211}
212
201}
202
203void
204Gicv3::deassertInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
205{
206 platform->intrctrl->clear(cpu, int_type, 0);
207}
208
213void
214Gicv3::postDelayedInt(uint32_t cpu, ArmISA::InterruptTypes int_type)
215{
216 platform->intrctrl->post(cpu, int_type, 0);
217}
218
219Gicv3Redistributor *
209Gicv3Redistributor *
220Gicv3::getRedistributorByAffinity(uint32_t affinity)
210Gicv3::getRedistributorByAffinity(uint32_t affinity) const
221{
222 for (auto & redistributor : redistributors) {
223 if (redistributor->getAffinity() == affinity) {
224 return redistributor;
225 }
226 }
227
228 return nullptr;
229}
230
231void
232Gicv3::serialize(CheckpointOut & cp) const
233{
234 distributor->serializeSection(cp, "distributor");
235
236 for (uint32_t redistributor_id = 0;
211{
212 for (auto & redistributor : redistributors) {
213 if (redistributor->getAffinity() == affinity) {
214 return redistributor;
215 }
216 }
217
218 return nullptr;
219}
220
221void
222Gicv3::serialize(CheckpointOut & cp) const
223{
224 distributor->serializeSection(cp, "distributor");
225
226 for (uint32_t redistributor_id = 0;
237 redistributor_id < redistributors.size();
238 redistributor_id++)
227 redistributor_id < redistributors.size(); redistributor_id++)
239 redistributors[redistributor_id]->serializeSection(cp,
240 csprintf("redistributors.%i", redistributor_id));
241
242 for (uint32_t cpu_interface_id = 0;
228 redistributors[redistributor_id]->serializeSection(cp,
229 csprintf("redistributors.%i", redistributor_id));
230
231 for (uint32_t cpu_interface_id = 0;
243 cpu_interface_id < cpuInterfaces.size();
244 cpu_interface_id++)
232 cpu_interface_id < cpuInterfaces.size(); cpu_interface_id++)
245 cpuInterfaces[cpu_interface_id]->serializeSection(cp,
246 csprintf("cpuInterface.%i", cpu_interface_id));
247}
248
249void
250Gicv3::unserialize(CheckpointIn & cp)
251{
252 getSystem()->setGIC(this);
253
254 distributor->unserializeSection(cp, "distributor");
255
256 for (uint32_t redistributor_id = 0;
233 cpuInterfaces[cpu_interface_id]->serializeSection(cp,
234 csprintf("cpuInterface.%i", cpu_interface_id));
235}
236
237void
238Gicv3::unserialize(CheckpointIn & cp)
239{
240 getSystem()->setGIC(this);
241
242 distributor->unserializeSection(cp, "distributor");
243
244 for (uint32_t redistributor_id = 0;
257 redistributor_id < redistributors.size();
258 redistributor_id++)
245 redistributor_id < redistributors.size(); redistributor_id++)
259 redistributors[redistributor_id]->unserializeSection(cp,
260 csprintf("redistributors.%i", redistributor_id));
261
262 for (uint32_t cpu_interface_id = 0;
246 redistributors[redistributor_id]->unserializeSection(cp,
247 csprintf("redistributors.%i", redistributor_id));
248
249 for (uint32_t cpu_interface_id = 0;
263 cpu_interface_id < cpuInterfaces.size();
264 cpu_interface_id++)
250 cpu_interface_id < cpuInterfaces.size(); cpu_interface_id++)
265 cpuInterfaces[cpu_interface_id]->unserializeSection(cp,
266 csprintf("cpuInterface.%i", cpu_interface_id));
267}
268
269Gicv3 *
270Gicv3Params::create()
271{
272 return new Gicv3(this);
273}
251 cpuInterfaces[cpu_interface_id]->unserializeSection(cp,
252 csprintf("cpuInterface.%i", cpu_interface_id));
253}
254
255Gicv3 *
256Gicv3Params::create()
257{
258 return new Gicv3(this);
259}