gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
upstream.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 REDS institute of the HEIG-VD
3 * All rights reserved
4 *
5 * Copyright (c) 2015 ARM Limited
6 * All rights reserved
7 *
8 * The license below extends only to copyright in the software and shall
9 * not be construed as granting a license to any other intellectual
10 * property including but not limited to intellectual property relating
11 * to a hardware implementation of the functionality of the software
12 * licensed hereunder. You may use the software subject to the license
13 * terms below provided that you ensure that this notice is replicated
14 * unmodified and in its entirety in all distributions of the software,
15 * modified or unmodified, in source code or in binary form.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef __DEV_PCI_UPSTREAM_HH__
42#define __DEV_PCI_UPSTREAM_HH__
43
44#include <map>
45
46#include "base/addr_range.hh"
47#include "dev/isa_fake.hh"
48#include "dev/pci/types.hh"
50#include "params/PciConfigError.hh"
51#include "params/PciUpstream.hh"
52#include "sim/clocked_object.hh"
53
54namespace gem5
55{
56
57class PciDevice;
58
59class PciConfigError : public IsaFake
60{
61 public:
63
64 PciConfigError(const Params &p);
65
66 void setAddrRange(AddrRange range);
67};
68
92{
93 public:
95
96 PciUpstream(const Params &p);
97
98 void init() override;
99
104
112 {
113 friend class gem5::PciUpstream;
114
115 protected:
124 PciIntPin pin);
125
126 public:
127 DeviceInterface() = delete;
128 void operator=(const DeviceInterface &) = delete;
129
130 const std::string name() const;
131
135 void postInt();
136
140 void clearInt();
141
150 {
151 return upstream.interfaceConfigRange(devAddr);
152 }
153
161 Addr
163 {
164 return upstream.interfacePioAddr(devAddr, addr);
165 }
166
174 Addr
176 {
177 return upstream.interfaceMemAddr(devAddr, addr);
178 }
179
187 Addr
189 {
190 return upstream.interfaceDmaAddr(devAddr, addr);
191 }
192
193 protected:
195
198 };
199
209 PciDevAddr dev_addr, PciIntPin pin);
210
212
217 void sendBusChange();
218
219 protected:
225 virtual AddrRange getConfigAddrRange() const = 0;
226
231
238 virtual void interfacePostInt(const PciDevAddr &dev_addr,
239 PciIntPin pin) = 0;
240
247 virtual void interfaceClearInt(const PciDevAddr &dev_addr,
248 PciIntPin pin) = 0;
249
258 virtual AddrRange
259 interfaceConfigRange(const PciDevAddr &dev_addr) const = 0;
260
269 virtual Addr interfacePioAddr(const PciDevAddr &dev_addr,
270 Addr pci_addr) const = 0;
271
280 virtual Addr interfaceMemAddr(const PciDevAddr &dev_addr,
281 Addr pci_addr) const = 0;
282
291 virtual Addr interfaceDmaAddr(const PciDevAddr &dev_addr,
292 Addr pci_addr) const = 0;
293
295
299 virtual PciBusNum getBusNum() const = 0;
300
301 protected:
309
316 const PciDevice *getDevice(const PciDevAddr &addr) const;
317
318 private:
320 std::map<PciDevAddr, PciDevice *> devices;
321
324
326};
327
328} // namespace gem5
329
330#endif // __DEV_PCI_UPSTREAM_HH__
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
ClockedObject(const ClockedObjectParams &p)
ClockedObjectParams Params
Parameters of ClockedObject.
IsaFake(const Params &p)
The constructor for Isa Fake just registers itself with the MMU.
Definition isa_fake.cc:44
PciConfigError(const Params &p)
Definition upstream.cc:52
void setAddrRange(AddrRange range)
Definition upstream.cc:56
PARAMS(PciConfigError)
Base class to represent a PCI device.
Definition device.hh:297
This bridge lets packets pass from upstream to downstream of a PCI bridge.
Callback interface from PCI devices to the upstream.
Definition upstream.hh:112
Addr memAddr(Addr addr) const
Calculate the physical address of a non-prefetchable memory location in the PCI address space.
Definition upstream.hh:175
void clearInt()
Clear a posted PCI interrupt.
Definition upstream.cc:134
DeviceInterface(PciUpstream &upstream, const PciDevAddr &dev_addr, PciIntPin pin)
Instantiate a device interface.
Definition upstream.cc:112
void postInt()
Post a PCI interrupt to the CPU.
Definition upstream.cc:126
void operator=(const DeviceInterface &)=delete
Addr dmaAddr(Addr addr) const
Calculate the physical address of a prefetchable memory location in the PCI address space.
Definition upstream.hh:188
AddrRange configRange() const
Calculate the physical address range of the PCI device configuration space.
Definition upstream.hh:149
Addr pioAddr(Addr addr) const
Calculate the physical address of an IO location on the PCI bus.
Definition upstream.hh:162
const std::string name() const
Definition upstream.cc:119
The PCI upstream describes any device (PCI host bridge, PCI-PCI bridge) that are connected upstream o...
Definition upstream.hh:92
PARAMS(PciUpstream)
void sendBusChange()
Inform each PCI devices connected to this upstream of a bus number change.
Definition upstream.cc:142
virtual PciBusNum getBusNum() const =0
Get the PCI bus number assign to that upstream.
virtual void interfaceClearInt(const PciDevAddr &dev_addr, PciIntPin pin)=0
Post an interrupt to the CPU.
PciUpstream(const Params &p)
Definition upstream.cc:69
PciUpDownBridge * upToDown
The two one way bridges to connect both side buses.
Definition upstream.hh:323
virtual Addr interfaceDmaAddr(const PciDevAddr &dev_addr, Addr pci_addr) const =0
Calculate the physical address of a prefetchable memory location in the PCI address space.
virtual Addr interfaceMemAddr(const PciDevAddr &dev_addr, Addr pci_addr) const =0
Calculate the physical address of a non-prefetchable memory location in the PCI address space.
PciDevice * getDevice(const PciDevAddr &addr)
Retrieve a PCI device from its bus address.
Definition upstream.cc:99
virtual void interfacePostInt(const PciDevAddr &dev_addr, PciIntPin pin)=0
Post an interrupt to the CPU.
virtual DeviceInterface registerDevice(PciDevice *device, PciDevAddr dev_addr, PciIntPin pin)
Register a PCI device with the host.
Definition upstream.cc:84
std::map< PciDevAddr, PciDevice * > devices
Currently registered PCI interfaces.
Definition upstream.hh:320
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition upstream.cc:76
virtual AddrRange getConfigAddrRange() const =0
Get the range for the configuration memory space for which this PCI upstream is responsible.
PciConfigError * configErrorDevice
Definition upstream.hh:325
virtual Addr interfacePioAddr(const PciDevAddr &dev_addr, Addr pci_addr) const =0
Calculate the physical address of an IO location on the PCI bus.
virtual AddrRange interfaceConfigRange(const PciDevAddr &dev_addr) const =0
Calculate the physical address range of the PCI device configuration space.
PioDeviceParams Params
Definition io_device.hh:134
ClockedObject declaration and implementation.
Declaration of a fake device.
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
PciIntPin
Definition types.hh:74
uint8_t PciBusNum
Definition types.hh:46
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147

Generated on Mon Oct 27 2025 04:13:02 for gem5 by doxygen 1.14.0