gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Authors: Andreas Sandberg
38  */
39 
40 #ifndef __DEV_PCI_HOST_HH__
41 #define __DEV_PCI_HOST_HH__
42 
43 #include "dev/io_device.hh"
44 #include "dev/pci/types.hh"
45 
46 struct PciHostParams;
47 struct GenericPciHostParams;
48 
49 class PciDevice;
50 class Platform;
51 
74 class PciHost : public PioDevice
75 {
76  public:
77  PciHost(const PciHostParams *p);
78  virtual ~PciHost();
79 
80  public:
94  {
95  friend class ::PciHost;
96 
97  protected:
105  DeviceInterface(PciHost &host, PciBusAddr &bus_addr, PciIntPin pin);
106 
107  public:
108  DeviceInterface() = delete;
109  void operator=(const DeviceInterface &) = delete;
110 
111  const std::string name() const;
112 
116  void postInt();
117 
121  void clearInt();
122 
130  Addr pioAddr(Addr addr) const { return host.pioAddr(busAddr, addr); }
131 
139  Addr memAddr(Addr addr) const { return host.memAddr(busAddr, addr); }
140 
148  Addr dmaAddr(Addr addr) const { return host.dmaAddr(busAddr, addr); }
149 
150  protected:
152 
155  };
156 
165  virtual DeviceInterface registerDevice(PciDevice *device,
166  PciBusAddr bus_addr, PciIntPin pin);
167 
170  protected:
182  virtual void postInt(const PciBusAddr &bus_addr, PciIntPin pin) = 0;
183 
190  virtual void clearInt(const PciBusAddr &bus_addr, PciIntPin pin) = 0;
191 
200  virtual Addr pioAddr(const PciBusAddr &bus_addr, Addr pci_addr) const = 0;
201 
210  virtual Addr memAddr(const PciBusAddr &bus_addr, Addr pci_addr) const = 0;
211 
212 
221  virtual Addr dmaAddr(const PciBusAddr &bus_addr, Addr pci_addr) const = 0;
222 
225  protected:
233 
240  const PciDevice *getDevice(const PciBusAddr &addr) const;
241 
242  private:
244  std::map<PciBusAddr, PciDevice *> devices;
245 };
246 
275 class GenericPciHost : public PciHost
276 {
277  public:
278  GenericPciHost(const GenericPciHostParams *p);
279  virtual ~GenericPciHost();
280 
281  public: // PioDevice
282  Tick read(PacketPtr pkt) override;
283  Tick write(PacketPtr pkt) override;
284 
285  AddrRangeList getAddrRanges() const override;
286 
287  protected: // PciHost
288  Addr pioAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override {
289  return pciPioBase + pci_addr;
290  }
291 
292  Addr memAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override {
293  return pciMemBase + pci_addr;
294  }
295 
296  Addr dmaAddr(const PciBusAddr &bus_addr, Addr pci_addr) const override {
297  return pciDmaBase + pci_addr;
298  }
299 
300  protected: // Configuration address space handling
310 
311  protected: // Interrupt handling
312  void postInt(const PciBusAddr &addr, PciIntPin pin) override;
313  void clearInt(const PciBusAddr &addr, PciIntPin pin) override;
314 
315  virtual uint32_t mapPciInterrupt(const PciBusAddr &bus_addr,
316  PciIntPin pin) const;
317 
318  protected:
320 
321  const Addr confBase;
322  const Addr confSize;
323  const uint8_t confDeviceBits;
324 
328 };
329 
330 #endif // __DEV_PCI_HOST_HH__
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...
void operator=(const DeviceInterface &)=delete
void postInt(const PciBusAddr &addr, PciIntPin pin) override
Post an interrupt to the CPU.
Definition: host.cc:201
Addr memAddr(Addr addr) const
Calculate the physical address of a non-prefetchable memory location in the PCI address space...
Definition: host.hh:139
virtual ~PciHost()
Definition: host.cc:55
Configurable generic PCI host interface.
Definition: host.hh:275
STL pair class.
Definition: stl.hh:61
PCI device, base implementation is only config space.
Definition: device.hh:70
const Addr pciPioBase
Definition: host.hh:325
Addr dmaAddr(Addr addr) const
Calculate the physical address of a prefetchable memory location in the PCI address space...
Definition: host.hh:148
virtual void postInt(const PciBusAddr &bus_addr, PciIntPin pin)=0
Post an interrupt to the CPU.
PciDevice * getDevice(const PciBusAddr &addr)
Retrieve a PCI device from its bus address.
Definition: host.cc:75
virtual DeviceInterface registerDevice(PciDevice *device, PciBusAddr bus_addr, PciIntPin pin)
Register a PCI device with the host.
Definition: host.cc:60
ip6_addr_t addr
Definition: inet.hh:335
const PciBusAddr busAddr
Definition: host.hh:153
virtual uint32_t mapPciInterrupt(const PciBusAddr &bus_addr, PciIntPin pin) const
Definition: host.cc:214
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: host.cc:160
const std::string name() const
Definition: host.cc:97
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: host.cc:181
void clearInt(const PciBusAddr &addr, PciIntPin pin) override
Post an interrupt to the CPU.
Definition: host.cc:207
const Addr confBase
Definition: host.hh:321
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...
Addr pioAddr(Addr addr) const
Calculate the physical address of an IO location on the PCI bus.
Definition: host.hh:130
virtual void clearInt(const PciBusAddr &bus_addr, PciIntPin pin)=0
Post an interrupt to the CPU.
void clearInt()
Clear a posted PCI interrupt.
Definition: host.cc:112
uint64_t Tick
Tick count type.
Definition: types.hh:63
virtual Addr pioAddr(const PciBusAddr &bus_addr, Addr pci_addr) const =0
Calculate the physical address of an IO location on the PCI bus.
const Addr confSize
Definition: host.hh:322
const PciIntPin interruptPin
Definition: host.hh:154
This device is the base class which all devices senstive to an address range inherit from...
Definition: io_device.hh:84
PciHost(const PciHostParams *p)
Definition: host.cc:50
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
The PCI host describes the interface between PCI devices and a simulated system.
Definition: host.hh:74
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
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:288
Platform & platform
Definition: host.hh:319
virtual std::pair< PciBusAddr, Addr > decodeAddress(Addr address)
Decode a configuration space address.
Definition: host.cc:187
Callback interface from PCI devices to the host.
Definition: host.hh:93
const Addr pciMemBase
Definition: host.hh:326
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: host.cc:136
GenericPciHost(const GenericPciHostParams *p)
Definition: host.cc:120
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:296
PciIntPin
Definition: types.hh:65
const uint8_t confDeviceBits
Definition: host.hh:323
std::map< PciBusAddr, PciDevice * > devices
Currently registered PCI devices.
Definition: host.hh:244
void postInt()
Post a PCI interrupt to the CPU.
Definition: host.cc:104
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:292
Bitfield< 0 > p
const Addr pciDmaBase
Definition: host.hh:327
virtual ~GenericPciHost()
Definition: host.cc:130

Generated on Fri Jun 9 2017 13:03:46 for gem5 by doxygen 1.8.6