#include "base/output.hh"
#include "config/the_isa.hh"
#include "cpu/base.hh"
-#include "cpu/quiesce_event.hh"
#include "cpu/thread_context.hh"
#include "debug/Loader.hh"
#include "debug/Quiesce.hh"
#include "debug/WorkItems.hh"
#include "dev/net/dist_iface.hh"
-#include "kern/kernel_stats.hh"
#include "params/BaseCPU.hh"
-#include "sim/full_system.hh"
#include "sim/process.hh"
#include "sim/serialize.hh"
#include "sim/sim_events.hh"
#include "sim/stat_control.hh"
#include "sim/stats.hh"
#include "sim/system.hh"
-#include "sim/vptr.hh"
-using namespace std;
using namespace Stats;
namespace PseudoInst
} // namespace InitParamKey
-static inline void
-panicFsOnlyPseudoInst(const char *name)
-{
- panic("Pseudo inst \"%s\" is only available in Full System mode.");
-}
-
void
arm(ThreadContext *tc)
{
DPRINTF(PseudoInst, "PseudoInst::arm()\n");
- if (!FullSystem)
- panicFsOnlyPseudoInst("arm");
- if (tc->getKernelStats())
- tc->getKernelStats()->arm();
+ auto *workload = tc->getSystemPtr()->workload;
+ if (workload)
+ workload->recordArm();
}
void
DPRINTF(PseudoInst, "PseudoInst::wakeCPU(%i)\n", cpuid);
System *sys = tc->getSystemPtr();
- if (sys->numContexts() <= cpuid) {
+ if (sys->threads.size() <= cpuid) {
warn("PseudoInst::wakeCPU(%i), cpuid greater than number of contexts"
- "(%i)\n",cpuid, sys->numContexts());
+ "(%i)\n", cpuid, sys->threads.size());
return;
}
- ThreadContext *other_tc = sys->threadContexts[cpuid];
+ ThreadContext *other_tc = sys->threads[cpuid];
if (other_tc->status() == ThreadContext::Suspended)
other_tc->activate();
}
}
}
+// m5sum is for sanity checking the gem5 op interface.
+uint64_t
+m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c,
+ uint64_t d, uint64_t e, uint64_t f)
+{
+ DPRINTF(PseudoInst, "PseudoInst::m5sum(%#x, %#x, %#x, %#x, %#x, %#x)\n",
+ a, b, c, d, e, f);
+ return a + b + c + d + e + f;
+}
+
void
m5fail(ThreadContext *tc, Tick delay, uint64_t code)
{
loadsymbol(ThreadContext *tc)
{
DPRINTF(PseudoInst, "PseudoInst::loadsymbol()\n");
- if (!FullSystem)
- panicFsOnlyPseudoInst("loadsymbol");
- const string &filename = tc->getCpuPtr()->system->params()->symbolfile;
+ const std::string &filename = tc->getCpuPtr()->system->params().symbolfile;
if (filename.empty()) {
return;
}
std::string buffer;
- ifstream file(filename.c_str());
+ std::ifstream file(filename.c_str());
if (!file)
fatal("file error: Can't open symbol table file %s\n", filename);
if (buffer.empty())
continue;
- string::size_type idx = buffer.find(' ');
- if (idx == string::npos)
+ std::string::size_type idx = buffer.find(' ');
+ if (idx == std::string::npos)
continue;
- string address = "0x" + buffer.substr(0, idx);
+ std::string address = "0x" + buffer.substr(0, idx);
eat_white(address);
if (address.empty())
continue;
// Skip over letter and space
- string symbol = buffer.substr(idx + 3);
+ std::string symbol = buffer.substr(idx + 3);
eat_white(symbol);
if (symbol.empty())
continue;
if (!to_number(address, addr))
continue;
- if (!tc->getSystemPtr()->workload->insertSymbol(addr, symbol))
+ if (!tc->getSystemPtr()->workload->insertSymbol(
+ { Loader::Symbol::Binding::Global, symbol, addr })) {
continue;
+ }
DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
{
DPRINTF(PseudoInst, "PseudoInst::addsymbol(0x%x, 0x%x)\n",
addr, symbolAddr);
- if (!FullSystem)
- panicFsOnlyPseudoInst("addSymbol");
std::string symbol;
tc->getVirtProxy().readString(symbol, symbolAddr);
DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
- tc->getSystemPtr()->workload->insertSymbol(addr, symbol);
- Loader::debugSymbolTable->insert(addr, symbol);
+ tc->getSystemPtr()->workload->insertSymbol(
+ { Loader::Symbol::Binding::Global, symbol, addr });
+ Loader::debugSymbolTable.insert(
+ { Loader::Symbol::Binding::Global, symbol, addr });
}
uint64_t
{
DPRINTF(PseudoInst, "PseudoInst::initParam() key:%s%s\n", (char *)&key_str1,
(char *)&key_str2);
- if (!FullSystem) {
- panicFsOnlyPseudoInst("initParam");
- return 0;
- }
// The key parameter string is passed in via two 64-bit registers. We copy
// out the characters from the 64-bit integer variables here, and
// concatenate them in the key character buffer
const int len = 2 * sizeof(uint64_t) + 1;
char key[len];
- memset(key, '\0', len);
+ std::memset(key, '\0', len);
- std::array<uint64_t, 2> key_regs = { key_str1, key_str2 };
+ std::array<uint64_t, 2> key_regs = {{ key_str1, key_str2 }};
key_regs = letoh(key_regs);
- memcpy(key, key_regs.data(), sizeof(key_regs));
+ std::memcpy(key, key_regs.data(), sizeof(key_regs));
// Check key parameter to figure out what to return.
const std::string key_str(key);
resetstats(ThreadContext *tc, Tick delay, Tick period)
{
DPRINTF(PseudoInst, "PseudoInst::resetstats(%i, %i)\n", delay, period);
- if (!tc->getCpuPtr()->params()->do_statistics_insts)
+ if (!tc->getCpuPtr()->params().do_statistics_insts)
return;
dumpstats(ThreadContext *tc, Tick delay, Tick period)
{
DPRINTF(PseudoInst, "PseudoInst::dumpstats(%i, %i)\n", delay, period);
- if (!tc->getCpuPtr()->params()->do_statistics_insts)
+ if (!tc->getCpuPtr()->params().do_statistics_insts)
return;
dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
{
DPRINTF(PseudoInst, "PseudoInst::dumpresetstats(%i, %i)\n", delay, period);
- if (!tc->getCpuPtr()->params()->do_statistics_insts)
+ if (!tc->getCpuPtr()->params().do_statistics_insts)
return;
m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
{
DPRINTF(PseudoInst, "PseudoInst::m5checkpoint(%i, %i)\n", delay, period);
- if (!tc->getCpuPtr()->params()->do_checkpoint_insts)
+ if (!tc->getCpuPtr()->params().do_checkpoint_insts)
return;
if (DistIface::readyToCkpt(delay, period)) {
{
DPRINTF(PseudoInst, "PseudoInst::readfile(0x%x, 0x%x, 0x%x)\n",
vaddr, len, offset);
- if (!FullSystem) {
- panicFsOnlyPseudoInst("readfile");
- return 0;
- }
- const string &file = tc->getSystemPtr()->params()->readfile;
+ const std::string &file = tc->getSystemPtr()->params().readfile;
if (file.empty()) {
return ULL(0);
}
// do not truncate file if offset is non-zero
// (ios::in flag is required as well to keep the existing data
// intact, otherwise existing data will be zeroed out.)
- out = simout.open(filename, ios::in | ios::out | ios::binary, true);
+ out = simout.open(filename,
+ std::ios::in | std::ios::out | std::ios::binary, true);
}
- ostream *os(out->stream());
+ std::ostream *os(out->stream());
if (!os)
panic("could not open file %s\n", filename);
exitSimLoop("switchcpu");
}
-/*
- * This function is executed when the simulation is executing the syscall
- * handler in System Emulation mode.
- */
void
-m5Syscall(ThreadContext *tc)
+togglesync(ThreadContext *tc)
{
- DPRINTF(PseudoInst, "PseudoInst::m5Syscall()\n");
- Fault fault;
- tc->syscall(&fault);
+ DPRINTF(PseudoInst, "PseudoInst::togglesync()\n");
+ DistIface::toggleSync(tc);
}
void
-togglesync(ThreadContext *tc)
+triggerWorkloadEvent(ThreadContext *tc)
{
- DPRINTF(PseudoInst, "PseudoInst::togglesync()\n");
- DistIface::toggleSync(tc);
+ DPRINTF(PseudoInst, "PseudoInst::triggerWorkloadEvent()\n");
+ tc->getSystemPtr()->workload->event(tc);
}
//
{
DPRINTF(PseudoInst, "PseudoInst::workbegin(%i, %i)\n", workid, threadid);
System *sys = tc->getSystemPtr();
- const System::Params *params = sys->params();
+ const System::Params ¶ms = sys->params();
- if (params->exit_on_work_items) {
+ if (params.exit_on_work_items) {
exitSimLoop("workbegin", static_cast<int>(workid));
return;
}
// If specified, determine if this is the specific work item the user
// identified
//
- if (params->work_item_id == -1 || params->work_item_id == workid) {
+ if (params.work_item_id == -1 || params.work_item_id == workid) {
uint64_t systemWorkBeginCount = sys->incWorkItemsBegin();
int cpuId = tc->getCpuPtr()->cpuId();
- if (params->work_cpus_ckpt_count != 0 &&
- sys->markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
+ if (params.work_cpus_ckpt_count != 0 &&
+ sys->markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
//
// If active cpus equals checkpoint count, create checkpoint
//
exitSimLoop("checkpoint");
}
- if (systemWorkBeginCount == params->work_begin_ckpt_count) {
+ if (systemWorkBeginCount == params.work_begin_ckpt_count) {
//
// Note: the string specified as the cause of the exit event must
// exactly equal "checkpoint" inorder to create a checkpoint
exitSimLoop("checkpoint");
}
- if (systemWorkBeginCount == params->work_begin_exit_count) {
+ if (systemWorkBeginCount == params.work_begin_exit_count) {
//
// If a certain number of work items started, exit simulation
//
exitSimLoop("work started count reach");
}
- if (cpuId == params->work_begin_cpu_id_exit) {
+ if (cpuId == params.work_begin_cpu_id_exit) {
//
// If work started on the cpu id specified, exit simulation
//
{
DPRINTF(PseudoInst, "PseudoInst::workend(%i, %i)\n", workid, threadid);
System *sys = tc->getSystemPtr();
- const System::Params *params = sys->params();
+ const System::Params ¶ms = sys->params();
- if (params->exit_on_work_items) {
+ if (params.exit_on_work_items) {
exitSimLoop("workend", static_cast<int>(workid));
return;
}
// If specified, determine if this is the specific work item the user
// identified
//
- if (params->work_item_id == -1 || params->work_item_id == workid) {
+ if (params.work_item_id == -1 || params.work_item_id == workid) {
uint64_t systemWorkEndCount = sys->incWorkItemsEnd();
int cpuId = tc->getCpuPtr()->cpuId();
- if (params->work_cpus_ckpt_count != 0 &&
- sys->markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
+ if (params.work_cpus_ckpt_count != 0 &&
+ sys->markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
//
// If active cpus equals checkpoint count, create checkpoint
//
exitSimLoop("checkpoint");
}
- if (params->work_end_ckpt_count != 0 &&
- systemWorkEndCount == params->work_end_ckpt_count) {
+ if (params.work_end_ckpt_count != 0 &&
+ systemWorkEndCount == params.work_end_ckpt_count) {
//
// If total work items completed equals checkpoint count, create
// checkpoint
exitSimLoop("checkpoint");
}
- if (params->work_end_exit_count != 0 &&
- systemWorkEndCount == params->work_end_exit_count) {
+ if (params.work_end_exit_count != 0 &&
+ systemWorkEndCount == params.work_end_exit_count) {
//
// If total work items completed equals exit count, exit simulation
//