56 #include "config/the_isa.hh" 60 #include "debug/Loader.hh" 61 #include "debug/Quiesce.hh" 62 #include "debug/WorkItems.hh" 65 #include "params/BaseCPU.hh" 77 using namespace Stats;
88 namespace InitParamKey
109 panic(
"Pseudo inst \"%s\" is only available in Full System mode.");
174 warn(
"PseudoInst::wakeCPU(%i), cpuid greater than number of contexts" 190 exitSimLoop(
"m5_exit instruction encountered", 0, when, 0,
true);
199 exitSimLoop(
"m5_fail instruction encountered", code, when, 0,
true);
210 if (filename.empty()) {
215 ifstream file(filename.c_str());
218 fatal(
"file error: Can't open symbol table file %s\n", filename);
220 while (!file.eof()) {
221 getline(file, buffer);
227 if (idx == string::npos)
230 string address =
"0x" + buffer.substr(0, idx);
236 string symbol = buffer.substr(idx + 3);
249 DPRINTF(
Loader,
"Loaded symbol: %s @ %#llx\n", symbol, addr);
265 DPRINTF(
Loader,
"Loaded symbol: %s @ %#llx\n", symbol, addr);
284 const int len = 2 *
sizeof(uint64_t) + 1;
286 memset(key,
'\0', len);
288 std::array<uint64_t, 2> key_regs = {{ key_str1, key_str2 }};
289 key_regs =
letoh(key_regs);
290 memcpy(key, key_regs.data(),
sizeof(key_regs));
293 const std::string key_str(key);
301 panic(
"Unknown key for initparam pseudo instruction:\"%s\"", key_str);
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);
408 vaddr, len, offset, filename_addr);
411 std::string filename;
422 out =
simout.
open(filename, ios::in | ios::out | ios::binary,
true);
427 panic(
"could not open file %s\n", filename);
435 char *buf =
new char[
len];
438 if (
os->fail() ||
os->bad())
439 panic(
"Error while doing writefile!\n");
493 if (params->exit_on_work_items) {
494 exitSimLoop(
"workbegin", static_cast<int>(workid));
498 DPRINTF(WorkItems,
"Work Begin workid: %d, threadid %d\n", workid,
507 if (params->work_item_id == -1 || params->work_item_id == workid) {
512 if (params->work_cpus_ckpt_count != 0 &&
513 sys->
markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
520 if (systemWorkBeginCount == params->work_begin_ckpt_count) {
528 if (systemWorkBeginCount == params->work_begin_exit_count) {
535 if (cpuId == params->work_begin_cpu_id_exit) {
556 if (params->exit_on_work_items) {
561 DPRINTF(WorkItems,
"Work End workid: %d, threadid %d\n", workid, threadid);
569 if (params->work_item_id == -1 || params->work_item_id == workid) {
574 if (params->work_cpus_ckpt_count != 0 &&
575 sys->
markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
582 if (params->work_end_ckpt_count != 0 &&
583 systemWorkEndCount == params->work_end_ckpt_count) {
591 if (params->work_end_exit_count != 0 &&
592 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)
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.
const std::string DIST_RANK
Unique key for "rank" param (distributed gem5 runs)
bool insert(Addr address, std::string symbol)
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
virtual bool insertSymbol(Addr address, const std::string &symbol)=0
const std::string DIST_SIZE
Unique key for "size" param (distributed gem5 runs)
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
const std::string DEFAULT
The default key (empty string)
Workload * workload
OS kernel.
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...
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.
SymbolTable * debugSymbolTable
Global unified debugging symbol table (for target).
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)