59a60,61
> #include "mem/mem_object.hh"
> #include "mem/port.hh"
62d63
< #include "sim/configfile.hh"
137,139c138
< " <configfile> config file name which ends in .py. (Normally you can\n"
< " run <configfile> --help to get help on that config files\n"
< " parameters.\n\n",
---
> " <configfile> config file name (ends in .py)\n\n",
300a300
> IniFile inifile;
302,303c302,341
< /// Initialize C++ configuration. Exported to Python via SWIG; invoked
< /// from m5.instantiate().
---
> SimObject *
> createSimObject(const string &name)
> {
> return SimObjectClass::createObject(inifile, name);
> }
>
>
> /**
> * Pointer to the Python function that maps names to SimObjects.
> */
> PyObject *resolveFunc = NULL;
>
> /**
> * Convert a pointer to the Python object that SWIG wraps around a C++
> * SimObject pointer back to the actual C++ pointer. See main.i.
> */
> extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
>
>
> SimObject *
> resolveSimObject(const string &name)
> {
> PyObject *pyPtr = PyEval_CallFunction(resolveFunc, "(s)", name.c_str());
> if (pyPtr == NULL) {
> PyErr_Print();
> panic("resolveSimObject: failure on call to Python for %s", name);
> }
>
> SimObject *simObj = convertSwigSimObjectPtr(pyPtr);
> if (simObj == NULL)
> panic("resolveSimObject: failure on pointer conversion for %s", name);
>
> return simObj;
> }
>
>
> /**
> * Load config.ini into C++ database. Exported to Python via SWIG;
> * invoked from m5.instantiate().
> */
305c343
< initialize()
---
> loadIniFile(PyObject *_resolveFunc)
306a345
> resolveFunc = _resolveFunc;
310d348
< IniFile inifile;
314a353
> }
316,319d354
< // Now process the configuration hierarchy and create the SimObjects.
< ConfigHierarchy configHierarchy(inifile);
< configHierarchy.build();
< configHierarchy.createSimObjects();
320a356,402
> /**
> * Look up a MemObject port. Helper function for connectPorts().
> */
> Port *
> lookupPort(SimObject *so, const std::string &name, int i)
> {
> MemObject *mo = dynamic_cast<MemObject *>(so);
> if (mo == NULL) {
> warn("error casting SimObject %s to MemObject", so->name());
> return NULL;
> }
>
> Port *p = mo->getPort(name, i);
> if (p == NULL)
> warn("error looking up port %s on object %s", name, so->name());
> return p;
> }
>
>
> /**
> * Connect the described MemObject ports. Called from Python via SWIG.
> */
> int
> connectPorts(SimObject *o1, const std::string &name1, int i1,
> SimObject *o2, const std::string &name2, int i2)
> {
> Port *p1 = lookupPort(o1, name1, i1);
> Port *p2 = lookupPort(o2, name2, i2);
>
> if (p1 == NULL || p2 == NULL) {
> warn("connectPorts: port lookup error");
> return 0;
> }
>
> p1->setPeer(p2);
> p2->setPeer(p1);
>
> return 1;
> }
>
> /**
> * Do final initialization steps after object construction but before
> * start of simulation.
> */
> void
> finalInit()
> {
328,331d409
< // Any objects that can't connect themselves until after construction should
< // do so now
< SimObject::connectAll();
<
335a414
> #if 0
336a416
> #endif
338,342d417
< // Done processing the configuration database.
< // Check for unreferenced entries.
< if (inifile.printUnreferenced())
< panic("unreferenced sections/entries in the intermediate ini file");
<