dev: clean up PioDevice and DmaDevive getPort() methods.
Make DmaDevice::getPort() call PioDevice::getPort() instead of just copying and pasting the code. Also move definitions from .hh to .cc file.
This commit is contained in:
parent
7b500f56ca
commit
38aef4c4c7
2 changed files with 31 additions and 29 deletions
|
@ -75,6 +75,18 @@ PioDevice::init()
|
||||||
pioPort->sendStatusChange(Port::RangeChange);
|
pioPort->sendStatusChange(Port::RangeChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Port *
|
||||||
|
PioDevice::getPort(const std::string &if_name, int idx)
|
||||||
|
{
|
||||||
|
if (if_name == "pio") {
|
||||||
|
if (pioPort != NULL)
|
||||||
|
fatal("%s: pio port already connected to %s",
|
||||||
|
name(), pioPort->getPeer()->name());
|
||||||
|
pioPort = new PioPort(this, sys);
|
||||||
|
return pioPort;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
PioDevice::drain(Event *de)
|
PioDevice::drain(Event *de)
|
||||||
|
@ -349,3 +361,19 @@ DmaDevice::~DmaDevice()
|
||||||
if (dmaPort)
|
if (dmaPort)
|
||||||
delete dmaPort;
|
delete dmaPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Port *
|
||||||
|
DmaDevice::getPort(const std::string &if_name, int idx)
|
||||||
|
{
|
||||||
|
if (if_name == "dma") {
|
||||||
|
if (dmaPort != NULL)
|
||||||
|
fatal("%s: dma port already connected to %s",
|
||||||
|
name(), dmaPort->getPeer()->name());
|
||||||
|
dmaPort = new DmaPort(this, sys, params()->min_backoff_delay,
|
||||||
|
params()->max_backoff_delay);
|
||||||
|
return dmaPort;
|
||||||
|
}
|
||||||
|
return PioDevice::getPort(if_name, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,17 +215,8 @@ class PioDevice : public MemObject
|
||||||
|
|
||||||
virtual unsigned int drain(Event *de);
|
virtual unsigned int drain(Event *de);
|
||||||
|
|
||||||
virtual Port *getPort(const std::string &if_name, int idx = -1)
|
virtual Port *getPort(const std::string &if_name, int idx = -1);
|
||||||
{
|
|
||||||
if (if_name == "pio") {
|
|
||||||
if (pioPort != NULL)
|
|
||||||
fatal("%s: pio port already connected to %s",
|
|
||||||
name(), pioPort->getPeer()->name());
|
|
||||||
pioPort = new PioPort(this, sys);
|
|
||||||
return pioPort;
|
|
||||||
} else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
friend class PioPort;
|
friend class PioPort;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -291,24 +282,7 @@ class DmaDevice : public PioDevice
|
||||||
|
|
||||||
unsigned cacheBlockSize() const { return dmaPort->cacheBlockSize(); }
|
unsigned cacheBlockSize() const { return dmaPort->cacheBlockSize(); }
|
||||||
|
|
||||||
virtual Port *getPort(const std::string &if_name, int idx = -1)
|
virtual Port *getPort(const std::string &if_name, int idx = -1);
|
||||||
{
|
|
||||||
if (if_name == "pio") {
|
|
||||||
if (pioPort != NULL)
|
|
||||||
fatal("%s: pio port already connected to %s",
|
|
||||||
name(), pioPort->getPeer()->name());
|
|
||||||
pioPort = new PioPort(this, sys);
|
|
||||||
return pioPort;
|
|
||||||
} else if (if_name == "dma") {
|
|
||||||
if (dmaPort != NULL)
|
|
||||||
fatal("%s: dma port already connected to %s",
|
|
||||||
name(), dmaPort->getPeer()->name());
|
|
||||||
dmaPort = new DmaPort(this, sys, params()->min_backoff_delay,
|
|
||||||
params()->max_backoff_delay);
|
|
||||||
return dmaPort;
|
|
||||||
} else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend class DmaPort;
|
friend class DmaPort;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue