SE/FS: Get rid of FULL_SYSTEM in sim.

This commit is contained in:
Gabe Black 2011-11-02 02:11:14 -07:00
parent fb15604f2c
commit 8b4a3f4070
8 changed files with 190 additions and 222 deletions

View file

@ -134,6 +134,7 @@
#include "mem/port.hh" #include "mem/port.hh"
#include "mem/translating_port.hh" #include "mem/translating_port.hh"
#include "mem/vport.hh" #include "mem/vport.hh"
#include "sim/full_system.hh"
#include "sim/system.hh" #include "sim/system.hh"
using namespace std; using namespace std;

View file

@ -78,10 +78,10 @@ class BaseCPU(MemObject):
do_statistics_insts = Param.Bool(True, do_statistics_insts = Param.Bool(True,
"enable statistics pseudo instructions") "enable statistics pseudo instructions")
if buildEnv['FULL_SYSTEM']: profile = Param.Latency('0ns', "trace the kernel stack")
profile = Param.Latency('0ns', "trace the kernel stack") do_quiesce = Param.Bool(True, "enable quiesce instructions")
do_quiesce = Param.Bool(True, "enable quiesce instructions")
else: if not buildEnv['FULL_SYSTEM']:
workload = VectorParam.Process("processes to run") workload = VectorParam.Process("processes to run")
if buildEnv['TARGET_ISA'] == 'sparc': if buildEnv['TARGET_ISA'] == 'sparc':

View file

@ -57,7 +57,7 @@ if env['TARGET_ISA'] != 'no':
Source('pseudo_inst.cc') Source('pseudo_inst.cc')
Source('system.cc') Source('system.cc')
if not env['FULL_SYSTEM'] and env['TARGET_ISA'] != 'no': if env['TARGET_ISA'] != 'no':
Source('tlb.cc') Source('tlb.cc')
DebugFlag('Checkpoint') DebugFlag('Checkpoint')

View file

