43 void CPUDyntransComponent::DyntransInit()
54 while (pageShift < 32 && (1 << pageShift) !=
m_pageSize)
57 if (pageShift >= 32) {
58 std::cerr <<
"Non-power-of-2 page size?\n";
59 throw std::exception();
97 std::cerr <<
"Internal error: m_nextIC or m_firstIConPage is NULL.\n";
98 throw std::exception();
102 if (nrOfCycles != 1) {
103 std::cerr <<
"Internal error: Single stepping," 104 " but nrOfCycles = " << nrOfCycles <<
".\n";
105 throw std::exception();
120 #define IC ic = m_nextIC ++; ic->f(this, ic); 141 const int ICsPerLoop = 60;
142 const int maxICcycles = 2;
143 if (nrOfCycles > ICsPerLoop * maxICcycles) {
144 int hazard = nrOfCycles - ICsPerLoop * maxICcycles;
156 if (m_executedCycles >= hazard ||
169 if (m_executedCycles == old)
175 if (m_executedCycles<nrOfCycles && m_nextIC->
f != instr_abort) {
192 void CPUDyntransComponent::DyntransClearICPage(
struct DyntransIC* icpage)
204 icpage[m_dyntransICentriesPerPage + 0].
f = CPUDyntransComponent::instr_endOfPage;
205 icpage[m_dyntransICentriesPerPage + 1].
f = CPUDyntransComponent::instr_endOfPage2;
209 struct DyntransIC *CPUDyntransComponent::DyntransGetICPage(uint64_t
addr)
225 DyntransClearICPage(icpage);
236 std::cerr <<
"TODO: Already aborted, let's not update m_nextIC." 237 " Is this correct behavior?\n";
287 std::cerr <<
"TODO: DyntransResyncPC: Second end-of-page slot.\n";
289 throw std::exception();
292 std::cerr <<
"TODO: DyntransResyncPC: next ic outside of page?!\n";
293 throw std::exception();
323 ss.flags(std::ios::hex);
325 <<
" could not be read!";
347 ss.flags(std::ios::hex);
349 <<
" could not be read!";
363 if (ic->
f == NULL || ic->
f == instr_abort) {
377 ss.flags(std::ios::hex);
378 ss <<
"instruction translation failed";
384 if (!isSingleStepping) {
415 if (singleInstructionLeft && !abort) {
419 if (ds && !dsExceptionOrAbort) {
452 -- cpubase->m_executedCycles;
455 if (cpubase->m_inDelaySlot)
456 cpubase->m_exceptionOrAbortInDelaySlot =
true;
458 cpubase->m_nextIC =
ic;
464 std::cerr <<
"TODO: endOfPage\n";
465 throw std::exception();
471 std::cerr <<
"TODO: endOfPage2\n";
472 throw std::exception();
495 REG64(
ic->arg[0]) = (int32_t)
ic->arg[1].u32;
547 REG64(
ic->arg[0]) = (int32_t) (
REG64(
ic->arg[1]) + (int32_t)
ic->arg[2].u32);
761 REG64(
ic->arg[0]) = (int32_t)(
REG64(
ic->arg[1]) << (
ic->arg[2].u32 & 0x1f));
776 REG64(
ic->arg[0]) = (int32_t)(((uint32_t)
REG64(
ic->arg[1])) >> (
ic->arg[2].u32 & 0x1f));
787 static void Test_CPUDyntransComponent_Dyntrans_PreReq()
794 UNITTEST(Test_CPUDyntransComponent_Dyntrans_PreReq);
virtual void ShowDebugMessage(const string &msg)=0
Shows a debug message.
#define DYNTRANS_PAGE_NSPECIALENTRIES
DYNTRANS_INSTR(CPUDyntransComponent, nop)
void DyntransResyncPC()
Calculate m_pc based on m_nextIC and m_firstIConPage.
bool DyntransReadInstruction(uint16_t &iword)
RunState GetRunState() const
Gets the current RunState.
DyntransTranslationCache m_translationCache
void(* f)(CPUDyntransComponent *, DyntransIC *)
void COMBINE() nop(struct cpu *cpu, struct mips_instr_call *ic, int low_addr)
struct arm_instr_call * ic
CPUDyntransComponent(const string &className, const string &cpuKind)
Constructs a CPUDyntransComponent.
uint64_t m_delaySlotTarget
UI * GetUI()
Gets an UI reference for outputting debug messages during runtime.
int m_nrOfCyclesToExecute
void f(int s, int func, int only_name)
virtual void(*)(CPUDyntransComponent *cpu, DyntransIC *ic) GetDyntransToBeTranslated()
virtual uint64_t PCtoInstructionAddress(uint64_t pc)
Convert PC value to instuction address.
void DyntransToBeTranslatedBegin(struct DyntransIC *)
A dyntrans instruction call.
struct DyntransIC m_abortIC
#define UNITTESTS(class)
Helper for unit test case execution.
bool m_showFunctionTraceCall
struct DyntransIC * m_firstIConPage
bool m_exceptionOrAbortInDelaySlot
string LookupAddress(uint64_t vaddr, bool allowOffset) const
Looks up an address.
virtual void AddressSelect(uint64_t address)
Place an address on the bus.
void DyntransToBeTranslatedDone(struct DyntransIC *)
#define N_DYNTRANS_IC_ARGS
SymbolRegistry & GetSymbolRegistry()
Gets a reference to the CPU's symbol registry.
virtual int GetDyntransICshift() const =0
int m_dyntransICentriesPerPage
A base-class for processors Component implementations that use dynamic translation.
void DyntransPCtoPointers()
Calculate m_nextIC and m_firstIConPage, based on m_pc.
A base-class for processors Component implementations.
static void Assert(const string &strFailMessage, bool condition)
Asserts that a boolean condition is correct.
virtual int Execute(GXemul *gxemul, int nrOfCycles)
Execute one or more cycles.
UI * GetUI()
Gets a pointer to the GXemul instance' active UI.
Base class for a User Interface.
void SetQuietMode(bool quietMode)
Sets whether or not to run in quiet mode.
uint64_t Unassemble(int nRows, bool indicatePC, uint64_t vaddr, ostream &output)
struct DyntransIC * m_nextIC
virtual bool ReadData(uint8_t &data, Endianness endianness)
Reads 8-bit data from the currently selected address.
GXemul * GetRunningGXemulInstance()
Returns a reference to the current GXemul instance.
#define UNITTEST(functionname)
Helper for unit test case execution.