42#include "debug/PciHost.hh"
45#include "params/GenericPciHost.hh"
46#include "params/PciHost.hh"
63 auto map_entry =
devices.emplace(bus_addr, device);
69 "%02x:%02x.%i: PCI bus ID collision\n",
79 return device !=
devices.end() ? device->second :
nullptr;
86 return device !=
devices.end() ? device->second :
nullptr;
93 busAddr(bus_addr), interruptPin(interrupt_pin)
100 return csprintf(
"%s.interface[%02x:%02x.%i]",
101 host.name(), busAddr.bus, busAddr.dev, busAddr.func);
109 host.postInt(busAddr, interruptPin);
117 host.clearInt(busAddr, interruptPin);
123 platform(*
p.platform),
124 confBase(
p.conf_base), confSize(
p.conf_size),
125 confDeviceBits(
p.conf_device_bits),
126 pciPioBase(
p.pci_pio_base), pciMemBase(
p.pci_mem_base),
127 pciDmaBase(
p.pci_dma_base)
143 dev_addr.first.bus, dev_addr.first.dev, dev_addr.first.func,
153 uint8_t *pkt_data(pkt->
getPtr<uint8_t>());
154 std::fill(pkt_data, pkt_data + size, 0xFF);
166 dev_addr.first.bus, dev_addr.first.dev, dev_addr.first.func,
172 "%02x:%02x.%i: Write to config space on non-existent PCI device\n",
173 dev_addr.first.bus, dev_addr.first.dev, dev_addr.first.func);
193 return std::make_pair(
195 bits(bus_addr, 7, 3),
196 bits(bus_addr, 2, 0)),
const uint8_t confDeviceBits
virtual uint32_t mapPciInterrupt(const PciBusAddr &bus_addr, PciIntPin pin) const
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
GenericPciHost(const GenericPciHostParams &p)
virtual std::pair< PciBusAddr, Addr > decodeAddress(Addr address)
Decode a configuration space address.
virtual ~GenericPciHost()
void postInt(const PciBusAddr &addr, PciIntPin pin) override
Post an interrupt to the CPU.
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
void clearInt(const PciBusAddr &addr, PciIntPin pin) override
Post an interrupt to the CPU.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
T * getPtr()
get a pointer to the data ptr.
void makeAtomicResponse()
PCI device, base implementation is only config space.
virtual Tick readConfig(PacketPtr pkt)
Read from the PCI config space data that is stored locally.
virtual Tick writeConfig(PacketPtr pkt)
Write to the PCI config space data that is stored locally.
uint8_t interruptLine() const
Callback interface from PCI devices to the host.
void postInt()
Post a PCI interrupt to the CPU.
const std::string name() const
void clearInt()
Clear a posted PCI interrupt.
The PCI host describes the interface between PCI devices and a simulated system.
std::map< PciBusAddr, PciDevice * > devices
Currently registered PCI devices.
PciHost(const PciHostParams &p)
PciDevice * getDevice(const PciBusAddr &addr)
Retrieve a PCI device from its bus address.
virtual DeviceInterface registerDevice(PciDevice *device, PciBusAddr bus_addr, PciIntPin pin)
Register a PCI device with the host.
This device is the base class which all devices senstive to an address range inherit from.
AddrRange RangeSize(Addr start, Addr size)
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
static SimObject * find(const char *name)
Find the SimObject with the given name and return a pointer to it.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
std::string csprintf(const char *format, const Args &...args)