summaryrefslogtreecommitdiff
path: root/src/arch/mips
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/mips')
-rwxr-xr-xsrc/arch/mips/BISystem.py5
-rw-r--r--src/arch/mips/MipsCPU.py5
-rw-r--r--src/arch/mips/MipsSystem.py6
-rwxr-xr-xsrc/arch/mips/dsp.cc4
-rw-r--r--src/arch/mips/isa.hh7
-rw-r--r--src/arch/mips/isa/formats/mem.isa2
-rw-r--r--src/arch/mips/linux/linux.hh17
-rw-r--r--src/arch/mips/linux/process.cc27
-rw-r--r--src/arch/mips/linux/process.hh2
-rw-r--r--src/arch/mips/process.cc85
-rw-r--r--src/arch/mips/process.hh6
11 files changed, 135 insertions, 31 deletions
diff --git a/src/arch/mips/BISystem.py b/src/arch/mips/BISystem.py
index dd4e4fe25..a6e4091f2 100755
--- a/src/arch/mips/BISystem.py
+++ b/src/arch/mips/BISystem.py
@@ -28,10 +28,11 @@
#
# Authors: Jaidev Patwardhan
-from m5 import build_env
+from m5.defines import buildEnv
+
from System import *
-if build_env['FULL_SYSTEM']:
+if buildEnv['FULL_SYSTEM']:
class BareIronMipsSystem(MipsSystem):
type = 'BareIronMipsSystem'
system_type = 34
diff --git a/src/arch/mips/MipsCPU.py b/src/arch/mips/MipsCPU.py
index 81c6bdacf..48ee4171c 100644
--- a/src/arch/mips/MipsCPU.py
+++ b/src/arch/mips/MipsCPU.py
@@ -29,12 +29,13 @@
# Authors: Jaidev Patwardhan
# Korey Sewell
-from m5.SimObject import SimObject
+from m5.defines import buildEnv
from m5.params import *
+
from BaseCPU import BaseCPU
class BaseMipsCPU(BaseCPU)
- if build_env['TARGET_ISA'] == 'mips':
+ if buildEnv['TARGET_ISA'] == 'mips':
CP0_IntCtl_IPTI = Param.Unsigned(0,"No Description")
CP0_IntCtl_IPPCI = Param.Unsigned(0,"No Description")
CP0_SrsCtl_HSS = Param.Unsigned(0,"No Description")
diff --git a/src/arch/mips/MipsSystem.py b/src/arch/mips/MipsSystem.py
index c3dcf4e0b..d271bd387 100644
--- a/src/arch/mips/MipsSystem.py
+++ b/src/arch/mips/MipsSystem.py
@@ -28,10 +28,10 @@
#
# Authors: Jaidev Patwardhan
-from m5.SimObject import SimObject
+from m5.defines import buildEnv
from m5.params import *
from m5.proxy import *
-from m5 import build_env
+
from System import System
class MipsSystem(System):
@@ -42,7 +42,7 @@ class MipsSystem(System):
system_type = Param.UInt64("Type of system we are emulating")
system_rev = Param.UInt64("Revision of system we are emulating")
-if build_env['FULL_SYSTEM']:
+if buildEnv['FULL_SYSTEM']:
class LinuxMipsSystem(MipsSystem):
type = 'LinuxMipsSystem'
system_type = 34
diff --git a/src/arch/mips/dsp.cc b/src/arch/mips/dsp.cc
index 6e4f7afea..b8b02ae9e 100755
--- a/src/arch/mips/dsp.cc
+++ b/src/arch/mips/dsp.cc
@@ -463,6 +463,8 @@ MipsISA::dspMuleq(int32_t a, int32_t b, int32_t mode, uint32_t *dspctl)
uint64_t b_values[SIMD_MAX_VALS];
uint64_t c_values[SIMD_MAX_VALS];
+ memset(c_values, 0, sizeof(c_values));
+
simdUnpack(a, a_values, SIMD_FMT_PH, SIGNED);
simdUnpack(b, b_values, SIMD_FMT_PH, SIGNED);
@@ -743,7 +745,7 @@ MipsISA::dspMulsaq(int64_t dspac, int32_t a, int32_t b, int32_t ac,
int nvals = SIMD_NVALS[fmt];
uint64_t a_values[SIMD_MAX_VALS];
uint64_t b_values[SIMD_MAX_VALS];
- int64_t temp[2];
+ int64_t temp[2] = {0, 0};
uint32_t ouflag = 0;
simdUnpack(a, a_values, fmt, SIGNED);
diff --git a/src/arch/mips/isa.hh b/src/arch/mips/isa.hh
index 15c043dc0..165adff83 100644
--- a/src/arch/mips/isa.hh
+++ b/src/arch/mips/isa.hh
@@ -172,8 +172,11 @@ namespace MipsISA
return reg;
}
- void serialize(std::ostream &os);
- void unserialize(Checkpoint *cp, const std::string &section);
+ void serialize(EventManager *em, std::ostream &os)
+ {}
+ void unserialize(EventManager *em, Checkpoint *cp,
+ const std::string &section)
+ {}
};
}
diff --git a/src/arch/mips/isa/formats/mem.isa b/src/arch/mips/isa/formats/mem.isa
index adcb16137..161a52b06 100644
--- a/src/arch/mips/isa/formats/mem.isa
+++ b/src/arch/mips/isa/formats/mem.isa
@@ -619,7 +619,7 @@ def format StoreUnalignedMemory(memacc_code, ea_code = {{ EA = (Rs + disp) & ~3;
def format Prefetch(ea_code = {{ EA = Rs + disp; }},
mem_flags = [], pf_flags = [], inst_flags = []) {{
- pf_mem_flags = mem_flags + pf_flags + ['NO_FAULT']
+ pf_mem_flags = mem_flags + pf_flags + ['PREFETCH']
pf_inst_flags = inst_flags + ['IsMemRef', 'IsLoad',
'IsDataPrefetch', 'MemReadOp']
diff --git a/src/arch/mips/linux/linux.hh b/src/arch/mips/linux/linux.hh
index ee81fa18f..a2418cfb6 100644
--- a/src/arch/mips/linux/linux.hh
+++ b/src/arch/mips/linux/linux.hh
@@ -100,6 +100,7 @@ class MipsLinux : public Linux
static const unsigned TIOCISATTY_ = 0x5480;
static const unsigned TIOCGETS_ = 0x540d;
static const unsigned TIOCGETA_ = 0x7417;
+ static const unsigned TCSETAW_ = 0x5403; // 2.6.15 kernel
//@}
/// For table().
@@ -126,6 +127,22 @@ class MipsLinux : public Linux
/// assign themselves to process IDs reserved for
/// the root users.
static const int NUM_ROOT_PROCS = 2;
+
+ typedef struct {
+ int32_t uptime; /* Seconds since boot */
+ uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
+ uint32_t totalram; /* Total usable main memory size */
+ uint32_t freeram; /* Available memory size */
+ uint32_t sharedram; /* Amount of shared memory */
+ uint32_t bufferram; /* Memory used by buffers */
+ uint32_t totalswap; /* Total swap space size */
+ uint32_t freeswap; /* swap space still available */
+ uint16_t procs; /* Number of current processes */
+ uint32_t totalhigh; /* Total high memory size */
+ uint32_t freehigh; /* Available high memory size */
+ uint32_t mem_unit; /* Memory unit size in bytes */
+ } tgt_sysinfo;
+
};
#endif
diff --git a/src/arch/mips/linux/process.cc b/src/arch/mips/linux/process.cc
index 53a24487f..c2a05b73b 100644
--- a/src/arch/mips/linux/process.cc
+++ b/src/arch/mips/linux/process.cc
@@ -51,7 +51,8 @@ static SyscallReturn
unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
+ int index = 0;
+ TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
strcpy(name->sysname, "Linux");
strcpy(name->nodename,"m5.eecs.umich.edu");
@@ -70,14 +71,16 @@ static SyscallReturn
sys_getsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- unsigned op = process->getSyscallArg(tc, 0);
- // unsigned nbytes = process->getSyscallArg(tc, 2);
+ int index = 0;
+ unsigned op = process->getSyscallArg(tc, index);
+ unsigned bufPtr = process->getSyscallArg(tc, index);
+ // unsigned nbytes = process->getSyscallArg(tc, index);
switch (op) {
case 45:
{
// GSI_IEEE_FP_CONTROL
- TypedBufferArg<uint64_t> fpcr(process->getSyscallArg(tc, 1));
+ TypedBufferArg<uint64_t> fpcr(bufPtr);
// I don't think this exactly matches the HW FPCR
*fpcr = 0;
fpcr.copyOut(tc->getMemPort());
@@ -97,15 +100,17 @@ static SyscallReturn
sys_setsysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- unsigned op = process->getSyscallArg(tc, 0);
- // unsigned nbytes = process->getSyscallArg(tc, 2);
+ int index = 0;
+ unsigned op = process->getSyscallArg(tc, index);
+ Addr bufPtr = process->getSyscallArg(tc, index);
+ // unsigned nbytes = process->getSyscallArg(tc, index);
switch (op) {
case 14:
{
// SSI_IEEE_FP_CONTROL
- TypedBufferArg<uint64_t> fpcr(process->getSyscallArg(tc, 1));
+ TypedBufferArg<uint64_t> fpcr(bufPtr);
// I don't think this exactly matches the HW FPCR
fpcr.copyIn(tc->getMemPort());
DPRINTFR(SyscallVerbose, "sys_setsysinfo(SSI_IEEE_FP_CONTROL): "
@@ -238,7 +243,7 @@ SyscallDesc MipsLinuxProcess::syscallDescs[] = {
/* 113 */ SyscallDesc("vm86", unimplementedFunc),
/* 114 */ SyscallDesc("wait4", unimplementedFunc),
/* 115 */ SyscallDesc("swapoff", unimplementedFunc),
- /* 116 */ SyscallDesc("sysinfo", unimplementedFunc),
+ /* 116 */ SyscallDesc("sysinfo", sysinfoFunc<MipsLinux>),
/* 117 */ SyscallDesc("ipc", unimplementedFunc),
/* 118 */ SyscallDesc("fsync", unimplementedFunc),
/* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
@@ -413,12 +418,6 @@ MipsLinuxProcess::MipsLinuxProcess(LiveProcessParams * params,
Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
{ }
-void
-MipsLinuxProcess::startup()
-{
- MipsLiveProcess::argsInit(MachineBytes, VMPageSize);
-}
-
SyscallDesc*
MipsLinuxProcess::getDesc(int callnum)
{
diff --git a/src/arch/mips/linux/process.hh b/src/arch/mips/linux/process.hh
index 5afde2be1..8c45014e0 100644
--- a/src/arch/mips/linux/process.hh
+++ b/src/arch/mips/linux/process.hh
@@ -43,8 +43,6 @@ class MipsLinuxProcess : public MipsLiveProcess
/// Constructor.
MipsLinuxProcess(LiveProcessParams * params, ObjectFile *objFile);
- void startup();
-
virtual SyscallDesc* getDesc(int callnum);
/// The target system's hostname.
diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc
index 3e9fb7c20..d96b0c81c 100644
--- a/src/arch/mips/process.cc
+++ b/src/arch/mips/process.cc
@@ -32,9 +32,15 @@
#include "arch/mips/isa_traits.hh"
#include "arch/mips/process.hh"
+
#include "base/loader/object_file.hh"
#include "base/misc.hh"
#include "cpu/thread_context.hh"
+
+#include "mem/page_table.hh"
+
+#include "sim/process.hh"
+#include "sim/process_impl.hh"
#include "sim/system.hh"
using namespace std;
@@ -62,14 +68,89 @@ MipsLiveProcess::MipsLiveProcess(LiveProcessParams * params,
void
MipsLiveProcess::startup()
{
+ Process::startup();
+
argsInit(MachineBytes, VMPageSize);
}
+void
+MipsLiveProcess::argsInit(int intSize, int pageSize)
+{
+ // load object file into target memory
+ objFile->loadSections(initVirtMem);
+
+ // Calculate how much space we need for arg & env arrays.
+ int argv_array_size = intSize * (argv.size() + 1);
+ int envp_array_size = intSize * (envp.size() + 1);
+ int arg_data_size = 0;
+ for (vector<string>::size_type i = 0; i < argv.size(); ++i) {
+ arg_data_size += argv[i].size() + 1;
+ }
+ int env_data_size = 0;
+ for (vector<string>::size_type i = 0; i < envp.size(); ++i) {
+ env_data_size += envp[i].size() + 1;
+ }
+
+ int space_needed =
+ argv_array_size + envp_array_size + arg_data_size + env_data_size;
+ if (space_needed < 32*1024)
+ space_needed = 32*1024;
+
+ // set bottom of stack
+ stack_min = stack_base - space_needed;
+ // align it
+ stack_min = roundDown(stack_min, pageSize);
+ stack_size = stack_base - stack_min;
+ // map memory
+ pTable->allocate(stack_min, roundUp(stack_size, pageSize));
+
+ // map out initial stack contents
+ // ========
+ // NOTE: Using uint32_t hardcodes MIPS32 and not MIPS64
+ // even if MIPS64 was intended. This is because the
+ // copyStringArray function templates on the parameters.
+ // Elegant way to check intSize and vary between 32/64?
+ // ========
+ uint32_t argv_array_base = stack_min + intSize; // room for argc
+ uint32_t envp_array_base = argv_array_base + argv_array_size;
+ uint32_t arg_data_base = envp_array_base + envp_array_size;
+ uint32_t env_data_base = arg_data_base + arg_data_size;
+
+ // write contents to stack
+ uint32_t argc = argv.size();
+
+ if (intSize == 8)
+ argc = htog((uint64_t)argc);
+ else if (intSize == 4)
+ argc = htog((uint32_t)argc);
+ else
+ panic("Unknown int size");
+
+
+ initVirtMem->writeBlob(stack_min, (uint8_t*)&argc, intSize);
+
+ copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
+
+ copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
+
+ ThreadContext *tc = system->getThreadContext(contextIds[0]);
+
+ setSyscallArg(tc, 0, argc);
+ setSyscallArg(tc, 1, argv_array_base);
+ tc->setIntReg(StackPointerReg, stack_min);
+
+ Addr prog_entry = objFile->entryPoint();
+ tc->setPC(prog_entry);
+ tc->setNextPC(prog_entry + sizeof(MachInst));
+ tc->setNextNPC(prog_entry + (2 * sizeof(MachInst)));
+}
+
+
MipsISA::IntReg
-MipsLiveProcess::getSyscallArg(ThreadContext *tc, int i)
+MipsLiveProcess::getSyscallArg(ThreadContext *tc, int &i)
{
assert(i < 6);
- return tc->readIntReg(FirstArgumentReg + i);
+ return tc->readIntReg(FirstArgumentReg + i++);
}
void
diff --git a/src/arch/mips/process.hh b/src/arch/mips/process.hh
index 87c62330f..f35ec8554 100644
--- a/src/arch/mips/process.hh
+++ b/src/arch/mips/process.hh
@@ -45,10 +45,12 @@ class MipsLiveProcess : public LiveProcess
protected:
MipsLiveProcess(LiveProcessParams * params, ObjectFile *objFile);
- virtual void startup();
+ void startup();
+
+ void argsInit(int intSize, int pageSize);
public:
- MipsISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+ MipsISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
void setSyscallArg(ThreadContext *tc, int i, MipsISA::IntReg val);
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
};