diff --git a/arch/alpha/alpha_linux_process.cc b/arch/alpha/alpha_linux_process.cc index 1c3a21582..be2013e1e 100644 --- a/arch/alpha/alpha_linux_process.cc +++ b/arch/alpha/alpha_linux_process.cc @@ -36,7 +36,7 @@ #include "cpu/base.hh" #include "cpu/exec_context.hh" -#include "mem/functional/functional.hh" +#include "mem/port.hh" #include "sim/fake_syscall.hh" #include "sim/host.hh" #include "sim/process.hh" @@ -236,7 +236,7 @@ class Linux { /// buffer. Also copies the target buffer out to the simulated /// memory space. Used by stat(), fstat(), and lstat(). static void - copyOutStatBuf(FunctionalMemory *mem, Addr addr, struct stat *host) + copyOutStatBuf(Port *memPort, Addr addr, struct stat *host) { TypedBufferArg tgt(addr); @@ -254,12 +254,12 @@ class Linux { tgt->st_blksize = host->st_blksize; tgt->st_blocks = host->st_blocks; - tgt.copyOut(mem); + tgt.copyOut(memPort); } // Same for stat64 static void - copyOutStat64Buf(FunctionalMemory *mem, Addr addr, struct stat64 *host) + copyOutStat64Buf(Port *memPort, Addr addr, struct stat64 *host) { TypedBufferArg tgt(addr); @@ -288,7 +288,7 @@ class Linux { tgt->st_mtime_nsec = 0; tgt->st_ctime_nsec = 0; #endif - tgt.copyOut(mem); + tgt.copyOut(memPort); } /// The target system's hostname. @@ -307,7 +307,7 @@ class Linux { strcpy(name->version, "#1 Mon Aug 18 11:32:15 EDT 2003"); strcpy(name->machine, "alpha"); - name.copyOut(xc->mem); + name.copyOut(xc->cpu->memPort); return 0; } @@ -327,7 +327,7 @@ class Linux { TypedBufferArg fpcr(xc->getSyscallArg(1)); // I don't think this exactly matches the HW FPCR *fpcr = 0; - fpcr.copyOut(xc->mem); + fpcr.copyOut(xc->cpu->memPort); return 0; } @@ -353,7 +353,7 @@ class Linux { case 14: { // SSI_IEEE_FP_CONTROL TypedBufferArg fpcr(xc->getSyscallArg(1)); // I don't think this exactly matches the HW FPCR - fpcr.copyIn(xc->mem); + fpcr.copyIn(xc->cpu->memPort); DPRINTFR(SyscallVerbose, "osf_setsysinfo(SSI_IEEE_FP_CONTROL): " " setting FPCR to 0x%x\n", *(uint64_t*)fpcr); return 0; diff --git a/cpu/base.hh b/cpu/base.hh index 826dcb2ec..870e26a39 100644 --- a/cpu/base.hh +++ b/cpu/base.hh @@ -41,6 +41,7 @@ class System; class BranchPred; class ExecContext; +class Port; class BaseCPU : public SimObject { @@ -153,6 +154,14 @@ class BaseCPU : public SimObject */ int number_of_threads; + /** + * A pointer to the port into the memory system to be used by syscall + * emulation. This way the data being accessed via syscalls looks in + * the memory heirachy for any changes that haven't been written back + * to main memory yet. + */ + Port* memPort; + /** * Vector of per-thread instruction-based event queues. Used for * scheduling events based on number of instructions committed by diff --git a/cpu/exec_context.cc b/cpu/exec_context.cc index edab25d0b..a281609f4 100644 --- a/cpu/exec_context.cc +++ b/cpu/exec_context.cc @@ -80,7 +80,7 @@ ExecContext::ExecContext(BaseCPU *_cpu, int _thread_num, System *_system, Memory *_mem, Process *_process, int _asid) : _status(ExecContext::Unallocated), cpu(_cpu), thread_num(_thread_num), cpu_id(-1), - system(_system), mem(_mem), + system(_system), process(_process), asid(_asid), func_exe_inst(0), storeCondFailures(0) @@ -109,7 +109,7 @@ void ExecContext::takeOverFrom(ExecContext *oldContext) { // some things should already be set up - assert(mem == oldContext->mem); +// assert(mem == oldContext->mem); #if FULL_SYSTEM assert(system == oldContext->system); #else diff --git a/cpu/exec_context.hh b/cpu/exec_context.hh index 8ab3506db..c40b00e4c 100644 --- a/cpu/exec_context.hh +++ b/cpu/exec_context.hh @@ -122,7 +122,7 @@ class ExecContext int cpu_id; System *system; - Memory *mem; +// Memory *mem; #if FULL_SYSTEM AlphaITB *itb; @@ -243,6 +243,7 @@ class ExecContext #endif +/* template Fault read(CpuRequestPtr &req, T &data) { @@ -308,7 +309,7 @@ class ExecContext #endif return mem->prot_write(req->paddr, (T)htog(data), req->size); } - +*/ virtual bool misspeculating(); diff --git a/cpu/simple/cpu.cc b/cpu/simple/cpu.cc index b6823fb63..7f589548d 100644 --- a/cpu/simple/cpu.cc +++ b/cpu/simple/cpu.cc @@ -152,6 +152,8 @@ SimpleCPU::SimpleCPU(Params *p) xc = new ExecContext(this, /* thread_num */ 0, p->process, /* asid */ 0); #endif // !FULL_SYSTEM + xc->memPort = dcachePort; + req = new CpuRequest; req->asid = 0; diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc index 4b6388a41..78b4201d4 100644 --- a/sim/syscall_emul.cc +++ b/sim/syscall_emul.cc @@ -128,7 +128,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->mem); + bufArg.copyOut(xc->cpu->memPort); return bytes_read; } @@ -140,7 +140,7 @@ writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) int nbytes = xc->getSyscallArg(2); BufferArg bufArg(xc->getSyscallArg(1), nbytes); - bufArg.copyIn(xc->mem); + bufArg.copyIn(xc->cpu->memPort); int bytes_written = write(fd, bufArg.bufferPtr(), nbytes); @@ -181,7 +181,7 @@ gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) strncpy((char *)name.bufferPtr(), hostname, name_len); - name.copyOut(xc->mem); + name.copyOut(xc->cpu->memPort); return 0; } @@ -191,7 +191,7 @@ unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string path; - if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault) + if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) return (TheISA::IntReg)-EFAULT; int result = unlink(path.c_str()); @@ -203,12 +203,12 @@ renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string old_name; - if (xc->mem->readString(old_name, xc->getSyscallArg(0)) != No_Fault) + if (xc->cpu->memPort->readStringFunctional(old_name, xc->getSyscallArg(0)) != No_Fault) return -EFAULT; string new_name; - if (xc->mem->readString(new_name, xc->getSyscallArg(1)) != No_Fault) + if (xc->cpu->memPort->readStringFunctional(new_name, xc->getSyscallArg(1)) != No_Fault) return -EFAULT; int64_t result = rename(old_name.c_str(), new_name.c_str()); @@ -220,7 +220,7 @@ truncateFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string path; - if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault) + if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) return -EFAULT; off_t length = xc->getSyscallArg(1); @@ -248,7 +248,7 @@ chownFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc) { string path; - if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault) + if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) return -EFAULT; /* XXX endianess */ diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh index bdaae9015..04b7bbe1c 100644 --- a/sim/syscall_emul.hh +++ b/sim/syscall_emul.hh @@ -48,6 +48,7 @@ #include "base/trace.hh" #include "cpu/exec_context.hh" +#include "cpu/base.hh" #include "sim/process.hh" /// @@ -314,8 +315,11 @@ openFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->mem->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) +/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) return -EFAULT; +*/ + //@todo Fix fault condition + xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)); if (path == "/dev/sysdev0") { // This is a memory-mapped high-resolution timer device on Alpha. @@ -361,8 +365,11 @@ chmodFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->mem->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) +/* + if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) return -EFAULT; +*/ + xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)); uint32_t mode = xc->getSyscallArg(1); mode_t hostMode = 0; @@ -414,8 +421,11 @@ statFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->mem->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) - return -EFAULT; +/* + if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) + return -EFAULT; */ + + xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)); struct stat hostBuf; int result = stat(path.c_str(), &hostBuf); @@ -423,7 +433,7 @@ statFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return errno; - OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -447,7 +457,7 @@ fstat64Func(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return errno; - OS::copyOutStat64Buf(xc->mem, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStat64Buf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -461,8 +471,10 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->mem->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) - return -EFAULT; +/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) + return -EFAULT;*/ + + xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)); struct stat hostBuf; int result = lstat(path.c_str(), &hostBuf); @@ -470,7 +482,7 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -483,8 +495,10 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->mem->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) - return -EFAULT; +/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) + return -EFAULT; */ + + xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)); struct stat64 hostBuf; int result = lstat64(path.c_str(), &hostBuf); @@ -492,7 +506,7 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStat64Buf(xc->mem, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStat64Buf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -516,7 +530,7 @@ fstatFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return -errno; - OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -530,8 +544,10 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->mem->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) - return -EFAULT; +/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) + return -EFAULT;*/ + + xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)); struct statfs hostBuf; int result = statfs(path.c_str(), &hostBuf); @@ -539,7 +555,7 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return errno; - OS::copyOutStatfsBuf(xc->mem, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatfsBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -562,7 +578,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, Process *process, if (result < 0) return errno; - OS::copyOutStatfsBuf(xc->mem, xc->getSyscallArg(1), &hostBuf); + OS::copyOutStatfsBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf); return 0; } @@ -586,11 +602,11 @@ writevFunc(SyscallDesc *desc, int callnum, Process *process, for (int i = 0; i < count; ++i) { typename OS::tgt_iovec tiov; - xc->mem->access(Read, tiov_base + i*sizeof(typename OS::tgt_iovec), + xc->cpu->memPort->readBlobFunctional(tiov_base + i*sizeof(typename OS::tgt_iovec), &tiov, sizeof(typename OS::tgt_iovec)); hiov[i].iov_len = tiov.iov_len; hiov[i].iov_base = new char [hiov[i].iov_len]; - xc->mem->access(Read, tiov.iov_base, + xc->cpu->memPort->readBlobFunctional(tiov.iov_base, hiov[i].iov_base, hiov[i].iov_len); } @@ -671,7 +687,7 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process, break; } - rlp.copyOut(xc->mem); + rlp.copyOut(xc->cpu->memPort); return 0; } @@ -686,7 +702,7 @@ gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process, getElapsedTime(tp->tv_sec, tp->tv_usec); tp->tv_sec += seconds_since_epoch; - tp.copyOut(xc->mem); + tp.copyOut(xc->cpu->memPort); return 0; } @@ -700,11 +716,13 @@ utimesFunc(SyscallDesc *desc, int callnum, Process *process, { std::string path; - if (xc->mem->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) - return -EFAULT; +/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault) + return -EFAULT;*/ + + xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)); TypedBufferArg tp(xc->getSyscallArg(1)); - tp.copyIn(xc->mem); + tp.copyIn(xc->cpu->memPort); struct timeval hostTimeval[2]; for (int i = 0; i < 2; ++i) @@ -754,7 +772,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process, rup->ru_nvcsw = 0; rup->ru_nivcsw = 0; - rup.copyOut(xc->mem); + rup.copyOut(xc->cpu->memPort); return 0; }