SE/FS: Build the base process class in FS.

This commit is contained in:
Gabe Black 2011-10-30 00:32:54 -07:00
parent ca36c01f7e
commit 5b433568f0
16 changed files with 37 additions and 145 deletions

View file

@ -267,7 +267,7 @@ InOrderCPU::InOrderCPU(Params *params)
#if FULL_SYSTEM #if FULL_SYSTEM
// SMT is not supported in FS mode yet. // SMT is not supported in FS mode yet.
assert(numThreads == 1); assert(numThreads == 1);
thread[tid] = new Thread(this, 0); thread[tid] = new Thread(this, 0, NULL);
#else #else
if (tid < (ThreadID)params->workload.size()) { if (tid < (ThreadID)params->workload.size()) {
DPRINTF(InOrderCPU, "Workload[%i] process is %#x\n", DPRINTF(InOrderCPU, "Workload[%i] process is %#x\n",

View file

@ -48,8 +48,8 @@ class FunctionProfile;
class ProfileNode; class ProfileNode;
#else #else
class FunctionalMemory; class FunctionalMemory;
class Process;
#endif #endif
class Process;
/** /**
* Class that has various thread state, such as the status, the * Class that has various thread state, such as the status, the
@ -76,24 +76,15 @@ class InOrderThreadState : public ThreadState {
*/ */
bool trapPending; bool trapPending;
#if FULL_SYSTEM
InOrderThreadState(InOrderCPU *_cpu, ThreadID _thread_num)
: ThreadState(reinterpret_cast<BaseCPU*>(_cpu), _thread_num),
cpu(_cpu), inSyscall(0), trapPending(0), lastGradIsBranch(false)
{ }
#else
InOrderThreadState(InOrderCPU *_cpu, ThreadID _thread_num, InOrderThreadState(InOrderCPU *_cpu, ThreadID _thread_num,
Process *_process) Process *_process)
: ThreadState(reinterpret_cast<BaseCPU*>(_cpu), _thread_num, : ThreadState(reinterpret_cast<BaseCPU*>(_cpu), _thread_num,
_process), _process),
cpu(_cpu), inSyscall(0), trapPending(0), lastGradIsBranch(false) cpu(_cpu), inSyscall(0), trapPending(0), lastGradIsBranch(false)
{ } { }
#endif
#if !FULL_SYSTEM
/** Handles the syscall. */ /** Handles the syscall. */
void syscall(int64_t callnum) { process->syscall(callnum, tc); } void syscall(int64_t callnum) { process->syscall(callnum, tc); }
#endif
#if FULL_SYSTEM #if FULL_SYSTEM
void dumpFuncProfile(); void dumpFuncProfile();

View file

@ -357,7 +357,7 @@ FullO3CPU<Impl>::FullO3CPU(DerivO3CPUParams *params)
#if FULL_SYSTEM #if FULL_SYSTEM
// SMT is not supported in FS mode yet. // SMT is not supported in FS mode yet.
assert(this->numThreads == 1); assert(this->numThreads == 1);
this->thread[tid] = new Thread(this, 0); this->thread[tid] = new Thread(this, 0, NULL);
#else #else
if (tid < params->workload.size()) { if (tid < params->workload.size()) {
DPRINTF(O3CPU, "Workload[%i] process is %#x", DPRINTF(O3CPU, "Workload[%i] process is %#x",

View file

@ -75,11 +75,11 @@ struct O3ThreadState : public ThreadState {
*/ */
bool trapPending; bool trapPending;
#if FULL_SYSTEM O3ThreadState(O3CPU *_cpu, int _thread_num, Process *_process)
O3ThreadState(O3CPU *_cpu, int _thread_num) : ThreadState(_cpu, _thread_num, _process),
: ThreadState(_cpu, _thread_num),
cpu(_cpu), inSyscall(0), trapPending(0) cpu(_cpu), inSyscall(0), trapPending(0)
{ {
#if FULL_SYSTEM
if (cpu->params()->profile) { if (cpu->params()->profile) {
profile = new FunctionProfile(cpu->params()->system->kernelSymtab); profile = new FunctionProfile(cpu->params()->system->kernelSymtab);
Callback *cb = Callback *cb =
@ -93,13 +93,8 @@ struct O3ThreadState : public ThreadState {
static ProfileNode dummyNode; static ProfileNode dummyNode;
profileNode = &dummyNode; profileNode = &dummyNode;
profilePC = 3; profilePC = 3;
}
#else
O3ThreadState(O3CPU *_cpu, int _thread_num, Process *_process)
: ThreadState(_cpu, _thread_num, _process),
cpu(_cpu), inSyscall(0), trapPending(0)
{ }
#endif #endif
}
/** Pointer to the ThreadContext of this thread. */ /** Pointer to the ThreadContext of this thread. */
ThreadContext *tc; ThreadContext *tc;

View file

@ -62,11 +62,20 @@
using namespace std; using namespace std;
// constructor // constructor
#if FULL_SYSTEM #if !FULL_SYSTEM
SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process,
TheISA::TLB *_itb, TheISA::TLB *_dtb)
: ThreadState(_cpu, _thread_num, _process),
cpu(_cpu), itb(_itb), dtb(_dtb)
{
clearArchRegs();
tc = new ProxyThreadContext<SimpleThread>(this);
}
#else
SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys, SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys,
TheISA::TLB *_itb, TheISA::TLB *_dtb, TheISA::TLB *_itb, TheISA::TLB *_dtb,
bool use_kernel_stats) bool use_kernel_stats)
: ThreadState(_cpu, _thread_num), : ThreadState(_cpu, _thread_num, NULL),
cpu(_cpu), system(_sys), itb(_itb), dtb(_dtb) cpu(_cpu), system(_sys), itb(_itb), dtb(_dtb)
{ {
@ -93,24 +102,10 @@ SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, System *_sys,
if (use_kernel_stats) if (use_kernel_stats)
kernelStats = new TheISA::Kernel::Statistics(system); kernelStats = new TheISA::Kernel::Statistics(system);
} }
#else
SimpleThread::SimpleThread(BaseCPU *_cpu, int _thread_num, Process *_process,
TheISA::TLB *_itb, TheISA::TLB *_dtb)
: ThreadState(_cpu, _thread_num, _process),
cpu(_cpu), itb(_itb), dtb(_dtb)
{
clearArchRegs();
tc = new ProxyThreadContext<SimpleThread>(this);
}
#endif #endif
SimpleThread::SimpleThread() SimpleThread::SimpleThread()
#if FULL_SYSTEM
: ThreadState(NULL, -1)
#else
: ThreadState(NULL, -1, NULL) : ThreadState(NULL, -1, NULL)
#endif
{ {
tc = new ProxyThreadContext<SimpleThread>(this); tc = new ProxyThreadContext<SimpleThread>(this);
} }

View file

@ -42,32 +42,24 @@
#include "cpu/quiesce_event.hh" #include "cpu/quiesce_event.hh"
#endif #endif
#if FULL_SYSTEM
ThreadState::ThreadState(BaseCPU *cpu, ThreadID _tid)
#else
ThreadState::ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process) ThreadState::ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process)
#endif
: numInst(0), numLoad(0), _status(ThreadContext::Halted), : numInst(0), numLoad(0), _status(ThreadContext::Halted),
baseCpu(cpu), _threadId(_tid), lastActivate(0), lastSuspend(0), baseCpu(cpu), _threadId(_tid), lastActivate(0), lastSuspend(0),
#if FULL_SYSTEM #if FULL_SYSTEM
profile(NULL), profileNode(NULL), profilePC(0), quiesceEvent(NULL), profile(NULL), profileNode(NULL), profilePC(0), quiesceEvent(NULL),
kernelStats(NULL), kernelStats(NULL),
#else
process(_process),
#endif #endif
port(NULL), virtPort(NULL), physPort(NULL), funcExeInst(0), process(_process), port(NULL), virtPort(NULL), physPort(NULL),
storeCondFailures(0) funcExeInst(0), storeCondFailures(0)
{ {
} }
ThreadState::~ThreadState() ThreadState::~ThreadState()
{ {
#if !FULL_SYSTEM
if (port) { if (port) {
delete port->getPeer(); delete port->getPeer();
delete port; delete port;
} }
#endif
} }
void void
@ -164,11 +156,7 @@ ThreadState::getMemPort()
/* Use this port to for syscall emulation writes to memory. */ /* Use this port to for syscall emulation writes to memory. */
port = new TranslatingPort(csprintf("%s-%d-funcport", baseCpu->name(), port = new TranslatingPort(csprintf("%s-%d-funcport", baseCpu->name(),
_threadId), _threadId), process, TranslatingPort::NextPage);
#if !FULL_SYSTEM
process,
#endif
TranslatingPort::NextPage);
connectToMemFunc(port); connectToMemFunc(port);

View file

@ -36,11 +36,8 @@
#include "cpu/base.hh" #include "cpu/base.hh"
#include "cpu/profile.hh" #include "cpu/profile.hh"
#include "cpu/thread_context.hh" #include "cpu/thread_context.hh"
#if !FULL_SYSTEM
#include "mem/mem_object.hh" #include "mem/mem_object.hh"
#include "sim/process.hh" #include "sim/process.hh"
#endif
#if FULL_SYSTEM #if FULL_SYSTEM
class EndQuiesceEvent; class EndQuiesceEvent;
@ -66,11 +63,7 @@ class TranslatingPort;
struct ThreadState { struct ThreadState {
typedef ThreadContext::Status Status; typedef ThreadContext::Status Status;
#if FULL_SYSTEM
ThreadState(BaseCPU *cpu, ThreadID _tid);
#else
ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process); ThreadState(BaseCPU *cpu, ThreadID _tid, Process *_process);
#endif
~ThreadState(); ~ThreadState();
@ -185,10 +178,9 @@ struct ThreadState {
EndQuiesceEvent *quiesceEvent; EndQuiesceEvent *quiesceEvent;
TheISA::Kernel::Statistics *kernelStats; TheISA::Kernel::Statistics *kernelStats;
protected:
#else
Process *process;
#endif #endif
protected:
Process *process;
TranslatingPort *port; TranslatingPort *port;

View file

@ -52,15 +52,9 @@
using namespace std; using namespace std;
using namespace TheISA; using namespace TheISA;
PageTable::PageTable( PageTable::PageTable(Process *_process, Addr _pageSize)
#if !FULL_SYSTEM : pageSize(_pageSize), offsetMask(mask(floorLog2(_pageSize))),
Process *_process, process(_process)
#endif
Addr _pageSize)
: pageSize(_pageSize), offsetMask(mask(floorLog2(_pageSize)))
#if !FULL_SYSTEM
, process(_process)
#endif
{ {
assert(isPowerOf2(pageSize)); assert(isPowerOf2(pageSize));
pTableCache[0].vaddr = 0; pTableCache[0].vaddr = 0;
@ -89,11 +83,9 @@ PageTable::allocate(Addr vaddr, int64_t size)
vaddr); vaddr);
} }
#if !FULL_SYSTEM
pTable[vaddr] = TheISA::TlbEntry(process->M5_pid, vaddr, pTable[vaddr] = TheISA::TlbEntry(process->M5_pid, vaddr,
process->system->new_page()); process->system->new_page());
updateCache(vaddr, pTable[vaddr]); updateCache(vaddr, pTable[vaddr]);
#endif
} }
} }
@ -204,9 +196,7 @@ PageTable::serialize(std::ostream &os)
PTableItr iter = pTable.begin(); PTableItr iter = pTable.begin();
PTableItr end = pTable.end(); PTableItr end = pTable.end();
while (iter != end) { while (iter != end) {
#if !FULL_SYSTEM
os << "\n[" << csprintf("%s.Entry%d", process->name(), count) << "]\n"; os << "\n[" << csprintf("%s.Entry%d", process->name(), count) << "]\n";
#endif
paramOut(os, "vaddr", iter->first); paramOut(os, "vaddr", iter->first);
iter->second.serialize(os); iter->second.serialize(os);
@ -226,7 +216,6 @@ PageTable::unserialize(Checkpoint *cp, const std::string &section)
pTable.clear(); pTable.clear();
while (i < count) { while (i < count) {
#if !FULL_SYSTEM
TheISA::TlbEntry *entry; TheISA::TlbEntry *entry;
Addr vaddr; Addr vaddr;
@ -235,7 +224,6 @@ PageTable::unserialize(Checkpoint *cp, const std::string &section)
entry->unserialize(cp, csprintf("%s.Entry%d", process->name(), i)); entry->unserialize(cp, csprintf("%s.Entry%d", process->name(), i));
pTable[vaddr] = *entry; pTable[vaddr] = *entry;
++i; ++i;
#endif
} }
} }

View file

@ -47,9 +47,7 @@
#include "mem/request.hh" #include "mem/request.hh"
#include "sim/serialize.hh" #include "sim/serialize.hh"
#if !FULL_SYSTEM
class Process; class Process;
#endif
/** /**
* Page Table Declaration. * Page Table Declaration.
@ -71,17 +69,11 @@ class PageTable
const Addr pageSize; const Addr pageSize;
const Addr offsetMask; const Addr offsetMask;
#if !FULL_SYSTEM
Process *process; Process *process;
#endif
public: public:
PageTable( PageTable(Process *_process, Addr _pageSize = TheISA::VMPageSize);
#if !FULL_SYSTEM
Process *_process,
#endif
Addr _pageSize = TheISA::VMPageSize);
~PageTable(); ~PageTable();

View file

@ -33,27 +33,17 @@
#include "arch/isa_traits.hh" #include "arch/isa_traits.hh"
#include "base/chunk_generator.hh" #include "base/chunk_generator.hh"
#include "config/full_system.hh"
#include "config/the_isa.hh" #include "config/the_isa.hh"
#include "mem/page_table.hh" #include "mem/page_table.hh"
#include "mem/port.hh" #include "mem/port.hh"
#include "mem/translating_port.hh" #include "mem/translating_port.hh"
#if !FULL_SYSTEM
#include "sim/process.hh" #include "sim/process.hh"
#endif
using namespace TheISA; using namespace TheISA;
TranslatingPort::TranslatingPort(const std::string &_name, TranslatingPort::TranslatingPort(const std::string &_name, Process *p,
#if !FULL_SYSTEM
Process *p,
#endif
AllocType alloc) AllocType alloc)
: FunctionalPort(_name), : FunctionalPort(_name), pTable(p->pTable), process(p), allocating(alloc)
#if !FULL_SYSTEM
pTable(p->pTable), process(p),
#endif
allocating(alloc)
{ } { }
TranslatingPort::~TranslatingPort() TranslatingPort::~TranslatingPort()
@ -99,11 +89,9 @@ TranslatingPort::tryWriteBlob(Addr addr, uint8_t *p, int size)
VMPageSize); VMPageSize);
} else if (allocating == NextPage) { } else if (allocating == NextPage) {
// check if we've accessed the next page on the stack // check if we've accessed the next page on the stack
#if !FULL_SYSTEM
if (!process->fixupStackFault(gen.addr())) if (!process->fixupStackFault(gen.addr()))
panic("Page table fault when accessing virtual address %#x " panic("Page table fault when accessing virtual address %#x "
"during functional write\n", gen.addr()); "during functional write\n", gen.addr());
#endif
} else { } else {
return false; return false;
} }

View file

@ -32,13 +32,10 @@
#ifndef __MEM_TRANSLATING_PROT_HH__ #ifndef __MEM_TRANSLATING_PROT_HH__
#define __MEM_TRANSLATING_PROT_HH__ #define __MEM_TRANSLATING_PROT_HH__
#include "config/full_system.hh"
#include "mem/port.hh" #include "mem/port.hh"
class PageTable; class PageTable;
#if !FULL_SYSTEM
class Process; class Process;
#endif
class TranslatingPort : public FunctionalPort class TranslatingPort : public FunctionalPort
{ {
@ -51,17 +48,11 @@ class TranslatingPort : public FunctionalPort
private: private:
PageTable *pTable; PageTable *pTable;
#if !FULL_SYSTEM
Process *process; Process *process;
#endif
AllocType allocating; AllocType allocating;
public: public:
TranslatingPort(const std::string &_name, TranslatingPort(const std::string &_name, Process *p, AllocType alloc);
#if !FULL_SYSTEM
Process *p,
#endif
AllocType alloc);
virtual ~TranslatingPort(); virtual ~TranslatingPort();
bool tryReadBlob(Addr addr, uint8_t *p, int size); bool tryReadBlob(Addr addr, uint8_t *p, int size);

View file

@ -48,8 +48,10 @@ Source('simulate.cc')
Source('stat_control.cc') Source('stat_control.cc')
if env['TARGET_ISA'] != 'no': if env['TARGET_ISA'] != 'no':
SimObject('Process.py')
SimObject('System.py') SimObject('System.py')
Source('faults.cc') Source('faults.cc')
Source('process.cc')
Source('pseudo_inst.cc') Source('pseudo_inst.cc')
Source('system.cc') Source('system.cc')
@ -57,9 +59,7 @@ if env['FULL_SYSTEM']:
Source('arguments.cc') Source('arguments.cc')
elif env['TARGET_ISA'] != 'no': elif env['TARGET_ISA'] != 'no':
Source('tlb.cc') Source('tlb.cc')
SimObject('Process.py')
Source('process.cc')
Source('syscall_emul.cc') Source('syscall_emul.cc')
DebugFlag('Checkpoint') DebugFlag('Checkpoint')

View file

@ -77,15 +77,6 @@
using namespace std; using namespace std;
using namespace TheISA; using namespace TheISA;
//
// The purpose of this code is to fake the loader & syscall mechanism
// when there's no OS: thus there's no resone to use it in FULL_SYSTEM
// mode when we do have an OS
//
#if FULL_SYSTEM
#error "process.cc not compatible with FULL_SYSTEM"
#endif
// current number of allocated processes // current number of allocated processes
int num_processes = 0; int num_processes = 0;
@ -579,6 +570,7 @@ 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);
@ -586,6 +578,7 @@ 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
@ -611,6 +604,7 @@ 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).");
@ -721,7 +715,7 @@ 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)
fatal("Unknown error creating process object."); fatal("Unknown error creating process object.");

View file

@ -32,15 +32,6 @@
#ifndef __PROCESS_HH__ #ifndef __PROCESS_HH__
#define __PROCESS_HH__ #define __PROCESS_HH__
//
// The purpose of this code is to fake the loader & syscall mechanism
// when there's no OS: thus there's no reason to use it in FULL_SYSTEM
// mode when we do have an OS.
//
#include "config/full_system.hh"
#if !FULL_SYSTEM
#include <string> #include <string>
#include <vector> #include <vector>
@ -317,6 +308,4 @@ class LiveProcess : public Process
}; };
#endif // !FULL_SYSTEM
#endif // __PROCESS_HH__ #endif // __PROCESS_HH__

View file

@ -32,15 +32,6 @@
#ifndef __SIM_PROCESS_IMPL_HH__ #ifndef __SIM_PROCESS_IMPL_HH__
#define __SIM_PROCESS_IMPL_HH__ #define __SIM_PROCESS_IMPL_HH__
//
// The purpose of this code is to fake the loader & syscall mechanism
// when there's no OS: thus there's no reason to use it in FULL_SYSTEM
// mode when we do have an OS.
//
#include "config/full_system.hh"
#if !FULL_SYSTEM
#include <string> #include <string>
#include <vector> #include <vector>
@ -69,7 +60,4 @@ copyStringArray(std::vector<std::string> &strings,
memPort->writeBlob(array_ptr, (uint8_t*)&data_ptr, sizeof(AddrType)); memPort->writeBlob(array_ptr, (uint8_t*)&data_ptr, sizeof(AddrType));
} }
#endif // !FULL_SYSTEM
#endif #endif

View file

@ -65,6 +65,7 @@
#include "mem/translating_port.hh" #include "mem/translating_port.hh"
#include "sim/byteswap.hh" #include "sim/byteswap.hh"
#include "sim/process.hh" #include "sim/process.hh"
#include "sim/syscallreturn.hh"
#include "sim/system.hh" #include "sim/system.hh"
/// ///