45#ifndef __DEV_PCI_DEVICE_HH__
46#define __DEV_PCI_DEVICE_HH__
54#include "params/PciBar.hh"
55#include "params/PciBarNone.hh"
56#include "params/PciBridge.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"
65#define PCI0_BAR_NUMBER(x) (((x) - PCI0_BASE_ADDR0) >> 0x2);
66#define PCI1_BAR_NUMBER(x) (((x) - PCI1_BASE_ADDR0) >> 0x2);
81 virtual bool isMem()
const {
return false; }
82 virtual bool isIo()
const {
return false; }
128 "Illegal size %d for bar %s.",
_size,
name());
132 bool isIo()
const override {
return true; }
195 "Illegal size %d for bar %s.",
_size,
name());
198 bool isMem()
const override {
return true; }
206 bar.type.wide =
wide() ? 1 : 0;
207 bar.type.reserved = 0;
220 bool wide()
const {
return _wide; }
262 _lower->upper(host, upper);
338 for (
int i = 0;
i <
BARs.size();
i++) {
340 if (!bar || !bar->range().contains(
addr))
343 offs =
addr - bar->addr();
402 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 PciHost::DeviceInterface &host, uint32_t val) override
virtual bool isIo() const
PciBar(const PciBarParams &p)
virtual uint32_t write(const PciHost::DeviceInterface &host, uint32_t val)=0
virtual bool isMem() const
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.
PCIConfigType1 & config()
PciBridge(const PciBridgeParams ¶ms)
Constructor for PCI Dev.
const int PMCAP_PC_OFFSET
PciHost::DeviceInterface hostInterface
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.
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
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
const PciBusAddr _busAddr
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 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 PciBusAddr & busAddr() const
const int MSIXCAP_MXC_OFFSET
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.
Callback interface from PCI devices to the host.
Addr pioAddr(Addr addr) const
Calculate the physical address of an IO location on the PCI bus.
Addr memAddr(Addr addr) const
Calculate the physical address of a non-prefetchable memory location in the PCI address space.
BitUnion32(Bar) Bitfield< 31
bool isIo() const override
uint32_t write(const PciHost::DeviceInterface &host, uint32_t val) override
PciLegacyIoBar(const PciLegacyIoBarParams &p)
uint32_t write(const PciHost::DeviceInterface &host, uint32_t val) override
PciMemBar(const PciMemBarParams &p)
bool isMem() const override
uint32_t write(const PciHost::DeviceInterface &host, uint32_t val) override
SubBitUnion(type, 2, 1) Bitfield< 2 > wide
EndSubBitUnion(type) Bitfield< 0 > io
EndBitUnion(Bar) bool _wide
void upper(const PciHost::DeviceInterface &host, uint32_t val)
BitUnion32(Bar) Bitfield< 31
PciMemUpperBar(const PciMemUpperBarParams &p)
void lower(PciMemBar *val)
uint32_t write(const PciHost::DeviceInterface &host, uint32_t val) override
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.