start porting over MetroTRK from Xenoblade

This commit is contained in:
Joshua Andrew 2023-09-12 15:34:26 -04:00
parent 4f0a78aeb2
commit 7fe7153389
18 changed files with 652 additions and 48 deletions

View File

@ -1,13 +1,13 @@
Symbol Name, Object File, Library Archive, Matching
TRKNubMainLoop,mainloop.o,TRK_Hollywood_Revolution.a,false
TRKNubMainLoop,mainloop.o,TRK_Hollywood_Revolution.a,true
TRKDestructEvent,nubevent.o,TRK_Hollywood_Revolution.a,true
TRKConstructEvent,nubevent.o,TRK_Hollywood_Revolution.a,true
TRKPostEvent,nubevent.o,TRK_Hollywood_Revolution.a,true
TRKGetNextEvent,nubevent.o,TRK_Hollywood_Revolution.a,true
TRKInitializeEventQueue,nubevent.o,TRK_Hollywood_Revolution.a,true
TRKNubWelcome,nubinit.o,TRK_Hollywood_Revolution.a,false
TRKTerminateNub,nubinit.o,TRK_Hollywood_Revolution.a,false
TRKInitializeNub,nubinit.o,TRK_Hollywood_Revolution.a,false
TRKNubWelcome,nubinit.o,TRK_Hollywood_Revolution.a,true
TRKTerminateNub,nubinit.o,TRK_Hollywood_Revolution.a,true
TRKInitializeNub,nubinit.o,TRK_Hollywood_Revolution.a,true
TRKMessageSend,msg.o,TRK_Hollywood_Revolution.a,true
TRKReadBuffer_ui32,msgbuf.o,TRK_Hollywood_Revolution.a,true
TRKReadBuffer_ui8,msgbuf.o,TRK_Hollywood_Revolution.a,true
@ -30,8 +30,8 @@ TRKGetInput,serpoll.o,TRK_Hollywood_Revolution.a,true
TRKTestForPacket,serpoll.o,TRK_Hollywood_Revolution.a,false
usr_put_initialize,usr_put.o,TRK_Hollywood_Revolution.a,true
usr_puts_serial,usr_put.o,TRK_Hollywood_Revolution.a,true
TRKDispatchMessage,dispatch.o,TRK_Hollywood_Revolution.a,false
TRKInitializeDispatcher,dispatch.o,TRK_Hollywood_Revolution.a,false
TRKDispatchMessage,dispatch.o,TRK_Hollywood_Revolution.a,true
TRKInitializeDispatcher,dispatch.o,TRK_Hollywood_Revolution.a,true
TRKDoSetOption,msghndlr.o,TRK_Hollywood_Revolution.a,false
TRKDoStop,msghndlr.o,TRK_Hollywood_Revolution.a,false
TRKDoStep,msghndlr.o,TRK_Hollywood_Revolution.a,false
@ -60,10 +60,10 @@ TRKDoNotifyStopped,notify.o,TRK_Hollywood_Revolution.a,false
TRK_flush_cache,flush_cache.o,TRK_Hollywood_Revolution.a,false
TRK_fill_mem,mem_TRK.o,TRK_Hollywood_Revolution.a,false
TRK_strlen,string_TRK.o,TRK_Hollywood_Revolution.a,false
__TRK_get_MSR,targimpl.o,TRK_Hollywood_Revolution.a,false
__TRK_set_MSR,targimpl.o,TRK_Hollywood_Revolution.a,false
__TRK_get_MSR,targimpl.o,TRK_Hollywood_Revolution.a,true
__TRK_set_MSR,targimpl.o,TRK_Hollywood_Revolution.a,true
TRK_ppc_memcpy,targimpl.o,TRK_Hollywood_Revolution.a,false
TRKInterruptHandler,targimpl.o,TRK_Hollywood_Revolution.a,false
TRKInterruptHandler,targimpl.o,TRK_Hollywood_Revolution.a,true
TRKExceptionHandler,targimpl.o,TRK_Hollywood_Revolution.a,false
TRKSwapAndGo,targimpl.o,TRK_Hollywood_Revolution.a,false
TRKInterruptHandlerEnableInterrupts,targimpl.o,TRK_Hollywood_Revolution.a,false

