45#ifndef __DEV_PCI_DEVICE_HH__
46#define __DEV_PCI_DEVICE_HH__
55#include "params/PciBar.hh"
56#include "params/PciBarNone.hh"
57#include "params/PciDevice.hh"
58#include "params/PciEndpoint.hh"
59#include "params/PciIoBar.hh"
60#include "params/PciLegacyIoBar.hh"
61#include "params/PciMemBar.hh"
62#include "params/PciMemUpperBar.hh"
63#include "params/PciType1Device.hh"
66#define PCI0_BAR_NUMBER(x) (((x) - PCI0_BASE_ADDR0) >> 0x2);
67#define PCI1_BAR_NUMBER(x) (((x) - PCI1_BASE_ADDR0) >> 0x2);
82 virtual bool isMem()
const {
return false; }
83 virtual bool isIo()
const {
return false; }
129 "Illegal size %d for bar %s.",
_size,
name());
133 bool isIo()
const override {
return true; }
196 "Illegal size %d for bar %s.",
_size,
name());
199 bool isMem()
const override {
return true; }
207 bar.type.wide =
wide() ? 1 : 0;
208 bar.type.reserved = 0;
221 bool wide()
const {
return _wide; }
264 _lower->upper(interface, upper);
360 for (
int i = 0;
i <
BARs.size();
i++) {
362 if (!bar || !bar->range().contains(
addr))
365 offs =
addr - bar->addr();
465 std::initializer_list<PciBar *> BARs_init);
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
DmaDevice(const Params &p)
virtual std::string name() const
PciBarNone(const PciBarNoneParams &p)
uint32_t write(const PciUpstream::DeviceInterface &interface, uint32_t val) override
virtual bool isIo() const
PciBar(const PciBarParams &p)
virtual uint32_t write(const PciUpstream::DeviceInterface &interface, uint32_t val)=0
virtual bool isMem() const
const int PMCAP_PC_OFFSET
Tick write(PacketPtr pkt) final
Final implementation of write access from DmaDevice.
const int MSIXCAP_MTAB_OFFSET
PciDevice(const PciDeviceParams ¶ms, std::initializer_list< PciBar * > BARs_init)
Constructor for PCI Dev.
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
std::vector< MSIXTable > msix_table
MSIX Table and PBA Structures.
const PciDevAddr & devAddr() const
PciUpstream::DeviceInterface upstreamInterface
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
void recvBusChange()
Called to receive a bus number change from the PCI upstream.
Tick read(PacketPtr pkt) final
Final implementation of read access from PioDevice.
bool getBAR(Addr addr, int &num, Addr &offs)
Which base address register (if any) maps the given address?
const int PMCAP_BASE
The capability list structures and base addresses.
Addr pciToDma(Addr pci_addr) const
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
const int PMCAP_PMCS_OFFSET
virtual Tick writeDevice(PacketPtr pkt)=0
Write to the PCI device.
std::vector< MSIXPbaEntry > msix_pba
virtual Tick readConfig(PacketPtr pkt)
Read from the PCI config space data that is stored locally.
PCIConfig _config
The current config space.
virtual Tick readDevice(PacketPtr pkt)=0
Read from the PCI device.
virtual Tick writeConfig(PacketPtr pkt)
Write to the PCI config space data that is stored locally.
const int MSIXCAP_ID_OFFSET
const int MSIXCAP_MPBA_OFFSET
std::vector< PciBar * > BARs
bool isCommonConfig(Addr offs)
uint8_t interruptLine() const
const int PMCAP_ID_OFFSET
const int MSIXCAP_MXC_OFFSET
const PciDevAddr _devAddr
PCIConfigType0 & config()
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
PciEndpoint(const PciEndpointParams ¶ms)
Constructor for PCI Dev.
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
uint32_t write(const PciUpstream::DeviceInterface &interface, uint32_t val) override
BitUnion32(Bar) Bitfield< 31
bool isIo() const override
uint32_t write(const PciUpstream::DeviceInterface &interface, uint32_t val) override
PciLegacyIoBar(const PciLegacyIoBarParams &p)
PciMemBar(const PciMemBarParams &p)
bool isMem() const override
SubBitUnion(type, 2, 1) Bitfield< 2 > wide
EndSubBitUnion(type) Bitfield< 0 > io
uint32_t write(const PciUpstream::DeviceInterface &interface, uint32_t val) override
void upper(const PciUpstream::DeviceInterface &interface, uint32_t val)
EndBitUnion(Bar) bool _wide
BitUnion32(Bar) Bitfield< 31
uint32_t write(const PciUpstream::DeviceInterface &interface, uint32_t val) override
PciMemUpperBar(const PciMemUpperBarParams &p)
void lower(PciMemBar *val)
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
PciType1Device(const PciType1DeviceParams ¶ms)
Constructor for PCI Dev.
PCIConfigType1 & config()
Callback interface from PCI devices to the upstream.
Addr memAddr(Addr addr) const
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.
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
static constexpr bool isPowerOf2(const T &n)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
const Params & params() const
SimObject(const Params &p)
Copyright (c) 2024 Arm Limited All rights reserved.
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint64_t Tick
Tick count type.
#define PCI_INTERRUPT_PIN
#define PCI_INTERRUPT_LINE
Defines the MSI Capability register and its associated bitfields for the a PCI/PCIe device.
Defines the Power Management capability register and all its associated bitfields for a PCIe device.
Defines the PCI Express capability register and its associated bitfields for a PCIe device.