gem5  v20.1.0.0
host.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __DEV_PCI_HOST_HH__
39 #define __DEV_PCI_HOST_HH__
40 
41 #include "dev/io_device.hh"
42 #include "dev/pci/types.hh"
43 
44 struct PciHostParams;
45 struct GenericPciHostParams;
46 
47 class PciDevice;
48 class Platform;
49 
72 class PciHost : public PioDevice
73 {
74  public:
75  PciHost(const PciHostParams *p);
76  virtual ~PciHost();
77 
78  public:
92  {
93  friend class ::PciHost;
94 
95  protected:
103  DeviceInterface(PciHost &host, PciBusAddr &bus_addr, PciIntPin pin);
104 
105  public:
106  DeviceInterface() = delete;
107  void operator=(const DeviceInterface &) = delete;
108 
109  const std::string name() const;
110 
114  void postInt();
115 
119  void clearInt();
120 
128  Addr pioAddr(Addr addr) const { return host.pioAddr(busAddr, addr); }
129 
137  Addr memAddr(Addr addr) const { return host.memAddr(busAddr, addr); }
138 
146  Addr dmaAddr(Addr addr) const { return host.dmaAddr(busAddr, addr); }
147 
148  protected:
150 
153  };
154 
163  virtual DeviceInterface registerDevice(PciDevice *device,
164  PciBusAddr bus_addr, PciIntPin pin);
165 
168  protected:
180  virtual void postInt(const PciBusAddr &bus_addr, PciIntPin pin) = 0;
181 
188  virtual void clearInt(const PciBusAddr &bus_addr, PciIntPin pin) = 0;
189 
198  virtual Addr pioAddr(const PciBusAddr &bus_addr, Addr pci_addr) const = 0;
199 
208  virtual Addr memAddr(const PciBusAddr &bus_addr, Addr pci_addr) const = 0;
209 
210 
219  virtual Addr dmaAddr(const PciBusAddr &bus_addr, Addr pci_addr) const = 0;
220 
223  protected:
231 
238  const PciDevice *getDevice(const PciBusAddr &addr) const;
239 
240  private:
242  std::map<PciBusAddr, PciDevice *> devices;
243 };
244 
273 class GenericPciHost : public PciHost
274 {
275  public:
276  GenericPciHost(const GenericPciHostParams *p);
277  virtual ~GenericPciHost();
278 
279  public: // PioDevice
280  Tick read(PacketPtr pkt) override;
281  Tick write(PacketPtr pkt) override;
282 
283  AddrRangeList getAddrRanges() const override;
284 
285  protected: // PciHost
286  Addr pioAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override {
287  return pciPioBase + pci_addr;
288  }
289 
290  Addr memAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override {
291  return pciMemBase + pci_addr;
292  }
293 
294  Addr dmaAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override {
295  return pciDmaBase + pci_addr;
296  }
297 
298  protected: // Configuration address space handling
308 
309  protected: // Interrupt handling
310  void postInt(const PciBusAddr &addr, PciIntPin pin) override;
311  void clearInt(const PciBusAddr &addr, PciIntPin pin) override;
312 
313  virtual uint32_t mapPciInterrupt(const PciBusAddr &bus_addr,
314  PciIntPin pin) const;
315 
316  protected:
318 
319  const Addr confBase;
320  const Addr confSize;
321  const uint8_t confDeviceBits;
322 
326 };
327 
328 #endif // __DEV_PCI_HOST_HH__
GenericPciHost::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: host.cc:134
GenericPciHost::GenericPciHost
GenericPciHost(const GenericPciHostParams *p)
Definition: host.cc:118
GenericPciHost::postInt
void postInt(const PciBusAddr &addr, PciIntPin pin) override
Post an interrupt to the CPU.
Definition: host.cc:199
PciIntPin
PciIntPin
Definition: types.hh:63
PciHost::getDevice
PciDevice * getDevice(const PciBusAddr &addr)
Retrieve a PCI device from its bus address.
Definition: host.cc:73
io_device.hh
PciHost::DeviceInterface::operator=
void operator=(const DeviceInterface &)=delete
PciHost::DeviceInterface::postInt
void postInt()
Post a PCI interrupt to the CPU.
Definition: host.cc:102
PciHost::clearInt
virtual void clearInt(const PciBusAddr &bus_addr, PciIntPin pin)=0
Post an interrupt to the CPU.
types.hh
PciHost::DeviceInterface::host
PciHost & host
Definition: host.hh:149
PciHost::DeviceInterface
Callback interface from PCI devices to the host.
Definition: host.hh:91
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
PciHost::DeviceInterface::busAddr
const PciBusAddr busAddr
Definition: host.hh:151
GenericPciHost::getAddrRanges
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: host.cc:179
GenericPciHost::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: host.cc:158
GenericPciHost::pciPioBase
const Addr pciPioBase
Definition: host.hh:323
GenericPciHost::clearInt
void clearInt(const PciBusAddr &addr, PciIntPin pin) override
Post an interrupt to the CPU.
Definition: host.cc:205
PciHost::devices
std::map< PciBusAddr, PciDevice * > devices
Currently registered PCI devices.
Definition: host.hh:242
GenericPciHost::confBase
const Addr confBase
Definition: host.hh:319
PioDevice
This device is the base class which all devices senstive to an address range inherit from.
Definition: io_device.hh:99
PciHost::DeviceInterface::clearInt
void clearInt()
Clear a posted PCI interrupt.
Definition: host.cc:110
PciBusAddr
Definition: types.hh:41
PciHost::DeviceInterface::memAddr
Addr memAddr(Addr addr) const
Calculate the physical address of a non-prefetchable memory location in the PCI address space.
Definition: host.hh:137
PciHost::PciHost
PciHost(const PciHostParams *p)
Definition: host.cc:48
PciHost::DeviceInterface::pioAddr
Addr pioAddr(Addr addr) const
Calculate the physical address of an IO location on the PCI bus.
Definition: host.hh:128
GenericPciHost
Configurable generic PCI host interface.
Definition: host.hh:273
GenericPciHost::pciMemBase
const Addr pciMemBase
Definition: host.hh:324
PciHost::DeviceInterface::name
const std::string name() const
Definition: host.cc:95
GenericPciHost::pioAddr
Addr pioAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override
Calculate the physical address of an IO location on the PCI bus.
Definition: host.hh:286
Platform
Definition: platform.hh:49
std::pair
STL pair class.
Definition: stl.hh:58
GenericPciHost::confSize
const Addr confSize
Definition: host.hh:320
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
PciHost::dmaAddr
virtual Addr dmaAddr(const PciBusAddr &bus_addr, Addr pci_addr) const =0
Calculate the physical address of a prefetchable memory location in the PCI address space.
PciHost::registerDevice
virtual DeviceInterface registerDevice(PciDevice *device, PciBusAddr bus_addr, PciIntPin pin)
Register a PCI device with the host.
Definition: host.cc:58
GenericPciHost::pciDmaBase
const Addr pciDmaBase
Definition: host.hh:325
PciHost::~PciHost
virtual ~PciHost()
Definition: host.cc:53
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
GenericPciHost::~GenericPciHost
virtual ~GenericPciHost()
Definition: host.cc:128
GenericPciHost::platform
Platform & platform
Definition: host.hh:317
addr
ip6_addr_t addr
Definition: inet.hh:423
PciHost::DeviceInterface::DeviceInterface
DeviceInterface()=delete
PciHost::pioAddr
virtual Addr pioAddr(const PciBusAddr &bus_addr, Addr pci_addr) const =0
Calculate the physical address of an IO location on the PCI bus.
PciHost::postInt
virtual void postInt(const PciBusAddr &bus_addr, PciIntPin pin)=0
Post an interrupt to the CPU.
GenericPciHost::confDeviceBits
const uint8_t confDeviceBits
Definition: host.hh:321
GenericPciHost::decodeAddress
virtual std::pair< PciBusAddr, Addr > decodeAddress(Addr address)
Decode a configuration space address.
Definition: host.cc:185
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< AddrRange >
PciHost::memAddr
virtual Addr memAddr(const PciBusAddr &bus_addr, Addr pci_addr) const =0
Calculate the physical address of a non-prefetchable memory location in the PCI address space.
PciHost
The PCI host describes the interface between PCI devices and a simulated system.
Definition: host.hh:72
GenericPciHost::dmaAddr
Addr dmaAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override
Calculate the physical address of a prefetchable memory location in the PCI address space.
Definition: host.hh:294
GenericPciHost::memAddr
Addr memAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override
Calculate the physical address of a non-prefetchable memory location in the PCI address space.
Definition: host.hh:290
PciHost::DeviceInterface::dmaAddr
Addr dmaAddr(Addr addr) const
Calculate the physical address of a prefetchable memory location in the PCI address space.
Definition: host.hh:146
PciHost::DeviceInterface::interruptPin
const PciIntPin interruptPin
Definition: host.hh:152
GenericPciHost::mapPciInterrupt
virtual uint32_t mapPciInterrupt(const PciBusAddr &bus_addr, PciIntPin pin) const
Definition: host.cc:212
PciDevice
PCI device, base implementation is only config space.
Definition: device.hh:66

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17