diff options
-rw-r--r-- | arch/alpha/freebsd/system.cc | 3 | ||||
-rw-r--r-- | arch/alpha/isa/decoder.isa | 3 | ||||
-rw-r--r-- | arch/alpha/linux/system.cc | 3 | ||||
-rw-r--r-- | arch/alpha/system.cc | 3 | ||||
-rw-r--r-- | arch/alpha/tru64/system.cc | 3 | ||||
-rw-r--r-- | python/m5/objects/System.py | 1 | ||||
-rw-r--r-- | sim/pseudo_inst.cc | 48 | ||||
-rw-r--r-- | sim/pseudo_inst.hh | 1 | ||||
-rw-r--r-- | sim/system.hh | 1 | ||||
-rw-r--r-- | util/m5/m5.c | 22 | ||||
-rw-r--r-- | util/m5/m5op.S | 8 |
11 files changed, 96 insertions, 0 deletions
diff --git a/arch/alpha/freebsd/system.cc b/arch/alpha/freebsd/system.cc index e32053afd..000c7e55a 100644 --- a/arch/alpha/freebsd/system.cc +++ b/arch/alpha/freebsd/system.cc @@ -111,6 +111,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(FreebsdAlphaSystem) Param<string> boot_osflags; Param<string> readfile; + Param<string> symbolfile; Param<unsigned int> init_param; Param<uint64_t> system_type; @@ -133,6 +134,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(FreebsdAlphaSystem) INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", "a"), INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), + INIT_PARAM_DFLT(symbolfile, "file to read symbols from", ""), INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0), INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34), INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10), @@ -155,6 +157,7 @@ CREATE_SIM_OBJECT(FreebsdAlphaSystem) p->boot_osflags = boot_osflags; p->init_param = init_param; p->readfile = readfile; + p->symbolfile = symbolfile; p->system_type = system_type; p->system_rev = system_rev; p->bin = bin; diff --git a/arch/alpha/isa/decoder.isa b/arch/alpha/isa/decoder.isa index 71b9131aa..6cc6f3a84 100644 --- a/arch/alpha/isa/decoder.isa +++ b/arch/alpha/isa/decoder.isa @@ -785,6 +785,9 @@ decode OPCODE default Unknown::unknown() { AlphaPseudo::m5exit(xc->xcBase(), R16); }}, No_OpClass, IsNonSpeculative); 0x30: initparam({{ Ra = xc->xcBase()->getCpuPtr()->system->init_param; }}); + 0x31: loadsymbol({{ + AlphaPseudo::loadsymbol(xc->xcBase()); + }}, No_OpClass, IsNonSpeculative); 0x40: resetstats({{ AlphaPseudo::resetstats(xc->xcBase(), R16, R17); }}, IsNonSpeculative); diff --git a/arch/alpha/linux/system.cc b/arch/alpha/linux/system.cc index f9275d15e..608e98a8c 100644 --- a/arch/alpha/linux/system.cc +++ b/arch/alpha/linux/system.cc @@ -233,6 +233,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(LinuxAlphaSystem) Param<string> boot_osflags; Param<string> readfile; + Param<string> symbolfile; Param<unsigned int> init_param; Param<uint64_t> system_type; @@ -255,6 +256,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(LinuxAlphaSystem) INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", "a"), INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), + INIT_PARAM_DFLT(symbolfile, "file to read symbols from", ""), INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0), INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34), INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10), @@ -277,6 +279,7 @@ CREATE_SIM_OBJECT(LinuxAlphaSystem) p->boot_osflags = boot_osflags; p->init_param = init_param; p->readfile = readfile; + p->symbolfile = symbolfile; p->system_type = system_type; p->system_rev = system_rev; p->bin = bin; diff --git a/arch/alpha/system.cc b/arch/alpha/system.cc index 25543da57..a1d00464e 100644 --- a/arch/alpha/system.cc +++ b/arch/alpha/system.cc @@ -242,6 +242,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(AlphaSystem) Param<std::string> boot_osflags; Param<std::string> readfile; + Param<std::string> symbolfile; Param<unsigned int> init_param; Param<uint64_t> system_type; @@ -264,6 +265,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(AlphaSystem) INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", "a"), INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), + INIT_PARAM_DFLT(symbolfile, "file to read symbols from", ""), INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0), INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34), INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10), @@ -286,6 +288,7 @@ CREATE_SIM_OBJECT(AlphaSystem) p->boot_osflags = boot_osflags; p->init_param = init_param; p->readfile = readfile; + p->symbolfile = symbolfile; p->system_type = system_type; p->system_rev = system_rev; p->bin = bin; diff --git a/arch/alpha/tru64/system.cc b/arch/alpha/tru64/system.cc index d09a0c85d..06da9fe91 100644 --- a/arch/alpha/tru64/system.cc +++ b/arch/alpha/tru64/system.cc @@ -105,6 +105,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(Tru64AlphaSystem) Param<string> boot_osflags; Param<string> readfile; + Param<string> symbolfile; Param<unsigned int> init_param; Param<uint64_t> system_type; @@ -126,6 +127,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(Tru64AlphaSystem) INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot", "a"), INIT_PARAM_DFLT(readfile, "file to read startup script from", ""), + INIT_PARAM_DFLT(symbolfile, "file to read symbols from", ""), INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0), INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 12), INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 2<<1), @@ -147,6 +149,7 @@ CREATE_SIM_OBJECT(Tru64AlphaSystem) p->boot_osflags = boot_osflags; p->init_param = init_param; p->readfile = readfile; + p->symbolfile = symbolfile; p->system_type = system_type; p->system_rev = system_rev; p->bin = bin; diff --git a/python/m5/objects/System.py b/python/m5/objects/System.py index 5925cadf5..40c4f24f2 100644 --- a/python/m5/objects/System.py +++ b/python/m5/objects/System.py @@ -11,6 +11,7 @@ class System(SimObject): binned_fns = VectorParam.String([], "functions broken down and binned") kernel = Param.String("file that contains the kernel code") readfile = Param.String("", "file to read startup script from") + symbolfile = Param.String("", "file to get the symbols from") class AlphaSystem(System): type = 'AlphaSystem' diff --git a/sim/pseudo_inst.cc b/sim/pseudo_inst.cc index 2d737c0a2..3b11eaaeb 100644 --- a/sim/pseudo_inst.cc +++ b/sim/pseudo_inst.cc @@ -150,6 +150,54 @@ namespace AlphaPseudo } void + loadsymbol(ExecContext *xc) + { + const string &filename = xc->getCpuPtr()->system->params()->symbolfile; + if (filename.empty()) { + return; + } + + std::string buffer; + ifstream file(filename.c_str()); + + if (!file) + fatal("file error: Can't open symbol table file %s\n", filename); + + while (!file.eof()) { + getline(file, buffer); + + if (buffer.empty()) + continue; + + int idx = buffer.find(' '); + if (idx == string::npos) + continue; + + string address = "0x" + buffer.substr(0, idx); + eat_white(address); + if (address.empty()) + continue; + + // Skip over letter and space + string symbol = buffer.substr(idx + 3); + eat_white(symbol); + if (symbol.empty()) + continue; + + Addr addr; + if (!to_number(address, addr)) + continue; + + if (!xc->getSystemPtr()->kernelSymtab->insert(addr, symbol)) + continue; + + + DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr); + } + file.close(); + } + + void resetstats(ExecContext *xc, Tick delay, Tick period) { if (!doStatisticsInsts) diff --git a/sim/pseudo_inst.hh b/sim/pseudo_inst.hh index 4dd427c99..595ddef1f 100644 --- a/sim/pseudo_inst.hh +++ b/sim/pseudo_inst.hh @@ -51,6 +51,7 @@ namespace AlphaPseudo void ivle(ExecContext *xc); void m5exit(ExecContext *xc, Tick delay); void m5exit_old(ExecContext *xc); + void loadsymbol(ExecContext *xc); void resetstats(ExecContext *xc, Tick delay, Tick period); void dumpstats(ExecContext *xc, Tick delay, Tick period); void dumpresetstats(ExecContext *xc, Tick delay, Tick period); diff --git a/sim/system.hh b/sim/system.hh index ea482a102..36aeb3700 100644 --- a/sim/system.hh +++ b/sim/system.hh @@ -137,6 +137,7 @@ class System : public SimObject std::string kernel_path; std::string readfile; + std::string symbolfile; }; protected: diff --git a/util/m5/m5.c b/util/m5/m5.c index 6fdbc0500..fa9be96e8 100644 --- a/util/m5/m5.c +++ b/util/m5/m5.c @@ -30,6 +30,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include "m5op.h" @@ -165,6 +166,22 @@ main(int argc, char *argv[]) } } + if (COMPARE("readfile")) { + char buf[256*1024]; + int offset = 0; + int len; + + if (argc != 2) + usage(); + + while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) { + write(STDOUT_FILENO, buf, len); + offset += len; + } + + return 0; + } + if (COMPARE("checkpoint")) { switch (argc) { case 4: @@ -182,5 +199,10 @@ main(int argc, char *argv[]) return 0; } + if (COMPARE("loadsymbol")) { + m5_loadsymbol(arg1); + return 0; + } + usage(); } diff --git a/util/m5/m5op.S b/util/m5/m5op.S index a53c45277..97eb9238d 100644 --- a/util/m5/m5op.S +++ b/util/m5/m5op.S @@ -38,6 +38,7 @@ #define exit_old_func 0x20 // deprectated! #define exit_func 0x21 #define initparam_func 0x30 +#define loadsymbol_func 0x31 #define resetstats_func 0x40 #define dumpstats_func 0x41 #define dumprststats_func 0x42 @@ -72,6 +73,7 @@ func: #define IVLE(reg) INST(m5_op, reg, 0, ivle_func) #define M5EXIT(reg) INST(m5_op, reg, 0, exit_func) #define INITPARAM(reg) INST(m5_op, reg, 0, initparam_func) +#define LOADSYMBOL(reg) INST(m5_op, reg, 0, loadsymbol_func) #define RESET_STATS(r1, r2) INST(m5_op, r1, r2, resetstats_func) #define DUMP_STATS(r1, r2) INST(m5_op, r1, r2, dumpstats_func) #define DUMPRST_STATS(r1, r2) INST(m5_op, r1, r2, dumprststats_func) @@ -140,6 +142,12 @@ LEAF(m5_initparam) END(m5_initparam) .align 4 +LEAF(m5_loadsymbol) + LOADSYMBOL(0) + RET +END(m5_loadsymbol) + + .align 4 LEAF(m5_reset_stats) RESET_STATS(16, 17) RET |