Yoink MetroTRK from Pikmin & Mario Party 4 (thanks!)

This commit is contained in:
Cuyler36
2025-05-25 13:06:26 -04:00
parent ce0aa347ee
commit 657c536ca4
40 changed files with 4095 additions and 350 deletions
@@ -0,0 +1,24 @@
#ifndef TRK_CIRCLE_BUFFER_H
#define TRK_CIRCLE_BUFFER_H
#include "types.h"
typedef struct CircleBuffer {
u8* mReadPtr; // _00
u8* mWritePtr; // _04
u8* mStartPtr; // _08
u32 mSize; // _0C
u32 mBytesToRead; // _10
u32 mBytesToWrite; // _14
uint mSection; // _18
u32 _1C; // _1C
} CircleBuffer;
u32 CBGetBytesAvailableForRead(CircleBuffer* cb);
u32 CBGetBytesAvailableForWrite(CircleBuffer* cb);
void CircleBufferInitialize(CircleBuffer* cb, u8* buf, u32 size);
void CircleBufferTerminate(CircleBuffer* cb);
int CircleBufferWriteBytes(CircleBuffer* cb, u8* buf, u32 size);
int CircleBufferReadBytes(CircleBuffer* cb, u8* buf, u32 size);
#endif
@@ -0,0 +1,23 @@
#ifndef TRK_CC_GDEV_H
#define TRK_CC_GDEV_H
#include "types.h"
#include "NdevExi2A/DebuggerDriver.h"
// TODO: figure out what these values represent
typedef enum { GDEV_RESULT_10009 = -10009, GDEV_RESULT_10005 = -10005, GDEV_RESULT_10001 = -10001 } UnkGdevEnum;
void OutputData();
BOOL IsInitialized();
int gdev_cc_initialize(u8** flagOut, OSInterruptHandler handler);
int gdev_cc_shutdown();
int gdev_cc_open();
int gdev_cc_close();
int gdev_cc_read(u8* dest, int size);
int gdev_cc_write(const u8* src, int size);
int gdev_cc_pre_continue();
int gdev_cc_post_stop();
int gdev_cc_peek();
int gdev_cc_initinterrupts();
#endif
@@ -0,0 +1,27 @@
#ifndef METROTRK_DSTYPES
#define METROTRK_DSTYPES
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
// typedef unsigned char ui8;
// typedef unsigned short ui16;
// typedef unsigned long ui32;
// typedef unsigned long long ui64;
typedef unsigned char u128[16];
// typedef unsigned long size_t;
// typedef unsigned int uint;
// typedef int bool;
// #define true 1
// #define false 0
// #define NULL 0
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
@@ -0,0 +1,15 @@
#ifndef METROTRK_MEM_TRK_H
#define METROTRK_MEM_TRK_H
#include "PowerPC_EABI_Support/MetroTRK/dstypes.h"
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
typedef struct memRange {
u8* start;
u8* end;
BOOL readable;
BOOL writeable;
} memRange;
const memRange gTRKMemMap[1] = { { (u8*)0, (u8*)-1, TRUE, TRUE } };
#endif
@@ -0,0 +1,242 @@
#ifndef _PPC_REG_H
#define _PPC_REG_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
typedef struct Default_PPC {
u32 GPR[32];
u32 PC;
u32 LR;
u32 CR;
u32 CTR;
u32 XER;
} Default_PPC;
typedef struct Float_PPC {
u64 FPR[32];
u64 FPSCR;
u64 FPECR;
} Float_PPC;
typedef struct Extended1_PPC_6xx_7xx {
// u8 pad[0x168];
u32 SR[16];
u32 TBL;
u32 TBU;
u32 HID0_;
u32 HID1;
u32 MSR;
u32 PVR;
u32 IBAT0U;
u32 IBAT0L;
u32 IBAT1U;
u32 IBAT1L;
u32 IBAT2U;
u32 IBAT2L;
u32 IBAT3U;
u32 IBAT3L;
u32 DBAT0U;
u32 DBAT0L;
u32 DBAT1U;
u32 DBAT1L;
u32 DBAT2U;
u32 DBAT2L;
u32 DBAT3U_;
u32 DBAT3L_;
u32 DMISS;
u32 DCMP;
u32 HASH1;
u32 HASH2;
u32 IMISS;
u32 ICMP;
u32 RPA;
u32 SDR1;
u32 DAR;
u32 DSISR;
u32 SPRG0;
u32 SPRG1;
u32 SPRG2;
u32 SPRG3;
u32 DEC;
u32 IABR;
u32 EAR;
u32 DABR;
u32 PMC1;
u32 PMC2;
u32 PMC3;
u32 PMC4;
u32 SIA;
u32 MMCR0;
u32 MMCR1;
u32 THRM1;
u32 THRM2;
u32 THRM3;
u32 ICTC;
u32 L2CR;
u32 UMMCR2;
u32 UBAMR;
u32 UMMCR0;
u32 UPMC1;
u32 UPMC2;
u32 USIA;
u32 UMMCR1;
u32 UPMC3;
u32 UPMC4;
u32 USDA;
u32 MMCR2;
u32 BAMR;
u32 SDA;
u32 MSSCR0;
u32 MSSCR1;
u32 PIR;
u32 exceptionID;
u32 GQR[8];
u32 HID_G;
u32 WPAR;
u32 DMA_U_;
u32 DMA_L_;
} Extended1_PPC_6xx_7xx;
typedef struct Extended2_PPC_6xx_7xx {
u32 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;
u32 transport_handler_saved_ra;
} ProcessorState_PPC_6xx_7xx;
typedef ProcessorState_PPC_6xx_7xx ProcessorState_PPC;
#define SPR_XER 1
#define SPR_LR 8
#define SPR_CTR 9
#define SPR_DSISR 18
#define SPR_DAR 19
#define SPR_DEC 22
#define SPR_SDR1 25
#define SPR_SRR0 26
#define SPR_SRR1 27
#define SPR_SPRG0 272
#define SPR_SPRG1 273
#define SPR_SPRG2 274
#define SPR_SPRG3 275
#define SPR_EAR 282
#define SPR_TBL 284
#define SPR_TBU 285
#define SPR_PVR 287
#define SPR_IBAT0U 528
#define SPR_IBAT0L 529
#define SPR_IBAT1U 530
#define SPR_IBAT1L 531
#define SPR_IBAT2U 532
#define SPR_IBAT2L 533
#define SPR_IBAT3U 534
#define SPR_IBAT3L 535
#define SPR_IBAT4U 560
#define SPR_IBAT4L 561
#define SPR_IBAT5U 562
#define SPR_IBAT5L 563
#define SPR_IBAT6U 564
#define SPR_IBAT6L 565
#define SPR_IBAT7U 566
#define SPR_IBAT7L 567
#define SPR_DBAT0U 536
#define SPR_DBAT0L 537
#define SPR_DBAT1U 538
#define SPR_DBAT1L 539
#define SPR_DBAT2U 540
#define SPR_DBAT2L 541
#define SPR_DBAT3U 542
#define SPR_DBAT3L 543
#define SPR_DBAT4U 568
#define SPR_DBAT4L 569
#define SPR_DBAT5U 570
#define SPR_DBAT5L 571
#define SPR_DBAT6U 572
#define SPR_DBAT6L 573
#define SPR_DBAT7U 574
#define SPR_DBAT7L 575
#define SPR_GQR0 912
#define SPR_GQR1 913
#define SPR_GQR2 914
#define SPR_GQR3 915
#define SPR_GQR4 916
#define SPR_GQR5 917
#define SPR_GQR6 918
#define SPR_GQR7 919
#define SPR_HID2 920
#define SPR_WPAR 921
#define SPR_DMA_U 922
#define SPR_DMA_L 923
#define SPR_UMMCR0 936
#define SPR_UPMC1 937
#define SPR_UPMC2 938
#define SPR_USIA 939
#define SPR_UMMCR1 940
#define SPR_UPMC3 941
#define SPR_UPMC4 942
#define SPR_USDA 943
#define SPR_MMCR0 952
#define SPR_PMC1 953
#define SPR_PMC2 954
#define SPR_SIA 955
#define SPR_MMCR1 956
#define SPR_PMC3 957
#define SPR_PMC4 958
#define SPR_SDA 959
#define SPR_HID0 1008
#define SPR_HID1 1009
#define SPR_IABR 1010
#define SPR_HID4 1011
#define SPR_DABR 1013
#define SPR_L2CR 1017
#define SPR_ICTC 1019
#define SPR_THRM1 1020
#define SPR_THRM2 1021
#define SPR_FPECR 1022
// PPC exceptions
// 0x000 is reserved
#define PPC_SystemReset 0x100
#define PPC_MachineCheck 0x200
#define PPC_DataStorage 0x300
#define PPC_InstructionStorage 0x400
#define PPC_ExternalInterrupt 0x500
#define PPC_Alignment 0x600
#define PPC_Program 0x700
#define PPC_FloatingPointUnavaiable 0x800
#define PPC_Decrementer 0x900
// 0xA00-0xB00 are reserved
#define PPC_SystemCall 0xC00
#define PPC_Trace 0xD00
#define PPC_FloatingPointAssist 0xE00 // unimplemented in 750CL
#define PPC_PerformanceMonitor 0xF00 // Dolphin/Broadway specific
// 0x1000-0x1200 are unimplemented in 750CL
#define PPC_InstructionAddressBreakpoint 0x1300 // Dolphin/Broadway specific
// 0x1400-0x2F00 are reserved, but TRK uses some
#define PPC_SystemManagementInterrupt 0x1400
// 0x1500-0x1600 are unimplemented in 750CL
#define PPC_ThermalManagementInterrupt 0x1700
#define PPC_1800Exception 0x1800
#define PPC_1900Exception 0x1900
#define PPC_1A00Exception 0x1A00
#define PPC_1B00Exception 0x1B00
#define PPC_1C00Exception 0x1C00 // Data breakpoint?
#define PPC_1D00Exception 0x1D00 // Instruction breakpoint?
#define PPC_1E00Exception 0x1E00 // Peripheral breakpoint?
#define PPC_1F00Exception 0x1F00 // Non maskable development port?
#define PPC_2000Exception 0x2000
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
+225
View File
@@ -0,0 +1,225 @@
#ifndef _DOLPHIN_TRK_H
#define _DOLPHIN_TRK_H
#include "types.h"
#include "PowerPC_EABI_Support/MetroTRK/trktypes.h"
#include "PowerPC_EABI_Support/MetroTRK/ppc_reg.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
////// MSG HANDLING FUNCTIONS //////
DSError TRKDoConnect(TRKBuffer*);
DSError TRKDoDisconnect(TRKBuffer*);
DSError TRKDoReset(TRKBuffer*);
DSError TRKDoVersions(TRKBuffer*);
DSError TRKDoSupportMask(TRKBuffer*);
DSError TRKDoOverride(TRKBuffer*);
DSError TRKDoReadMemory(TRKBuffer*);
DSError TRKDoWriteMemory(TRKBuffer*);
DSError TRKDoReadRegisters(TRKBuffer*);
DSError TRKDoWriteRegisters(TRKBuffer*);
DSError TRKDoSetOption(TRKBuffer*);
DSError TRKDoContinue(TRKBuffer*);
DSError TRKDoStep(TRKBuffer*);
DSError TRKDoStop(TRKBuffer*);
DSError TRKDoUnsupported(TRKBuffer*);
DSError TRKDoCPUType(TRKBuffer*);
DSError TRKDoFlushCache(TRKBuffer*);
void __TRK_copy_vectors();
void SetBufferPosition(TRKBuffer*, u32);
void SetTRKConnected(int);
int GetTRKConnected(void);
DSError TRKGetFreeBuffer(int*, TRKBuffer**);
void OutputData(void* data, int length);
void TRKResetBuffer(TRKBuffer* msg, u8 keepData);
DSError TRKReadBuffer_ui8(TRKBuffer* buffer, u8* data, int count);
DSError TRKReadBuffer_ui32(TRKBuffer* buffer, u32* data, int count);
DSError TRKReadBuffer1_ui8(TRKBuffer* buffer, u8* data);
DSError TRKReadBuffer1_ui16(TRKBuffer* buffer, u16* data);
DSError TRKReadBuffer1_ui32(TRKBuffer* buffer, u32* data);
DSError TRKReadBuffer1_ui64(TRKBuffer* buffer, u64* data);
DSError TRKAppendBuffer_ui8(TRKBuffer* buffer, const u8* data, int count);
DSError TRKAppendBuffer_ui32(TRKBuffer* buffer, const u32* data, int count);
DSError TRKAppendBuffer1_ui16(TRKBuffer* buffer, const u16 data);
DSError TRKAppendBuffer1_ui32(TRKBuffer* buffer, const u32 data);
DSError TRKAppendBuffer1_ui64(TRKBuffer* buffer, const u64 data);
////////////////////////////////////
/////// DOLPHIN TRK FUNCTIONS //////
void InitMetroTRK(void);
void InitMetroTRK_BBA(void);
void EnableMetroTRKInterrupts(void);
void TRKLoadContext(OSContext* ctx, u32);
void TRKSaveExtended1Block();
void TRKRestoreExtended1Block();
int InitMetroTRKCommTable(int);
void TRK_board_display(char*);
////////////////////////////////////
////////// GDEV FUNCTIONS //////////
int gdev_cc_initialize(void* flagOut, __OSInterruptHandler handler);
int gdev_cc_shutdown();
int gdev_cc_open();
int gdev_cc_close();
int gdev_cc_read(u8* dest, int size);
int gdev_cc_write(const u8* src, int size);
int gdev_cc_pre_continue();
int gdev_cc_post_stop();
int gdev_cc_peek();
int gdev_cc_initinterrupts();
////////////////////////////////////
/////////// UDP FUNCTIONS //////////
int udp_cc_initialize(void* flagOut, __OSInterruptHandler handler);
int udp_cc_shutdown();
int udp_cc_open();
int udp_cc_close();
int udp_cc_read(u8* dest, int size);
int udp_cc_write(const u8* src, int size);
int udp_cc_pre_continue();
int udp_cc_post_stop();
int udp_cc_peek();
int udp_cc_initinterrupts();
////////////////////////////////////
/////////// DDH FUNCTIONS //////////
#define DDH_ERR_NOT_INITIALIZED -0x2711
#define DDH_ERR_ALREADY_INITIALIZED -0x2715
#define DDH_ERR_READ_ERROR -0x2719
int ddh_cc_initialize(void* flagOut, __OSInterruptHandler handler);
int ddh_cc_shutdown();
int ddh_cc_open();
int ddh_cc_close();
int ddh_cc_read(u8* dest, int size);
int ddh_cc_write(const u8* src, int size);
int ddh_cc_pre_continue();
int ddh_cc_post_stop();
int ddh_cc_peek();
int ddh_cc_initinterrupts();
////////////////////////////////////
////////// EVENT FUNCTIONS /////////
void TRKConstructEvent(TRKEvent* event, int eventType);
void TRKDestructEvent(TRKEvent* event);
DSError TRKPostEvent(TRKEvent* event);
BOOL TRKGetNextEvent(TRKEvent* event);
DSError TRKDispatchMessage(TRKBuffer*);
void* TRKGetBuffer(int);
void TRKReleaseBuffer(int);
void TRKGetInput();
////////////////////////////////////
///////// TARGET FUNCTIONS /////////
DSError TRKTargetContinue(void);
DSError TRKTargetInterrupt(TRKEvent*);
BOOL TRKTargetStopped();
void TRKTargetSetStopped(uint);
DSError TRKTargetSupportRequest();
////////////////////////////////////
////// NUB AND MEM FUNCTIONS ///////
DSError TRKAppendBuffer_ui8(TRKBuffer*, const u8*, int);
DSError TRKSetBufferPosition(TRKBuffer*, u32);
DSError TRKMessageSend(TRKBuffer*);
void TRKSwapAndGo(void);
DSError TRKInitializeNub(void);
DSError TRKTerminateNub(void);
void TRKNubWelcome(void);
void TRKNubMainLoop(void);
DSError TRKInitializeMutex(void*);
DSError TRKAcquireMutex(void*);
DSError TRKReleaseMutex(void*);
void* TRK_memcpy(void* dst, const void* src, size_t n);
////////////////////////////////////
/////// INITIALIZE FUNCTIONS ///////
DSError TRKInitializeEventQueue();
DSError TRKInitializeMessageBuffers();
DSError TRKInitializeDispatcher();
DSError InitializeProgramEndTrap();
DSError TRKInitializeSerialHandler();
DSError TRKTerminateSerialHandler();
DSError TRKInitializeTarget();
////////////////////////////////////
////////// EXI2 FUNCTIONS //////////
/* EXI2 */
void UnreserveEXI2Port(void);
void ReserveEXI2Port(void);
////////////////////////////////////
/////////// MW FUNCTIONS ///////////
void MWTRACE(u8, char*, ...);
////////////////////////////////////
//////// SUPPORT FUNCTIONS /////////
DSError TRKRequestSend();
u32 TRKAccessFile(u32, u32, u32*, u8*);
////////////////////////////////////
///// SERIAL POLLING FUNCTIONS /////
TRKBufferID TRKTestForPacker();
void TRKGetInput();
void TRKProcessInput(TRKBufferID bufID);
////////////////////////////////////
////////// OTHER FUNCTIONS /////////
DSError TRK_main(void);
UARTError InitializeUART(UARTBaudRate baudRate);
DSError TRKInitializeIntDrivenUART(u32, u32, u32, volatile u8**);
int TRKPollUART();
UARTError TRKReadUARTN(void*, u32);
UARTError TRKWriteUARTN(const void* bytes, u32 length);
void usr_put_initialize();
void TRKTargetSetInputPendingPtr(void*);
void SetUseSerialIO(u8);
u8 GetUseSerialIO(void);
u8 TRKTargetCPUMinorType();
DSError TRKTargetAddStopInfo(TRKBuffer*);
DSError TRKTargetAddExceptionInfo(TRKBuffer*);
void TRKInterruptHandler();
void TRKPostInterruptEvent();
BOOL usr_puts_serial(const char* msg);
////////////////////////////////////
//////// EXTERNAL DECLARES /////////
extern BOOL gTRKBigEndian;
extern void* gTRKInputPendingPtr;
extern ProcessorState_PPC gTRKCPUState;
extern ProcessorRestoreFlags_PPC gTRKRestoreFlags;
extern u8 gTRKInterruptVectorTable[];
extern TRKState gTRKState;
extern TRKBuffer gTRKMsgBufs[3];
////////////////////////////////////
////////// USEFUL STATICS //////////
static inline DSError TRKAppendBuffer1_ui8(TRKBuffer* buffer, const u8 data)
{
if (buffer->position >= 0x880) {
return DS_MessageBufferOverflow;
}
buffer->data[buffer->position++] = data;
buffer->length++;
return DS_NoError;
}
////////////////////////////////////
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
@@ -0,0 +1,212 @@
#ifndef _METROTRK_TRKENUM_H
#define _METROTRK_TRKENUM_H
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
//////////// TRK ENUMS /////////////
// Hardware types.
typedef enum {
HARDWARE_AMC_DDH = 0,
HARDWARE_GDEV = 1,
HARDWARE_BBA = 2,
} HardwareType;
// DS Error returns.
typedef enum {
DS_NoError = 0x0,
DS_StepError = 0x1,
DS_ParameterError = 0x2,
DS_EventQueueFull = 0x100,
DS_NoMessageBufferAvailable = 0x300,
DS_MessageBufferOverflow = 0x301,
DS_MessageBufferReadError = 0x302,
DS_DispatchError = 0x500,
DS_InvalidMemory = 0x700,
DS_InvalidRegister = 0x701,
DS_CWDSException = 0x702,
DS_UnsupportedError = 0x703,
DS_InvalidProcessID = 0x704,
DS_InvalidThreadID = 0x705,
DS_OSError = 0x706,
DS_Error800 = 0x800,
} DSError;
typedef struct DSCPUType {
u8 cpuMajor;
u8 cpuMinor;
u8 bigEndian;
u8 defaultTypeSize;
u8 fpTypeSize;
u8 extended1TypeSize;
u8 extended2TypeSize;
} DSCPUType;
DSError TRKTargetCPUType(DSCPUType* cpuType);
// Where to read/write.
typedef enum {
DS_Stdin = 0,
DS_Stdout = 1,
DS_Stderr = 2,
} DSFileHandle;
// IO returns.
typedef enum {
DS_IONoError = 0,
DS_IOError = 1,
DS_IOEOF = 2,
} DSIOResult;
// Message command IDs
typedef enum {
DSMSG_Ping = 0x0,
DSMSG_Connect = 0x1,
DSMSG_Disconnect = 0x2,
DSMSG_Reset = 0x3,
DSMSG_Versions = 0x4,
DSMSG_SupportMask = 0x5,
DSMSG_Override = 0x7,
DSMSG_ReadMemory = 0x10,
DSMSG_WriteMemory = 0x11,
DSMSG_ReadRegisters = 0x12,
DSMSG_WriteRegisters = 0x13,
DSMSG_SetOption = 0x17,
DSMSG_Continue = 0x18,
DSMSG_Step = 0x19,
DSMSG_Stop = 0x1A,
DSMSG_ReplyACK = 0x80,
DSMSG_NotifyStopped = 0x90,
DSMSG_NotifyException = 0x91,
DSMSG_WriteFile = 0xD0,
DSMSG_ReadFile = 0xD1,
DSMSG_OpenFile = 0xD2,
DSMSG_CloseFile = 0xD3,
DSMSG_PositionFile = 0xD4,
DSMSG_ReplyNAK = 0xFF,
} MessageCommandID;
// Register commands.
typedef enum {
DSREG_Default = 0,
DSREG_FP = 1,
DSREG_Extended1 = 2,
DSREG_Extended2 = 3,
} DSMessageRegisterOptions;
// Step commands.
typedef enum {
DSSTEP_IntoCount = 0x0,
DSSTEP_IntoRange = 0x1,
DSSTEP_OverCount = 0x10,
DSSTEP_OverRange = 0x11,
} DSMessageStepOptions;
typedef enum {
DSREPLY_NoError = 0x0,
DSREPLY_Error = 0x1,
DSREPLY_PacketSizeError = 0x2,
DSREPLY_CWDSError = 0x3,
DSREPLY_EscapeError = 0x4,
DSREPLY_BadFCS = 0x5,
DSREPLY_Overflow = 0x6,
DSREPLY_SequenceMissing = 0x7,
DSREPLY_UnsupportedCommandError = 0x10,
DSREPLY_ParameterError = 0x11,
DSREPLY_UnsupportedOptionError = 0x12,
DSREPLY_InvalidMemoryRange = 0x13,
DSREPLY_InvalidRegisterRange = 0x14,
DSREPLY_CWDSException = 0x15,
DSREPLY_NotStopped = 0x16,
DSREPLY_BreakpointsFull = 0x17,
DSREPLY_BreakpointConflict = 0x18,
DSREPLY_OSError = 0x20,
DSREPLY_InvalidProcessID = 0x21,
DSREPLY_InvalidThreadID = 0x22,
DSREPLY_DebugSecurityError = 0x23,
} DSReplyError;
typedef enum {
DSRECV_Wait = 0,
DSRECV_Found = 1,
DSRECV_InFrame = 2,
DSRECV_FrameOverflow = 3,
} ReceiverState;
typedef enum {
DSMSGMEMORY_Segmented = 0x01, /* non-flat addr space */
DSMSGMEMORY_Extended = 0x02, /* > 32-bit data addr */
DSMSGMEMORY_Protected = 0x04, /* non-user memory */
DSMSGMEMORY_Userview = 0x08, /* breakpoints are invisible */
DSMSGMEMORY_Space_program = 0x00,
DSMSGMEMORY_Space_data = 0x40,
DSMSGMEMORY_Space_io = 0x80
};
typedef enum {
NUBEVENT_Null = 0,
NUBEVENT_Shutdown = 1,
NUBEVENT_Request = 2,
NUBEVENT_Breakpoint = 3,
NUBEVENT_Exception = 4,
NUBEVENT_Support = 5,
} NubEventType;
typedef enum {
VALIDMEM_Readable = 0,
VALIDMEM_Writeable = 1,
} ValidMemoryOptions;
typedef enum {
MEMACCESS_UserMemory = 0,
MEMACCESS_DebuggerMemory = 1,
} MemoryAccessOptions;
typedef enum {
UART_NoError = 0,
UART_UnknownBaudRate = 1,
UART_ConfigurationError = 2,
UART_BufferOverflow = 3, // specified buffer was too small
UART_NoData = 4, // no data available from polling
} UARTErrorOptions;
typedef enum {
kBaudHWSet = -1, // use HW settings such as DIP switches
kBaud300 = 300, // valid baud rates
kBaud600 = 600,
kBaud1200 = 1200,
kBaud1800 = 1800,
kBaud2000 = 2000,
kBaud2400 = 2400,
kBaud3600 = 3600,
kBaud4800 = 4800,
kBaud7200 = 7200,
kBaud9600 = 9600,
kBaud19200 = 19200,
kBaud38400 = 38400,
kBaud57600 = 57600,
kBaud115200 = 115200,
kBaud230400 = 230400
} UARTBaudRate;
////////////////////////////////////
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif
@@ -0,0 +1,144 @@
#ifndef _METROTRK_TRKTYPES_H
#define _METROTRK_TRKTYPES_H
#include "types.h"
#include "Dolphin/OS/OSInterrupt.h"
#include "PowerPC_EABI_Support/MetroTRK/trkenum.h"
#ifdef __cplusplus
extern "C" {
#endif // ifdef __cplusplus
/////// TRK STRUCTS AND TYPES //////
// Function types for DB communications.
typedef int (*DBCommFunc)();
typedef void (*DBCommInitFunc)(volatile u8**, __OSInterruptHandler);
typedef int (*DBCommReadFunc)(void*, u32);
typedef int (*DBCommWriteFunc)(const void*, u32);
// Message buffer ID type.
typedef int TRKBufferID;
// Nub event ID type.
typedef u32 NubEventID;
// UART Error type.
typedef int UARTError;
// Size of message buffer.
#define TRKMSGBUF_SIZE (0x800 + 0x80)
// Struct for sending and receiving messages (size 0x88C).
typedef struct TRKBuffer {
u32 mutex; // _00
BOOL isInUse; // _04
u32 length; // _08
u32 position; // _0C
u8 data[TRKMSGBUF_SIZE]; // _10
} TRKBuffer;
// Struct for storing DB communication functions (size 0x1C).
typedef struct DBCommTable {
DBCommInitFunc initialize_func; // _00
DBCommFunc init_interrupts_func; // _04
DBCommFunc peek_func; // _08
DBCommReadFunc read_func; // _0C
DBCommWriteFunc write_func; // _10
DBCommFunc open_func; // _14
DBCommFunc close_func; // _18
} DBCommTable;
// Struct for information on DS versions (kernel and protocol) (size 0x4)
typedef struct DSVersions {
u8 kernelMajor; // _00
u8 kernelMinor; // _01
u8 protocolMajor; // _02
u8 protocolMinor; // _03
} DSVersions;
// Struct for packet information (size 0x8).
typedef struct TRKPacketSeq {
u16 _00; // _00, unknown
u8 _02[6]; // _02, unknown
} TRKPacketSeq;
// Struct for receiving packets from serial poll (size 0x14).
typedef struct TRKFramingState {
TRKBufferID msgBufID; // _00
TRKBuffer* buffer; // _04
u8 receiveState; // _08
BOOL isEscape; // _0C
u8 fcsType; // _10
} TRKFramingState;
// Command reply information (size 0x40).
typedef struct CommandReply {
u32 _00; // _00
union {
u8 b;
MessageCommandID m;
} commandID; // _04, use MessageCommandID enum
union {
u8 b;
DSReplyError r;
} replyError; // _08, use DSReplyError enum - should be enum type? check size.
u32 _0C; // _0C
u8 _10[0x30]; // _10, unknown
} CommandReply;
// Nub event information (size 0xC).
typedef struct TRKEvent {
u8 eventType; // _00
NubEventID eventID; // _04
TRKBufferID msgBufID; // _08
} TRKEvent;
// Event queue (size 0x28).
typedef struct TRKEventQueue {
u8 _00[4]; // _00, unknown
int count; // _04, number of events in queue
int next; // _08, next event in `events` to handle (0 or 1)
TRKEvent events[2]; // _0C
NubEventID eventID; // _24, ID to assign next event, min 0x100
} TRKEventQueue;
// Struct for state information (size 0xB0).
typedef struct TRKState {
u32 gpr[32]; // _00
u32 lr; // _80
u32 ctr; // _84
u32 xer; // _88
u32 msr; // _8C
u32 dar; // _90
u32 dsisr; // _94
BOOL isStopped; // _98
BOOL inputActivated; // _9C
void* inputPendingPtr; // _A0
} TRKState;
typedef struct TRKState_PPC {
u32 GPR[32]; // 0x0
u32 LR; // 0x80
u32 CTR; // 0x84
u32 XER; // 0x88
u32 MSR; // 0x8c
u32 DAR; // 0x90
u32 DSISR; // 0x94
BOOL stopped; // 0x98
BOOL inputActivated; // 0x9c
u8* inputPendingPtr; // 0xA0
} TRKState_PPC;
typedef struct ProcessorRestoreFlags_PPC {
u8 TBR;
u8 DEC;
u8 linker_padding[0x9 - 0x2];
} ProcessorRestoreFlags_PPC;
////////////////////////////////////
#ifdef __cplusplus
};
#endif // ifdef __cplusplus
#endif