summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorRon Dreslinski <rdreslin@umich.edu>2006-02-20 23:26:39 -0500
committerRon Dreslinski <rdreslin@umich.edu>2006-02-20 23:26:39 -0500
commitd96de69abc02b40e1dec4843a7a7b7e30749f4fa (patch)
tree0c3fd42012ec416fcabdc8691f2ccd202ee98865 /sim
parentb74f1b829d14e43256fb4a9efd3b951e81ad12d2 (diff)
downloadgem5-d96de69abc02b40e1dec4843a7a7b7e30749f4fa.tar.xz
Add in a new translating port that allows syscalls to translate addresses via the page table before accessing the memory port.
Other compile issues cleaned up. SConscript: Changes to compile the new Translating Port. Split out memtester and eio support, will rework them back in after first getting a simpleCPU to work arch/alpha/alpha_linux_process.cc: arch/alpha/alpha_tru64_process.cc: sim/syscall_emul.cc: sim/syscall_emul.hh: Changes to use the new translating Port. cpu/exec_context.cc: cpu/exec_context.hh: Create a translating port in each execution context. sim/process.cc: Fix the way we do proxy memory --HG-- extra : convert_revision : 3d33218fe8b425a5d9ce24757f1112b4aa6001fd
Diffstat (limited to 'sim')
-rw-r--r--sim/process.cc4
-rw-r--r--sim/syscall_emul.cc16
-rw-r--r--sim/syscall_emul.hh75
3 files changed, 39 insertions, 56 deletions
diff --git a/sim/process.cc b/sim/process.cc
index 26d6bf708..2355fdc19 100644
--- a/sim/process.cc
+++ b/sim/process.cc
@@ -154,7 +154,7 @@ Process::startup()
if (execContexts.empty())
fatal("Process %s is not associated with any CPUs!\n", name());
- initVirtMem = new ProxyMemory<Memory>(system->physmem, pTable);
+ initVirtMem = new ProxyMemory(system->physmem, pTable);
// first exec context for this process... initialize & enable
ExecContext *xc = execContexts[0];
@@ -249,7 +249,7 @@ copyStringArray(vector<string> &strings, Addr array_ptr, Addr data_ptr,
{
for (int i = 0; i < strings.size(); ++i) {
func->prot_write(array_ptr, (uint8_t*)&data_ptr, sizeof(Addr));
- func->writeString(data_ptr, strings[i].c_str());
+ func->writeStringFunctional(data_ptr, strings[i].c_str());
array_ptr += sizeof(Addr);
data_ptr += strings[i].size() + 1;
}
diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc
index 78b4201d4..0cebee0e1 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->cpu->memPort);
+ bufArg.copyOut(xc->port);
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->cpu->memPort);
+ bufArg.copyIn(xc->port);
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->cpu->memPort);
+ name.copyOut(xc->port);
return 0;
}
@@ -191,7 +191,7 @@ unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
string path;
- if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ if (xc->port->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->cpu->memPort->readStringFunctional(old_name, xc->getSyscallArg(0)) != No_Fault)
+ if (xc->port->readStringFunctional(old_name, xc->getSyscallArg(0)) != No_Fault)
return -EFAULT;
string new_name;
- if (xc->cpu->memPort->readStringFunctional(new_name, xc->getSyscallArg(1)) != No_Fault)
+ if (xc->port->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->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ if (xc->port->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->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
return -EFAULT;
/* XXX endianess */
diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh
index 04b7bbe1c..ed3b0fc8b 100644
--- a/sim/syscall_emul.hh
+++ b/sim/syscall_emul.hh
@@ -43,7 +43,7 @@
#include <sys/uio.h>
#include "base/intmath.hh" // for RoundUp
-#include "mem/port.hh"
+#include "mem/translating_port.hh"
#include "targetarch/isa_traits.hh" // for Addr
#include "base/trace.hh"
@@ -104,7 +104,7 @@ class BaseBufferArg {
//
// copy data into simulator space (read from target memory)
//
- virtual bool copyIn(Port *memport)
+ virtual bool copyIn(TranslatingPort *memport)
{
memport->readBlobFunctional(addr, bufPtr, size);
return true; // no EFAULT detection for now
@@ -113,7 +113,7 @@ class BaseBufferArg {
//
// copy data out of simulator space (write to target memory)
//
- virtual bool copyOut(Port *memport)
+ virtual bool copyOut(TranslatingPort *memport)
{
memport->writeBlobFunctional(addr, bufPtr, size);
return true; // no EFAULT detection for now
@@ -315,11 +315,8 @@ openFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
-/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ if (xc->port->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.
@@ -365,11 +362,8 @@ chmodFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
-/*
- if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ if (xc->port->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;
@@ -421,11 +415,8 @@ statFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
-/*
- if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT; */
-
- xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0));
+ if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ return -EFAULT;
struct stat hostBuf;
int result = stat(path.c_str(), &hostBuf);
@@ -433,7 +424,7 @@ statFunc(SyscallDesc *desc, int callnum, Process *process,
if (result < 0)
return errno;
- OS::copyOutStatBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf);
+ OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf);
return 0;
}
@@ -457,7 +448,7 @@ fstat64Func(SyscallDesc *desc, int callnum, Process *process,
if (result < 0)
return errno;
- OS::copyOutStat64Buf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf);
+ OS::copyOutStat64Buf(xc->port, xc->getSyscallArg(1), &hostBuf);
return 0;
}
@@ -471,10 +462,8 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
-/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT;*/
-
- xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0));
+ if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ return -EFAULT;
struct stat hostBuf;
int result = lstat(path.c_str(), &hostBuf);
@@ -482,7 +471,7 @@ lstatFunc(SyscallDesc *desc, int callnum, Process *process,
if (result < 0)
return -errno;
- OS::copyOutStatBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf);
+ OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf);
return 0;
}
@@ -495,10 +484,8 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
-/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT; */
-
- xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0));
+ if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ return -EFAULT;
struct stat64 hostBuf;
int result = lstat64(path.c_str(), &hostBuf);
@@ -506,7 +493,7 @@ lstat64Func(SyscallDesc *desc, int callnum, Process *process,
if (result < 0)
return -errno;
- OS::copyOutStat64Buf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf);
+ OS::copyOutStat64Buf(xc->port, xc->getSyscallArg(1), &hostBuf);
return 0;
}
@@ -530,7 +517,7 @@ fstatFunc(SyscallDesc *desc, int callnum, Process *process,
if (result < 0)
return -errno;
- OS::copyOutStatBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf);
+ OS::copyOutStatBuf(xc->port, xc->getSyscallArg(1), &hostBuf);
return 0;
}
@@ -544,10 +531,8 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
-/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT;*/
-
- xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0));
+ if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ return -EFAULT;
struct statfs hostBuf;
int result = statfs(path.c_str(), &hostBuf);
@@ -555,7 +540,7 @@ statfsFunc(SyscallDesc *desc, int callnum, Process *process,
if (result < 0)
return errno;
- OS::copyOutStatfsBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf);
+ OS::copyOutStatfsBuf(xc->port, xc->getSyscallArg(1), &hostBuf);
return 0;
}
@@ -578,7 +563,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, Process *process,
if (result < 0)
return errno;
- OS::copyOutStatfsBuf(xc->cpu->memPort, xc->getSyscallArg(1), &hostBuf);
+ OS::copyOutStatfsBuf(xc->port, xc->getSyscallArg(1), &hostBuf);
return 0;
}
@@ -602,12 +587,12 @@ writevFunc(SyscallDesc *desc, int callnum, Process *process,
for (int i = 0; i < count; ++i)
{
typename OS::tgt_iovec tiov;
- xc->cpu->memPort->readBlobFunctional(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 = tiov.iov_len;
hiov[i].iov_base = new char [hiov[i].iov_len];
- xc->cpu->memPort->readBlobFunctional(tiov.iov_base,
- hiov[i].iov_base, hiov[i].iov_len);
+ xc->port->readBlobFunctional(tiov.iov_base,
+ (uint8_t *)hiov[i].iov_base, hiov[i].iov_len);
}
int result = writev(process->sim_fd(fd), hiov, count);
@@ -687,7 +672,7 @@ getrlimitFunc(SyscallDesc *desc, int callnum, Process *process,
break;
}
- rlp.copyOut(xc->cpu->memPort);
+ rlp.copyOut(xc->port);
return 0;
}
@@ -702,7 +687,7 @@ gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process,
getElapsedTime(tp->tv_sec, tp->tv_usec);
tp->tv_sec += seconds_since_epoch;
- tp.copyOut(xc->cpu->memPort);
+ tp.copyOut(xc->port);
return 0;
}
@@ -716,13 +701,11 @@ utimesFunc(SyscallDesc *desc, int callnum, Process *process,
{
std::string path;
-/* if (xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT;*/
-
- xc->cpu->memPort->readStringFunctional(path, xc->getSyscallArg(0));
+ if (xc->port->readStringFunctional(path, xc->getSyscallArg(0)) != No_Fault)
+ return -EFAULT;
TypedBufferArg<typename OS::timeval [2]> tp(xc->getSyscallArg(1));
- tp.copyIn(xc->cpu->memPort);
+ tp.copyIn(xc->port);
struct timeval hostTimeval[2];
for (int i = 0; i < 2; ++i)
@@ -772,7 +755,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process,
rup->ru_nvcsw = 0;
rup->ru_nivcsw = 0;
- rup.copyOut(xc->cpu->memPort);
+ rup.copyOut(xc->port);
return 0;
}