Adding gem5 source to svn.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1819 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
friemel
2012-10-24 19:18:57 +00:00
parent f7ff71bd46
commit b41eec3f65
3222 changed files with 658579 additions and 1 deletions

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
* Steve Reinhardt
*/
%module(package="m5.internal") core
%{
#include "base/misc.hh"
#include "base/random.hh"
#include "base/socket.hh"
#include "base/types.hh"
#include "python/swig/pyobject.hh"
#include "sim/core.hh"
extern const char *compileDate;
#ifdef DEBUG
const bool flag_DEBUG = true;
#else
const bool flag_DEBUG = false;
#endif
#ifdef NDEBUG
const bool flag_NDEBUG = true;
#else
const bool flag_NDEBUG = false;
#endif
const bool flag_TRACING_ON = TRACING_ON;
inline void disableAllListeners() { ListenSocket::disableAll(); }
inline void
seedRandom(uint64_t seed)
{
random_mt.init(seed);
}
%}
%include <std_string.i>
%include <stdint.i>
%include "base/types.hh"
void setOutputDir(const std::string &dir);
void doExitCleanup();
void disableAllListeners();
void seedRandom(uint64_t seed);
%immutable compileDate;
char *compileDate;
const bool flag_DEBUG;
const bool flag_NDEBUG;
const bool flag_TRACING_ON;
void setClockFrequency(Tick ticksPerSecond);
Tick curTick();
class Checkpoint;
void serializeAll(const std::string &cpt_dir);
Checkpoint *getCheckpoint(const std::string &cpt_dir);
void unserializeGlobals(Checkpoint *cp);
bool want_warn, warn_verbose;
bool want_info, info_verbose;
bool want_hack, hack_verbose;

View File

@ -0,0 +1,93 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* Copyright (c) 2010 The Hewlett-Packard Development Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
%module(package="m5.internal") debug
%{
#include <cassert>
#include <map>
#include <string>
#include <vector>
#include "base/debug.hh"
#include "base/types.hh"
#include "sim/debug.hh"
using namespace std;
typedef map<string, Debug::Flag *> FlagsMap;
typedef vector<Debug::Flag *> FlagsVec;
namespace Debug {
extern int allFlagsVersion;
FlagsMap &allFlags();
}
inline int
getAllFlagsVersion()
{
return Debug::allFlagsVersion;
}
inline FlagsVec
getAllFlags()
{
FlagsMap &flagsMap = Debug::allFlags();
FlagsVec flags(flagsMap.size());
int index = 0;
FlagsMap::iterator i = flagsMap.begin();
FlagsMap::iterator end = flagsMap.end();
for (; i != end; ++i) {
assert(index < flags.size());
flags[index++] = i->second;
}
return flags;
}
%}
%ignore Debug::SimpleFlag::operator!;
%include <std_string.i>
%include <std_vector.i>
%include <stdint.i>
%include "base/debug.hh"
%include "base/types.hh"
%include "sim/debug.hh"
%template(AllFlags) std::vector<Debug::Flag *>;
int getAllFlagsVersion();
std::vector<Debug::Flag *> getAllFlags();

View File