1 Symbol Name Object File Library Archive Matching
2 TRKNubMainLoop mainloop.o TRK_Hollywood_Revolution.a false true
3 TRKDestructEvent nubevent.o TRK_Hollywood_Revolution.a true
4 TRKConstructEvent nubevent.o TRK_Hollywood_Revolution.a true
5 TRKPostEvent nubevent.o TRK_Hollywood_Revolution.a true
6 TRKGetNextEvent nubevent.o TRK_Hollywood_Revolution.a true
7 TRKInitializeEventQueue nubevent.o TRK_Hollywood_Revolution.a true
8 TRKNubWelcome nubinit.o TRK_Hollywood_Revolution.a false true
9 TRKTerminateNub nubinit.o TRK_Hollywood_Revolution.a false true
10 TRKInitializeNub nubinit.o TRK_Hollywood_Revolution.a false true
11 TRKMessageSend msg.o TRK_Hollywood_Revolution.a true
12 TRKReadBuffer_ui32 msgbuf.o TRK_Hollywood_Revolution.a true
13 TRKReadBuffer_ui8 msgbuf.o TRK_Hollywood_Revolution.a true
30 TRKTestForPacket serpoll.o TRK_Hollywood_Revolution.a false
31 usr_put_initialize usr_put.o TRK_Hollywood_Revolution.a true
32 usr_puts_serial usr_put.o TRK_Hollywood_Revolution.a true
33 TRKDispatchMessage dispatch.o TRK_Hollywood_Revolution.a false true
34 TRKInitializeDispatcher dispatch.o TRK_Hollywood_Revolution.a false true
35 TRKDoSetOption msghndlr.o TRK_Hollywood_Revolution.a false
36 TRKDoStop msghndlr.o TRK_Hollywood_Revolution.a false
37 TRKDoStep msghndlr.o TRK_Hollywood_Revolution.a false
60 TRK_flush_cache flush_cache.o TRK_Hollywood_Revolution.a false
61 TRK_fill_mem mem_TRK.o TRK_Hollywood_Revolution.a false
62 TRK_strlen string_TRK.o TRK_Hollywood_Revolution.a false
63 __TRK_get_MSR targimpl.o TRK_Hollywood_Revolution.a false true
64 __TRK_set_MSR targimpl.o TRK_Hollywood_Revolution.a false true
65 TRK_ppc_memcpy targimpl.o TRK_Hollywood_Revolution.a false
66 TRKInterruptHandler targimpl.o TRK_Hollywood_Revolution.a false true
67 TRKExceptionHandler targimpl.o TRK_Hollywood_Revolution.a false
68 TRKSwapAndGo targimpl.o TRK_Hollywood_Revolution.a false
69 TRKInterruptHandlerEnableInterrupts targimpl.o TRK_Hollywood_Revolution.a false

View File

@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"label": "MetroTRK",
"message": "15.398%",
"message": "21.608%",
"color": "blue"
}

View File

