From 8b4a3f4070f6d0af07c3f08dcdbd8b6aa05e34f4 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 2 Nov 2011 02:11:14 -0700 Subject: [PATCH] SE/FS: Get rid of FULL_SYSTEM in sim. --- src/base/remote_gdb.cc | 1 + src/cpu/BaseCPU.py | 8 +- src/sim/SConscript | 2 +- src/sim/faults.cc | 12 +- src/sim/process.cc | 4 - src/sim/pseudo_inst.cc | 302 +++++++++++++++++++++++------------------ src/sim/pseudo_inst.hh | 67 --------- src/sim/tlb.cc | 16 +-- 8 files changed, 190 insertions(+), 222 deletions(-) diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc index aa13e1f50..77f793769 100644 --- a/src/base/remote_gdb.cc +++ b/src/base/remote_gdb.cc @@ -134,6 +134,7 @@ #include "mem/port.hh" #include "mem/translating_port.hh" #include "mem/vport.hh" +#include "sim/full_system.hh" #include "sim/system.hh" using namespace std; diff --git a/src/cpu/BaseCPU.py b/src/cpu/BaseCPU.py index 277a2c8b4..1ff4c85b4 100644 --- a/src/cpu/BaseCPU.py +++ b/src/cpu/BaseCPU.py @@ -78,10 +78,10 @@ class BaseCPU(MemObject): do_statistics_insts = Param.Bool(True, "enable statistics pseudo instructions") - if buildEnv['FULL_SYSTEM']: - profile = Param.Latency('0ns', "trace the kernel stack") - do_quiesce = Param.Bool(True, "enable quiesce instructions") - else: + profile = Param.Latency('0ns', "trace the kernel stack") + do_quiesce = Param.Bool(True, "enable quiesce instructions") + + if not buildEnv['FULL_SYSTEM']: workload = VectorParam.Process("processes to run") if buildEnv['TARGET_ISA'] == 'sparc': diff --git a/src/sim/SConscript b/src/sim/SConscript index aae3eb5ad..25b965d59 100644 --- a/src/sim/SConscript +++ b/src/sim/SConscript @@ -57,7 +57,7 @@ if env['TARGET_ISA'] != 'no': Source('pseudo_inst.cc') Source('system.cc') -if not env['FULL_SYSTEM'] and env['TARGET_ISA'] != 'no': +if env['TARGET_ISA'] != 'no': Source('tlb.cc') DebugFlag('Checkpoint') diff --git a/src/sim/faults.cc b/src/sim/faults.cc index 6403953db..c409aa95b 100644 --- a/src/sim/faults.cc +++ b/src/sim/faults.cc @@ -36,11 +36,12 @@ #include "debug/Fault.hh" #include "mem/page_table.hh" #include "sim/faults.hh" +#include "sim/full_system.hh" #include "sim/process.hh" void FaultBase::invoke(ThreadContext * tc, StaticInstPtr inst) { - if (FULL_SYSTEM) { + if (FullSystem) { DPRINTF(Fault, "Fault %s at PC: %s\n", name(), tc->pcState()); assert(!tc->misspeculating()); } else { @@ -61,11 +62,10 @@ void ReExec::invoke(ThreadContext *tc, StaticInstPtr inst) void GenericPageTableFault::invoke(ThreadContext *tc, StaticInstPtr inst) { bool handled = false; -#if !FULL_SYSTEM - Process *p = tc->getProcessPtr(); - - handled = p->fixupStackFault(vaddr); -#endif + if (!FullSystem) { + Process *p = tc->getProcessPtr(); + handled = p->fixupStackFault(vaddr); + } if (!handled) panic("Page table fault when accessing virtual address %#x\n", vaddr); diff --git a/src/sim/process.cc b/src/sim/process.cc index f28b1f1ca..68d82362d 100644 --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -570,7 +570,6 @@ LiveProcess::LiveProcess(LiveProcessParams * params, ObjectFile *_objFile) void LiveProcess::syscall(int64_t callnum, ThreadContext *tc) { -#if !FULL_SYSTEM num_syscalls++; SyscallDesc *desc = getDesc(callnum); @@ -578,7 +577,6 @@ LiveProcess::syscall(int64_t callnum, ThreadContext *tc) fatal("Syscall %d out of range", callnum); desc->doSyscall(callnum, this, tc); -#endif } IntReg @@ -604,7 +602,6 @@ LiveProcess::create(LiveProcessParams * params) "executables are supported!\n Please recompile your " "executable as a static binary and try again.\n"); -#if !FULL_SYSTEM #if THE_ISA == ALPHA_ISA if (objFile->getArch() != ObjectFile::Alpha) fatal("Object file architecture does not match compiled ISA (Alpha)."); @@ -714,7 +711,6 @@ LiveProcess::create(LiveProcessParams * params) } #else #error "THE_ISA not set" -#endif #endif if (process == NULL) diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc index 8857e9a66..f8a46cead 100644 --- a/src/sim/pseudo_inst.cc +++ b/src/sim/pseudo_inst.cc @@ -60,6 +60,7 @@ #include "debug/Quiesce.hh" #include "debug/WorkItems.hh" #include "params/BaseCPU.hh" +#include "sim/full_system.hh" #include "sim/pseudo_inst.hh" #include "sim/serialize.hh" #include "sim/sim_events.hh" @@ -76,103 +77,130 @@ using namespace TheISA; namespace PseudoInst { -#if FULL_SYSTEM +static inline void +panicFsOnlyPseudoInst(const char *name) +{ + panic("Pseudo inst \"%s\" is only available in Full System mode."); +} void arm(ThreadContext *tc) { - if (tc->getKernelStats()) - tc->getKernelStats()->arm(); + if (FullSystem) { + if (tc->getKernelStats()) + tc->getKernelStats()->arm(); + } else { + panicFsOnlyPseudoInst("arm"); + } } void quiesce(ThreadContext *tc) { - if (!tc->getCpuPtr()->params()->do_quiesce) - return; + if (FullSystem) { + if (!tc->getCpuPtr()->params()->do_quiesce) + return; - DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name()); + DPRINTF(Quiesce, "%s: quiesce()\n", tc->getCpuPtr()->name()); - tc->suspend(); - if (tc->getKernelStats()) - tc->getKernelStats()->quiesce(); + tc->suspend(); + if (tc->getKernelStats()) + tc->getKernelStats()->quiesce(); + } else { + panicFsOnlyPseudoInst("quiesce"); + } } void quiesceSkip(ThreadContext *tc) { - BaseCPU *cpu = tc->getCpuPtr(); + if (FullSystem) { + 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(); + tc->suspend(); + if (tc->getKernelStats()) + tc->getKernelStats()->quiesce(); + } else { + panicFsOnlyPseudoInst("quiesceSkip"); + } } void quiesceNs(ThreadContext *tc, uint64_t ns) { - BaseCPU *cpu = tc->getCpuPtr(); + if (FullSystem) { + BaseCPU *cpu = tc->getCpuPtr(); - if (!cpu->params()->do_quiesce || ns == 0) - return; + if (!cpu->params()->do_quiesce || ns == 0) + return; - EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); + EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); - Tick resume = curTick() + SimClock::Int::ns * ns; + Tick resume = curTick() + SimClock::Int::ns * ns; - cpu->reschedule(quiesceEvent, resume, true); + cpu->reschedule(quiesceEvent, resume, true); - DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n", - cpu->name(), ns, resume); + DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n", + cpu->name(), ns, resume); - tc->suspend(); - if (tc->getKernelStats()) - tc->getKernelStats()->quiesce(); + tc->suspend(); + if (tc->getKernelStats()) + tc->getKernelStats()->quiesce(); + } else { + panicFsOnlyPseudoInst("quiesceNs"); + } } void quiesceCycles(ThreadContext *tc, uint64_t cycles) { - BaseCPU *cpu = tc->getCpuPtr(); + if (FullSystem) { + BaseCPU *cpu = tc->getCpuPtr(); - if (!cpu->params()->do_quiesce || cycles == 0) - return; + if (!cpu->params()->do_quiesce || cycles == 0) + return; - EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); + EndQuiesceEvent *quiesceEvent = tc->getQuiesceEvent(); - Tick resume = curTick() + cpu->ticks(cycles); + Tick resume = curTick() + cpu->ticks(cycles); - cpu->reschedule(quiesceEvent, resume, true); + cpu->reschedule(quiesceEvent, resume, true); - DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n", - cpu->name(), cycles, resume); + DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n", + cpu->name(), cycles, resume); - tc->suspend(); - if (tc->getKernelStats()) - tc->getKernelStats()->quiesce(); + tc->suspend(); + if (tc->getKernelStats()) + tc->getKernelStats()->quiesce(); + } else { + panicFsOnlyPseudoInst("quiesceCycles"); + } } uint64_t quiesceTime(ThreadContext *tc) { - return (tc->readLastActivate() - tc->readLastSuspend()) / - SimClock::Int::ns; + if (FullSystem) { + return (tc->readLastActivate() - tc->readLastSuspend()) / + SimClock::Int::ns; + } else { + panicFsOnlyPseudoInst("quiesceTime"); + return 0; + } } -#endif - uint64_t rpns(ThreadContext *tc) { @@ -195,77 +223,86 @@ m5exit(ThreadContext *tc, Tick delay) exitSimLoop("m5_exit instruction encountered", 0, when); } -#if FULL_SYSTEM - void loadsymbol(ThreadContext *tc) { - const string &filename = tc->getCpuPtr()->system->params()->symbolfile; - if (filename.empty()) { - return; + if (FullSystem) { + const string &filename = tc->getCpuPtr()->system->params()->symbolfile; + if (filename.empty()) { + return; + } + + std::string buffer; + ifstream file(filename.c_str()); + + if (!file) + fatal("file error: Can't open symbol table file %s\n", filename); + + while (!file.eof()) { + getline(file, buffer); + + if (buffer.empty()) + continue; + + string::size_type idx = buffer.find(' '); + if (idx == string::npos) + continue; + + string address = "0x" + buffer.substr(0, idx); + eat_white(address); + if (address.empty()) + continue; + + // Skip over letter and space + string symbol = buffer.substr(idx + 3); + eat_white(symbol); + if (symbol.empty()) + 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"); } - - std::string buffer; - ifstream file(filename.c_str()); - - if (!file) - fatal("file error: Can't open symbol table file %s\n", filename); - - while (!file.eof()) { - getline(file, buffer); - - if (buffer.empty()) - continue; - - string::size_type idx = buffer.find(' '); - if (idx == string::npos) - continue; - - string address = "0x" + buffer.substr(0, idx); - eat_white(address); - if (address.empty()) - continue; - - // Skip over letter and space - string symbol = buffer.substr(idx + 3); - eat_white(symbol); - if (symbol.empty()) - 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(); } void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr) { - char symb[100]; - CopyStringOut(tc, symb, symbolAddr, 100); - std::string symbol(symb); + if (FullSystem) { + char symb[100]; + CopyStringOut(tc, symb, symbolAddr, 100); + std::string symbol(symb); - DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); + DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); - tc->getSystemPtr()->kernelSymtab->insert(addr,symbol); - debugSymbolTable->insert(addr,symbol); + tc->getSystemPtr()->kernelSymtab->insert(addr,symbol); + debugSymbolTable->insert(addr,symbol); + } else { + panicFsOnlyPseudoInst("addSymbol"); + } } uint64_t initParam(ThreadContext *tc) { - return tc->getCpuPtr()->system->init_param; + if (FullSystem) { + return tc->getCpuPtr()->system->init_param; + } else { + panicFsOnlyPseudoInst("initParam"); + return 0; + } } -#endif - void resetstats(ThreadContext *tc, Tick delay, Tick period) @@ -318,45 +355,46 @@ m5checkpoint(ThreadContext *tc, Tick delay, Tick period) exitSimLoop("checkpoint", 0, when, repeat); } -#if FULL_SYSTEM - uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset) { - const string &file = tc->getSystemPtr()->params()->readfile; - if (file.empty()) { - return ULL(0); + if (FullSystem) { + const string &file = tc->getSystemPtr()->params()->readfile; + if (file.empty()) { + return ULL(0); + } + + uint64_t result = 0; + + int fd = ::open(file.c_str(), O_RDONLY, 0); + if (fd < 0) + panic("could not open file %s\n", file); + + if (::lseek(fd, offset, SEEK_SET) < 0) + panic("could not seek: %s", strerror(errno)); + + char *buf = new char[len]; + char *p = buf; + while (len > 0) { + int bytes = ::read(fd, p, len); + if (bytes <= 0) + break; + + p += bytes; + result += bytes; + len -= bytes; + } + + close(fd); + CopyIn(tc, vaddr, buf, result); + delete [] buf; + return result; + } else { + panicFsOnlyPseudoInst("readfile"); + return 0; } - - uint64_t result = 0; - - int fd = ::open(file.c_str(), O_RDONLY, 0); - if (fd < 0) - panic("could not open file %s\n", file); - - if (::lseek(fd, offset, SEEK_SET) < 0) - panic("could not seek: %s", strerror(errno)); - - char *buf = new char[len]; - char *p = buf; - while (len > 0) { - int bytes = ::read(fd, p, len); - if (bytes <= 0) - break; - - p += bytes; - result += bytes; - len -= bytes; - } - - close(fd); - CopyIn(tc, vaddr, buf, result); - delete [] buf; - return result; } -#endif - void debugbreak(ThreadContext *tc) { diff --git a/src/sim/pseudo_inst.hh b/src/sim/pseudo_inst.hh index 673ec6170..399c88a4f 100644 --- a/src/sim/pseudo_inst.hh +++ b/src/sim/pseudo_inst.hh @@ -45,8 +45,6 @@ extern bool doStatisticsInsts; extern bool doCheckpointInsts; extern bool doQuiesce; -#if FULL_SYSTEM - void arm(ThreadContext *tc); void quiesce(ThreadContext *tc); void quiesceSkip(ThreadContext *tc); @@ -58,71 +56,6 @@ uint64_t readfile(ThreadContext *tc, Addr vaddr, uint64_t len, void loadsymbol(ThreadContext *xc); void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr); uint64_t initParam(ThreadContext *xc); - -#else - -static inline void -panicFsOnlyPseudoInst(const char *name) -{ - panic("Pseudo inst \"%s\" is only available in Full System mode."); -} - -static inline void -arm(ThreadContext *tc) -{ - panicFsOnlyPseudoInst("arm"); -} -static inline void -quiesce(ThreadContext *tc) -{ - panicFsOnlyPseudoInst("quiesce"); -} -static inline void -quiesceSkip(ThreadContext *tc) -{ - panicFsOnlyPseudoInst("quiesceSkip"); -} -static inline void -quiesceNs(ThreadContext *tc, uint64_t ns) -{ - panicFsOnlyPseudoInst("quiesceNs"); -} -static inline void -quiesceCycles(ThreadContext *tc, uint64_t cycles) -{ - panicFsOnlyPseudoInst("quiesceCycles"); -} -static inline uint64_t -quiesceTime(ThreadContext *tc) -{ - panicFsOnlyPseudoInst("quiesceTime"); - return 0; -} -static inline uint64_t -readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset) -{ - panicFsOnlyPseudoInst("readFile"); - return 0; -} -static inline void -loadsymbol(ThreadContext *xc) -{ - panicFsOnlyPseudoInst("loadSymbol"); -} -static inline void -addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr) -{ - panicFsOnlyPseudoInst("addSymbol"); -} -static inline uint64_t -initParam(ThreadContext *tc) -{ - panicFsOnlyPseudoInst("initParam"); - return 0; -} - -#endif - uint64_t rpns(ThreadContext *tc); void wakeCPU(ThreadContext *tc, uint64_t cpuid); void m5exit(ThreadContext *tc, Tick delay); diff --git a/src/sim/tlb.cc b/src/sim/tlb.cc index 8cde0db2e..86428f168 100644 --- a/src/sim/tlb.cc +++ b/src/sim/tlb.cc @@ -31,23 +31,23 @@ #include "cpu/thread_context.hh" #include "mem/page_table.hh" #include "sim/faults.hh" +#include "sim/full_system.hh" #include "sim/process.hh" #include "sim/tlb.hh" Fault GenericTLB::translateAtomic(RequestPtr req, ThreadContext *tc, Mode) { -#if FULL_SYSTEM + if (FullSystem) panic("Generic translation shouldn't be used in full system mode.\n"); -#else - Process * p = tc->getProcessPtr(); - Fault fault = p->pTable->translate(req); - if(fault != NoFault) - return fault; + Process * p = tc->getProcessPtr(); - return NoFault; -#endif + Fault fault = p->pTable->translate(req); + if(fault != NoFault) + return fault; + + return NoFault; } void