mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-02-16 17:35:39 +00:00
Added hooks into debugger classes
This commit is contained in:
parent
46944e8c96
commit
aa0c598a4c
|
@ -41,6 +41,10 @@ typedef unsigned int UINT;
|
|||
// Model 3 context provides read/write handlers
|
||||
static class CBus *Bus = NULL; // pointer to Model 3 bus object (for access handlers)
|
||||
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
// Pointer to current PPC debugger (if any)
|
||||
static class Debugger::CPPCDebug *PPCDebug = NULL;
|
||||
#endif
|
||||
|
||||
void ppc603_exception(int exception);
|
||||
static void ppc603_check_interrupts(void);
|
||||
|
@ -275,8 +279,6 @@ static int bus_freq_multiplier = 1;
|
|||
static PPC_REGS ppc;
|
||||
static UINT32 ppc_rotate_mask[32][32];
|
||||
|
||||
|
||||
|
||||
static void ppc_change_pc(UINT32 newpc)
|
||||
{
|
||||
UINT i;
|
||||
|
@ -298,7 +300,6 @@ static void ppc_change_pc(UINT32 newpc)
|
|||
|
||||
// ppc.op = (UINT32 *)((UINT32)ppc.cur_fetch.ptr + (UINT32)(newpc - ppc.cur_fetch.start));
|
||||
ppc.op = &ppc.cur_fetch.ptr[(newpc-ppc.cur_fetch.start)/4];
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1030,6 +1031,11 @@ UINT32 ppc_get_gpr(unsigned num)
|
|||
return ppc.r[num&31];
|
||||
}
|
||||
|
||||
double ppc_get_fpr(unsigned num)
|
||||
{
|
||||
return ppc.fpr[num&31].fd;
|
||||
}
|
||||
|
||||
UINT32 ppc_get_lr(void)
|
||||
{
|
||||
return ppc.lr;
|
||||
|
@ -1043,4 +1049,68 @@ UINT32 ppc_read_spr(unsigned spr)
|
|||
UINT32 ppc_read_sr(unsigned num)
|
||||
{
|
||||
return ppc.sr[num&15];
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
Debugger Interface
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
void ppc_attach_debugger(Debugger::CPPCDebug *PPCDebugPtr)
|
||||
{
|
||||
if (PPCDebug != NULL)
|
||||
ppc_detach_debugger();
|
||||
PPCDebug = PPCDebugPtr;
|
||||
Bus = PPCDebug->AttachBus(Bus);
|
||||
}
|
||||
|
||||
void ppc_detach_debugger()
|
||||
{
|
||||
if (PPCDebug == NULL)
|
||||
return;
|
||||
Bus = PPCDebug->DetachBus();
|
||||
PPCDebug = NULL;
|
||||
}
|
||||
|
||||
void ppc_set_pc(UINT32 pc)
|
||||
{
|
||||
ppc.pc = pc;
|
||||
ppc_change_pc(pc);
|
||||
ppc.npc = pc + 4;
|
||||
}
|
||||
|
||||
UINT8 ppc_get_cr(unsigned num)
|
||||
{
|
||||
return ppc.cr[num&7];
|
||||
}
|
||||
|
||||
void ppc_set_cr(unsigned num, UINT8 val)
|
||||
{
|
||||
ppc.cr[num&7] = val;
|
||||
}
|
||||
|
||||
void ppc_set_gpr(unsigned num, UINT32 val)
|
||||
{
|
||||
ppc.r[num&31] = val;
|
||||
}
|
||||
|
||||
void ppc_set_fpr(unsigned num, double val)
|
||||
{
|
||||
ppc.fpr[num&31].fd = val;
|
||||
}
|
||||
|
||||
void ppc_write_spr(unsigned spr, UINT32 val)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void ppc_write_sr(unsigned num, UINT32 val)
|
||||
{
|
||||
ppc.sr[num&15] = val;
|
||||
}
|
||||
|
||||
UINT32 ppc_read_msr()
|
||||
{
|
||||
return ppc_get_msr();
|
||||
}
|
||||
#endif // SUPERMODEL_DEBUGGER
|
|
@ -358,9 +358,23 @@ extern void ppc_attach_bus(class CBus *BusPtr); // must be called first!
|
|||
extern void ppc_save_state(class CBlockFile *SaveState);
|
||||
extern void ppc_load_state(class CBlockFile *SaveState);
|
||||
extern UINT32 ppc_get_gpr(unsigned num);
|
||||
extern double ppc_get_fpr(unsigned num);
|
||||
extern UINT32 ppc_get_lr(void);
|
||||
extern UINT32 ppc_read_spr(unsigned spr);
|
||||
extern UINT32 ppc_read_sr(unsigned num);
|
||||
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
// These have been added to support the Supermodel debugger
|
||||
extern void ppc_attach_debugger(class Debugger::CPPCDebug *PPCDebugPtr);
|
||||
extern void ppc_detach_debugger();
|
||||
extern void ppc_set_pc(UINT32 pc);
|
||||
extern UINT8 ppc_get_cr(unsigned num);
|
||||
extern void ppc_set_cr(unsigned num, UINT8 val);
|
||||
extern void ppc_set_gpr(unsigned num, UINT32 val);
|
||||
extern void ppc_set_fpr(unsigned num, double val);
|
||||
extern void ppc_write_spr(unsigned spr, UINT32 val);
|
||||
extern void ppc_write_sr(unsigned num, UINT32 val);
|
||||
extern UINT32 ppc_read_msr();
|
||||
#endif // SUPERMODEL_DEBUGGER
|
||||
|
||||
#endif // INCLUDED_PPC_H
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
|
||||
void ppc603_exception(int exception)
|
||||
{
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
if (PPCDebug != NULL)
|
||||
PPCDebug->CheckException(exception);
|
||||
#endif
|
||||
|
||||
switch( exception )
|
||||
{
|
||||
case EXCEPTION_IRQ: /* External Interrupt */
|
||||
|
@ -284,8 +289,17 @@ int ppc_execute(int cycles)
|
|||
|
||||
opcode = *ppc.op++; // Supermodel byte reverses each aligned word (converting them to little endian) so they can be fetched directly
|
||||
//opcode = BSWAP32(*ppc.op++);
|
||||
|
||||
|
||||
ppc.npc = ppc.pc + 4;
|
||||
|
||||
#ifdef SUPERMODEL_DEBUGGER
|
||||
if (PPCDebug != NULL)
|
||||
{
|
||||
while (PPCDebug->CheckExecution(ppc.pc, opcode))
|
||||
opcode = *ppc.op++;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch(opcode >> 26)
|
||||
{
|
||||
case 19: optable19[(opcode >> 1) & 0x3ff](opcode); break;
|
||||
|
|
Loading…
Reference in a new issue