54 #include "arch/vtophys.hh" 57 #include "config/the_isa.hh" 61 #include "debug/Loader.hh" 62 #include "debug/Quiesce.hh" 63 #include "debug/WorkItems.hh" 66 #include "params/BaseCPU.hh" 79 using namespace Stats;
87 panic(
"Pseudo inst \"%s\" is only available in Full System mode.");
152 warn(
"PseudoInst::wakeCPU(%i), cpuid greater than number of contexts" 168 exitSimLoop(
"m5_exit instruction encountered", 0, when, 0,
true);
177 exitSimLoop(
"m5_fail instruction encountered", code, when, 0,
true);
188 if (filename.empty()) {
193 ifstream file(filename.c_str());
196 fatal(
"file error: Can't open symbol table file %s\n", filename);
198 while (!file.eof()) {
199 getline(file, buffer);
205 if (idx == string::npos)
208 string address =
"0x" + buffer.substr(0, idx);
214 string symbol = buffer.substr(idx + 3);
227 DPRINTF(Loader,
"Loaded symbol: %s @ %#llx\n", symbol, addr);
243 DPRINTF(Loader,
"Loaded symbol: %s @ %#llx\n", symbol, addr);
262 const int len = 2 *
sizeof(uint64_t) + 1;
264 memset(key_str,
'\0', len);
266 assert(key_str2 == 0);
268 strncpy(key_str, (
char *)&key_str1,
sizeof(uint64_t));
271 if (strlen(key_str) ==
sizeof(uint64_t)) {
272 strncpy(key_str +
sizeof(uint64_t), (
char *)&key_str2,
275 assert(key_str2 == 0);
281 if (strcmp(key_str, InitParamKey::DEFAULT) == 0) {
283 }
else if (strcmp(key_str, InitParamKey::DIST_RANK) == 0) {
285 }
else if (strcmp(key_str, InitParamKey::DIST_SIZE) == 0) {
288 panic(
"Unknown key for initparam pseudo instruction:\"%s\"", key_str);
367 int fd = ::open(file.c_str(), O_RDONLY, 0);
369 panic(
"could not open file %s\n", file);
371 if (::lseek(fd, offset, SEEK_SET) < 0)
372 panic(
"could not seek: %s", strerror(errno));
374 char *buf =
new char[
len];
377 int bytes = ::read(fd, p, len);
397 vaddr, len, offset, filename_addr);
400 std::string filename;
411 out =
simout.
open(filename, ios::in | ios::out | ios::binary,
true);
416 panic(
"could not open file %s\n", filename);
422 char *buf =
new char[
len];
425 if (
os->fail() ||
os->bad())
426 panic(
"Error while doing writefile!\n");
480 if (params->exit_on_work_items) {
481 exitSimLoop(
"workbegin", static_cast<int>(workid));
485 DPRINTF(WorkItems,
"Work Begin workid: %d, threadid %d\n", workid,
494 if (params->work_item_id == -1 || params->work_item_id == workid) {
499 if (params->work_cpus_ckpt_count != 0 &&
500 sys->
markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
507 if (systemWorkBeginCount == params->work_begin_ckpt_count) {
515 if (systemWorkBeginCount == params->work_begin_exit_count) {
522 if (cpuId == params->work_begin_cpu_id_exit) {
543 if (params->exit_on_work_items) {
548 DPRINTF(WorkItems,
"Work End workid: %d, threadid %d\n", workid, threadid);
556 if (params->work_item_id == -1 || params->work_item_id == workid) {
561 if (params->work_cpus_ckpt_count != 0 &&
562 sys->
markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
569 if (params->work_end_ckpt_count != 0 &&
570 systemWorkEndCount == params->work_end_ckpt_count) {
578 if (params->work_end_exit_count != 0 &&
579 systemWorkEndCount == params->work_end_exit_count) {
#define panic(...)
This implements a cprintf based panic() function.
void m5fail(ThreadContext *tc, Tick delay, uint64_t code)
virtual System * getSystemPtr()=0
Cycles is a wrapper class for representing cycle counts, i.e.
void quiesceNs(ThreadContext *tc, uint64_t ns)
#define fatal(...)
This implements a cprintf based fatal() function.
virtual void syscall(Fault *fault)=0
const std::string & name()
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
void arm(ThreadContext *tc)
const Params * params() const
virtual ::Kernel::Statistics * getKernelStats()=0
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
uint64_t incWorkItemsEnd()
Called by pseudo_inst to track the number of work items completed by this system. ...
virtual PortProxy & getVirtProxy()=0
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
uint64_t quiesceTime(ThreadContext *tc)
void quiesceSkip(ThreadContext *tc)
void m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
void workItemEnd(uint32_t tid, uint32_t workid)
SymbolTable * debugSymbolTable
Global unified debugging symbol table (for target).
uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, Addr filename_addr)
Overload hash function for BasicBlockRange type.
virtual BaseCPU * getCpuPtr()=0
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
int cpuId() const
Reads this CPU's ID.
virtual Tick readLastSuspend()=0
static void toggleSync(ThreadContext *tc)
Trigger the master to start/stop synchronization.
ThreadContext is the external interface to all thread state for anything outside of the CPU...
void togglesync(ThreadContext *tc)
void quiesce()
Quiesce thread context.
std::ostream * stream() const
Get the output underlying output stream.
uint64_t initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
Tick curTick()
The current simulated tick.
void quiesce(ThreadContext *tc)
static uint64_t sizeParam()
Getter for the dist size param.
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
uint64_t Tick
Tick count type.
void switchcpu(ThreadContext *tc)
int markWorkItem(int index)
Called by pseudo_inst to mark the cpus actively executing work items.
static bool readyToCkpt(Tick delay, Tick period)
Initiate taking a checkpoint.
std::vector< ThreadContext * > threadContexts
void close(OutputStream *file)
Closes an output file and free the corresponding OutputFile.
unsigned numContexts() const
bool insert(Addr address, std::string symbol)
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
bool to_number(const std::string &value, VecPredRegContainer< NumBits, Packed > &p)
Helper functions used for serialization/de-serialization.
virtual void activate()=0
Set the status to Active.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
#define ULL(N)
uint64_t constant
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...
SymbolTable * kernelSymtab
kernel symbol table
void debugbreak(ThreadContext *tc)
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
void resetstats(ThreadContext *tc, Tick delay, Tick period)
uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
void readString(std::string &str, Addr addr) const
Same as tryReadString, but insists on success.
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 (...
uint64_t incWorkItemsBegin()
Called by pseudo_inst to track the number of work items started by this system.
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
void workItemBegin(uint32_t tid, uint32_t workid)
void eat_white(std::string &s)
void dumpstats(ThreadContext *tc, Tick delay, Tick period)
virtual Tick readLastActivate()=0
virtual Status status() const =0
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
void quiesceTick(Tick resume)
Quiesce, suspend, and schedule activate at resume.
void m5exit(ThreadContext *tc, Tick delay)
static void panicFsOnlyPseudoInst(const char *name)
static uint64_t rankParam()
Getter for the dist rank param.
std::shared_ptr< FaultBase > Fault
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).
const Params * params() const
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
void loadsymbol(ThreadContext *tc)
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
void m5Syscall(ThreadContext *tc)
uint64_t rpns(ThreadContext *tc)