summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabor Dozsa <gabor.dozsa@arm.com>2016-01-07 16:33:47 -0600
committerGabor Dozsa <gabor.dozsa@arm.com>2016-01-07 16:33:47 -0600
commite67749426054d8ddb7f11b53a89741d4808f3acb (patch)
tree6070cdd030bb632be375ababdf30680f50fccae0 /src
parent6caa2c9b4ea8ed3a29c44dec60b791344b5fd477 (diff)
downloadgem5-e67749426054d8ddb7f11b53a89741d4808f3acb.tar.xz
pseudo inst,util: Add optional key to initparam pseudo instruction
The key parameter can be used to read out various config parameters from within the simulated software.
Diffstat (limited to 'src')
-rw-r--r--src/arch/alpha/isa/decoder.isa2
-rw-r--r--src/arch/arm/isa/insts/m5ops.isa5
-rw-r--r--src/arch/x86/isa/decoder/two_byte_opcodes.isa2
-rw-r--r--src/sim/pseudo_inst.cc36
-rw-r--r--src/sim/pseudo_inst.hh2
5 files changed, 38 insertions, 9 deletions
diff --git a/src/arch/alpha/isa/decoder.isa b/src/arch/alpha/isa/decoder.isa
index e61bb43ff..a114afaea 100644
--- a/src/arch/alpha/isa/decoder.isa
+++ b/src/arch/alpha/isa/decoder.isa
@@ -982,7 +982,7 @@ decode OPCODE default Unknown::unknown() {
PseudoInst::loadsymbol(xc->tcBase());
}}, No_OpClass, IsNonSpeculative);
0x30: initparam({{
- Ra = PseudoInst::initParam(xc->tcBase());
+ Ra = PseudoInst::initParam(xc->tcBase(), R16, R17);
}});
0x40: resetstats({{
PseudoInst::resetstats(xc->tcBase(), R16, R17);
diff --git a/src/arch/arm/isa/insts/m5ops.isa b/src/arch/arm/isa/insts/m5ops.isa
index e18d0682c..efe88c73a 100644
--- a/src/arch/arm/isa/insts/m5ops.isa
+++ b/src/arch/arm/isa/insts/m5ops.isa
@@ -276,13 +276,14 @@ let {{
exec_output += PredOpExecute.subst(loadsymbolIop)
initparamCode = '''
- uint64_t ip_val = PseudoInst::initParam(xc->tcBase());
+ uint64_t ip_val = PseudoInst::initParam(xc->tcBase(), join32to64(R1, R0),
+ join32to64(R3, R2));
R0 = bits(ip_val, 31, 0);
R1 = bits(ip_val, 63, 32);
'''
initparamCode64 = '''
- X0 = PseudoInst::initParam(xc->tcBase());
+ X0 = PseudoInst::initParam(xc->tcBase(), X0, X1);
'''
initparamIop = InstObjParams("initparam", "Initparam", "PredOp",
diff --git a/src/arch/x86/isa/decoder/two_byte_opcodes.isa b/src/arch/x86/isa/decoder/two_byte_opcodes.isa
index 4a21e2900..01e8e9b0c 100644
--- a/src/arch/x86/isa/decoder/two_byte_opcodes.isa
+++ b/src/arch/x86/isa/decoder/two_byte_opcodes.isa
@@ -173,7 +173,7 @@
PseudoInst::m5fail(xc->tcBase(), Rdi, Rsi);
}}, IsNonSpeculative);
0x30: m5initparam({{
- Rax = PseudoInst::initParam(xc->tcBase());
+ Rax = PseudoInst::initParam(xc->tcBase(), Rdi, Rsi);
}}, IsNonSpeculative);
0x31: m5loadsymbol({{
PseudoInst::loadsymbol(xc->tcBase());
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index 260ffec6e..0f7de0c3a 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -141,7 +141,7 @@ pseudoInst(ThreadContext *tc, uint8_t func, uint8_t subfunc)
break;
case 0x30: // initparam_func
- return initParam(tc);
+ return initParam(tc, args[0], args[1]);
case 0x31: // loadsymbol_func
loadsymbol(tc);
@@ -440,15 +440,43 @@ addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
}
uint64_t
-initParam(ThreadContext *tc)
+initParam(ThreadContext *tc, uint64_t key_str1, uint64_t key_str2)
{
- DPRINTF(PseudoInst, "PseudoInst::initParam()\n");
+ DPRINTF(PseudoInst, "PseudoInst::initParam() key:%s%s\n", (char *)&key_str1,
+ (char *)&key_str2);
if (!FullSystem) {
panicFsOnlyPseudoInst("initParam");
return 0;
}
- return tc->getCpuPtr()->system->init_param;
+ // The key parameter string is passed in via two 64-bit registers. We copy
+ // out the characters from the 64-bit integer variables here and concatenate
+ // them in the key_str character buffer
+ const int len = 2 * sizeof(uint64_t) + 1;
+ char key_str[len];
+ memset(key_str, '\0', len);
+ if (key_str1 == 0) {
+ assert(key_str2 == 0);
+ } else {
+ strncpy(key_str, (char *)&key_str1, sizeof(uint64_t));
+ }
+
+ if (strlen(key_str) == sizeof(uint64_t)) {
+ strncpy(key_str + sizeof(uint64_t), (char *)&key_str2,
+ sizeof(uint64_t));
+ } else {
+ assert(key_str2 == 0);
+ }
+
+ // Compare the key parameter with the known values to select the return
+ // value
+ uint64_t val;
+ if (strlen(key_str) == 0) {
+ val = tc->getCpuPtr()->system->init_param;
+ } else {
+ panic("Unknown key for initparam pseudo instruction");
+ }
+ return val;
}
diff --git a/src/sim/pseudo_inst.hh b/src/sim/pseudo_inst.hh
index b6e32847a..5f0b700c6 100644
--- a/src/sim/pseudo_inst.hh
+++ b/src/sim/pseudo_inst.hh
@@ -75,7 +75,7 @@ uint64_t writefile(ThreadContext *tc, Addr vaddr, uint64_t len,
uint64_t offset, Addr filenameAddr);
void loadsymbol(ThreadContext *xc);
void addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr);
-uint64_t initParam(ThreadContext *xc);
+uint64_t initParam(ThreadContext *xc, uint64_t key_str1, uint64_t key_str2);
uint64_t rpns(ThreadContext *tc);
void wakeCPU(ThreadContext *tc, uint64_t cpuid);
void m5exit(ThreadContext *tc, Tick delay);