#include "mem/page_table.hh"
#include "mem/physical.hh"
#include "mem/translating_port.hh"
-#include "sim/builder.hh"
+#include "params/LiveProcess.hh"
#include "sim/process.hh"
+#include "sim/process_impl.hh"
#include "sim/stats.hh"
#include "sim/syscall_emul.hh"
#include "sim/system.hh"
#include "arch/sparc/solaris/process.hh"
#elif THE_ISA == MIPS_ISA
#include "arch/mips/linux/process.hh"
+#elif THE_ISA == X86_ISA
+#include "arch/x86/linux/process.hh"
#else
#error "THE_ISA not set"
#endif
int myIndex = threadContexts.size();
threadContexts.push_back(tc);
- RemoteGDB *rgdb = new RemoteGDB(system, tc);
- GDBListener *gdbl = new GDBListener(rgdb, 7000 + myIndex);
- gdbl->listen();
+// RemoteGDB *rgdb = new RemoteGDB(system, tc);
+// GDBListener *gdbl = new GDBListener(rgdb, 7000 + myIndex);
+// gdbl->listen();
//gdbl->accept();
- remoteGDB.push_back(rgdb);
+// remoteGDB.push_back(rgdb);
// return CPU number to caller
return myIndex;
Port *mem_port;
mem_port = system->physmem->getPort("functional");
- initVirtMem = new TranslatingPort("process init port", pTable, true);
+ initVirtMem = new TranslatingPort("process init port", this,
+ TranslatingPort::Always);
mem_port->setPeer(initVirtMem);
initVirtMem->setPeer(mem_port);
}
return fd_map[tgt_fd];
}
+bool
+Process::checkAndAllocNextPage(Addr vaddr)
+{
+ // if this is an initial write we might not have
+ if (vaddr >= stack_min && vaddr < stack_base) {
+ pTable->allocate(roundDown(vaddr, VMPageSize), VMPageSize);
+ return true;
+ }
+
+ // We've accessed the next page of the stack, so extend the stack
+ // to cover it.
+ if(vaddr < stack_min && vaddr >= stack_min - TheISA::PageBytes)
+ {
+ stack_min -= TheISA::PageBytes;
+ if(stack_base - stack_min > 8*1024*1024)
+ fatal("Over max stack size for one thread\n");
+ pTable->allocate(stack_min, TheISA::PageBytes);
+ warn("Increasing stack size by one page.");
+ return true;
+ }
+ return false;
+}
+
void
Process::serialize(std::ostream &os)
{
}
-//
-// need to declare these here since there is no concrete Process type
-// that can be constructed (i.e., no REGISTER_SIM_OBJECT() macro call,
-// which is where these get declared for concrete types).
-//
-DEFINE_SIM_OBJECT_CLASS_NAME("Process", Process)
-
-
////////////////////////////////////////////////////////////////////////
//
// LiveProcess member definitions
default:
fatal("Unknown/unsupported operating system.");
}
+#elif THE_ISA == X86_ISA
+ if (objFile->getArch() != ObjectFile::X86)
+ fatal("Object file architecture does not match compiled ISA (x86).");
+ switch (objFile->getOpSys()) {
+ case ObjectFile::Linux:
+ process = new X86LinuxProcess(nm, objFile, system,
+ stdin_fd, stdout_fd, stderr_fd,
+ argv, envp, cwd,
+ _uid, _euid, _gid,
+ _egid, _pid, _ppid);
+ break;
+ default:
+ fatal("Unknown/unsupported operating system.");
+ }
#elif THE_ISA == MIPS_ISA
if (objFile->getArch() != ObjectFile::Mips)
fatal("Object file architecture does not match compiled ISA (MIPS).");
return process;
}
-
-BEGIN_DECLARE_SIM_OBJECT_PARAMS(LiveProcess)
-
- VectorParam<string> cmd;
- Param<string> executable;
- Param<string> input;
- Param<string> output;
- VectorParam<string> env;
- Param<string> cwd;
- SimObjectParam<System *> system;
- Param<uint64_t> uid;
- Param<uint64_t> euid;
- Param<uint64_t> gid;
- Param<uint64_t> egid;
- Param<uint64_t> pid;
- Param<uint64_t> ppid;
-
-END_DECLARE_SIM_OBJECT_PARAMS(LiveProcess)
-
-
-BEGIN_INIT_SIM_OBJECT_PARAMS(LiveProcess)
-
- INIT_PARAM(cmd, "command line (executable plus arguments)"),
- 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(cwd, "current working directory"),
- INIT_PARAM(system, "system"),
- INIT_PARAM(uid, "user id"),
- INIT_PARAM(euid, "effective user id"),
- INIT_PARAM(gid, "group id"),
- INIT_PARAM(egid, "effective group id"),
- INIT_PARAM(pid, "process id"),
- INIT_PARAM(ppid, "parent process id")
-
-END_INIT_SIM_OBJECT_PARAMS(LiveProcess)
-
-
-CREATE_SIM_OBJECT(LiveProcess)
+LiveProcess *
+LiveProcessParams::create()
{
string in = input;
string out = output;
stderr_fd = (stdout_fd != STDOUT_FILENO) ? stdout_fd : STDERR_FILENO;
- return LiveProcess::create(getInstanceName(), system,
+ return LiveProcess::create(name, system,
stdin_fd, stdout_fd, stderr_fd,
(string)executable == "" ? cmd[0] : executable,
cmd, env, cwd,
uid, euid, gid, egid, pid, ppid);
}
-
-
-REGISTER_SIM_OBJECT("LiveProcess", LiveProcess)