47 #include "pybind11/pybind11.h" 48 #include "pybind11/stl.h" 66 namespace py = pybind11;
80 py::module
m = py::module::import(
"m5.SimObject");
81 auto f = m.attr(
"resolveSimObject");
103 py::module
m = m_native.def_submodule(
"drain");
105 py::enum_<DrainState>(
m,
"DrainState")
111 py::class_<Drainable, std::unique_ptr<Drainable, py::nodelete>>(
119 py::class_<DrainManager, std::unique_ptr<DrainManager, py::nodelete>>(
128 py::return_value_policy::reference)
135 py::module
m = m_native.def_submodule(
"serialize");
137 py::class_<Serializable, std::unique_ptr<Serializable, py::nodelete>>(
141 py::class_<CheckpointIn>(
m,
"CheckpointIn")
148 py::module
m = m_native.def_submodule(
"range");
150 py::class_<AddrRange>(
m,
"AddrRange")
152 .def(py::init<Addr &, Addr &>())
155 .def(py::init<Addr, Addr, uint8_t, uint8_t, uint8_t, uint8_t>())
173 py::bind_vector<std::vector<AddrRange>>(
m,
"AddrRangeVector");
183 py::module
m = m_native.def_submodule(
"net");
185 py::class_<Net::EthAddr>(
m,
"EthAddr")
187 .def(py::init<const std::string &>())
190 py::class_<Net::IpAddress>(
m,
"IpAddress")
192 .def(py::init<uint32_t>())
195 py::class_<Net::IpNetmask, Net::IpAddress>(
m,
"IpNetmask")
197 .def(py::init<uint32_t, uint8_t>())
200 py::class_<Net::IpWithPort, Net::IpAddress>(
m,
"IpWithPort")
202 .def(py::init<uint32_t, uint16_t>())
209 py::module
m = m_native.def_submodule(
"loader");
217 py::module m_core = m_native.def_submodule(
"core");
219 py::class_<Cycles>(m_core,
"Cycles")
221 .def(py::init<uint64_t>())
222 .def(
"__int__", &Cycles::operator uint64_t)
223 .def(
"__add__", &Cycles::operator+)
224 .def(
"__sub__", &Cycles::operator-)
227 py::class_<tm>(m_core,
"tm")
228 .def_static(
"gmtime", [](std::time_t
t) {
return *std::gmtime(&t); })
229 .def_readwrite(
"tm_sec", &tm::tm_sec)
230 .def_readwrite(
"tm_min", &tm::tm_min)
231 .def_readwrite(
"tm_hour", &tm::tm_hour)
232 .def_readwrite(
"tm_mday", &tm::tm_mday)
233 .def_readwrite(
"tm_mon", &tm::tm_mon)
234 .def_readwrite(
"tm_wday", &tm::tm_wday)
235 .def_readwrite(
"tm_yday", &tm::tm_yday)
236 .def_readwrite(
"tm_isdst", &tm::tm_isdst)
239 py::enum_<Logger::LogLevel>(m_core,
"LogLevel")
255 .def(
"seedRandom", [](uint64_t seed) {
random_mt.
init(seed); })
267 m_core.attr(
"compileDate") = py::cast(
compileDate);
269 m_core.attr(
"flag_DEBUG") = py::cast(
flag_DEBUG);
270 m_core.attr(
"flag_DEBUG") = py::cast(
flag_DEBUG);
271 m_core.attr(
"flag_NDEBUG") = py::cast(
flag_NDEBUG);
274 m_core.attr(
"MaxTick") = py::cast(
MaxTick);
282 .def(
"getCheckpoint", [](
const std::string &cpt_dir) {
283 return new CheckpointIn(cpt_dir, pybindSimObjectResolver);
static void unserializeGlobals(CheckpointIn &cp)
AddrRange RangeSize(Addr start, Addr size)
void pybind_init_core(py::module &m_native)
void preCheckpointRestore()
Run state fixups before a checkpoint restore operation.
const std::string & name()
void setInterpDir(const std::string &dirname)
This is the interface for setting up a base path for the elf interpreter.
static void init_serialize(py::module &m_native)
DrainState state() const
Get the simulators global drain state.
uint64_t granularity() const
Determing the interleaving granularity of the range.
void doExitCleanup()
Do C++ simulator exit processing.
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
DrainState drainState() const
Return the current drain state of an object.
void setClockFrequency(Tick tps)
Resolve a SimObject name using the Pybind configuration.
uint32_t stripes() const
Determine the number of interleaved address stripes this range is part of.
PybindSimObjectResolver pybindSimObjectResolver
static void init_loader(py::module &m_native)
Base class to wrap object resolving functionality.
bool intersects(const AddrRange &r) const
Determine if another range intersects this one, i.e.
static void init_range(py::module &m_native)
bool valid() const
Determine if the range is valid.
static void setLevel(LogLevel ll)
void setOutputDir(const string &dir)
const bool flag_TRACING_ON
Tick curTick()
The current simulated tick.
static bool allDisabled()
Addr end() const
Get the end address of the range.
bool isDrained() const
Check if the system is drained.
bool clockFrequencyFixed()
static void loopbackOnly()
AddrRange RangeIn(Addr start, Addr end)
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Draining buffers pending serialization/handover.
static void init_drain(py::module &m_native)
bool tryDrain()
Try to drain the system.
AddrRange RangeEx(Addr start, Addr end)
bool mergesWith(const AddrRange &r) const
Determine if another range merges with the current one, i.e.
virtual void notifyFork()
Notify a child process of a fork.
bool interleaved() const
Determine if the range is interleaved or not.
static DrainManager & instance()
Get the singleton DrainManager instance.
void resume()
Resume normal simulation in a Drained system.
SimObject * resolveSimObject(const std::string &name)
Addr start() const
Get the start address of the range.
Addr size() const
Get the size of the address range.
std::string to_string() const
Get a string representation of the range.
static void init_net(py::module &m_native)
void signalDrainDone()
Notify the DrainManager that a Drainable object has finished draining.
Abstract superclass for simulation objects.
const FlagsType init
This Stat is Initialized.
static void serializeAll(const std::string &cpt_dir)