diff options
Diffstat (limited to 'sim')
-rw-r--r-- | sim/process.cc | 110 | ||||
-rw-r--r-- | sim/process.hh | 40 | ||||
-rw-r--r-- | sim/syscall_emul.cc | 16 | ||||
-rw-r--r-- | sim/syscall_emul.hh | 64 | ||||
-rw-r--r-- | sim/system.cc | 56 | ||||
-rw-r--r-- | sim/system.hh | 45 |
6 files changed, 212 insertions, 119 deletions
diff --git a/sim/process.cc b/sim/process.cc index f02ca8bfd..70a92a604 100644 --- a/sim/process.cc +++ b/sim/process.cc @@ -42,12 +42,15 @@ #include "cpu/smt.hh" #include "encumbered/cpu/full/thread.hh" #include "encumbered/eio/eio.hh" -#include "encumbered/mem/functional/main.hh" +#include "mem/page_table.hh" +#include "mem/memory.hh" +#include "mem/translating_port.hh" #include "sim/builder.hh" #include "sim/fake_syscall.hh" #include "sim/process.hh" #include "sim/stats.hh" #include "sim/syscall_emul.hh" +#include "sim/system.hh" #include "arch/process.hh" @@ -67,20 +70,12 @@ using namespace TheISA; int num_processes = 0; Process::Process(const string &nm, + System *_system, int stdin_fd, // initial I/O descriptors int stdout_fd, int stderr_fd) - : SimObject(nm) + : SimObject(nm), system(_system) { - // allocate memory space - memory = new MainMemory(nm + ".MainMem"); - - // allocate initial register file - init_regs = new RegFile; - memset(init_regs, 0, sizeof(RegFile)); - - cpuXC = new CPUExecContext(init_regs); - // initialize first 3 fds (stdin, stdout, stderr) fd_map[STDIN_FILENO] = stdin_fd; fd_map[STDOUT_FILENO] = stdout_fd; @@ -93,9 +88,11 @@ Process::Process(const string &nm, mmap_start = mmap_end = 0; nxm_start = nxm_end = 0; + pTable = new PageTable(system); // other parameters will be initialized when the program is loaded } + void Process::regStats() { @@ -147,12 +144,7 @@ Process::registerExecContext(ExecContext *xc) int myIndex = execContexts.size(); execContexts.push_back(xc); - if (myIndex == 0) { - // copy process's initial regs struct - xc->copyArchRegs(cpuXC->getProxy()); - } - - // return CPU number to caller and increment available CPU count + // return CPU number to caller return myIndex; } @@ -160,7 +152,9 @@ void Process::startup() { if (execContexts.empty()) - return; + fatal("Process %s is not associated with any CPUs!\n", name()); + + initVirtMem = new TranslatingPort((system->physmem->getPort("DCACHE"))->getPeer(), pTable); // first exec context for this process... initialize & enable ExecContext *xc = execContexts[0]; @@ -251,25 +245,28 @@ DEFINE_SIM_OBJECT_CLASS_NAME("Process", Process) static void copyStringArray(vector<string> &strings, Addr array_ptr, Addr data_ptr, - FunctionalMemory *memory) + TranslatingPort* memPort) { Addr data_ptr_swap; for (int i = 0; i < strings.size(); ++i) { data_ptr_swap = htog(data_ptr); - memory->access(Write, array_ptr, &data_ptr_swap, sizeof(Addr)); - memory->writeString(data_ptr, strings[i].c_str()); + memPort->writeBlobFunctional(array_ptr, (uint8_t*)&data_ptr_swap, sizeof(Addr)); + memPort->writeStringFunctional(data_ptr, strings[i].c_str()); array_ptr += sizeof(Addr); data_ptr += strings[i].size() + 1; } // add NULL terminator data_ptr = 0; - memory->access(Write, array_ptr, &data_ptr, sizeof(Addr)); + + memPort->writeBlobFunctional(array_ptr, (uint8_t*)&data_ptr, sizeof(Addr)); } -LiveProcess::LiveProcess(const string &nm, ObjectFile *objFile, +LiveProcess::LiveProcess(const string &nm, ObjectFile *_objFile, + System *_system, int stdin_fd, int stdout_fd, int stderr_fd, - vector<string> &argv, vector<string> &envp) - : Process(nm, stdin_fd, stdout_fd, stderr_fd) + vector<string> &_argv, vector<string> &_envp) + : Process(nm, _system, stdin_fd, stdout_fd, stderr_fd), + objFile(_objFile), argv(_argv), envp(_envp) { prog_fname = argv[0]; @@ -280,8 +277,16 @@ LiveProcess::LiveProcess(const string &nm, ObjectFile *objFile, data_size = objFile->dataSize() + objFile->bssSize(); brk_point = roundUp(data_base + data_size, VMPageSize); - // load object file into target memory - objFile->loadSections(memory); + // Set up stack. On Alpha, stack goes below text section. This + // code should get moved to some architecture-specific spot. + stack_base = text_base - (409600+4096); + + // Set up region for mmaps. Tru64 seems to start just above 0 and + // grow up from there. + mmap_start = mmap_end = 0x10000; + + // Set pointer for next thread stack. Reserve 8M for main stack. + next_thread_stack_base = stack_base - (8 * 1024 * 1024); // load up symbols, if any... these may be used for debugging or // profiling. @@ -294,17 +299,15 @@ LiveProcess::LiveProcess(const string &nm, ObjectFile *objFile, debugSymbolTable = NULL; } } +} - // Set up stack. On Alpha, stack goes below text section. This - // code should get moved to some architecture-specific spot. - stack_base = text_base - (409600+4096); - - // Set up region for mmaps. Tru64 seems to start just above 0 and - // grow up from there. - mmap_start = mmap_end = 0x10000; +void +LiveProcess::startup() +{ + Process::startup(); - // Set pointer for next thread stack. Reserve 8M for main stack. - next_thread_stack_base = stack_base - (8 * 1024 * 1024); + // load object file into target memory + objFile->loadSections(initVirtMem); // Calculate how much space we need for arg & env arrays. int argv_array_size = sizeof(Addr) * (argv.size() + 1); @@ -329,6 +332,9 @@ LiveProcess::LiveProcess(const string &nm, ObjectFile *objFile, // align it stack_min &= ~7; stack_size = stack_base - stack_min; + // map memory + pTable->allocate(roundDown(stack_min, VMPageSize), + roundUp(stack_size, VMPageSize)); // map out initial stack contents Addr argv_array_base = stack_min + sizeof(uint64_t); // room for argc @@ -339,17 +345,19 @@ LiveProcess::LiveProcess(const string &nm, ObjectFile *objFile, // write contents to stack uint64_t argc = argv.size(); argc = htog(argc); - memory->access(Write, stack_min, &argc, sizeof(uint64_t)); + initVirtMem->writeBlobFunctional(stack_min, (uint8_t*)&argc, sizeof(uint64_t)); - copyStringArray(argv, argv_array_base, arg_data_base, memory); - copyStringArray(envp, envp_array_base, env_data_base, memory); + copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); + copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); - init_regs->intRegFile[ArgumentReg0] = argc; - init_regs->intRegFile[ArgumentReg1] = argv_array_base; - init_regs->intRegFile[StackPointerReg] = stack_min; - init_regs->intRegFile[GlobalPointerReg] = objFile->globalPointer(); - init_regs->pc = prog_entry; - init_regs->npc = prog_entry + sizeof(MachInst); + execContexts[0]->setIntReg(ArgumentReg0, argc); + execContexts[0]->setIntReg(ArgumentReg1, argv_array_base); + execContexts[0]->setIntReg(StackPointerReg, stack_min); + execContexts[0]->setIntReg(GlobalPointerReg, objFile->globalPointer()); + execContexts[0]->setPC(prog_entry); + execContexts[0]->setNextPC(prog_entry + sizeof(MachInst)); + + num_processes++; } void @@ -367,7 +375,7 @@ LiveProcess::syscall(ExecContext *xc) } LiveProcess * -LiveProcess::create(const string &nm, +LiveProcess::create(const string &nm, System *system, int stdin_fd, int stdout_fd, int stderr_fd, string executable, vector<string> &argv, vector<string> &envp) @@ -379,12 +387,10 @@ LiveProcess::create(const string &nm, } // set up syscall emulation pointer for the current ISA - process = createProcess(nm, objFile, + process = createProcess(nm, objFile, system, stdin_fd, stdout_fd, stderr_fd, argv, envp); - delete objFile; - if (process == NULL) fatal("Unknown error creating process object."); @@ -400,6 +406,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(LiveProcess) Param<string> input; Param<string> output; VectorParam<string> env; + SimObjectParam<System *> system; END_DECLARE_SIM_OBJECT_PARAMS(LiveProcess) @@ -410,7 +417,8 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(LiveProcess) INIT_PARAM(executable, "executable (overrides cmd[0] if set)"), INIT_PARAM(input, "filename for stdin (dflt: use sim stdin)"), INIT_PARAM(output, "filename for stdout/stderr (dflt: use sim stdout)"), - INIT_PARAM(env, "environment settings") + INIT_PARAM(env, "environment settings"), + INIT_PARAM(system, "system") END_INIT_SIM_OBJECT_PARAMS(LiveProcess) @@ -437,7 +445,7 @@ CREATE_SIM_OBJECT(LiveProcess) stderr_fd = (stdout_fd != STDOUT_FILENO) ? stdout_fd : STDERR_FILENO; - return LiveProcess::create(getInstanceName(), + return LiveProcess::create(getInstanceName(), system, stdin_fd, stdout_fd, stderr_fd, (string)executable == "" ? cmd[0] : executable, cmd, env); diff --git a/sim/process.hh b/sim/process.hh index 3a48f128c..fc600fb06 100644 --- a/sim/process.hh +++ b/sim/process.hh @@ -41,15 +41,21 @@ #include <vector> #include "arch/isa_traits.hh" -#include "sim/sim_object.hh" -#include "sim/stats.hh" #include "base/statistics.hh" #include "base/trace.hh" +#include "mem/memory.hh" +//#include "mem/mem_interface.hh" +#include "mem/page_table.hh" +#include "sim/sim_object.hh" +#include "sim/stats.hh" +#include "targetarch/isa_traits.hh" class CPUExecContext; class ExecContext; -class FunctionalMemory; class SyscallDesc; +class TranslatingPort; +class System; + class Process : public SimObject { protected: @@ -57,6 +63,10 @@ class Process : public SimObject typedef TheISA::MachInst MachInst; public: + /// Pointer to object representing the system this process is + /// running on. + System *system; + // have we initialized an execution context from this process? If // yes, subsequent contexts are assumed to be for dynamically // created threads and are not initialized. @@ -76,16 +86,12 @@ class Process : public SimObject WaitRec(Addr chan, ExecContext *ctx) : waitChan(chan), waitingContext(ctx) - { - } + { } }; // list of all blocked contexts std::list<WaitRec> waitList; - RegFile *init_regs; // initial register contents - CPUExecContext *cpuXC; // XC to hold the init_regs - Addr text_base; // text (code) segment base unsigned text_size; // text (code) size in bytes @@ -118,6 +124,7 @@ class Process : public SimObject protected: // constructor Process(const std::string &nm, + System *_system, int stdin_fd, // initial I/O descriptors int stdout_fd, int stderr_fd); @@ -126,7 +133,11 @@ class Process : public SimObject virtual void startup(); protected: - FunctionalMemory *memory; + /// Memory object for initialization (image loading) + TranslatingPort *initVirtMem; + + public: + PageTable *pTable; private: // file descriptor remapping support @@ -181,8 +192,6 @@ class Process : public SimObject } virtual void syscall(ExecContext *xc) = 0; - - virtual FunctionalMemory *getMemory() { return memory; } }; // @@ -192,16 +201,23 @@ class ObjectFile; class LiveProcess : public Process { protected: + ObjectFile *objFile; + std::vector<std::string> argv; + std::vector<std::string> envp; + LiveProcess(const std::string &nm, ObjectFile *objFile, - int stdin_fd, int stdout_fd, int stderr_fd, + System *_system, int stdin_fd, int stdout_fd, int stderr_fd, std::vector<std::string> &argv, std::vector<std::string> &envp); + void startup(); + public: // this function is used to create the LiveProcess object, since // we can't tell which subclass of LiveProcess to use until we // open and look at the object file. static LiveProcess *create(const std::string &nm, + System *_system, int stdin_fd, int stdout_fd, int stderr_fd, std::string executable, std::vector<std::string> &argv, diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc index 00168b025..1d0b3a375 100644 --- a/sim/syscall_emul.cc +++ b/sim/syscall_emul.cc @@ -130,7 +130,7 @@ readFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) int bytes_read = read(fd, bufArg.bufferPtr(), nbytes); if (bytes_read != -1) - bufArg.copyOut(xc->getMemPtr()); + bufArg.copyOut(xc->port); return bytes_read; } @@ -142,7 +142,7 @@ writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) int nbytes = xc->getSyscallArg(2); BufferArg bufArg(xc->getSyscallArg(1), nbytes); - bufArg.copyIn(xc->getMemPtr()); + bufArg.copyIn(xc->port); int bytes_written = write(fd, bufArg.bufferPtr(), nbytes); @@ -183,7 +183,7 @@ gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) strncpy((char *)name.bufferPtr(), hostname, name_len); - name.copyOut(xc->getMemPtr()); + name.copyOut(xc->port); return 0; } @@ -193,7 +193,7 @@ unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) return (TheISA::IntReg)-EFAULT; int result = unlink(path.c_str()); @@ -205,12 +205,12 @@ renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string old_name; - if (xc->getMemPtr()->readString(old_name, xc->getSyscallArg(0)) != NoFault) + if (xc->port->readStringFunctional(old_name, xc->getSyscallArg(0)) != NoFault) return -EFAULT; string new_name; - if (xc->getMemPtr()->readString(new_name, xc->getSyscallArg(1)) != NoFault) + if (xc->port->readStringFunctional(new_name, xc->getSyscallArg(1)) != NoFault) return -EFAULT; int64_t result = rename(old_name.c_str(), new_name.c_str()); @@ -222,7 +222,7 @@ truncateFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) return -EFAULT; off_t length = xc->getSyscallArg(1); @@ -250,7 +250,7 @@ chownFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) return -EFAULT; /* XXX endianess */ diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh index 35129bcb4..25f8c6cb8 100644 --- a/sim/syscall_emul.hh +++ b/sim/syscall_emul.hh @@ -46,11 +46,12 @@ #include <sys/uio.h> #include "base/intmath.hh" // for RoundUp -#include "mem/functional/functional.hh" +#include "mem/translating_port.hh" #include "arch/isa_traits.hh" // for Addr #include "base/trace.hh" #include "cpu/exec_context.hh" +#include "cpu/base.hh" #include "sim/process.hh" /// @@ -106,18 +107,18 @@ class BaseBufferArg { // // copy data into simulator space (read from target memory) // - virtual bool copyIn(FunctionalMemory *mem) + virtual bool copyIn(TranslatingPort *memport) { - mem->access(Read, addr, bufPtr, size); + memport->readBlobFunctional(addr, bufPtr, size); return true; // no EFAULT detection for now } // // copy data out of simulator space (write to target memory) // - virtual bool copyOut(FunctionalMemory *mem) + virtual bool copyOut(TranslatingPort *memport) { - mem->access(Write, addr, bufPtr, size); + memport->writeBlobFunctional(addr, bufPtr, size); return true; // no EFAULT detection for now } @@ -369,7 +370,7 @@ openFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) return -EFAULT; if (path == "/dev/sysdev0") { @@ -416,7 +417,7 @@ chmodFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) return -EFAULT; uint32_t mode = xc->getSyscallArg(1); @@ -469,8 +470,8 @@ statFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; struct stat hostBuf; int result = stat(path.c_str(), &hostBuf); @@ -478,7 +479,7 @@ statFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -507,7 +508,7 @@ fstat64Func(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStat64Buf(xc->getMemPtr(), fd, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStat64Buf(xc->port, fd, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -521,8 +522,8 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; struct stat hostBuf; int result = lstat(path.c_str(), &hostBuf); @@ -530,7 +531,7 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -543,8 +544,8 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; #if BSD_HOST struct stat hostBuf; @@ -557,7 +558,7 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStat64Buf(xc->getMemPtr(), -1, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStat64Buf(xc->port, -1, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -581,7 +582,8 @@ fstatFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf); + return 0; } @@ -594,8 +596,8 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; struct statfs hostBuf; int result = statfs(path.c_str(), &hostBuf); @@ -603,7 +605,7 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatfsBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatfsBuf(xc->port, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -626,7 +628,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatfsBuf(xc->getMemPtr(), xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatfsBuf(xc->port, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -650,12 +652,12 @@ writevFunc(SyscallDesc *desc, int callnum, Process *process, for (int i = 0; i < count; ++i) { typename OS::tgt_iovec tiov; - xc->getMemPtr()->access(Read, tiov_base + i*sizeof(typename OS::tgt_iovec), + xc->port->readBlobFunctional(tiov_base + i*sizeof(typename OS::tgt_iovec),(uint8_t*) &tiov, sizeof(typename OS::tgt_iovec)); hiov[i].iov_len = gtoh(tiov.iov_len); hiov[i].iov_base = new char [hiov[i].iov_len]; - xc->getMemPtr()->access(Read, gtoh(tiov.iov_base), - hiov[i].iov_base, hiov[i].iov_len); + xc->port->readBlobFunctional(gtoh(tiov.iov_base), + (uint8_t *)hiov[i].iov_base, hiov[i].iov_len); } int result = writev(process->sim_fd(fd), hiov, count); @@ -737,7 +739,7 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process, break; } - rlp.copyOut(xc->getMemPtr()); + rlp.copyOut(xc->port); return 0; } @@ -754,7 +756,7 @@ gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process, tp->tv_sec = htog(tp->tv_sec); tp->tv_usec = htog(tp->tv_usec); - tp.copyOut(xc->getMemPtr()); + tp.copyOut(xc->port); return 0; } @@ -768,11 +770,11 @@ utimesFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->getMemPtr()->readString(path, xc->getSyscallArg(0)) != NoFault) - return -EFAULT; + if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != NoFault) + return -EFAULT; TypedBufferArg<typename OS::timeval [2]> tp(xc->getSyscallArg(1)); - tp.copyIn(xc->getMemPtr()); + tp.copyIn(xc->port); struct timeval hostTimeval[2]; for (int i = 0; i < 2; ++i) @@ -824,7 +826,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process, rup->ru_nvcsw = 0; rup->ru_nivcsw = 0; - rup.copyOut(xc->getMemPtr()); + rup.copyOut(xc->port); return 0; } diff --git a/sim/system.cc b/sim/system.cc index 8820922c1..3ed7ed590 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -1,16 +1,19 @@ #include "base/loader/object_file.hh" #include "base/loader/symtab.hh" -#include "base/remote_gdb.hh" #include "cpu/exec_context.hh" -#include "kern/kernel_stats.hh" -#include "mem/functional/memory_control.hh" -#include "mem/functional/physical.hh" #include "arch/vtophys.hh" +#include "mem/memory.hh" #include "sim/builder.hh" #include "arch/isa_traits.hh" #include "sim/byteswap.hh" #include "sim/system.hh" #include "base/trace.hh" +#if FULL_SYSTEM +#include "base/remote_gdb.hh" +#include "kern/kernel_stats.hh" +#include "mem/functional/memory_control.hh" +#include "targetarch/vtophys.hh" +#endif using namespace std; using namespace TheISA; @@ -20,12 +23,18 @@ vector<System *> System::systemList; int System::numSystemsRunning = 0; System::System(Params *p) - : SimObject(p->name), memctrl(p->memctrl), physmem(p->physmem), - init_param(p->init_param), numcpus(0), _params(p) + : SimObject(p->name), physmem(p->physmem), numcpus(0), +#if FULL_SYSTEM + memctrl(p->memctrl), init_param(p->init_param), +#else + page_ptr(0), +#endif + _params(p) { // add self to global system list systemList.push_back(this); +#if FULL_SYSTEM kernelSymtab = new SymbolTable; debugSymbolTable = new SymbolTable; @@ -63,25 +72,34 @@ System::System(Params *p) DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry); DPRINTF(Loader, "Kernel loaded...\n"); +#if FULL_SYSTEM + kernelBinning = new Kernel::Binning(this); +#endif // FULL_SYSTEM + // increment the number of running systms numSystemsRunning++; - - kernelBinning = new Kernel::Binning(this); } System::~System() { +#if FULL_SYSTEM delete kernelSymtab; delete kernel; delete kernelBinning; +#else + panic("System::fixFuncEventAddr needs to be rewritten " + "to work with syscall emulation"); +#endif // FULL_SYSTEM} } - +#if FULL_SYSTEM int rgdb_wait = -1; +#endif // FULL_SYSTEM + int System::registerExecContext(ExecContext *xc, int id) { @@ -101,6 +119,7 @@ System::registerExecContext(ExecContext *xc, int id) execContexts[id] = xc; numcpus++; +#if FULL_SYSTEM RemoteGDB *rgdb = new RemoteGDB(this, xc); GDBListener *gdbl = new GDBListener(rgdb, 7000 + id); gdbl->listen(); @@ -116,6 +135,7 @@ System::registerExecContext(ExecContext *xc, int id) } remoteGDB[id] = rgdb; +#endif // FULL_SYSTEM return id; } @@ -137,30 +157,48 @@ System::replaceExecContext(ExecContext *xc, int id) } execContexts[id] = xc; +#if FULL_SYSTEM remoteGDB[id]->replaceExecContext(xc); +#endif // FULL_SYSTEM +} + +#if !FULL_SYSTEM +Addr +System::new_page() +{ + Addr return_addr = page_ptr << LogVMPageSize; + ++page_ptr; + return return_addr; } +#endif void System::regStats() { +#if FULL_SYSTEM kernelBinning->regStats(name() + ".kern"); +#endif // FULL_SYSTEM } void System::serialize(ostream &os) { +#if FULL_SYSTEM kernelBinning->serialize(os); kernelSymtab->serialize("kernel_symtab", os); +#endif // FULL_SYSTEM } void System::unserialize(Checkpoint *cp, const string §ion) { +#if FULL_SYSTEM kernelBinning->unserialize(cp, section); kernelSymtab->unserialize("kernel_symtab", cp, section); +#endif // FULL_SYSTEM } void diff --git a/sim/system.hh b/sim/system.hh index ea482a102..cbe876c42 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -35,27 +35,29 @@ #include "base/statistics.hh" #include "base/loader/symtab.hh" #include "cpu/pc_event.hh" -#include "kern/system_events.hh" #include "sim/sim_object.hh" +#if FULL_SYSTEM +#include "kern/system_events.hh" +#endif class BaseCPU; class ExecContext; -class GDBListener; class MemoryController; class ObjectFile; -class PhysicalMemory; +class Memory; + +#if FULL_SYSTEM class Platform; +class GDBListener; class RemoteGDB; namespace Kernel { class Binning; } +#endif class System : public SimObject { public: - MemoryController *memctrl; - PhysicalMemory *physmem; - Platform *platform; + Memory *physmem; PCEventQueue pcEventQueue; - uint64_t init_param; std::vector<ExecContext *> execContexts; int numcpus; @@ -68,6 +70,11 @@ class System : public SimObject return numcpus; } +#if FULL_SYSTEM + MemoryController *memctrl; + Platform *platform; + uint64_t init_param; + /** kernel symbol table */ SymbolTable *kernelSymtab; @@ -85,6 +92,13 @@ class System : public SimObject Kernel::Binning *kernelBinning; +#else + + int page_ptr; + + +#endif // FULL_SYSTEM + protected: /** @@ -111,6 +125,7 @@ class System : public SimObject return NULL; } +#if FULL_SYSTEM /** Add a function-based event to kernel code. */ template <class T> T *System::addKernelFuncEvent(const char *lbl) @@ -118,18 +133,23 @@ class System : public SimObject return addFuncEvent<T>(kernelSymtab, lbl); } +#endif public: +#if FULL_SYSTEM std::vector<RemoteGDB *> remoteGDB; std::vector<GDBListener *> gdbListen; virtual bool breakpoint() = 0; +#endif // FULL_SYSTEM public: struct Params { std::string name; + Memory *physmem; + +#if FULL_SYSTEM Tick boot_cpu_frequency; MemoryController *memctrl; - PhysicalMemory *physmem; uint64_t init_param; bool bin; std::vector<std::string> binned_fns; @@ -137,6 +157,7 @@ class System : public SimObject std::string kernel_path; std::string readfile; +#endif }; protected: @@ -151,6 +172,8 @@ class System : public SimObject const Params *params() const { return (const Params *)_params; } public: + +#if FULL_SYSTEM /** * Returns the addess the kernel starts at. * @return address the kernel starts at @@ -169,6 +192,12 @@ class System : public SimObject */ Addr getKernelEntry() const { return kernelEntry; } +#else + + Addr new_page(); + +#endif // FULL_SYSTEM + int registerExecContext(ExecContext *xc, int xcIndex); void replaceExecContext(ExecContext *xc, int xcIndex); |