@ -1,3 +1,3 @@
| Library | Percentage |
| ------------- | ------------- |
| [TRK_Hollywood_Revolution](https://github.com/shibbo/RVL_SDK/blob/main/docs/lib/TRK_Hollywood_Revolution.md) | 15.398420674802585% |
| [TRK_Hollywood_Revolution](https://github.com/shibbo/RVL_SDK/blob/main/docs/lib/TRK_Hollywood_Revolution.md) | 21.608040201005025% |

View File

@ -8,14 +8,14 @@
| Object | Percentage (of Bytes) | Functions Done / Total Functions | Percentage (Functions) | Status
| ------------- | ------------- | ------------- | ------------- | -------------
| mainloop.o | 0.0% | 0 / 1 | 0.0% | :x:
| mainloop.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| nubevent.o | 100.0% | 5 / 5 | 100.0% | :white_check_mark:
| nubinit.o | 0.0% | 0 / 3 | 0.0% | :x:
| nubinit.o | 100.0% | 3 / 3 | 100.0% | :white_check_mark:
| msg.o | 100.0% | 1 / 1 | 100.0% | :white_check_mark:
| msgbuf.o | 100.0% | 14 / 14 | 100.0% | :white_check_mark:
| serpoll.o | 51.4018691588785% | 4 / 5 | 80.0% | :eight_pointed_black_star:
| usr_put.o | 100.0% | 2 / 2 | 100.0% | :white_check_mark:
| dispatch.o | 0.0% | 0 / 2 | 0.0% | :x:
| dispatch.o | 100.0% | 2 / 2 | 100.0% | :white_check_mark:
| msghndlr.o | 0.0% | 0 / 16 | 0.0% | :x:
| support.o | 0.0% | 0 / 5 | 0.0% | :x:
| mutex_TRK.o | 100.0% | 3 / 3 | 100.0% | :white_check_mark:
@ -23,7 +23,7 @@
| flush_cache.o | 0.0% | 0 / 1 | 0.0% | :x:
| mem_TRK.o | 0.0% | 0 / 1 | 0.0% | :x:
| string_TRK.o | 0.0% | 0 / 1 | 0.0% | :x:
| targimpl.o | 0.0% | 0 / 28 | 0.0% | :x:
| targimpl.o | 6.287425149700598% | 3 / 28 | 10.714285714285714% | :eight_pointed_black_star:
| mpc_7xx_603e.o | 0.0% | 0 / 2 | 0.0% | :x:
| mslsupp.o | 0.0% | 0 / 2 | 0.0% | :x:
| dolphin_trk.o | 0.0% | 0 / 6 | 0.0% | :x:
@ -40,7 +40,7 @@
# mainloop.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| TRKNubMainLoop | :x: |
| TRKNubMainLoop | :white_check_mark: |
# nubevent.o
@ -56,9 +56,9 @@
# nubinit.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| TRKNubWelcome | :x: |
| TRKTerminateNub | :x: |
| TRKInitializeNub | :x: |
| TRKNubWelcome | :white_check_mark: |
| TRKTerminateNub | :white_check_mark: |
| TRKInitializeNub | :white_check_mark: |
# msg.o
@ -106,8 +106,8 @@
# dispatch.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| TRKDispatchMessage | :x: |
| TRKInitializeDispatcher | :x: |
| TRKDispatchMessage | :white_check_mark: |
| TRKInitializeDispatcher | :white_check_mark: |
# msghndlr.o
@ -176,10 +176,10 @@
# targimpl.o
| Symbol | Decompiled? |
| ------------- | ------------- |
| __TRK_get_MSR | :x: |
| __TRK_set_MSR | :x: |
| __TRK_get_MSR | :white_check_mark: |
| __TRK_set_MSR | :white_check_mark: |
| TRK_ppc_memcpy | :x: |
| TRKInterruptHandler | :x: |
| TRKInterruptHandler | :white_check_mark: |
| TRKExceptionHandler | :x: |
| TRKSwapAndGo | :x: |
| TRKInterruptHandlerEnableInterrupts | :x: |

View File

@ -31,6 +31,9 @@ typedef struct TRKBuffer {
} TRKBuffer;
typedef int bool;
#define true 1
#define false 0
#define NULL 0
typedef unsigned char ui8;
typedef unsigned short ui16;
@ -42,4 +45,6 @@ typedef unsigned short u16;
typedef unsigned long u32;
typedef double f64;
typedef short s16;
#endif // TRK_TYPES_H

View File

@ -1,3 +1,52 @@
#ifndef DOLPHIN_H
#define DOLPHIN_H
#include "TRK_Types.h"
#include "export/UART.h"
typedef struct OSContext OSContext;
typedef s16 __OSInterrupt;
typedef void (*__OSInterruptHandler)(__OSInterrupt, OSContext *);
typedef int (*DBCommFunc)();
typedef int (*DBCommInitFunc)(void*, __OSInterruptHandler);
typedef int (*DBCommReadFunc)(ui8*, int);
typedef int (*DBCommWriteFunc)(const ui8*, int);
typedef struct DBCommTable{
DBCommInitFunc initialize_func;
DBCommFunc initinterrupts_func;
DBCommFunc shutdown_func;
DBCommFunc peek_func;
DBCommReadFunc read_func;
DBCommWriteFunc write_func;
DBCommFunc open_func;
DBCommFunc close_func;
DBCommFunc pre_continue_func;
DBCommFunc post_stop_func;
} DBCommTable;
void TKR_board_display(char *);
void TRKUARTInterruptHandler(void);
UARTError TRK_InitializeIntDrivenUART(ui32 r3, ui32 r4, ui32 r5, void* r6);
void EnableEXI2Interrupts(void);
void EnableMetroTRKInterrupts(void);
void EnableMetroTRKInterrupts(void);
typedef struct TRKState_PPC {
ui32 GPR[32]; //0x0
ui32 LR; //0x80
ui32 CTR; //0x84
ui32 XER; //0x88
ui32 MSR; //0x8c
ui32 DAR; //0x90
ui32 DSISR; //0x94
bool stopped; //0x98
bool inputActivated; //0x9c
ui8* inputPendingPtr; //0xA0
} TRKState_PPC;
#endif // DOLPHIN_H

View File

@ -0,0 +1,16 @@
#ifndef DISPATCH_H
#define DISPATCH_H
#include "portable/dserror.h"
#ifdef __cplusplus
extern "C" {
#endif
DSError TRKInitializeDispatcher();
#ifdef __cplusplus
}
#endif
#endif // DISPATCH_H

View File

@ -0,0 +1,32 @@
#ifndef DSERROR_H
#define DSERROR_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
kNoError = 0,
kStepError = 1,
kParameterError = 2,
kEventQueueFull = 0x100,
kNoMessageBufferAvailable = 0x300,
kMessageBufferOverflow = 0x301,
kMessageBufferReadError = 0x302,
kDispatchError = 0x500,
kInvalidMemory = 0x700,
kInvalidRegister = 0x701,
kCWDSException = 0x702,
kUnsupportedError = 0x703,
kInvalidProcessId = 0x704,
kInvalidThreadId = 0x705,
kOsError = 0x706,
kError800 = 0x800
} DSError;
#ifdef __cplusplus
};
#endif
#endif // DSERROR_H

