changeset c7fec2cb91cb in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=c7fec2cb91cb
description:
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.
diffstat:
src/dev/io_device.cc | 28 ++++++++++++++++++++++++++++
src/dev/io_device.hh | 32 +++-----------------------------
2 files changed, 31 insertions(+), 29 deletions(-)
diffs (91 lines):
diff -r 45c9f664a365 -r c7fec2cb91cb src/dev/io_device.cc
--- a/src/dev/io_device.cc Thu Oct 20 13:09:10 2011 -0700
+++ b/src/dev/io_device.cc Thu Oct 20 13:11:56 2011 -0700
@@ -75,6 +75,18 @@
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
PioDevice::drain(Event *de)
@@ -349,3 +361,19 @@
if (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);
+}
+
diff -r 45c9f664a365 -r c7fec2cb91cb src/dev/io_device.hh
--- a/src/dev/io_device.hh Thu Oct 20 13:09:10 2011 -0700
+++ b/src/dev/io_device.hh Thu Oct 20 13:11:56 2011 -0700
@@ -215,17 +215,8 @@
virtual unsigned int drain(Event *de);
- 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;
- }
+ virtual Port *getPort(const std::string &if_name, int idx = -1);
+
friend class PioPort;
};
@@ -291,24 +282,7 @@
unsigned cacheBlockSize() const { return dmaPort->cacheBlockSize(); }
- 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;
- }
+ virtual Port *getPort(const std::string &if_name, int idx = -1);
friend class DmaPort;
};
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev