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/PciIoBar.hh"
59#include "params/PciLegacyIoBar.hh"
60#include "params/PciMemBar.hh"
61#include "params/PciMemUpperBar.hh"
64#define BAR_NUMBER(x) (((x) - PCI0_BASE_ADDR0) >> 0x2);
79 virtual bool isMem()
const {
return false; }
80 virtual bool isIo()
const {
return false; }
126 "Illegal size %d for bar %s.",
_size,
name());
130 bool isIo()
const override {
return true; }
193 "Illegal size %d for bar %s.",
_size,
name());
196 bool isMem()
const override {
return true; }
204 bar.type.wide =
wide() ? 1 : 0;
205 bar.type.reserved = 0;
218 bool wide()
const {
return _wide; }
308 std::array<PciBar *, 6>
BARs{};
322 for (
int i = 0;
i <
BARs.size();
i++) {
324 if (!bar || !bar->range().contains(
addr))
327 offs =
addr - bar->addr();
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
virtual std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
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
PCI device, base implementation is only config space.
const int PMCAP_PC_OFFSET
PciHost::DeviceInterface hostInterface
PCIConfig config
The current config space.
const int MSIXCAP_MTAB_OFFSET
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
std::array< PciBar *, 6 > BARs
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.
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
PciDevice(const PciDeviceParams ¶ms)
Constructor for PCI Dev.
uint8_t interruptLine() const
const int PMCAP_ID_OFFSET
const PciBusAddr & busAddr() const
const int MSIXCAP_MXC_OFFSET
Callback interface from PCI devices to the host.
void postInt()
Post a PCI interrupt to the CPU.
Addr pioAddr(Addr addr) const
Calculate the physical address of an IO location on the PCI bus.
Addr dmaAddr(Addr addr) const
Calculate the physical address of a prefetchable memory location in the PCI address space.
Addr memAddr(Addr addr) const
Calculate the physical address of a non-prefetchable memory location in the PCI address space.
void clearInt()
Clear a posted PCI interrupt.
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
bool isMem() const override
uint32_t write(const PciHost::DeviceInterface &host, uint32_t val) override
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
Abstract superclass for simulation objects.
static constexpr bool isPowerOf2(const T &n)
#define EndBitUnion(name)
This closes off the class and union started by the above macro.
#define SubBitUnion(name, first, last)
Regular bitfields These define macros for read/write regular bitfield based subbitfields.
#define EndSubBitUnion(name)
This closes off the union created above and gives it a name.
#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
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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.
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.