Go to the documentation of this file.
56 #include "config/the_isa.hh"
59 #include "debug/Loader.hh"
60 #include "debug/Quiesce.hh"
61 #include "debug/WorkItems.hh"
63 #include "params/BaseCPU.hh"
74 using namespace Stats;
85 namespace InitParamKey
106 panic(
"Pseudo inst \"%s\" is only available in Full System mode.");
172 warn(
"PseudoInst::wakeCPU(%i), cpuid greater than number of contexts"
188 exitSimLoop(
"m5_exit instruction encountered", 0, when, 0,
true);
195 uint64_t
d, uint64_t
e, uint64_t
f)
199 return a +
b +
c +
d +
e +
f;
207 exitSimLoop(
"m5_fail instruction encountered", code, when, 0,
true);
218 if (filename.empty()) {
223 ifstream file(filename.c_str());
226 fatal(
"file error: Can't open symbol table file %s\n", filename);
228 while (!file.eof()) {
229 getline(file, buffer);
235 if (idx == string::npos)
238 string address =
"0x" + buffer.substr(0, idx);
244 string symbol = buffer.substr(idx + 3);
254 { Loader::Symbol::Binding::Global, symbol, addr })) {
296 const int len = 2 *
sizeof(uint64_t) + 1;
298 memset(key,
'\0',
len);
300 std::array<uint64_t, 2> key_regs = {{ key_str1, key_str2 }};
301 key_regs =
letoh(key_regs);
302 memcpy(key, key_regs.data(),
sizeof(key_regs));
305 const std::string key_str(key);
313 panic(
"Unknown key for initparam pseudo instruction:\"%s\"", key_str);
390 int fd = ::open(file.c_str(), O_RDONLY, 0);
392 panic(
"could not open file %s\n", file);
394 if (::lseek(
fd,
offset, SEEK_SET) < 0)
395 panic(
"could not seek: %s", strerror(errno));
397 char *buf =
new char[
len];
400 int bytes = ::read(
fd,
p,
len);
423 std::string filename;
434 out =
simout.
open(filename, ios::in | ios::out | ios::binary,
true);
439 panic(
"could not open file %s\n", filename);
447 char *buf =
new char[
len];
450 if (
os->fail() ||
os->bad())
451 panic(
"Error while doing writefile!\n");
504 if (params->exit_on_work_items) {
505 exitSimLoop(
"workbegin",
static_cast<int>(workid));
509 DPRINTF(WorkItems,
"Work Begin workid: %d, threadid %d\n", workid,
518 if (params->work_item_id == -1 || params->work_item_id == workid) {
523 if (params->work_cpus_ckpt_count != 0 &&
524 sys->
markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
531 if (systemWorkBeginCount == params->work_begin_ckpt_count) {
539 if (systemWorkBeginCount == params->work_begin_exit_count) {
546 if (cpuId == params->work_begin_cpu_id_exit) {
567 if (params->exit_on_work_items) {
572 DPRINTF(WorkItems,
"Work End workid: %d, threadid %d\n", workid, threadid);
580 if (params->work_item_id == -1 || params->work_item_id == workid) {
585 if (params->work_cpus_ckpt_count != 0 &&
586 sys->
markWorkItem(cpuId) >= params->work_cpus_ckpt_count) {
593 if (params->work_end_ckpt_count != 0 &&
594 systemWorkEndCount == params->work_end_ckpt_count) {
602 if (params->work_end_exit_count != 0 &&
603 systemWorkEndCount == params->work_end_exit_count) {
#define fatal(...)
This implements a cprintf based fatal() function.
void debugbreak(ThreadContext *tc)
void workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
virtual void activate()=0
Set the status to Active.
void quiesce()
Quiesce thread context.
void workItemEnd(uint32_t tid, uint32_t workid)
const std::string DIST_RANK
Unique key for "rank" param (distributed gem5 runs)
void m5Syscall(ThreadContext *tc)
void m5exit(ThreadContext *tc, Tick delay)
uint64_t Tick
Tick count type.
uint64_t rpns(ThreadContext *tc)
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
static void toggleSync(ThreadContext *tc)
Trigger the primary to start/stop synchronization.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
int markWorkItem(int index)
Called by pseudo_inst to mark the cpus actively executing work items.
void workItemBegin(uint32_t tid, uint32_t workid)
uint64_t quiesceTime(ThreadContext *tc)
uint64_t incWorkItemsEnd()
Called by pseudo_inst to track the number of work items completed by this system.
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
void dumpstats(ThreadContext *tc, Tick delay, Tick period)
virtual Tick readLastSuspend()=0
bool to_number(const std::string &value, VecPredRegContainer< NumBits, Packed > &p)
Helper functions used for serialization/de-serialization.
uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
virtual Tick readLastActivate()=0
void switchcpu(ThreadContext *tc)
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
void togglesync(ThreadContext *tc)
const std::string DIST_SIZE
Unique key for "size" param (distributed gem5 runs)
static uint64_t rankParam()
Getter for the dist rank param.
Workload * workload
OS kernel.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
void readString(std::string &str, Addr addr) const
Same as tryReadString, but insists on success.
std::ostream * stream() const
Get the output underlying output stream.
uint64_t initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
void workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
void dumpresetstats(ThreadContext *tc, Tick delay, Tick period)
void quiesceSkip(ThreadContext *tc)
void close(OutputStream *file)
Closes an output file and free the corresponding OutputFile.
virtual bool insertSymbol(const Loader::Symbol &symbol)=0
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.
uint64_t m5sum(ThreadContext *tc, uint64_t a, uint64_t b, uint64_t c, uint64_t d, uint64_t e, uint64_t f)
static void panicFsOnlyPseudoInst(const char *name)
virtual Status status() const =0
void m5fail(ThreadContext *tc, Tick delay, uint64_t code)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
const Params * params() const
uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset, Addr filename_addr)
const std::string & name()
void quiesceTick(Tick resume)
Quiesce, suspend, and schedule activate at resume.
static bool readyToExit(Tick delay)
Initiate the exit from the simulation.
void eat_white(std::string &s)
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
virtual PortProxy & getVirtProxy()=0
@ Suspended
Temporarily inactive.
void quiesce(ThreadContext *tc)
void quiesceCycles(ThreadContext *tc, uint64_t cycles)
Overload hash function for BasicBlockRange type.
const std::string DEFAULT
The default key (empty string)
void wakeCPU(ThreadContext *tc, uint64_t cpuid)
static bool readyToCkpt(Tick delay, Tick period)
Initiate taking a checkpoint.
Cycles is a wrapper class for representing cycle counts, i.e.
void arm(ThreadContext *tc)
void m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
void quiesceNs(ThreadContext *tc, uint64_t ns)
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
bool insert(const Symbol &symbol)
void loadsymbol(ThreadContext *tc)
void resetstats(ThreadContext *tc, Tick delay, Tick period)
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).
void readBlob(Addr addr, void *p, int size) const
Higher level interfaces based on the above.
virtual BaseCPU * getCpuPtr()=0
const Params * params() const
static uint64_t sizeParam()
Getter for the dist size param.
#define ULL(N)
uint64_t constant
int cpuId() const
Reads this CPU's ID.
virtual System * getSystemPtr()=0
#define panic(...)
This implements a cprintf based panic() function.
Tick curTick()
The current simulated tick.
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17