View File

@ -0,0 +1,15 @@
#ifndef MPC_7XX_603E_H
#define MPC_7XX_603E_H
#ifdef __cplusplus
extern "C"{
#endif
void TRKSaveExtended1Block();
void TRKRestoreExtended1Block();
#ifdef __cplusplus
}
#endif
#endif // MPC_7XX_603E_H

View File

@ -0,0 +1,31 @@
#ifndef MSGCMD_H
#define MSGCMD_H
typedef enum {
kDSPing = 0x00,
kDSConnect = 0x01,
kDSDisconnect = 0x02,
kDSReset = 0x03,
kDSVersions = 0x04,
kDSSupportMask = 0x05,
kDSOverride = 0x07,
kDSReadMemory = 0x10,
kDSWriteMemory = 0x11,
kDSReadRegisters = 0x12,
kDSWriteRegisters = 0x13,
kDSSetOption = 0x17,
kDSContinue = 0x18,
kDSStep = 0x19,
kDSStop = 0x1a,
kDSReplyACK = 0x80,
kDSReplyNAK = 0xFF,
kDSNotifyStopped = 0x90,
kDSNotifyException = 0x91,
kDSWriteFile = 0xD0,
kDSReadFile = 0xD1,
kDSOpenFile = 0xD2,
kDSCloseFile = 0xD3,
kDSPositionFile = 0xD4
} MessageCommandID;
#endif // MSGCMD_H

View File

@ -1,10 +1,27 @@
#ifndef MSGHNDLR_H
#define MSGHNDLR_H
#include "portable/dserror.h"
#include "portable/msgbuf.h"
static int* IsTRKConnected;
int TRKDoConnect(void);
DSError TRKDoConnect(MessageBuffer*);
DSError TRKDoDisconnect(MessageBuffer*);
DSError TRKDoReset(MessageBuffer*);
DSError TRKDoVersions(MessageBuffer*);
DSError TRKDoSupportMask(MessageBuffer*);
DSError TRKDoOverride(MessageBuffer*);
DSError TRKDoReadMemory(MessageBuffer*);
DSError TRKDoWriteMemory(MessageBuffer*);
DSError TRKDoReadRegisters(MessageBuffer*);
DSError TRKDoWriteRegisters(MessageBuffer*);
DSError TRKDoContinue(MessageBuffer*);
DSError TRKDoStep(MessageBuffer*);
DSError TRKDoStop(MessageBuffer*);
DSError TRKDoSetOption(MessageBuffer*);
void SetTRKConnected(int);
int GetTRKConnected(void);
DSError GetTRKConnected(void);
#endif // MSGHNDLR_H

View File