@ -36,11 +36,12 @@
#include "debug/Fault.hh" #include "debug/Fault.hh"
#include "mem/page_table.hh" #include "mem/page_table.hh"
#include "sim/faults.hh" #include "sim/faults.hh"
#include "sim/full_system.hh"
#include "sim/process.hh" #include "sim/process.hh"
void FaultBase::invoke(ThreadContext * tc, StaticInstPtr inst) void FaultBase::invoke(ThreadContext * tc, StaticInstPtr inst)
{ {
if (FULL_SYSTEM) { if (FullSystem) {
DPRINTF(Fault, "Fault %s at PC: %s\n", name(), tc->pcState()); DPRINTF(Fault, "Fault %s at PC: %s\n", name(), tc->pcState());
assert(!tc->misspeculating()); assert(!tc->misspeculating());
} else { } else {
@ -61,11 +62,10 @@ void ReExec::invoke(ThreadContext *tc, StaticInstPtr inst)
void GenericPageTableFault::invoke(ThreadContext *tc, StaticInstPtr inst) void GenericPageTableFault::invoke(ThreadContext *tc, StaticInstPtr inst)
{ {
bool handled = false; bool handled = false;
#if !FULL_SYSTEM if (!FullSystem) {
Process *p = tc->getProcessPtr(); Process *p = tc->getProcessPtr();
handled = p->fixupStackFault(vaddr);
handled = p->fixupStackFault(vaddr); }
#endif
if (!handled) if (!handled)
panic("Page table fault when accessing virtual address %#x\n", vaddr); panic("Page table fault when accessing virtual address %#x\n", vaddr);

View file

@ -570,7 +570,6 @@ LiveProcess::LiveProcess(LiveProcessParams * params, ObjectFile *_objFile)
void void
LiveProcess::syscall(int64_t callnum, ThreadContext *tc) LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
{ {
#if !FULL_SYSTEM
num_syscalls++; num_syscalls++;
SyscallDesc *desc = getDesc(callnum); SyscallDesc *desc = getDesc(callnum);
@ -578,7 +577,6 @@ LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
fatal("Syscall %d out of range", callnum); fatal("Syscall %d out of range", callnum);
desc->doSyscall(callnum, this, tc); desc->doSyscall(callnum, this, tc);
#endif
} }
IntReg IntReg
@ -604,7 +602,6 @@ LiveProcess::create(LiveProcessParams * params)
"executables are supported!\n Please recompile your " "executables are supported!\n Please recompile your "
"executable as a static binary and try again.\n"); "executable as a static binary and try again.\n");
#if !FULL_SYSTEM
#if THE_ISA == ALPHA_ISA #if THE_ISA == ALPHA_ISA
if (objFile->getArch() != ObjectFile::Alpha) if (objFile->getArch() != ObjectFile::Alpha)
fatal("Object file architecture does not match compiled ISA (Alpha)."); fatal("Object file architecture does not match compiled ISA (Alpha).");
@ -714,7 +711,6 @@ LiveProcess::create(LiveProcessParams * params)
} }
#else #else
#error "THE_ISA not set" #error "THE_ISA not set"
#endif
#endif #endif
if (process == NULL) if (process == NULL)

View file

@ -60,6 +60,7 @@
#include "debug/Quiesce.hh" #include "debug/Quiesce.hh"
#include "debug/WorkItems.hh" #include "debug/WorkItems.hh"
#include "params/BaseCPU.hh" #include "params/BaseCPU.hh"
#include "sim/full_system.hh"
#include "sim/pseudo_inst.hh" #include "sim/pseudo_inst.hh"
#include "sim/serialize.hh" #include "sim/serialize.hh"
#include "sim/sim_events.hh" #include "sim/sim_events.hh"
@ -76,103 +77,130 @@ using namespace TheISA;
namespace PseudoInst { namespace PseudoInst {
#if FULL_SYSTEM static inline void
panicFsOnlyPseudoInst(const char *name)
{
panic("Pseudo inst \"%s\" is only available in Full System mode.");
}
void void
arm(ThreadContext *tc) arm(ThreadContext *tc)
{ {
if (tc->getKernelStats()) if (FullSystem) {
tc->getKernelStats()->arm(); if (tc->getKernelStats())
tc->getKernelStats()->arm();
} else {
panicFsOnlyPseudoInst("arm");
}
} }
void void
quiesce(ThreadContext *tc) quiesce(ThreadContext *tc)
{ {
if (!tc->getCpuPtr()->params()->do_quiesce) if (FullSystem) {
return; 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(); tc->suspend();
if (tc->getKernelStats()) if (tc->getKernelStats())
tc->getKernelStats()->quiesce(); tc->getKernelStats()->quiesce();
} else {
panicFsOnlyPseudoInst("quiesce");
}
} }
void void
quiesceSkip(ThreadContext *tc) quiesceSkip(ThreadContext *tc)
{ {
BaseCPU *cpu = tc->getCpuPtr(); if (FullSystem) {
BaseCPU *cpu = tc->getCpuPtr();
if (!cpu->params()->do_quiesce) if (!cpu->params()->do_quiesce)
return; 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", DPRINTF(Quiesce, "%s: quiesceSkip() until %d\n",
cpu->name(), resume); cpu->name(), resume);
tc->suspend(); tc->suspend();
if (tc->getKernelStats()) if (tc->getKernelStats())
tc->getKernelStats()->quiesce(); tc->getKernelStats()->quiesce();
} else {
panicFsOnlyPseudoInst("quiesceSkip");
}
} }
void void
quiesceNs(ThreadContext *tc, uint64_t ns) quiesceNs(ThreadContext *tc, uint64_t ns)
{ {
BaseCPU *cpu = tc->getCpuPtr(); if (FullSystem) {
BaseCPU *cpu = tc->getCpuPtr();
if (!cpu->params()->do_quiesce || ns == 0) if (!cpu->params()->do_quiesce || ns == 0)
return; 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", DPRINTF(Quiesce, "%s: quiesceNs(%d) until %d\n",
cpu->name(), ns, resume); cpu->name(), ns, resume);
tc->suspend(); tc->suspend();
if (tc->getKernelStats()) if (tc->getKernelStats())
tc->getKernelStats()->quiesce(); tc->getKernelStats()->quiesce();
} else {
panicFsOnlyPseudoInst("quiesceNs");
}
} }
void void
quiesceCycles(ThreadContext *tc, uint64_t cycles) quiesceCycles(ThreadContext *tc, uint64_t cycles)
{ {
BaseCPU *cpu = tc->getCpuPtr(); if (FullSystem) {
BaseCPU *cpu = tc->getCpuPtr();
if (!cpu->params()->do_quiesce || cycles == 0) if (!cpu->params()->do_quiesce || cycles == 0)
return; 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", DPRINTF(Quiesce, "%s: quiesceCycles(%d) until %d\n",
cpu->name(), cycles, resume); cpu->name(), cycles, resume);
tc->suspend(); tc->suspend();
if (tc->getKernelStats()) if (tc->getKernelStats())
tc->getKernelStats()->quiesce(); tc->getKernelStats()->quiesce();
} else {
panicFsOnlyPseudoInst("quiesceCycles");
}
} }
uint64_t uint64_t
quiesceTime(ThreadContext *tc) quiesceTime(ThreadContext *tc)
{ {
return (tc->readLastActivate() - tc->readLastSuspend()) / if (FullSystem) {
SimClock::Int::ns; return (tc->readLastActivate() - tc->readLastSuspend()) /
SimClock::Int::ns;
} else {
panicFsOnlyPseudoInst("quiesceTime");
return 0;
}
} }
#endif
uint64_t uint64_t
rpns(ThreadContext *tc) rpns(ThreadContext *tc)
{ {
@ -195,77 +223,86 @@ m5exit(ThreadContext *tc, Tick delay)
exitSimLoop("m5_exit instruction encountered", 0, when); exitSimLoop("m5_exit instruction encountered", 0, when);
} }
#if FULL_SYSTEM
void void
loadsymbol(ThreadContext *tc) loadsymbol(ThreadContext *tc)
{ {
const string &filename = tc->getCpuPtr()->system->params()->symbolfile; if (FullSystem) {
if (filename.empty()) { const string &filename = tc->getCpuPtr()->system->params()->symbolfile;
return; 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 void
addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr) addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
{ {
char symb[100]; if (FullSystem) {
CopyStringOut(tc, symb, symbolAddr, 100); char symb[100];
std::string symbol(symb); 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); tc->getSystemPtr()->kernelSymtab->insert(addr,symbol);
debugSymbolTable->insert(addr,symbol); debugSymbolTable->insert(addr,symbol);
} else {
panicFsOnlyPseudoInst("addSymbol");
}
} }
uint64_t uint64_t
initParam(ThreadContext *tc) initParam(ThreadContext *tc)
{ {
return tc->getCpuPtr()->system->init_param; if (FullSystem) {
return tc->getCpuPtr()->system->init_param;
} else {
panicFsOnlyPseudoInst("initParam");
return 0;
}
} }
#endif
void void
resetstats(ThreadContext *tc, Tick delay, Tick period) resetstats(ThreadContext *tc, Tick delay, Tick period)
@ -318,45 +355,46 @@ m5checkpoint(ThreadContext *tc, Tick delay, Tick period)
exitSimLoop("checkpoint", 0, when, repeat); exitSimLoop("checkpoint", 0, when, repeat);
} }
#if FULL_SYSTEM
uint64_t uint64_t
readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset) readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
{ {
const string &file = tc->getSystemPtr()->params()->readfile; if (FullSystem) {
if (file.empty()) { const string &file = tc->getSystemPtr()->params()->readfile;
return ULL(0); 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 void
debugbreak(ThreadContext *tc) debugbreak(ThreadContext *tc)
{ {

View file

@ -45,8 +45,6 @@ extern bool doStatisticsInsts;
extern bool doCheckpointInsts; extern bool doCheckpointInsts;
extern bool doQuiesce; extern bool doQuiesce;
#if FULL_SYSTEM
void arm(ThreadContext *tc); void arm(ThreadContext *tc);
void quiesce(ThreadContext *tc); void quiesce(ThreadContext *tc);
void quiesceSkip(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 loadsymbol(ThreadContext *xc);
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr); void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr);
uint64_t initParam(ThreadContext *xc); 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); uint64_t rpns(ThreadContext *tc);
void wakeCPU(ThreadContext *tc, uint64_t cpuid); void wakeCPU(ThreadContext *tc, uint64_t cpuid);
void m5exit(ThreadContext *tc, Tick delay); void m5exit(ThreadContext *tc, Tick delay);

View file

@ -31,23 +31,23 @@
#include "cpu/thread_context.hh" #include "cpu/thread_context.hh"
#include "mem/page_table.hh" #include "mem/page_table.hh"
#include "sim/faults.hh" #include "sim/faults.hh"
#include "sim/full_system.hh"
#include "sim/process.hh" #include "sim/process.hh"
#include "sim/tlb.hh" #include "sim/tlb.hh"
Fault Fault
GenericTLB::translateAtomic(RequestPtr req, ThreadContext *tc, Mode) GenericTLB::translateAtomic(RequestPtr req, ThreadContext *tc, Mode)
{ {
#if FULL_SYSTEM if (FullSystem)
panic("Generic translation shouldn't be used in full system mode.\n"); panic("Generic translation shouldn't be used in full system mode.\n");
#else
Process * p = tc->getProcessPtr();
Fault fault = p->pTable->translate(req); Process * p = tc->getProcessPtr();
if(fault != NoFault)
return fault;
return NoFault; Fault fault = p->pTable->translate(req);
#endif if(fault != NoFault)
return fault;
return NoFault;
} }
void void