diff options
Diffstat (limited to 'sim')
-rw-r--r-- | sim/process.cc | 29 | ||||
-rw-r--r-- | sim/process.hh | 14 | ||||
-rw-r--r-- | sim/syscall_emul.cc | 10 | ||||
-rw-r--r-- | sim/syscall_emul.hh | 30 | ||||
-rw-r--r-- | sim/system.cc | 4 | ||||
-rw-r--r-- | sim/system.hh | 6 |
6 files changed, 50 insertions, 43 deletions
diff --git a/sim/process.cc b/sim/process.cc index c8c4d0ba6..80f787062 100644 --- a/sim/process.cc +++ b/sim/process.cc @@ -39,7 +39,7 @@ #include "config/full_system.hh" #include "cpu/exec_context.hh" #include "mem/page_table.hh" -#include "mem/memory.hh" +#include "mem/mem_object.hh" #include "mem/translating_port.hh" #include "sim/builder.hh" #include "sim/process.hh" @@ -149,13 +149,27 @@ Process::startup() if (execContexts.empty()) 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]; // mark this context as active so it will start ticking. xc->activate(0); + + // Here we are grabbing the memory port of the CPU hosting the + // initial execution context for initialization. In the long run + // this is not what we want, since it means that all + // initialization accesses (e.g., loading object file sections) + // will be done a cache block at a time through the CPU's cache. + // We really want something more like: + // + // memport = system->physmem->getPort(); + // myPort.setPeer(memport); + // memport->setPeer(&myPort); + // initVirtMem = new TranslatingPort(myPort, pTable); + // + // but we need our own dummy port "myPort" that doesn't exist. + // In the short term it works just fine though. + initVirtMem = xc->getMemPort(); } void @@ -245,15 +259,15 @@ copyStringArray(vector<string> &strings, Addr array_ptr, Addr data_ptr, Addr data_ptr_swap; for (int i = 0; i < strings.size(); ++i) { data_ptr_swap = htog(data_ptr); - memPort->writeBlobFunctional(array_ptr, (uint8_t*)&data_ptr_swap, sizeof(Addr)); - memPort->writeStringFunctional(data_ptr, strings[i].c_str()); + memPort->writeBlob(array_ptr, (uint8_t*)&data_ptr_swap, sizeof(Addr)); + memPort->writeString(data_ptr, strings[i].c_str()); array_ptr += sizeof(Addr); data_ptr += strings[i].size() + 1; } // add NULL terminator data_ptr = 0; - memPort->writeBlobFunctional(array_ptr, (uint8_t*)&data_ptr, sizeof(Addr)); + memPort->writeBlob(array_ptr, (uint8_t*)&data_ptr, sizeof(Addr)); } LiveProcess::LiveProcess(const string &nm, ObjectFile *_objFile, @@ -336,7 +350,7 @@ LiveProcess::startup() // write contents to stack uint64_t argc = argv.size(); argc = htog(argc); - initVirtMem->writeBlobFunctional(stack_min, (uint8_t*)&argc, sizeof(uint64_t)); + initVirtMem->writeBlob(stack_min, (uint8_t*)&argc, sizeof(uint64_t)); copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); @@ -367,6 +381,7 @@ LiveProcess::syscall(ExecContext *xc) desc->doSyscall(callnum, this, xc); } + LiveProcess * LiveProcess::create(const string &nm, System *system, int stdin_fd, int stdout_fd, int stderr_fd, diff --git a/sim/process.hh b/sim/process.hh index ffdca819e..68312f115 100644 --- a/sim/process.hh +++ b/sim/process.hh @@ -40,27 +40,18 @@ #include <vector> -#include "arch/isa_traits.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 "arch/isa_traits.hh" class CPUExecContext; class ExecContext; class SyscallDesc; +class PageTable; class TranslatingPort; class System; class Process : public SimObject { - protected: - typedef TheISA::RegFile RegFile; - typedef TheISA::MachInst MachInst; public: /// Pointer to object representing the system this process is @@ -198,8 +189,7 @@ class LiveProcess : public Process virtual void syscall(ExecContext *xc); - virtual SyscallDesc* getDesc(int callnum) { panic("Must be implemented."); } - + virtual SyscallDesc* getDesc(int callnum) = 0; }; diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc index 6c24b6dc5..3dedb7c5e 100644 --- a/sim/syscall_emul.cc +++ b/sim/syscall_emul.cc @@ -193,7 +193,7 @@ unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string path; - if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) 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->getMemPort()->tryReadStringFunctional(old_name, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(old_name, xc->getSyscallArg(0))) return -EFAULT; string new_name; - if (!xc->getMemPort()->tryReadStringFunctional(new_name, xc->getSyscallArg(1))) + if (!xc->getMemPort()->tryReadString(new_name, xc->getSyscallArg(1))) 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->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) 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->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) return -EFAULT; /* XXX endianess */ diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh index 60e06b294..9554ab318 100644 --- a/sim/syscall_emul.hh +++ b/sim/syscall_emul.hh @@ -48,7 +48,7 @@ #include "base/intmath.hh" // for RoundUp #include "mem/translating_port.hh" #include "arch/isa_traits.hh" // for Addr - +#include "base/misc.hh" #include "base/trace.hh" #include "cpu/exec_context.hh" #include "cpu/base.hh" @@ -109,7 +109,7 @@ class BaseBufferArg { // virtual bool copyIn(TranslatingPort *memport) { - memport->readBlobFunctional(addr, bufPtr, size); + memport->readBlob(addr, bufPtr, size); return true; // no EFAULT detection for now } @@ -118,7 +118,7 @@ class BaseBufferArg { // virtual bool copyOut(TranslatingPort *memport) { - memport->writeBlobFunctional(addr, bufPtr, size); + memport->writeBlob(addr, bufPtr, size); return true; // no EFAULT detection for now } @@ -370,7 +370,7 @@ openFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) return -EFAULT; if (path == "/dev/sysdev0") { @@ -417,7 +417,7 @@ chmodFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) return -EFAULT; uint32_t mode = xc->getSyscallArg(1); @@ -470,7 +470,7 @@ statFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) return -EFAULT; struct stat hostBuf; @@ -522,7 +522,7 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) return -EFAULT; struct stat hostBuf; @@ -544,7 +544,7 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) return -EFAULT; #if BSD_HOST @@ -596,7 +596,7 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) return -EFAULT; struct statfs hostBuf; @@ -646,18 +646,20 @@ writevFunc(SyscallDesc *desc, int callnum, Process *process, return -EBADF; } + TranslatingPort *p = xc->getMemPort(); uint64_t tiov_base = xc->getSyscallArg(1); size_t count = xc->getSyscallArg(2); struct iovec hiov[count]; for (int i = 0; i < count; ++i) { typename OS::tgt_iovec tiov; - xc->getMemPort()->readBlobFunctional(tiov_base + i*sizeof(typename OS::tgt_iovec),(uint8_t*) - &tiov, sizeof(typename OS::tgt_iovec)); + + p->readBlob(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->getMemPort()->readBlobFunctional(gtoh(tiov.iov_base), - (uint8_t *)hiov[i].iov_base, hiov[i].iov_len); + p->readBlob(gtoh(tiov.iov_base), (uint8_t *)hiov[i].iov_base, + hiov[i].iov_len); } int result = writev(process->sim_fd(fd), hiov, count); @@ -770,7 +772,7 @@ utimesFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (!xc->getMemPort()->tryReadStringFunctional(path, xc->getSyscallArg(0))) + if (!xc->getMemPort()->tryReadString(path, xc->getSyscallArg(0))) return -EFAULT; TypedBufferArg<typename OS::timeval [2]> tp(xc->getSyscallArg(1)); diff --git a/sim/system.cc b/sim/system.cc index 05b41e32b..409e41ead 100644 --- a/sim/system.cc +++ b/sim/system.cc @@ -1,12 +1,12 @@ #include "base/loader/object_file.hh" #include "base/loader/symtab.hh" #include "cpu/exec_context.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" +#include "mem/mem_object.hh" #if FULL_SYSTEM #include "base/remote_gdb.hh" #include "kern/kernel_stats.hh" @@ -228,7 +228,7 @@ DEFINE_SIM_OBJECT_CLASS_NAME("System", System) BEGIN_DECLARE_SIM_OBJECT_PARAMS(System) - SimObjectParam<Memory *> physmem; + SimObjectParam<MemObject *> physmem; END_DECLARE_SIM_OBJECT_PARAMS(System) diff --git a/sim/system.hh b/sim/system.hh index a0ba4f141..0f82f81f5 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -45,7 +45,7 @@ class BaseCPU; class ExecContext; class MemoryController; class ObjectFile; -class Memory; +class MemObject; #if FULL_SYSTEM class Platform; @@ -57,7 +57,7 @@ namespace Kernel { class Binning; } class System : public SimObject { public: - Memory *physmem; + MemObject *physmem; PCEventQueue pcEventQueue; std::vector<ExecContext *> execContexts; @@ -146,7 +146,7 @@ class System : public SimObject struct Params { std::string name; - Memory *physmem; + MemObject *physmem; #if FULL_SYSTEM Tick boot_cpu_frequency; |