@ -0,0 +1,112 @@
#ifndef PPC_REG_H
#define PPC_REG_H
typedef struct Default_PPC{
ui32 GPR[32];
ui32 PC;
ui32 LR;
ui32 CR;
ui32 CTR;
ui32 XER;
} Default_PPC;
typedef struct Float_PPC{
ui64 FPR[32];
ui64 FPSCR;
ui64 FPECR;
} Float_PPC;
typedef struct Extended1_PPC_6xx_7xx{
ui32 SR[16];
ui32 TBL;
ui32 TBU;
ui32 HID0;
ui32 HID1;
ui32 MSR;
ui32 PVR;
ui32 IBAT0U;
ui32 IBAT0L;
ui32 IBAT1U;
ui32 IBAT1L;
ui32 IBAT2U;
ui32 IBAT2L;
ui32 IBAT3U;
ui32 IBAT3L;
ui32 DBAT0U;
ui32 DBAT0L;
ui32 DBAT1U;
ui32 DBAT1L;
ui32 DBAT2U;
ui32 DBAT2L;
ui32 DBAT3U;
ui32 DBAT3L;
ui32 DMISS;
ui32 DCMP;
ui32 HASH1;
ui32 HASH2;
ui32 IMISS;
ui32 ICMP;
ui32 RPA;
ui32 SDR1;
ui32 DAR;
ui32 DSISR;
ui32 SPRG0;
ui32 SPRG1;
ui32 SPRG2;
ui32 SPRG3;
ui32 DEC;
ui32 IABR;
ui32 EAR;
ui32 DABR;
ui32 PMC1;
ui32 PMC2;
ui32 PMC3;
ui32 PMC4;
ui32 SIA;
ui32 MMCR0;
ui32 MMCR1;
ui32 THRM1;
ui32 THRM2;
ui32 THRM3;
ui32 ICTC;
ui32 L2CR;
ui32 UMMCR2;
ui32 UBAMR;
ui32 UMMCR0;
ui32 UPMC1;
ui32 UPMC2;
ui32 USIA;
ui32 UMMCR1;
ui32 UPMC3;
ui32 UPMC4;
ui32 USDA;
ui32 MMCR2;
ui32 BAMR;
ui32 SDA;
ui32 MSSCR0;
ui32 MSSCR1;
ui32 PIR;
ui32 exceptionID;
ui32 GQR[8];
ui32 HID_G;
ui32 WPAR;
ui32 DMA_U;
ui32 DMA_L;
} Extended1_PPC_6xx_7xx;
typedef struct Extended2_PPC_6xx_7xx{
ui32 PSR[32][2];
} Extended2_PPC_6xx_7xx;
typedef struct ProcessorState_PPC_6xx_7xx{
Default_PPC Default;
Float_PPC Float;
Extended1_PPC_6xx_7xx Extended1;
Extended2_PPC_6xx_7xx Extended2;
ui32 transport_handler_saved_ra;
} ProcessorState_PPC_6xx_7xx;
typedef ProcessorState_PPC_6xx_7xx ProcessorState_PPC;
#endif // PPC_REG_H

View File

@ -6,4 +6,6 @@
MessageBufferID TRKTestForPacket();
extern void* gTRKInputPendingPtr;
#endif // SERPOLL_H

View File

@ -0,0 +1,66 @@
#include "portable/msgbuf.h"
#include "portable/msgcmd.h"
#include "portable/msghndlr.h"
#include "portable/dserror.h"
#include "TRK_Types.h"
DSError TRKDispatchMessage(MessageBuffer* buffer) {
DSError result = kDispatchError;
MessageBuffer* temp = buffer;
ui8 command;
TRKSetBufferPosition(buffer, 0);
command = temp->fData[4];
switch(command){
case kDSConnect:
result = TRKDoConnect(temp);
break;
case kDSDisconnect:
result = TRKDoDisconnect(temp);
break;
case kDSReset:
result = TRKDoReset(temp);
break;
case kDSOverride:
result = TRKDoOverride(temp);
break;
/* v0.4 removes these two cases */
case kDSVersions:
result = TRKDoVersions(temp);
break;
case kDSSupportMask:
result = TRKDoSupportMask(temp);
break;
case kDSReadMemory:
result = TRKDoReadMemory(temp);
break;
case kDSWriteMemory:
result = TRKDoWriteMemory(temp);
break;
case kDSReadRegisters:
result = TRKDoReadRegisters(temp);
break;
case kDSWriteRegisters:
result = TRKDoWriteRegisters(temp);
break;
case kDSContinue:
result = TRKDoContinue(temp);
break;
case kDSStep:
result = TRKDoStep(temp);
break;
case kDSStop:
result = TRKDoStop(temp);
break;
case kDSSetOption:
result = TRKDoSetOption(temp);
break;
}
return result;
}
DSError TRKInitializeDispatcher(void) {
return kNoError;
}

View File

