Import gx, PadClamp, rest of mtx, TRK 2.6 and MSL (#525)

* Match mtx and Padclamp.c

* Match the rest of GX

* Import TRK 2.6

* Import MSL headers and files

* Merge some MSL headers into ours
This commit is contained in:
dbalatoni13 2025-01-12 15:11:23 +01:00 committed by GitHub
parent a79294aac0
commit cdb1d1fc37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
113 changed files with 11219 additions and 394 deletions

View file

@ -0,0 +1,35 @@
#ifndef METROTRK_PORTABLE_DISPATCH_H
#define METROTRK_PORTABLE_DISPATCH_H
#include "dolphin/types.h"
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#ifdef __cplusplus
extern "C" {
#endif
#define TRK_DISPATCH_CMD_CONNECT 1 /* Connect to the console */
#define TRK_DISPATCH_CMD_DISCONNECT 2 /* Disconnect from the console */
#define TRK_DISPATCH_CMD_RESET 3 /* Reset the debugger */
#define TRK_DISPATCH_CMD_GETVERSION 4 /* Get debugger version */
#define TRK_DISPATCH_CMD_GETSUPPORTMASK 5 /* Get Support Mask */
#define TRK_DISPATCH_CMD_OVERRIDE 7 /* Override? */
#define TRK_DISPATCH_CMD_READMEM 16 /* Reading from memory */
#define TRK_DISPATCH_CMD_WRITEMEM 17 /* Writing to memory */
#define TRK_DISPATCH_CMD_READREGS 18 /* Read a register value */
#define TRK_DISPATCH_CMD_WRITEREGS 19 /* Set a register */
#define TRK_DISPATCH_CMD_SETOPTION 23 /* Set an option? */
#define TRK_DISPATCH_CMD_CONTINUE 24 /* Continue debugging */
#define TRK_DISPATCH_CMD_STEP 25 /* Step through an instruction */
#define TRK_DISPATCH_CMD_STOP 26 /* Stop the debugger */
typedef struct TRKBuffer TRKBuffer;
DSError TRKInitializeDispatcher();
BOOL TRKDispatchMessage(TRKBuffer* buffer);
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_DISPATCH_H */

View file

@ -0,0 +1,16 @@
#ifndef METROTRK_PORTABLE_MAIN_TRK_H
#define METROTRK_PORTABLE_MAIN_TRK_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#ifdef __cplusplus
extern "C" {
#endif
DSError TRK_main(void);
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_MAIN_TRK_H */

View file

@ -0,0 +1,14 @@
#ifndef METROTRK_PORTABLE_MAINLOOP_H
#define METROTRK_PORTABLE_MAINLOOP_H
#ifdef __cplusplus
extern "C" {
#endif
void TRKNubMainLoop(void);
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_MAINLOOP_H */

View file

@ -0,0 +1,17 @@
#ifndef METROTRK_PORTABLE_MEM_TRK_H
#define METROTRK_PORTABLE_MEM_TRK_H
#include "stddef.h"
#ifdef __cplusplus
extern "C" {
#endif
void* TRK_memset(void* dst, int val, size_t n);
void* TRK_memcpy(void* dst, const void* src, size_t n);
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_MEM_TRK_H */

View file

@ -0,0 +1,24 @@
#ifndef METROTRK_PORTABLE_MSG_H
#define METROTRK_PORTABLE_MSG_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#include "dolphin/types.h"
typedef struct _TRK_Msg {
u8 _00[8];
u32 m_msgLength;
u32 _0C;
u32 m_msg;
} TRK_Msg;
#ifdef __cplusplus
extern "C" {
#endif
DSError TRKMessageSend(TRK_Msg* msg);
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_MSG_H */

View file

@ -0,0 +1,50 @@
#ifndef METROTRK_PORTABLE_MSGBUF_H
#define METROTRK_PORTABLE_MSGBUF_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#include "stddef.h"
#ifdef __cplusplus
extern "C" {
#endif
DSError TRKInitializeMessageBuffers(void);
DSError TRKSetBufferPosition(TRKBuffer* msg, u32 pos);
void* TRKGetBuffer(int);
void TRKResetBuffer(TRKBuffer* msg, BOOL keepData);
void* TRKGetBuffer(int idx);
void TRKReleaseBuffer(int idx);
DSError TRKGetFreeBuffer(int* msgID, TRKBuffer** outMsg);
DSError TRKAppendBuffer(TRKBuffer* msg, const void* data, size_t length);
DSError TRKAppendBuffer1_ui8(TRKBuffer* buffer, const u8 data);
inline DSError TRKAppendBuffer1_ui8(TRKBuffer* buffer, const u8 data)
{
if (buffer->position >= TRKMSGBUF_SIZE) {
return DS_MessageBufferOverflow;
}
buffer->data[buffer->position++] = data;
buffer->length++;
return DS_NoError;
}
DSError TRKAppendBuffer1_ui16(TRKBuffer* buffer, const u16 data);
DSError TRKAppendBuffer1_ui32(TRKBuffer* buffer, const u32 data);
DSError TRKAppendBuffer1_ui64(TRKBuffer* buffer, const u64 data);
DSError TRKAppendBuffer_ui8(TRKBuffer* buffer, const u8* data, int count);
DSError TRKAppendBuffer_ui32(TRKBuffer* buffer, const 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 TRKReadBuffer_ui8(TRKBuffer* buffer, u8* data, int count);
DSError TRKReadBuffer_ui32(TRKBuffer* buffer, u32* data, int count);
DSError TRKReadBuffer(TRKBuffer* msg, void* data, size_t length);
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_MSGBUF_H */

View file

@ -0,0 +1,31 @@
#ifndef METROTRK_PORTABLE_MSGHNDLR_H
#define METROTRK_PORTABLE_MSGHNDLR_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
void SetTRKConnected(BOOL);
BOOL GetTRKConnected(void);
DSError TRKDoUnsupported(TRKBuffer*);
DSError TRKDoSetOption(TRKBuffer*);
DSError TRKDoStop(TRKBuffer*);
DSError TRKDoStep(TRKBuffer*);
DSError TRKDoContinue(TRKBuffer*);
DSError TRKDoWriteRegisters(TRKBuffer*);
DSError TRKDoReadRegisters(TRKBuffer*);
DSError TRKDoFlushCache(TRKBuffer*);
DSError TRKDoWriteMemory(TRKBuffer*);
DSError TRKDoReadMemory(TRKBuffer*);
DSError TRKDoSupportMask(TRKBuffer*);
DSError TRKDoVersions(TRKBuffer*);
DSError TRKDoSupportMask(TRKBuffer*);
DSError TRKDoCPUType(TRKBuffer*);
DSError TRKDoOverride(TRKBuffer*);
DSError TRKDoReset(TRKBuffer*);
DSError TRKDoDisconnect(TRKBuffer*);
DSError TRKDoConnect(TRKBuffer*);
DSError TRKStandardACK(TRKBuffer* buffer, MessageCommandID commandID,
DSReplyError replyError);
void OutputData(void* data, int length);
#endif /* METROTRK_PORTABLE_MSGHNDLR_H */

View file

@ -0,0 +1,10 @@
#ifndef METROTRK_PORTABLE_MUTEX_TRK_H
#define METROTRK_PORTABLE_MUTEX_TRK_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
DSError TRKInitializeMutex(void*);
DSError TRKAcquireMutex(void*);
DSError TRKReleaseMutex(void*);
#endif /* METROTRK_PORTABLE_MUTEX_TRK_H */

View file

@ -0,0 +1,16 @@
#ifndef METROTRK_PORTABLE_NOTIFY_H
#define METROTRK_PORTABLE_NOTIFY_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#ifdef __cplusplus
extern "C" {
#endif
DSError TRKDoNotifyStopped(MessageCommandID cmd);
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_NOTIFY_H */

View file

@ -0,0 +1,37 @@
#ifndef METROTRK_PORTABLE_NUBEVENT_H
#define METROTRK_PORTABLE_NUBEVENT_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef u32 NubEventID;
typedef struct TRKEvent {
NubEventType eventType;
NubEventID eventID;
MessageBufferID msgBufID;
} TRKEvent;
typedef struct TRKEventQueue {
int _00;
int count;
int next;
TRKEvent events[2];
NubEventID eventID;
} TRKEventQueue;
extern TRKEventQueue gTRKEventQueue;
BOOL TRKGetNextEvent(TRKEvent* event);
void TRKDestructEvent(TRKEvent*);
void TRKConstructEvent(TRKEvent*, NubEventType);
DSError TRKPostEvent(TRKEvent*);
DSError TRKInitializeEventQueue();
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_NUBEVENT_H */

View file

@ -0,0 +1,21 @@
#ifndef METROTRK_PORTABLE_NUBINIT_H
#define METROTRK_PORTABLE_NUBINIT_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#ifdef __cplusplus
extern "C" {
#endif
void TRKNubWelcome(void);
void TRKNubMainLoop(void);
DSError TRKTerminateNub(void);
DSError TRKInitializeNub(void);
extern BOOL gTRKBigEndian;
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_NUBINIT_H */

View file

@ -0,0 +1,23 @@
#ifndef METROTRK_PORTABLE_SERPOLL_H
#define METROTRK_PORTABLE_SERPOLL_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#ifdef __cplusplus
extern "C" {
#endif
DSError TRKInitializeSerialHandler(void);
DSError TRKTerminateSerialHandler(void);
void TRKGetInput(void);
MessageBufferID TRKTestForPacket();
void TRKProcessInput(int bufferIdx);
extern void* gTRKInputPendingPtr;
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_SERPOLL_H */

View file

@ -0,0 +1,29 @@
#ifndef METROTRK_PORTABLE_SUPPORT_H
#define METROTRK_PORTABLE_SUPPORT_H
#include "PowerPC_EABI_Support/MetroTRK/trk.h"
#include "stddef.h"
#ifdef __cplusplus
extern "C" {
#endif
DSError TRKSuppAccessFile(u32 file_handle, u8* data, size_t* count,
DSIOResult* io_result, BOOL need_reply, BOOL read);
DSError TRKRequestSend(TRKBuffer* msgBuf, int* bufferId, u32 p1, u32 p2,
int p3);
DSError HandleOpenFileSupportRequest(const char* path, u8 replyError,
u32* param_3, DSIOResult* ioResult);
DSError HandleCloseFileSupportRequest(int replyError, DSIOResult* ioResult);
DSError HandlePositionFileSupportRequest(DSReplyError replyErr, u32* param_2,
u8 param_3, DSIOResult* ioResult);
#ifdef __cplusplus
}
#endif
#endif /* METROTRK_PORTABLE_SUPPORT_H */