diff options
Diffstat (limited to 'cpu')
-rw-r--r-- | cpu/exec_context.cc | 15 | ||||
-rw-r--r-- | cpu/exec_context.hh | 24 | ||||
-rw-r--r-- | cpu/simple_cpu/simple_cpu.cc | 3 | ||||
-rw-r--r-- | cpu/static_inst.hh | 8 |
4 files changed, 48 insertions, 2 deletions
diff --git a/cpu/exec_context.cc b/cpu/exec_context.cc index a89cf4bb5..832a621f8 100644 --- a/cpu/exec_context.cc +++ b/cpu/exec_context.cc @@ -106,6 +106,7 @@ ExecContext::serialize(ostream &os) regs.serialize(os); // thread_num and cpu_id are deterministic from the config SERIALIZE_SCALAR(func_exe_inst); + SERIALIZE_SCALAR(inst); #ifdef FULL_SYSTEM bool ctx = false; @@ -143,6 +144,7 @@ ExecContext::unserialize(Checkpoint *cp, const std::string §ion) regs.unserialize(cp, section); // thread_num and cpu_id are deterministic from the config UNSERIALIZE_SCALAR(func_exe_inst); + UNSERIALIZE_SCALAR(inst); #ifdef FULL_SYSTEM bool ctx; @@ -233,3 +235,16 @@ ExecContext::regStats(const string &name) kernelStats.regStats(name + ".kern"); #endif } + +void +ExecContext::trap(Fault fault) +{ + //TheISA::trap(fault); //One possible way to do it... + + /** @todo: Going to hack it for now. Do a true fixup later. */ +#ifdef FULL_SYSTEM + ev5_trap(fault); +#else + fatal("fault (%d) detected @ PC 0x%08p", fault, readPC()); +#endif +} diff --git a/cpu/exec_context.hh b/cpu/exec_context.hh index 7be83539a..a62225f1b 100644 --- a/cpu/exec_context.hh +++ b/cpu/exec_context.hh @@ -31,6 +31,7 @@ #include "sim/host.hh" #include "mem/mem_req.hh" +#include "mem/functional_mem/functional_memory.hh" #include "sim/serialize.hh" // forward declaration: see functional_memory.hh @@ -114,6 +115,9 @@ class ExecContext // pointer to CPU associated with this context BaseCPU *cpu; + // Current instruction + MachInst inst; + // Index of hardware thread context on the CPU that this represents. int thread_num; @@ -311,6 +315,18 @@ class ExecContext virtual bool misspeculating(); + MachInst getInst() { return inst; } + + void setInst(MachInst new_inst) + { + inst = new_inst; + } + + Fault instRead(MemReqPtr &req) + { + return mem->read(req, inst); + } + // // New accessors for new decoder. // @@ -395,6 +411,14 @@ class ExecContext bool simPalCheck(int palFunc); #endif + /** Meant to be more generic trap function to be + * called when an instruction faults. + * @param fault The fault generated by executing the instruction. + * @todo How to do this properly so it's dependent upon ISA only? + */ + + void trap(Fault fault); + #ifndef FULL_SYSTEM IntReg getSyscallArg(int i) { diff --git a/cpu/simple_cpu/simple_cpu.cc b/cpu/simple_cpu/simple_cpu.cc index 065140883..05b88b04b 100644 --- a/cpu/simple_cpu/simple_cpu.cc +++ b/cpu/simple_cpu/simple_cpu.cc @@ -708,8 +708,7 @@ SimpleCPU::tick() xc->regs.pc); #ifdef FULL_SYSTEM - xc->regs.opcode = (inst >> 26) & 0x3f; - xc->regs.ra = (inst >> 21) & 0x1f; + xc->setInst(inst); #endif // FULL_SYSTEM xc->func_exe_inst++; diff --git a/cpu/static_inst.hh b/cpu/static_inst.hh index 57208f8e6..131c5f756 100644 --- a/cpu/static_inst.hh +++ b/cpu/static_inst.hh @@ -43,6 +43,8 @@ class ExecContext; class DynInst; typedef DynInst FullCPUExecContext; +class FastCPU; +typedef FastCPU FastCPUExecContext; class SimpleCPU; typedef SimpleCPU SimpleCPUExecContext; class SymbolTable; @@ -311,6 +313,12 @@ class StaticInst : public StaticInstBase Trace::InstRecord *traceData) = 0; /** + * Execute this instruction under FastCPU model. + */ + virtual Fault execute(FastCPUExecContext *xc, + Trace::InstRecord *traceData) = 0; + + /** * Execute this instruction under detailed FullCPU model. */ virtual Fault execute(FullCPUExecContext *xc, |