@ -0,0 +1,48 @@
#include "portable/msgbuf.h"
#include "portable/nubevent.h"
#include "portable/serpoll.h"
#include "TRK_Types.h"
void TRKNubMainLoop(void) {
MessageBuffer* msg;
NubEvent event;
bool var_r31 = false;
bool var_r30 = false;
while (var_r31 == false) {
if (TRKGetNextEvent(&event) != false) {
var_r30 = false;
switch (event.fType) {
case kNullEvent:
break;
case kRequestEvent:
msg = TRKGetBuffer(event.fMessageBufferID);
TRKDispatchMessage(msg);
break;
case kShutdownEvent:
var_r31 = true;
break;
case kBreakpointEvent:
case kExceptionEvent:
TRKTargetInterrupt(&event);
break;
case kSupportEvent:
TRKTargetSupportRequest();
break;
}
TRKDestructEvent(&event);
}
else if (var_r30 == false || *(ui8*)gTRKInputPendingPtr != 0) {
var_r30 = true;
TRKGetInput();
}
else {
if (TRKTargetStopped() == false) {
TRKTargetContinue();
}
var_r30 = false;
}
}
}

View File

@ -1,3 +1,84 @@
#include "portable/nubinit.h"
#include "portable/dserror.h"
#include "portable/dispatch.h"
#include "portable/serpoll.h"
#include "dolphin.h"
bool gTRKBigEndian;
bool gTRKBigEndian;
void TRKNubWelcome(void) {
TRK_board_display("MetroTRK for Revolution v0.1");
}
DSError TRKTerminateNub(void) {
TRKTerminateSerialHandler();
return kNoError;
}
bool TRKInitializeEndian(void) {
ui8 bendian[4];
bool result = false;
gTRKBigEndian = true;
bendian[0] = 0x12;
bendian[1] = 0x34;
bendian[2] = 0x56;
bendian[3] = 0x78;
if (*(ui32*)bendian == 0x12345678) {
gTRKBigEndian = true;
}
else if (*(ui32*)bendian == 0x78563412) {
gTRKBigEndian = false;
}
else {
result = true;
}
/* v0.1 has this call, v0.4 removes it */
if (result == false) {
usr_put_initialize();
}
return result;
}
DSError TRKInitializeNub(void) {
DSError result;
DSError resultTemp;
result = TRKInitializeEndian();
if (result == kNoError) {
result = TRKInitializeEventQueue();
}
if (result == kNoError) {
result = TRKInitializeMessageBuffers();
}
/* v0.1 has this call, v0.4 removes it */
if (result == kNoError) {
result = TRKInitializeDispatcher();
}
InitializeProgramEndTrap();
if (result == kNoError) {
result = TRKInitializeSerialHandler();
}
if (result == kNoError) {
result = TRKInitializeTarget();
}
if (result == kNoError) {
/* v0.4 has this line as resultTemp = TRK_InitializeIntDrivenUART(1, 0, &gTRKInputPendingPtr); */
resultTemp = TRKInitializeIntDrivenUART(0xE100, 1, 0, &gTRKInputPendingPtr);
TRKTargetSetInputPendingPtr(gTRKInputPendingPtr);
if (resultTemp != kNoError) {
result = resultTemp;
}
}
return result;
}

View File

@ -54,24 +54,4 @@ void TRKGetInput(void) {
gTRKFramingState.fBufferID = -1;
TRKPostEvent(&event);
}
}
MessageBufferID TRKTestForPacket(void) {
int dbgErr, err;
MessageBufferID id;
MessageBuffer* b;
int bytes, i;
bytes = TRKPollUART();
if (bytes > 0) {
dbgErr = TRKGetFreeBuffer(&id, &b);
TRKSetBufferPosition(b, 0);
err = TRKReadUARTN(b->fData, 0x40);
if (err == 0) {
TRKAppendBuffer_ui8(b, b->fData, 0x40);
}
}
}

View File

