58#include "debug/Loader.hh"
59#include "debug/Quiesce.hh"
60#include "debug/WorkItems.hh"
64#include "params/BaseCPU.hh"
77using namespace statistics;
94const std::string DEFAULT =
"";
98const std::string DIST_RANK =
"dist-rank";
102const std::string DIST_SIZE =
"dist-size";
109 DPRINTF(PseudoInst,
"pseudo_inst::arm()\n");
119 DPRINTF(PseudoInst,
"pseudo_inst::quiesce()\n");
126 DPRINTF(PseudoInst,
"pseudo_inst::quiesceSkip()\n");
133 DPRINTF(PseudoInst,
"pseudo_inst::quiesceNs(%i)\n",
ns);
140 DPRINTF(PseudoInst,
"pseudo_inst::quiesceCycles(%i)\n", cycles);
147 DPRINTF(PseudoInst,
"pseudo_inst::quiesceTime()\n");
156 DPRINTF(PseudoInst,
"pseudo_inst::rpns()\n");
163 DPRINTF(PseudoInst,
"pseudo_inst::wakeCPU(%i)\n",
cpuid);
167 warn(
"pseudo_inst::wakeCPU(%i), cpuid greater than number of contexts"
180 DPRINTF(PseudoInst,
"pseudo_inst::m5exit(%i)\n", delay);
183 exitSimLoop(
"m5_exit instruction encountered", 0, when, 0,
true);
190 uint64_t
d, uint64_t
e, uint64_t
f)
192 DPRINTF(PseudoInst,
"pseudo_inst::m5sum(%#x, %#x, %#x, %#x, %#x, %#x)\n",
194 return a +
b +
c +
d +
e +
f;
200 DPRINTF(PseudoInst,
"pseudo_inst::m5fail(%i, %i)\n", delay, code);
202 exitSimLoop(
"m5_fail instruction encountered", code, when, 0,
true);
208 DPRINTF(PseudoInst,
"pseudo_inst::loadsymbol()\n");
211 if (filename.empty()) {
216 std::ifstream file(filename.c_str());
219 fatal(
"file error: Can't open symbol table file %s\n", filename);
221 while (!file.eof()) {
222 getline(file, buffer);
227 std::string::size_type idx = buffer.find(
' ');
228 if (idx == std::string::npos)
231 std::string address =
"0x" + buffer.substr(0, idx);
237 std::string symbol = buffer.substr(idx + 3);
247 { loader::Symbol::Binding::Global, symbol, addr })) {
252 DPRINTF(Loader,
"Loaded symbol: %s @ %#llx\n", symbol,
addr);
260 DPRINTF(PseudoInst,
"pseudo_inst::addsymbol(0x%x, 0x%x)\n",
270 DPRINTF(Loader,
"Loaded symbol: %s @ %#llx\n", symbol,
addr);
281 DPRINTF(PseudoInst,
"pseudo_inst::initParam() key:%s%s\n",
282 (
char *)&key_str1, (
char *)&key_str2);
287 const int len = 2 *
sizeof(uint64_t) + 1;
289 std::memset(key,
'\0',
len);
291 std::array<uint64_t, 2> key_regs = {{ key_str1, key_str2 }};
292 key_regs =
letoh(key_regs);
293 std::memcpy(key, key_regs.data(),
sizeof(key_regs));
296 const std::string key_str(key);
299 else if (key == DIST_RANK)
301 else if (key == DIST_SIZE)
304 panic(
"Unknown key for initparam pseudo instruction:\"%s\"", key_str);
311 DPRINTF(PseudoInst,
"pseudo_inst::resetstats(%i, %i)\n", delay, period);
325 DPRINTF(PseudoInst,
"pseudo_inst::dumpstats(%i, %i)\n", delay, period);
339 DPRINTF(PseudoInst,
"pseudo_inst::dumpresetstats(%i, %i)\n", delay,
354 DPRINTF(PseudoInst,
"pseudo_inst::m5checkpoint(%i, %i)\n", delay, period);
368 DPRINTF(PseudoInst,
"pseudo_inst::readfile(0x%x, 0x%x, 0x%x)\n",
378 int fd = ::open(file.c_str(), O_RDONLY, 0);
380 panic(
"could not open file %s\n", file);
382 if (::lseek(
fd,
offset, SEEK_SET) < 0)
383 panic(
"could not seek: %s", strerror(errno));
385 char *buf =
new char[
len];
388 int bytes = ::read(
fd,
p,
len);
411 DPRINTF(PseudoInst,
"pseudo_inst::writefile(0x%x, 0x%x, 0x%x, 0x%x)\n",
415 std::string filename;
420 virt_proxy.
readString(filename, filename_addr);
431 std::ios::in | std::ios::out | std::ios::binary,
true);
436 panic(
"could not open file %s\n", filename);
444 char *buf =
new char[
len];
448 if (
os->fail() ||
os->bad())
449 panic(
"Error while doing writefile!\n");
461 DPRINTF(PseudoInst,
"pseudo_inst::debugbreak()\n");
468 DPRINTF(PseudoInst,
"pseudo_inst::switchcpu()\n");
475 DPRINTF(PseudoInst,
"pseudo_inst::togglesync()\n");
482 DPRINTF(PseudoInst,
"pseudo_inst::triggerWorkloadEvent()\n");
494 DPRINTF(PseudoInst,
"pseudo_inst::workbegin(%i, %i)\n", workid, threadid);
498 if (params.exit_on_work_items) {
499 exitSimLoop(
"workbegin",
static_cast<int>(workid));
503 DPRINTF(WorkItems,
"Work Begin workid: %d, threadid %d\n", workid,
512 if (params.work_item_id == -1 || params.work_item_id == workid) {
517 if (params.work_cpus_ckpt_count != 0 &&
518 sys->
markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
525 if (systemWorkBeginCount == params.work_begin_ckpt_count) {
533 if (systemWorkBeginCount == params.work_begin_exit_count) {
540 if (cpuId == params.work_begin_cpu_id_exit) {
557 DPRINTF(PseudoInst,
"pseudo_inst::workend(%i, %i)\n", workid, threadid);
561 if (params.exit_on_work_items) {
566 DPRINTF(WorkItems,
"Work End workid: %d, threadid %d\n", workid, threadid);
574 if (params.work_item_id == -1 || params.work_item_id == workid) {
579 if (params.work_cpus_ckpt_count != 0 &&
580 sys->
markWorkItem(cpuId) >= params.work_cpus_ckpt_count) {
587 if (params.work_end_ckpt_count != 0 &&
588 systemWorkEndCount == params.work_end_ckpt_count) {
596 if (params.work_end_exit_count != 0 &&
597 systemWorkEndCount == params.work_end_exit_count) {
int cpuId() const
Reads this CPU's ID.
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
Cycles is a wrapper class for representing cycle counts, i.e.
static uint64_t rankParam()
Getter for the dist rank param.
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
static void toggleSync(ThreadContext *tc)
Trigger the primary to start/stop synchronization.
static bool readyToCkpt(Tick delay, Tick period)
Initiate taking a checkpoint.
static uint64_t sizeParam()
Getter for the dist size param.
void close(OutputStream *file)
Closes an output file and free the corresponding OutputFile.
OutputStream * open(const std::string &name, std::ios_base::openmode mode, bool recreateable=true, bool no_gz=false)
Open a file in this directory (optionally compressed).
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
std::ostream * stream() const
Get the output underlying output stream.
This object is a proxy for a port or other object which implements the functional response protocol,...
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
void readString(std::string &str, Addr addr) const
Same as tryReadString, but insists on success.
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
int markWorkItem(int index)
Called by pseudo_inst to mark the cpus actively executing work items.
uint64_t incWorkItemsEnd()
Called by pseudo_inst to track the number of work items completed by this system.
uint64_t incWorkItemsBegin()
Called by pseudo_inst to track the number of work items started by this system.
void workItemEnd(uint32_t tid, uint32_t workid)
Workload * workload
OS kernel.
void workItemBegin(uint32_t tid, uint32_t workid)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void activate()=0
Set the status to Active.
virtual System * getSystemPtr()=0
virtual BaseCPU * getCpuPtr()=0
virtual Tick readLastActivate()=0
void quiesceTick(Tick resume)
Quiesce, suspend, and schedule activate at resume.
virtual Tick readLastSuspend()=0
void quiesce()
Quiesce thread context.
@ Suspended
Temporarily inactive.
virtual Status status() const =0
This proxy attempts to translate virtual addresses using the TLBs.
virtual void event(ThreadContext *tc)
virtual bool insertSymbol(const loader::Symbol &symbol)=0
bool insert(const Symbol &symbol)
Insert a new symbol in the table if it does not already exist.
#define panic(...)
This implements a cprintf based panic() function.
#define fatal(...)
This implements a cprintf based fatal() function.
const Params & params() const
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
uint64_t m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f)
uint64_t rpns(ThreadContext *tc)
void loadsymbol(ThreadContext *tc)
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
void arm(ThreadContext *tc)
void debugbreak(ThreadContext *tc)
void m5fail(ThreadContext *tc, Tick delay, uint64_t code)
void quiesce(ThreadContext *tc)
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, Addr filename_addr)
uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
void quiesceNs(ThreadContext *tc, uint64_t ns)
void m5exit(ThreadContext *tc, Tick delay)
void quiesceSkip(ThreadContext *tc)
void togglesync(ThreadContext *tc)
void resetstats(ThreadContext *tc, Tick delay, Tick period)
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
uint64_t initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
void triggerWorkloadEvent(ThreadContext *tc)
uint64_t quiesceTime(ThreadContext *tc)
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
void m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
void switchcpu(ThreadContext *tc)
void dumpstats(ThreadContext *tc, Tick delay, Tick period)
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
bool to_number(const std::string &value, Pixel &retval)
Tick curTick()
The universal simulation clock.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
uint64_t Tick
Tick count type.
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
void eat_white(std::string &s)