diff options
Diffstat (limited to 'src/sim')
-rw-r--r-- | src/sim/pseudo_inst.cc | 273 | ||||
-rw-r--r-- | src/sim/system.cc | 12 |
2 files changed, 139 insertions, 146 deletions
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc index d5bc8fa0e..b72fdca4a 100644 --- a/src/sim/pseudo_inst.cc +++ b/src/sim/pseudo_inst.cc @@ -85,119 +85,114 @@ panicFsOnlyPseudoInst(const char *name) void arm(ThreadContext *tc) { - if (FullSystem) { - if (tc->getKernelStats()) - tc->getKernelStats()->arm(); - } else { + if (!FullSystem) panicFsOnlyPseudoInst("arm"); - } + + if (tc->getKernelStats()) + tc->getKernelStats()->arm(); } void quiesce(ThreadContext *tc) { - if (FullSystem) { - if (!tc->getCpuPtr()->params()->do_quiesce) - return; + if (!FullSystem) + panicFsOnlyPseudoInst("quiesce"); - DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name()); + if (!tc->getCpuPtr()->params()->do_quiesce) + return; - tc->suspend(); - if (tc->getKernelStats()) - tc->getKernelStats()->quiesce(); - } else { - panicFsOnlyPseudoInst("quiesce"); - } + DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name()); + + tc->suspend(); + if (tc->getKernelStats()) + tc->getKernelStats()->quiesce(); } void quiesceSkip(ThreadContext *tc) { - if (FullSystem) { - BaseCPU *cpu = tc->getCpuPtr(); + if (!FullSystem) + panicFsOnlyPseudoInst("quiesceSkip"); + + BaseCPU *cpu = tc->getCpuPtr(); - if (!cpu->params()->do_quiesce) - return; + if (!cpu->params()->do_quiesce) + return; - EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); + EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); - Tick resume = curTick() + 1; + Tick resume = curTick() + 1; - cpu->reschedule(quiesceEvent, resume, true); + cpu->reschedule(quiesceEvent, resume, true); - DPRINTF(Quiesce, "%s: quiesceSkip() until %d\n", - cpu->name(), resume); + DPRINTF(Quiesce, "%s: quiesceSkip() until %d\n", + cpu->name(), resume); - tc->suspend(); - if (tc->getKernelStats()) - tc->getKernelStats()->quiesce(); - } else { - panicFsOnlyPseudoInst("quiesceSkip"); - } + tc->suspend(); + if (tc->getKernelStats()) + tc->getKernelStats()->quiesce(); } void quiesceNs(ThreadContext *tc, uint64_t ns) { - if (FullSystem) { - BaseCPU *cpu = tc->getCpuPtr(); + if (!FullSystem) + panicFsOnlyPseudoInst("quiesceNs"); - if (!cpu->params()->do_quiesce || ns == 0) - return; + BaseCPU *cpu = tc->getCpuPtr(); - EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); + if (!cpu->params()->do_quiesce || ns == 0) + return; - Tick resume = curTick() + SimClock::Int::ns * ns; + EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); - cpu->reschedule(quiesceEvent, resume, true); + Tick resume = curTick() + SimClock::Int::ns * ns; - DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n", - cpu->name(), ns, resume); + cpu->reschedule(quiesceEvent, resume, true); - tc->suspend(); - if (tc->getKernelStats()) - tc->getKernelStats()->quiesce(); - } else { - panicFsOnlyPseudoInst("quiesceNs"); - } + DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n", + cpu->name(), ns, resume); + + tc->suspend(); + if (tc->getKernelStats()) + tc->getKernelStats()->quiesce(); } void quiesceCycles(ThreadContext *tc, uint64_t cycles) { - if (FullSystem) { - BaseCPU *cpu = tc->getCpuPtr(); + if (!FullSystem) + panicFsOnlyPseudoInst("quiesceCycles"); - if (!cpu->params()->do_quiesce || cycles == 0) - return; + BaseCPU *cpu = tc->getCpuPtr(); - EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); + if (!cpu->params()->do_quiesce || cycles == 0) + return; - Tick resume = curTick() + cpu->ticks(cycles); + EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); - cpu->reschedule(quiesceEvent, resume, true); + Tick resume = curTick() + cpu->ticks(cycles); - DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n", - cpu->name(), cycles, resume); + cpu->reschedule(quiesceEvent, resume, true); - tc->suspend(); - if (tc->getKernelStats()) - tc->getKernelStats()->quiesce(); - } else { - panicFsOnlyPseudoInst("quiesceCycles"); - } + DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n", + cpu->name(), cycles, resume); + + tc->suspend(); + if (tc->getKernelStats()) + tc->getKernelStats()->quiesce(); } uint64_t quiesceTime(ThreadContext *tc) { - if (FullSystem) { - return (tc->readLastActivate() - tc->readLastSuspend()) / - SimClock::Int::ns; - } else { + if (!FullSystem) { panicFsOnlyPseudoInst("quiesceTime"); return 0; } + + return (tc->readLastActivate() - tc->readLastSuspend()) / + SimClock::Int::ns; } uint64_t @@ -225,81 +220,79 @@ m5exit(ThreadContext *tc, Tick delay) void loadsymbol(ThreadContext *tc) { - if (FullSystem) { - const string &filename = tc->getCpuPtr()->system->params()->symbolfile; - if (filename.empty()) { - return; - } + if (!FullSystem) + panicFsOnlyPseudoInst("loadsymbol"); - std::string buffer; - ifstream file(filename.c_str()); + const string &filename = tc->getCpuPtr()->system->params()->symbolfile; + if (filename.empty()) { + return; + } - if (!file) - fatal("file error: Can't open symbol table file %s\n", filename); + std::string buffer; + ifstream file(filename.c_str()); - while (!file.eof()) { - getline(file, buffer); + if (!file) + fatal("file error: Can't open symbol table file %s\n", filename); - if (buffer.empty()) - continue; + while (!file.eof()) { + getline(file, buffer); - string::size_type idx = buffer.find(' '); - if (idx == string::npos) - continue; + if (buffer.empty()) + continue; - string address = "0x" + buffer.substr(0, idx); - eat_white(address); - if (address.empty()) - continue; + string::size_type idx = buffer.find(' '); + if (idx == string::npos) + continue; - // Skip over letter and space - string symbol = buffer.substr(idx + 3); - eat_white(symbol); - if (symbol.empty()) - continue; + string address = "0x" + buffer.substr(0, idx); + eat_white(address); + if (address.empty()) + continue; - Addr addr; - if (!to_number(address, addr)) - continue; + // Skip over letter and space + string symbol = buffer.substr(idx + 3); + eat_white(symbol); + if (symbol.empty()) + continue; - if (!tc->getSystemPtr()->kernelSymtab->insert(addr, symbol)) - continue; + Addr addr; + if (!to_number(address, addr)) + continue; + if (!tc->getSystemPtr()->kernelSymtab->insert(addr, symbol)) + continue; - DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); - } - file.close(); - } else { - panicFsOnlyPseudoInst("loadsymbol"); + + DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); } + file.close(); } void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr) { - if (FullSystem) { - char symb[100]; - CopyStringOut(tc, symb, symbolAddr, 100); - std::string symbol(symb); + if (!FullSystem) + panicFsOnlyPseudoInst("addSymbol"); - DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); + char symb[100]; + CopyStringOut(tc, symb, symbolAddr, 100); + std::string symbol(symb); - tc->getSystemPtr()->kernelSymtab->insert(addr,symbol); - debugSymbolTable->insert(addr,symbol); - } else { - panicFsOnlyPseudoInst("addSymbol"); - } + DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); + + tc->getSystemPtr()->kernelSymtab->insert(addr,symbol); + debugSymbolTable->insert(addr,symbol); } uint64_t initParam(ThreadContext *tc) { - if (FullSystem) { - return tc->getCpuPtr()->system->init_param; - } else { + if (!FullSystem) { panicFsOnlyPseudoInst("initParam"); return 0; } + + return tc->getCpuPtr()->system->init_param; } @@ -357,41 +350,41 @@ m5checkpoint(ThreadContext *tc, Tick delay, Tick period) uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset) { - if (FullSystem) { - const string &file = tc->getSystemPtr()->params()->readfile; - if (file.empty()) { - return ULL(0); - } + if (!FullSystem) { + panicFsOnlyPseudoInst("readfile"); + return 0; + } - uint64_t result = 0; + const string &file = tc->getSystemPtr()->params()->readfile; + if (file.empty()) { + return ULL(0); + } - int fd = ::open(file.c_str(), O_RDONLY, 0); - if (fd < 0) - panic("could not open file %s\n", file); + uint64_t result = 0; - if (::lseek(fd, offset, SEEK_SET) < 0) - panic("could not seek: %s", strerror(errno)); + int fd = ::open(file.c_str(), O_RDONLY, 0); + if (fd < 0) + panic("could not open file %s\n", file); - char *buf = new char[len]; - char *p = buf; - while (len > 0) { - int bytes = ::read(fd, p, len); - if (bytes <= 0) - break; + if (::lseek(fd, offset, SEEK_SET) < 0) + panic("could not seek: %s", strerror(errno)); - p += bytes; - result += bytes; - len -= bytes; - } + char *buf = new char[len]; + char *p = buf; + while (len > 0) { + int bytes = ::read(fd, p, len); + if (bytes <= 0) + break; - close(fd); - CopyIn(tc, vaddr, buf, result); - delete [] buf; - return result; - } else { - panicFsOnlyPseudoInst("readfile"); - return 0; + p += bytes; + result += bytes; + len -= bytes; } + + close(fd); + CopyIn(tc, vaddr, buf, result); + delete [] buf; + return result; } void diff --git a/src/sim/system.cc b/src/sim/system.cc index 14c44d063..83610a102 100644 --- a/src/sim/system.cc +++ b/src/sim/system.cc @@ -218,8 +218,8 @@ System::numRunningContexts() void System::initState() { + int i; if (FullSystem) { - int i; for (i = 0; i < threadContexts.size(); i++) TheISA::startupCPU(threadContexts[i], i); // Moved from the constructor to here since it relies on the @@ -271,11 +271,11 @@ System::initState() activeCpus.clear(); - if (FullSystem) { - int i; - for (i = 0; i < threadContexts.size(); i++) - TheISA::startupCPU(threadContexts[i], i); - } + if (!FullSystem) + return; + + for (i = 0; i < threadContexts.size(); i++) + TheISA::startupCPU(threadContexts[i], i); } void |