diff options
author | Gabe Black <gblack@eecs.umich.edu> | 2007-08-18 19:41:08 -0700 |
---|---|---|
committer | Gabe Black <gblack@eecs.umich.edu> | 2007-08-18 19:41:08 -0700 |
commit | a874cb40ab9f22612b0609cbac2c739daebacbd5 (patch) | |
tree | 551e5aadc93be0ba3013e2b33272d08c78da01f9 /src/python | |
parent | 4bce50340f8fc1e1e0361cef1971dd127125d5a5 (diff) | |
parent | 464a51e29e858d6dc38847120868b36e97c8bb6d (diff) | |
download | gem5-a874cb40ab9f22612b0609cbac2c739daebacbd5.tar.xz |
Merge with head.
--HG--
extra : convert_revision : 6ce77b5bd4f43ddecd51ea8c66759e4b70d4ad82
Diffstat (limited to 'src/python')
-rw-r--r-- | src/python/swig/pyobject.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/python/swig/pyobject.cc b/src/python/swig/pyobject.cc index 455888c04..5ae2aa177 100644 --- a/src/python/swig/pyobject.cc +++ b/src/python/swig/pyobject.cc @@ -34,10 +34,17 @@ #include "base/inifile.hh" #include "base/output.hh" +#include "config/full_system.hh" #include "mem/mem_object.hh" #include "mem/port.hh" #include "sim/sim_object.hh" +#if FULL_SYSTEM +#include "dev/etherdevice.hh" +#include "dev/etherobject.hh" +#include "dev/etherint.hh" +#endif + using namespace std; /** @@ -58,6 +65,26 @@ lookupPort(SimObject *so, const std::string &name, int i) return p; } +#if FULL_SYSTEM + +EtherInt * +lookupEthPort(SimObject *so, const std::string &name, int i) +{ + EtherObject *eo = dynamic_cast<EtherObject *>(so); + EtherDevice *ed = dynamic_cast<EtherDevice *>(so); + if (eo == NULL && ed == NULL) { + warn("error casting SimObject %s", so->name()); + return NULL; + } + + EtherInt *p = NULL; + if (eo) + p = eo->getEthPort(name, i); + else + p = ed->getEthPort(name, i); + return p; +} +#endif /** * Connect the described MemObject ports. Called from Python via SWIG. @@ -67,6 +94,32 @@ int connectPorts(SimObject *o1, const std::string &name1, int i1, SimObject *o2, const std::string &name2, int i2) { + MemObject *mo1, *mo2; + mo1 = dynamic_cast<MemObject*>(o1); + mo2 = dynamic_cast<MemObject*>(o2); + +#if FULL_SYSTEM + EtherObject *eo1, *eo2; + EtherDevice *ed1, *ed2; + eo1 = dynamic_cast<EtherObject*>(o1); + ed1 = dynamic_cast<EtherDevice*>(o1); + + eo2 = dynamic_cast<EtherObject*>(o2); + ed2 = dynamic_cast<EtherDevice*>(o2); + + if ((eo1 || ed1) && (eo2 || ed2)) { + EtherInt *p1 = lookupEthPort(o1, name1, i1); + EtherInt *p2 = lookupEthPort(o2, name2, i2); + + if (p1 != NULL && p2 != NULL) { + + p1->setPeer(p2); + p2->setPeer(p1); + + return 1; + } + } +#endif Port *p1 = lookupPort(o1, name1, i1); Port *p2 = lookupPort(o2, name2, i2); |