diff options
Diffstat (limited to 'src/dev/pcidev.hh')
-rw-r--r-- | src/dev/pcidev.hh | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/src/dev/pcidev.hh b/src/dev/pcidev.hh index 847fb07d0..22dd6296e 100644 --- a/src/dev/pcidev.hh +++ b/src/dev/pcidev.hh @@ -62,7 +62,6 @@ class PciConfigData : public SimObject : SimObject(name) { memset(config.data, 0, sizeof(config.data)); - memset(BARAddrs, 0, sizeof(BARAddrs)); memset(BARSize, 0, sizeof(BARSize)); } @@ -71,29 +70,23 @@ class PciConfigData : public SimObject /** The size of the BARs */ uint32_t BARSize[6]; - - /** The addresses of the BARs */ - Addr BARAddrs[6]; }; /** - * PCI device, base implemnation is only config space. + * PCI device, base implementation is only config space. */ class PciDev : public DmaDevice { - class PciConfigPort : public PioPort + class PciConfigPort : public SimpleTimingPort { protected: PciDev *device; - virtual bool recvTiming(Packet *pkt); - virtual Tick recvAtomic(Packet *pkt); - virtual void recvFunctional(Packet *pkt) ; - - virtual void getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop); + virtual void getDeviceAddressRanges(AddrRangeList &resp, + AddrRangeList &snoop); Platform *platform; @@ -105,9 +98,7 @@ class PciDev : public DmaDevice public: PciConfigPort(PciDev *dev, int busid, int devid, int funcid, - Platform *p); - - friend class PioPort::SendEvent; + Platform *p); }; public: @@ -151,6 +142,10 @@ class PciDev : public DmaDevice /** The current address mapping of the BARs */ Addr BARAddrs[6]; + /** + * Does the given address lie within the space mapped by the given + * base address register? + */ bool isBAR(Addr addr, int bar) const { @@ -158,6 +153,10 @@ class PciDev : public DmaDevice return BARAddrs[bar] <= addr && addr < BARAddrs[bar] + BARSize[bar]; } + /** + * Which base address register (if any) maps the given address? + * @return The BAR number (0-5 inclusive), or -1 if none. + */ int getBAR(Addr addr) { @@ -168,14 +167,23 @@ class PciDev : public DmaDevice return -1; } + /** + * Which base address register (if any) maps the given address? + * @param addr The address to check. + * @retval bar The BAR number (0-5 inclusive), + * only valid if return value is true. + * @retval offs The offset from the base address, + * only valid if return value is true. + * @return True iff address maps to a base address register's region. + */ bool - getBAR(Addr paddr, Addr &daddr, int &bar) + getBAR(Addr addr, int &bar, Addr &offs) { - int b = getBAR(paddr); + int b = getBAR(addr); if (b < 0) return false; - daddr = paddr - BARAddrs[b]; + offs = addr - BARAddrs[b]; bar = b; return true; } @@ -225,10 +233,6 @@ class PciDev : public DmaDevice */ void addressRanges(AddrRangeList &range_list); - /** Do a PCI Configspace memory access. */ - Tick recvConfig(Packet *pkt) - { return pkt->isRead() ? readConfig(pkt) : writeConfig(pkt); } - /** * Constructor for PCI Dev. This function copies data from the * config file object PCIConfigData and registers the device with |