@ -0,0 +1,150 @@
#include "TRK_Types.h"
#include "dolphin.h"
#include "portable/mpc_7xx_603e.h"
#include "portable/ppc_reg.h"
static void TRKExceptionHandler(ui16);
typedef struct StopInfo_PPC{
ui32 PC;
ui32 PCInstruction;
ui16 exceptionID;
} StopInfo_PPC;
typedef struct TRKExceptionStatus{
StopInfo_PPC exceptionInfo;
ui8 inTRK;
ui8 exceptionDetected;
}TRKExceptionStatus;
static TRKExceptionStatus gTRKExceptionStatus = {
{0,0,0},
true,
0
};
ProcessorState_PPC gTRKCPUState;
TRKState_PPC gTRKState;
static ui16 TRK_saved_exceptionID = 0;
Default_PPC gTRKSaveState;
asm ui32 __TRK_get_MSR(){
nofralloc
mfmsr r3
blr
}
asm void __TRK_set_MSR(ui32 val){
nofralloc
mtmsr r3
blr
}
void TRKPostInterruptEvent(void);
asm void TRKInterruptHandler() {
nofralloc
mtsrr0 r2
mtsrr1 r4
mfsprg r4, 3
mfcr r2
mtsprg 3, r2
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
lwz r2, TRKState_PPC.MSR(r2)
ori r2, r2, 0x8002
xori r2, r2, 0x8002
sync
mtmsr r2
sync
lis r2, TRK_saved_exceptionID@h
ori r2, r2, TRK_saved_exceptionID@l
sth r3, 0(r2)
cmpwi r3, 0x500
bne L_802CF694
lis r2, gTRKCPUState@h
ori r2, r2, gTRKCPUState@l
mflr r3
stw r3, ProcessorState_PPC.transport_handler_saved_ra(r2)
bl TRKUARTInterruptHandler
lis r2, gTRKCPUState@h
ori r2, r2, gTRKCPUState@l
lwz r3, ProcessorState_PPC.transport_handler_saved_ra(r2)
mtlr r3
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
lwz r2, TRKState_PPC.inputPendingPtr(r2)
lbz r2, TRKState_PPC.GPR[0](r2)
cmpwi r2, 0
beq L_802CF678
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
lbz r2, TRKExceptionStatus.inTRK(r2)
cmpwi r2, 1
beq L_802CF678
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
li r3, 1
stb r3, TRKState_PPC.inputActivated(r2)
b L_802CF694
L_802CF678:
lis r2, gTRKSaveState@h
ori r2, r2, gTRKSaveState@l
lwz r3, Default_PPC.CR(r2)
mtcrf 0xff, r3
lwz r3, Default_PPC.GPR[3](r2)
lwz r2, Default_PPC.GPR[2](r2)
rfi
L_802CF694:
lis r2, TRK_saved_exceptionID@h
ori r2, r2, TRK_saved_exceptionID@l
lhz r3, 0(r2)
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
lbz r2, TRKExceptionStatus.inTRK(r2)
cmpwi r2, 0
bne TRKExceptionHandler
lis r2, gTRKCPUState@h
ori r2, r2, gTRKCPUState@l
stw r0, ProcessorState_PPC.Default.GPR[0](r2)
stw r1, ProcessorState_PPC.Default.GPR[1](r2)
mfsprg r0, 1
stw r0, ProcessorState_PPC.Default.GPR[2](r2)
sth r3, ProcessorState_PPC.Extended1.exceptionID(r2)
sth r3, (ProcessorState_PPC.Extended1.exceptionID + 2)(r2)
mfsprg r0, 2
stw r0, ProcessorState_PPC.Default.GPR[3](r2)
stmw r4, ProcessorState_PPC.Default.GPR[4](r2)
mfsrr0 r27
mflr r28
mfsprg r29, 3
mfctr r30
mfxer r31
stmw r27, ProcessorState_PPC.Default.PC(r2)
bl TRKSaveExtended1Block
lis r2, gTRKExceptionStatus@h
ori r2, r2, gTRKExceptionStatus@l
li r3, 1
stb r3, TRKExceptionStatus.inTRK(r2)
lis r2, gTRKState@h
ori r2, r2, gTRKState@l
lwz r0, TRKState_PPC.MSR(r2)
sync
mtmsr r0
sync
lwz r0, TRKState_PPC.LR(r2)
mtlr r0
lwz r0, TRKState_PPC.CTR(r2)
mtctr r0
lwz r0, TRKState_PPC.XER(r2)
mtxer r0
lwz r0, TRKState_PPC.DSISR(r2)
mtdsisr r0
lwz r0, TRKState_PPC.DAR(r2)
mtdar r0
lmw r3, TRKState_PPC.GPR[3](r2)
lwz r0, TRKState_PPC.GPR[0](r2)
lwz r1, TRKState_PPC.GPR[1](r2)
lwz r2, TRKState_PPC.GPR[2](r2)
b TRKPostInterruptEvent
}