@ -0,0 +1,105 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
%module(package="m5.internal") event
%{
#include "base/types.hh"
#include "python/swig/pyevent.hh"
#include "sim/eventq.hh"
#include "sim/sim_events.hh"
#include "sim/sim_exit.hh"
#include "sim/simulate.hh"
%}
#pragma SWIG nowarn=350,351
%extend EventQueue {
void
schedule(Event *event, Tick when)
{
// Any python event that are scheduled must have their
// internal object's refcount incremented so that the object
// sticks around while it is in the event queue.
PythonEvent *pyevent = dynamic_cast<PythonEvent *>(event);
if (pyevent)
pyevent->incref();
$self->schedule(event, when);
}
void
deschedule(Event *event)
{
$self->deschedule(event);
// Now that we're removing the python object from the event
// queue, we need to decrement its reference count.
PythonEvent *pyevent = dynamic_cast<PythonEvent *>(event);
if (pyevent)
pyevent->decref();
}
}
%ignore EventQueue::schedule;
%ignore EventQueue::deschedule;
%include <std_string.i>
%include <stdint.i>
%import "sim/serialize.hh"
%include "base/types.hh"
%include "sim/eventq.hh"
// This must follow eventq.hh
%include "python/swig/pyevent.hh"
struct CountedDrainEvent : public Event
{
void setCount(int _count);
};
// minimal definition of SimExitEvent interface to wrap
class SimLoopExitEvent : public Event
{
public:
std::string getCause();
int getCode();
SimLoopExitEvent(const std::string &_cause, int c, Tick _repeat = 0);
};
%exception simulate {
$action
if (!result) {
return NULL;
}
}
SimLoopExitEvent *simulate(Tick num_cycles = MaxTick);
void exitSimLoop(const std::string &message, int exit_code);

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* Copyright (c) 2010 Advanced Micro Devices, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
* Gabe Black
*/
%{
#include "base/inet.hh"
%}
%import <std_string.i>
%import <stdint.i>
namespace Net {
struct EthAddr
{
EthAddr();
EthAddr(const uint8_t ea[6]);
EthAddr(const std::string &addr);
};
struct IpAddress
{
IpAddress();
IpAddress(const uint32_t __addr);
};
struct IpNetmask : IpAddress
{
IpNetmask();
IpNetmask(const uint32_t __addr, const uint8_t __netmask);
};
struct IpWithPort : IpAddress
{
IpWithPort();
IpWithPort(const uint32_t __addr, const uint16_t __port);
};
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
#include <Python.h>
#include "python/swig/pyevent.hh"
#include "sim/async.hh"
PythonEvent::PythonEvent(PyObject *obj, Priority priority)
: Event(priority), object(obj)
{
if (object == NULL)
panic("Passed in invalid object");
}
PythonEvent::~PythonEvent()
{
}
void
PythonEvent::process()
{
PyObject *args = PyTuple_New(0);
PyObject *result = PyObject_Call(object, args, NULL);
Py_DECREF(args);
if (result) {
// Nothing to do just decrement the reference count
Py_DECREF(result);
} else {
// Somethign should be done to signal back to the main interpreter
// that there's been an exception.
async_event = true;
async_exception = true;
}
// Since the object has been removed from the event queue, its
// reference count must be decremented.
Py_DECREF(object);
}
CountedDrainEvent *
createCountedDrain()
{
return new CountedDrainEvent();
}
void
cleanupCountedDrain(Event *counted_drain)
{
CountedDrainEvent *event =
dynamic_cast<CountedDrainEvent *>(counted_drain);
if (event == NULL) {
fatal("Called cleanupCountedDrain() on an event that was not "
"a CountedDrainEvent.");
}
assert(event->getCount() == 0);
delete event;
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
#ifndef __PYTHON_SWIG_PYEVENT_HH__
#define __PYTHON_SWIG_PYEVENT_HH__
#include "sim/eventq.hh"
#include "sim/sim_events.hh"
class PythonEvent : public Event
{
private:
PyObject *object;
public:
PythonEvent(PyObject *obj, Event::Priority priority);
~PythonEvent();
void incref() { Py_INCREF(object); }
void decref() { Py_DECREF(object); }
virtual void process();
};
CountedDrainEvent *createCountedDrain();
void cleanupCountedDrain(Event *counted_drain);
#endif // __PYTHON_SWIG_PYEVENT_HH__

View File

@ -0,0 +1,162 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
#include <Python.h>
#include <string>
#include "base/inifile.hh"
#include "base/output.hh"
#include "dev/etherdevice.hh"
#include "dev/etherint.hh"
#include "dev/etherobject.hh"
#include "mem/mem_object.hh"
#include "mem/port.hh"
#include "sim/full_system.hh"
#include "sim/sim_object.hh"
using namespace std;
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;
}
/**
* Connect the described MemObject ports. Called from Python via SWIG.
* The indices i1 & i2 will be -1 for regular ports, >= 0 for vector ports.
* SimObject1 is the master, and SimObject2 is the slave
*/
int
connectPorts(SimObject *o1, const std::string &name1, int i1,
SimObject *o2, const std::string &name2, int i2)
{
if (FullSystem) {
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;
}
}
}
MemObject *mo1, *mo2;
mo1 = dynamic_cast<MemObject*>(o1);
mo2 = dynamic_cast<MemObject*>(o2);
if(mo1 == NULL || mo2 == NULL) {
panic ("Error casting SimObjects %s and %s to MemObject", o1->name(),
o2->name());
}
// generic master/slave port connection
MasterPort& masterPort = mo1->getMasterPort(name1, i1);
SlavePort& slavePort = mo2->getSlavePort(name2, i2);
masterPort.bind(slavePort);
return 1;
}
inline IniFile &
inifile()
{
static IniFile inifile;
return inifile;
}
/**
* 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 *);
// Python.h is notoriously not const-correct (for 2.4, anyway)... make
// a little define here to reduce the noise and make it easier to
// #ifdef away if Python.h gets fixed. Note there are a couple of
// these in sim/main.cc as well that are handled without this define.
#define PCC(s) const_cast<char *>(s)
SimObject *
resolveSimObject(const string &name)
{
PyObject *module = PyImport_ImportModule(PCC("m5.SimObject"));
if (module == NULL)
panic("Could not import m5.SimObject");
PyObject *resolver =
PyObject_GetAttrString(module, PCC("resolveSimObject"));
if (resolver == NULL) {
PyErr_Print();
panic("resolveSimObject: failed to find resolveSimObject");
}
PyObject *ptr = PyObject_CallFunction(resolver, PCC("(s)"), name.c_str());
if (ptr == NULL) {
PyErr_Print();
panic("resolveSimObject: failure on call to Python for %s", name);
}
SimObject *obj = convertSwigSimObjectPtr(ptr);
if (obj == NULL)
panic("resolveSimObject: failure on pointer conversion for %s", name);
Py_DECREF(module);
Py_DECREF(resolver);
Py_DECREF(ptr);
return obj;
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
#include <Python.h>
#include "base/types.hh"
#include "sim/serialize.hh"
#include "sim/sim_object.hh"
extern "C" SimObject *convertSwigSimObjectPtr(PyObject *);
SimObject *resolveSimObject(const std::string &name);
/**
* 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);
inline void
serializeAll(const std::string &cpt_dir)
{
Serializable::serializeAll(cpt_dir);
}
inline Checkpoint *
getCheckpoint(const std::string &cpt_dir)
{
return new Checkpoint(cpt_dir);
}
inline void
unserializeGlobals(Checkpoint *cp)
{
Serializable::unserializeGlobals(cp);
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
%module(package="m5.internal") pyobject
%{
#include "python/swig/pyobject.hh"
%}
// import these files for SWIG to wrap
%include <std_string.i>
%include <stdint.i>
int connectPorts(SimObject *o1, const std::string &name1, int i1,
SimObject *o2, const std::string &name2, int i2);
%wrapper %{
// Convert a pointer to the Python object that SWIG wraps around a
// C++ SimObject pointer back to the actual C++ pointer.
SimObject *
convertSwigSimObjectPtr(PyObject *pyObj)
{
SimObject *so;
if (SWIG_ConvertPtr(pyObj, (void **) &so, SWIGTYPE_p_SimObject, 0) == -1)
return NULL;
return so;
}
%}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
%module(package="m5.internal") range
%{
#include "base/range.hh"
#include "base/types.hh"
%}
%include <stdint.i>
%rename(assign) *::operator=;
%include "base/range.hh"
%include "base/types.hh"
%template(AddrRange) Range<Addr>;
%template(TickRange) Range<Tick>;

View File

@ -0,0 +1,162 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
%module(package="m5.internal") stats
%include <std_list.i>
%include <std_string.i>
%include <std_vector.i>
%include <stdint.i>
%{
#include "base/stats/text.hh"
#include "base/stats/types.hh"
#include "base/callback.hh"
#include "base/misc.hh"
#include "base/statistics.hh"
#include "sim/core.hh"
#include "sim/stat_control.hh"
namespace Stats {
template <class T>
inline T
cast_info(Info *info)
{
return dynamic_cast<T>(info);
}
inline FlagsType
Stats_Info_flags_get(Info *info)
{
return info->flags;
}
inline void
Stats_Info_flags_set(Info *info, FlagsType flags)
{
info->flags = flags;
}
inline void
processResetQueue()
{
extern CallbackQueue resetQueue;
resetQueue.process();
}
inline void
processDumpQueue()
{
extern CallbackQueue dumpQueue;
dumpQueue.process();
}
inline char *
PCC(const char *string)
{
return const_cast<char *>(string);
}
void
call_module_function(const char *module_name, const char *func_name)
{
PyObject *module = PyImport_ImportModule(PCC(module_name));
if (module == NULL)
panic("Could not import %s", module);
PyObject *result = PyObject_CallMethod(module, PCC(func_name), PCC(""));
if (result == NULL) {
PyErr_Print();
panic("failure on call to function %s", func_name);
}
Py_DECREF(module);
Py_DECREF(result);
}
void
dump()
{
call_module_function("m5.stats", "dump");
}
void
reset()
{
call_module_function("m5.stats", "reset");
}
} // namespace Stats
%}
%extend Stats::Info {
short flags;
}
%ignore Stats::Info::flags;
%import "base/stats/types.hh"
%include "base/stats/info.hh"
%include "base/stats/output.hh"
namespace std {
%template(list_info) list<Stats::Info *>;
%template(vector_double) vector<double>;
%template(vector_string) vector<string>;
%template(vector_DistData) vector<Stats::DistData>;
}
namespace Stats {
template <class T> T cast_info(Info *info);
%template(dynamic_ScalarInfo) cast_info<ScalarInfo *>;
%template(dynamic_VectorInfo) cast_info<VectorInfo *>;
%template(dynamic_DistInfo) cast_info<DistInfo *>;
%template(dynamic_VectorDistInfo) cast_info<VectorDistInfo *>;
%template(dynamic_Vector2dInfo) cast_info<Vector2dInfo *>;
%template(dynamic_FormulaInfo) cast_info<FormulaInfo *>;
%template(dynamic_SparseHistInfo) cast_info<SparseHistInfo *>;
void initSimStats();
Output *initText(const std::string &filename, bool desc);
void schedStatEvent(bool dump, bool reset,
Tick when = curTick(), Tick repeat = 0);
void processResetQueue();
void processDumpQueue();
void enable();
bool enabled();
std::list<Info *> &statsList();
} // namespace Stats

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
%{
#include <sys/time.h>
%}
struct tm {
int tm_sec; /* seconds after the minute [0-60] */
int tm_min; /* minutes after the hour [0-59] */
int tm_hour; /* hours since midnight [0-23] */
int tm_mday; /* day of the month [1-31] */
int tm_mon; /* months since January [0-11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday [0-6] */
int tm_yday; /* days since January 1 [0-365] */
};

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) 2006 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
*/
%module(package="m5.internal") trace
%{
#include "base/trace.hh"
#include "base/types.hh"
inline void
output(const char *filename)
{
Trace::setOutput(filename);
}
inline void
ignore(const char *expr)
{
Trace::ignore.setExpression(expr);
}
using Trace::enabled;
%}
extern void output(const char *string);
extern void ignore(const char *expr);
extern bool enabled;