mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-07-07 12:03:27 -04:00
Link TRK/msgbuf, refactor TRK headers
This commit is contained in:
+3
-2
@@ -872,9 +872,10 @@ config.libs = [
|
||||
"-O4,p",
|
||||
"-sdata 0",
|
||||
"-sdata2 0",
|
||||
"-inline deferred",
|
||||
"-inline auto,deferred",
|
||||
"-rostr",
|
||||
"-char signed",
|
||||
"-use_lmw_stmw on"
|
||||
],
|
||||
"progress_category": "sdk",
|
||||
"src_dir": "src/static",
|
||||
@@ -889,7 +890,7 @@ config.libs = [
|
||||
Object(Matching, "TRK_MINNOW_DOLPHIN/mem_TRK.c"),
|
||||
Object(NonMatching, "TRK_MINNOW_DOLPHIN/mpc_7xx_603e.c"),
|
||||
Object(NonMatching, "TRK_MINNOW_DOLPHIN/msg.c"),
|
||||
Object(NonMatching, "TRK_MINNOW_DOLPHIN/msgbuf.c"),
|
||||
Object(Matching, "TRK_MINNOW_DOLPHIN/msgbuf.c"),
|
||||
Object(NonMatching, "TRK_MINNOW_DOLPHIN/msghndlr.c"),
|
||||
Object(NonMatching, "TRK_MINNOW_DOLPHIN/mslsupp.c"),
|
||||
Object(NonMatching, "TRK_MINNOW_DOLPHIN/mutex_TRK.c"),
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef MEM_TRK_H
|
||||
#define MEM_TRK_H
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void* TRK_memcpy(void* dst, const void* src, size_t size);
|
||||
void* TRK_memset(void* dst, int val, size_t size);
|
||||
void TRK_fill_mem(void*, int, size_t);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -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,24 @@
|
||||
#ifndef TRK_CC_GDEV_H
|
||||
#define TRK_CC_GDEV_H
|
||||
|
||||
#include "types.h"
|
||||
#include <dolphin/os/OSInterrupt.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
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef TRK_DISPATCH
|
||||
#define TRK_DISPATCH
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#include "TRK/msgbuf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
TRKResult TRKDispatchMessage(MessageBuffer* mBuf);
|
||||
TRKResult TRKInitializeDispatcher();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef DOLPHIN_TRK_H
|
||||
#define DOLPHIN_TRK_H
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
void InitMetroTRK(void);
|
||||
void exit(void);
|
||||
TRKResult TRKInitializeTarget();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef DOLPHIN_TRK_GLUE_H
|
||||
#define DOLPHIN_TRK_GLUE_H
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
|
||||
TRKResult TRKInitializeIntDrivenUART(u32, u32, u32, void*);
|
||||
void TRK_board_display(const char*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#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
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef TRK_MAINLOOP
|
||||
#define TRK_MAINLOOP
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
void TRKNubMainLoop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef METROTRK_MEM_TRK_H
|
||||
#define METROTRK_MEM_TRK_H
|
||||
#include "TRK/dstypes.h"
|
||||
#include "TRK/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
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef TRK_MSGBUF
|
||||
#define TRK_MSGBUF
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct MessageBuffer {
|
||||
int unk0;
|
||||
int unk4;
|
||||
int unk8;
|
||||
u32 unkC;
|
||||
u8 mBuffer[0x87C];
|
||||
} MessageBuffer;
|
||||
|
||||
MessageBuffer* TRKGetBuffer(int);
|
||||
void TRKReleaseBuffer(int);
|
||||
TRKResult TRKInitializeMessageBuffers();
|
||||
void TRKSetBufferPosition(MessageBuffer*, u32);
|
||||
void TRKReadBuffer1_ui8(MessageBuffer*, u8*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
#ifndef TRK_MSGHNDLR
|
||||
#define TRK_MSGHNDLR
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#include "TRK/msgbuf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
TRKResult TRKDoUnsupported(MessageBuffer*);
|
||||
TRKResult TRKDoConnect(MessageBuffer*);
|
||||
TRKResult TRKDoDisconnect(MessageBuffer*);
|
||||
TRKResult TRKDoReset(MessageBuffer*);
|
||||
TRKResult TRKDoVersions(MessageBuffer*);
|
||||
TRKResult TRKDoSupportMask(MessageBuffer*);
|
||||
TRKResult TRKDoCPUType(MessageBuffer*);
|
||||
TRKResult TRKDoReadMemory(MessageBuffer*);
|
||||
TRKResult TRKDoWriteMemory(MessageBuffer*);
|
||||
TRKResult TRKDoReadRegisters(MessageBuffer*);
|
||||
TRKResult TRKDoWriteRegisters(MessageBuffer*);
|
||||
TRKResult TRKDoFlushCache(MessageBuffer*);
|
||||
TRKResult TRKDoSetOption(MessageBuffer*);
|
||||
TRKResult TRKDoContinue(MessageBuffer*);
|
||||
TRKResult TRKDoStep(MessageBuffer*);
|
||||
TRKResult TRKDoStop(MessageBuffer*);
|
||||
|
||||
BOOL GetTRKConnected();
|
||||
void SetTRKConnected(BOOL);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef TRK_MUTEX_TRK
|
||||
#define TRK_MUTEX_TRK
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
TRKResult TRKAcquireMutex(void*);
|
||||
TRKResult TRKReleaseMutex(void*);
|
||||
TRKResult TRKInitializeMutex(void*);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,28 +0,0 @@
|
||||
#ifndef TRK_NUBEVENT
|
||||
#define TRK_NUBEVENT
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct TRKEventQueue{
|
||||
int unk0;
|
||||
int mCurrEvtID;
|
||||
int mNextSlotToOverwrite;
|
||||
TRKEvent mEvents[2];
|
||||
u32 mMax;
|
||||
}TRKEventQueue;
|
||||
|
||||
|
||||
TRKResult TRKInitializeEventQueue();
|
||||
BOOL TRKGetNextEvent(TRKEvent*);
|
||||
TRKResult TRKPostEvent(TRKEvent*);
|
||||
void TRKConstructEvent(TRKEvent*, int);
|
||||
void TRKDestructEvent(TRKEvent*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef TRK_NUBINIT
|
||||
#define TRK_NUBINIT
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
TRKResult TRKInitializeNub(void);
|
||||
TRKResult TRKTerminateNub(void);
|
||||
void TRKNubWelcome(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef TRK_SERPOLL
|
||||
#define TRK_SERPOLL
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void TRKGetInput();
|
||||
TRKResult TRKInitializeSerialHandler();
|
||||
TRKResult TRKTerminateSerialHandler();
|
||||
|
||||
extern u8* gTRKInputPendingPtr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef TRK_TARGIMPL
|
||||
#define TRK_TARGIMPL
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void TRKTargeInterrupt(TRKEvent*);
|
||||
void TRKTargetSupportRequest();
|
||||
BOOL TRKTargetStopped();
|
||||
void TRKTargetContinue();
|
||||
void TRKTargetSetInputPendingPtr(void*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
+197
-19
@@ -1,26 +1,204 @@
|
||||
#ifndef TRK_H
|
||||
#define TRK_H
|
||||
#include "types.h"
|
||||
#ifndef _DOLPHIN_TRK_H
|
||||
#define _DOLPHIN_TRK_H
|
||||
|
||||
#include <dolphin/types.h>
|
||||
#include "TRK/trktypes.h"
|
||||
#include "TRK/ppc_reg.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
extern "C" {
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
typedef enum {
|
||||
TRKSuccess = 0,
|
||||
TRKError100 = 0x100,
|
||||
TRKError301 = 0x301,
|
||||
TRKError302 = 0x302,
|
||||
TRKError500 = 0x500
|
||||
}TRKResult;
|
||||
////// MSG HANDLING FUNCTIONS //////
|
||||
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 TRKDoSetOption(MessageBuffer*);
|
||||
DSError TRKDoContinue(MessageBuffer*);
|
||||
DSError TRKDoStep(MessageBuffer*);
|
||||
DSError TRKDoStop(MessageBuffer*);
|
||||
DSError TRKDoUnsupported(MessageBuffer*);
|
||||
DSError TRKDoCPUType(MessageBuffer*);
|
||||
DSError TRKDoFlushCache(MessageBuffer*);
|
||||
|
||||
typedef struct TRKEvent{
|
||||
u8 mEventType;
|
||||
int mMax;
|
||||
int mBufferIndex;
|
||||
}TRKEvent;
|
||||
void SetBufferPosition(MessageBuffer*, u32);
|
||||
void SetTRKConnected(int);
|
||||
int GetTRKConnected(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
DSError TRKGetFreeBuffer(int*, MessageBuffer**);
|
||||
void OutputData(void* data, int length);
|
||||
void TRKResetBuffer(MessageBuffer* msg, u8 keepData);
|
||||
|
||||
DSError TRKReadBuffer1_ui64(MessageBuffer* buffer, u64* data);
|
||||
DSError TRKAppendBuffer1_ui64(MessageBuffer* 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(MessageBuffer*);
|
||||
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(MessageBuffer*, const u8*, int);
|
||||
DSError TRKSetBufferPosition(MessageBuffer*, u32);
|
||||
|
||||
DSError TRKMessageSend(MessageBuffer*);
|
||||
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*);
|
||||
////////////////////////////////////
|
||||
|
||||
////////// OTHER FUNCTIONS /////////
|
||||
DSError TRK_main(void);
|
||||
UARTError InitializeUART(UARTBaudRate baudRate);
|
||||
DSError TRKInitializeIntDrivenUART(u32, u32, u32, void*);
|
||||
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);
|
||||
|
||||
DSError TRKTargetAddStopInfo(MessageBuffer*);
|
||||
void TRKTargetAddExceptionInfo(MessageBuffer*);
|
||||
void TRKInterruptHandler();
|
||||
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 MessageBuffer gTRKMsgBufs[3];
|
||||
////////////////////////////////////
|
||||
|
||||
////////// USEFUL STATICS //////////
|
||||
static inline DSError TRKAppendBuffer1_ui8(MessageBuffer* buffer, const u8 data)
|
||||
{
|
||||
if (buffer->position >= 0x880) {
|
||||
return DS_MessageBufferOverflow;
|
||||
}
|
||||
|
||||
buffer->data[buffer->position++] = data;
|
||||
buffer->length++;
|
||||
return DS_NoError;
|
||||
}
|
||||
#endif
|
||||
////////////////////////////////////
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
#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;
|
||||
|
||||
// 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,147 @@
|
||||
#ifndef _METROTRK_TRKTYPES_H
|
||||
#define _METROTRK_TRKTYPES_H
|
||||
|
||||
#include "types.h"
|
||||
#include <dolphin/os/OSInterrupt.h>
|
||||
#include "TRK/trkenum.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
/////// TRK STRUCTS AND TYPES //////
|
||||
// Function types for DB communications.
|
||||
typedef int (*DBCommFunc)();
|
||||
typedef int (*DBCommInitFunc)(void*, __OSInterruptHandler);
|
||||
typedef int (*DBCommReadFunc)(u8*, int);
|
||||
typedef int (*DBCommWriteFunc)(const u8*, int);
|
||||
|
||||
// Message buffer ID type.
|
||||
typedef int MessageBufferID;
|
||||
|
||||
// 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 MessageBuffer {
|
||||
u32 _00; // _00, unknown
|
||||
BOOL isInUse; // _04
|
||||
u32 length; // _08
|
||||
u32 position; // _0C
|
||||
u8 data[TRKMSGBUF_SIZE]; // _10
|
||||
} MessageBuffer;
|
||||
|
||||
// Struct for storing DB communication functions (size 0x28).
|
||||
typedef struct DBCommTable {
|
||||
DBCommInitFunc initialize_func; // _00
|
||||
DBCommFunc init_interrupts_func; // _04
|
||||
DBCommFunc shutdown_func; // _08
|
||||
DBCommFunc peek_func; // _0C
|
||||
DBCommReadFunc read_func; // _10
|
||||
DBCommWriteFunc write_func; // _14
|
||||
DBCommFunc open_func; // _18
|
||||
DBCommFunc close_func; // _1C
|
||||
DBCommFunc pre_continue_func; // _20
|
||||
DBCommFunc post_stop_func; // _24
|
||||
} 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 {
|
||||
MessageBufferID msgBufID; // _00
|
||||
MessageBuffer* buffer; // _04
|
||||
ReceiverState 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
|
||||
MessageBufferID 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
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef TRK_USER_PUT
|
||||
#define TRK_USER_PUT
|
||||
#include "types.h"
|
||||
#include "TRK/trk.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
TRKResult usr_put_initialize();
|
||||
TRKResult usr_puts_serial(const char*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef PPC_EABI_INIT_H
|
||||
#define PPC_EABI_INIT_H
|
||||
|
||||
#include "types.h"
|
||||
#include <dolphin/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ typedef u32 unknown;
|
||||
|
||||
#ifndef __cplusplus
|
||||
// Some definitions rely on wchar_t being defined
|
||||
typedef short wchar_t;
|
||||
typedef unsigned short wchar_t;
|
||||
#endif
|
||||
|
||||
// #if DEBUG
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#include "TRK/dispatch.h"
|
||||
#include "TRK/msghndlr.h"
|
||||
#include "TRK/trk.h"
|
||||
|
||||
u32 gTRKDispatchTableSize;
|
||||
|
||||
TRKResult (*gTRKDispatchTable[])(MessageBuffer*) = {
|
||||
DSError (*gTRKDispatchTable[])(MessageBuffer*) = {
|
||||
&TRKDoUnsupported, &TRKDoConnect, &TRKDoDisconnect,
|
||||
&TRKDoReset, &TRKDoVersions, &TRKDoSupportMask,
|
||||
&TRKDoCPUType, &TRKDoUnsupported, &TRKDoUnsupported,
|
||||
@@ -17,16 +16,16 @@ TRKResult (*gTRKDispatchTable[])(MessageBuffer*) = {
|
||||
&TRKDoUnsupported, &TRKDoUnsupported, NULL,
|
||||
};
|
||||
|
||||
TRKResult TRKInitializeDispatcher() {
|
||||
DSError TRKInitializeDispatcher() {
|
||||
gTRKDispatchTableSize = 32;
|
||||
return TRKSuccess;
|
||||
return DS_NoError;
|
||||
}
|
||||
|
||||
TRKResult TRKDispatchMessage(MessageBuffer* mbuf) {
|
||||
DSError TRKDispatchMessage(MessageBuffer* mbuf) {
|
||||
|
||||
u8 buf;
|
||||
s16 val;
|
||||
TRKResult res = TRKError500;
|
||||
DSError res = DS_DispatchError;
|
||||
|
||||
TRKSetBufferPosition(mbuf, 0);
|
||||
TRKReadBuffer1_ui8(mbuf, &buf);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "TRK/_mem_trk.h"
|
||||
#include "TRK/trk.h"
|
||||
|
||||
__declspec(section ".init") asm void __TRK_reset(void){
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
#include "TRK/mainloop.h"
|
||||
#include "TRK/nubevent.h"
|
||||
#include "TRK/dispatch.h"
|
||||
#include "TRK/targimpl.h"
|
||||
#include "TRK/serpoll.h"
|
||||
#include "TRK/trk.h"
|
||||
|
||||
void TRKNubMainLoop(void){
|
||||
|
||||
@@ -14,11 +10,11 @@ void TRKNubMainLoop(void){
|
||||
while(loop == FALSE){
|
||||
if(TRKGetNextEvent(&event) != FALSE){
|
||||
statInput = FALSE;
|
||||
switch(event.mEventType){
|
||||
switch(event.eventType){
|
||||
case 0:
|
||||
break;
|
||||
case 2:
|
||||
msg = TRKGetBuffer(event.mBufferIndex);
|
||||
msg = TRKGetBuffer(event.msgBufID);
|
||||
TRKDispatchMessage(msg);
|
||||
break;
|
||||
case 1:
|
||||
@@ -34,7 +30,7 @@ void TRKNubMainLoop(void){
|
||||
}
|
||||
TRKDestructEvent(&event);
|
||||
}
|
||||
else if((statInput == FALSE) || ((u8)*gTRKInputPendingPtr != 0)){
|
||||
else if((statInput == FALSE) || (*(u8*)gTRKInputPendingPtr != 0)){
|
||||
statInput = TRUE;
|
||||
TRKGetInput();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "TRK/_mem_trk.h"
|
||||
#include "TRK/trk.h"
|
||||
|
||||
void TRK_fill_mem(void *dst, int val, u32 length);
|
||||
|
||||
__declspec(section ".init") void *TRK_memcpy(void *dst, const void *src, size_t n)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "TRK/trk.h"
|
||||
|
||||
DSError TRKMessageSend(MessageBuffer* msg)
|
||||
{
|
||||
DSError writeErr = TRKWriteUARTN(&msg->data, msg->length);
|
||||
return DS_NoError;
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
#include "TRK/trk.h"
|
||||
|
||||
MessageBuffer gTRKMsgBufs[3];
|
||||
|
||||
void TRKSetBufferUsed(MessageBuffer* msg, BOOL state) { msg->isInUse = state; }
|
||||
|
||||
DSError TRKInitializeMessageBuffers(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 3; i++) {
|
||||
TRKInitializeMutex(&gTRKMsgBufs[i]);
|
||||
TRKAcquireMutex(&gTRKMsgBufs[i]);
|
||||
TRKSetBufferUsed(&gTRKMsgBufs[i], FALSE);
|
||||
TRKReleaseMutex(&gTRKMsgBufs[i]);
|
||||
}
|
||||
|
||||
return DS_NoError;
|
||||
}
|
||||
|
||||
DSError TRKGetFreeBuffer(int* msgID, MessageBuffer** outMsg)
|
||||
{
|
||||
MessageBuffer* buf;
|
||||
DSError error = DS_NoMessageBufferAvailable;
|
||||
int i;
|
||||
|
||||
*outMsg = nullptr;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
buf = TRKGetBuffer(i);
|
||||
|
||||
TRKAcquireMutex(buf);
|
||||
if (!buf->isInUse) {
|
||||
TRKResetBuffer(buf, TRUE);
|
||||
TRKSetBufferUsed(buf, TRUE);
|
||||
error = DS_NoError;
|
||||
*outMsg = buf;
|
||||
*msgID = i;
|
||||
i = 3; // why not break? weird choice
|
||||
}
|
||||
TRKReleaseMutex(buf);
|
||||
}
|
||||
|
||||
if (error == DS_NoMessageBufferAvailable) {
|
||||
usr_puts_serial("ERROR : No buffer available\n");
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void* TRKGetBuffer(int idx)
|
||||
{
|
||||
MessageBuffer* buf = nullptr;
|
||||
if (idx >= 0 && idx < 3) {
|
||||
buf = &gTRKMsgBufs[idx];
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void TRKReleaseBuffer(int idx)
|
||||
{
|
||||
MessageBuffer* msg;
|
||||
if (idx != -1 && idx >= 0 && idx < 3) {
|
||||
msg = &gTRKMsgBufs[idx];
|
||||
TRKAcquireMutex(msg);
|
||||
TRKSetBufferUsed(msg, FALSE);
|
||||
TRKReleaseMutex(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void TRKResetBuffer(MessageBuffer* msg, u8 keepData)
|
||||
{
|
||||
msg->length = 0;
|
||||
msg->position = 0;
|
||||
|
||||
if (!keepData) {
|
||||
TRK_memset(msg->data, 0, 0x880);
|
||||
}
|
||||
}
|
||||
|
||||
DSError TRKSetBufferPosition(MessageBuffer* msg, u32 pos)
|
||||
{
|
||||
DSError error = DS_NoError;
|
||||
|
||||
if (pos > 0x880) {
|
||||
error = DS_MessageBufferOverflow;
|
||||
} else {
|
||||
msg->position = pos;
|
||||
// If the new position is past the current length,
|
||||
// update the length
|
||||
if (pos > msg->length) {
|
||||
msg->length = pos;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
#pragma dont_inline on
|
||||
DSError TRKAppendBuffer(MessageBuffer* msg, const void* data, size_t length)
|
||||
{
|
||||
DSError error = DS_NoError; // r31
|
||||
u32 bytesLeft;
|
||||
|
||||
// Return if no bytes to append
|
||||
if (length == 0) {
|
||||
return DS_NoError;
|
||||
}
|
||||
|
||||
bytesLeft = 0x880 - msg->position;
|
||||
|
||||
// If there isn't enough space left in the buffer, change the number
|
||||
// of bytes to append to the remaning number of bytes
|
||||
if (bytesLeft < length) {
|
||||
error = DS_MessageBufferOverflow;
|
||||
length = bytesLeft;
|
||||
}
|
||||
|
||||
if (length == 1) {
|
||||
// If the length of bytes to append is 1, just copy the byte over
|
||||
msg->data[msg->position] = ((u8*)data)[0];
|
||||
} else {
|
||||
// Otherwise, use memcpy
|
||||
TRK_memcpy(msg->data + msg->position, data, length);
|
||||
}
|
||||
|
||||
// Update the position and length
|
||||
msg->position += length;
|
||||
msg->length = msg->position;
|
||||
|
||||
return error;
|
||||
}
|
||||
#pragma dont_inline reset
|
||||
|
||||
DSError TRKReadBuffer(MessageBuffer* msg, void* data, size_t length)
|
||||
{
|
||||
DSError error = DS_NoError;
|
||||
uint bytesLeft; // this has to be uint not u32 to match lmfao.
|
||||
|
||||
// Return if no bytes to read
|
||||
if (length == 0) {
|
||||
return DS_NoError;
|
||||
}
|
||||
|
||||
bytesLeft = msg->length - msg->position;
|
||||
|
||||
// If the number of bytes to read exceeds the buffer length, change
|
||||
// the length to the remaining number of bytes
|
||||
if (length > bytesLeft) {
|
||||
error = DS_MessageBufferReadError;
|
||||
length = bytesLeft;
|
||||
}
|
||||
|
||||
TRK_memcpy(data, msg->data + msg->position, length);
|
||||
msg->position += length;
|
||||
return error;
|
||||
}
|
||||
|
||||
DSError TRKAppendBuffer1_ui16(MessageBuffer* buffer, const u16 data)
|
||||
{
|
||||
u8* bigEndianData;
|
||||
u8* byteData;
|
||||
u8 swapBuffer[sizeof(data)];
|
||||
|
||||
if (gTRKBigEndian) {
|
||||
bigEndianData = (u8*)&data;
|
||||
} else {
|
||||
byteData = (u8*)&data;
|
||||
bigEndianData = swapBuffer;
|
||||
|
||||
bigEndianData[0] = byteData[1];
|
||||
bigEndianData[1] = byteData[0];
|
||||
}
|
||||
|
||||
return TRKAppendBuffer(buffer, (const void*)bigEndianData, sizeof(data));
|
||||
}
|
||||
|
||||
DSError TRKAppendBuffer1_ui32(MessageBuffer* buffer, const u32 data)
|
||||
{
|
||||
u8* bigEndianData;
|
||||
u8* byteData;
|
||||
u8 swapBuffer[sizeof(data)];
|
||||
|
||||
if (gTRKBigEndian) {
|
||||
bigEndianData = (u8*)&data;
|
||||
} else {
|
||||
byteData = (u8*)&data;
|
||||
bigEndianData = swapBuffer;
|
||||
|
||||
bigEndianData[0] = byteData[3];
|
||||
bigEndianData[1] = byteData[2];
|
||||
bigEndianData[2] = byteData[1];
|
||||
bigEndianData[3] = byteData[0];
|
||||
}
|
||||
|
||||
return TRKAppendBuffer(buffer, (const void*)bigEndianData, sizeof(data));
|
||||
}
|
||||
|
||||
DSError TRKAppendBuffer1_ui64(MessageBuffer* buffer, const u64 data)
|
||||
{
|
||||
u8* bigEndianData;
|
||||
u8* byteData;
|
||||
u8 swapBuffer[sizeof(data)];
|
||||
if (gTRKBigEndian) {
|
||||
bigEndianData = (u8*)&data;
|
||||
} else {
|
||||
byteData = (u8*)&data;
|
||||
bigEndianData = swapBuffer;
|
||||
|
||||
bigEndianData[0] = byteData[7];
|
||||
bigEndianData[1] = byteData[6];
|
||||
bigEndianData[2] = byteData[5];
|
||||
bigEndianData[3] = byteData[4];
|
||||
bigEndianData[4] = byteData[3];
|
||||
bigEndianData[5] = byteData[2];
|
||||
bigEndianData[6] = byteData[1];
|
||||
bigEndianData[7] = byteData[0];
|
||||
}
|
||||
|
||||
return TRKAppendBuffer(buffer, (const void*)bigEndianData, sizeof(data));
|
||||
}
|
||||
|
||||
void TRKAppendBuffer1_ui128(void)
|
||||
{
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
DSError TRKAppendBuffer_ui8(MessageBuffer* buffer, const u8* data, int count)
|
||||
{
|
||||
DSError err;
|
||||
int i;
|
||||
|
||||
for (i = 0, err = DS_NoError; err == DS_NoError && i < count; i++) {
|
||||
err = TRKAppendBuffer1_ui8(buffer, data[i]);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
DSError TRKAppendBuffer_ui16(MessageBuffer* buffer, const u16* data, int count)
|
||||
{
|
||||
DSError err;
|
||||
int i;
|
||||
|
||||
for (i = 0, err = DS_NoError; err == DS_NoError && i < count; i++) {
|
||||
err = TRKAppendBuffer1_ui16(buffer, data[i]);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
DSError TRKAppendBuffer_ui32(MessageBuffer* buffer, const u32* data, int count)
|
||||
{
|
||||
DSError err;
|
||||
int i;
|
||||
|
||||
for (i = 0, err = DS_NoError; err == DS_NoError && i < count; i++) {
|
||||
err = TRKAppendBuffer1_ui32(buffer, data[i]);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void TRKAppendBuffer_ui64(void)
|
||||
{
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
void TRKAppendBuffer_ui128(void)
|
||||
{
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
DSError TRKReadBuffer1_ui8(MessageBuffer* buffer, u8* data) { return TRKReadBuffer(buffer, (void*)data, 1); }
|
||||
|
||||
DSError TRKReadBuffer1_ui16(MessageBuffer* buffer, u16* data)
|
||||
{
|
||||
DSError err;
|
||||
|
||||
u8* bigEndianData;
|
||||
u8* byteData;
|
||||
u8 swapBuffer[sizeof(data)];
|
||||
|
||||
if (gTRKBigEndian) {
|
||||
bigEndianData = (u8*)data;
|
||||
} else {
|
||||
bigEndianData = swapBuffer;
|
||||
}
|
||||
|
||||
err = TRKReadBuffer(buffer, (void*)bigEndianData, sizeof(*data));
|
||||
|
||||
if (!gTRKBigEndian && err == DS_NoError) {
|
||||
byteData = (u8*)data;
|
||||
|
||||
byteData[0] = bigEndianData[1];
|
||||
byteData[1] = bigEndianData[0];
|
||||
}
|
||||
|
||||
return err;
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
DSError TRKReadBuffer1_ui32(MessageBuffer* buffer, u32* data)
|
||||
{
|
||||
DSError err;
|
||||
|
||||
u8* bigEndianData;
|
||||
u8* byteData;
|
||||
u8 swapBuffer[sizeof(data)];
|
||||
|
||||
if (gTRKBigEndian) {
|
||||
bigEndianData = (u8*)data;
|
||||
} else {
|
||||
bigEndianData = swapBuffer;
|
||||
}
|
||||
|
||||
err = TRKReadBuffer(buffer, (void*)bigEndianData, sizeof(*data));
|
||||
|
||||
if (!gTRKBigEndian && err == DS_NoError) {
|
||||
byteData = (u8*)data;
|
||||
|
||||
byteData[0] = bigEndianData[3];
|
||||
byteData[1] = bigEndianData[2];
|
||||
byteData[2] = bigEndianData[1];
|
||||
byteData[3] = bigEndianData[0];
|
||||
}
|
||||
|
||||
return err;
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
DSError TRKReadBuffer1_ui64(MessageBuffer* buffer, u64* data)
|
||||
{
|
||||
DSError err;
|
||||
|
||||
u8* bigEndianData;
|
||||
u8* byteData;
|
||||
u8 swapBuffer[sizeof(data)];
|
||||
|
||||
if (gTRKBigEndian) {
|
||||
bigEndianData = (u8*)data;
|
||||
} else {
|
||||
bigEndianData = swapBuffer;
|
||||
}
|
||||
|
||||
err = TRKReadBuffer(buffer, (void*)bigEndianData, sizeof(*data));
|
||||
|
||||
if (!gTRKBigEndian && err == 0) {
|
||||
byteData = (u8*)data;
|
||||
|
||||
byteData[0] = bigEndianData[7];
|
||||
byteData[1] = bigEndianData[6];
|
||||
byteData[2] = bigEndianData[5];
|
||||
byteData[3] = bigEndianData[4];
|
||||
byteData[4] = bigEndianData[3];
|
||||
byteData[5] = bigEndianData[2];
|
||||
byteData[6] = bigEndianData[1];
|
||||
byteData[7] = bigEndianData[0];
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void TRKReadBuffer1_ui128(MessageBuffer* buffer, u8* p2, int p3)
|
||||
{
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
DSError TRKReadBuffer_ui8(MessageBuffer* buffer, u8* data, int count)
|
||||
{
|
||||
DSError err;
|
||||
int i;
|
||||
|
||||
for (i = 0, err = DS_NoError; err == DS_NoError && i < count; i++) {
|
||||
err = TRKReadBuffer1_ui8(buffer, &(data[i]));
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void TRKReadBuffer_ui16(MessageBuffer* buffer, u8* p2, int p3)
|
||||
{
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
DSError TRKReadBuffer_ui32(MessageBuffer* buffer, u32* data, int count)
|
||||
{
|
||||
DSError err;
|
||||
s32 i;
|
||||
|
||||
for (i = 0, err = DS_NoError; err == DS_NoError && i < count; i++) {
|
||||
err = TRKReadBuffer1_ui32(buffer, &(data[i]));
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void TRKReadBuffer_ui64(MessageBuffer* buffer, u8* p2, int p3)
|
||||
{
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
|
||||
void TRKReadBuffer_ui128(MessageBuffer* buffer, u8* p2, int p3)
|
||||
{
|
||||
// UNUSED FUNCTION
|
||||
}
|
||||
@@ -1,18 +1,15 @@
|
||||
#include "TRK/nubevent.h"
|
||||
#include "TRK/mutex_trk.h"
|
||||
#include "TRK/_mem_trk.h"
|
||||
#include "TRK/msgbuf.h"
|
||||
#include "TRK/trk.h"
|
||||
|
||||
TRKEventQueue gTRKEventQueue;
|
||||
|
||||
TRKResult TRKInitializeEventQueue(){
|
||||
DSError TRKInitializeEventQueue(){
|
||||
TRKInitializeMutex(&gTRKEventQueue);
|
||||
TRKAcquireMutex(&gTRKEventQueue);
|
||||
gTRKEventQueue.mCurrEvtID = 0;
|
||||
gTRKEventQueue.mNextSlotToOverwrite = 0;
|
||||
gTRKEventQueue.mMax = 0x100;
|
||||
gTRKEventQueue.count = 0;
|
||||
gTRKEventQueue.next = 0;
|
||||
gTRKEventQueue.eventID = 0x100;
|
||||
TRKReleaseMutex(&gTRKEventQueue);
|
||||
return TRKSuccess;
|
||||
return DS_NoError;
|
||||
}
|
||||
|
||||
BOOL TRKGetNextEvent(TRKEvent* event){
|
||||
@@ -20,11 +17,11 @@ BOOL TRKGetNextEvent(TRKEvent* event){
|
||||
BOOL res = FALSE;
|
||||
TRKAcquireMutex(&gTRKEventQueue);
|
||||
|
||||
if(gTRKEventQueue.mCurrEvtID > 0){
|
||||
TRK_memcpy(event, &gTRKEventQueue.mEvents[gTRKEventQueue.mNextSlotToOverwrite], sizeof(TRKEvent));
|
||||
gTRKEventQueue.mCurrEvtID--;
|
||||
if(++gTRKEventQueue.mNextSlotToOverwrite == 2){
|
||||
gTRKEventQueue.mNextSlotToOverwrite = 0;
|
||||
if(gTRKEventQueue.count > 0){
|
||||
TRK_memcpy(event, &gTRKEventQueue.events[gTRKEventQueue.next], sizeof(TRKEvent));
|
||||
gTRKEventQueue.count--;
|
||||
if(++gTRKEventQueue.next == 2){
|
||||
gTRKEventQueue.next = 0;
|
||||
}
|
||||
res = TRUE;
|
||||
}
|
||||
@@ -32,35 +29,35 @@ BOOL TRKGetNextEvent(TRKEvent* event){
|
||||
return res;
|
||||
}
|
||||
|
||||
TRKResult TRKPostEvent(TRKEvent* event){
|
||||
DSError TRKPostEvent(TRKEvent* event){
|
||||
|
||||
TRKResult res = 0;
|
||||
DSError res = 0;
|
||||
int evId;
|
||||
|
||||
TRKAcquireMutex(&gTRKEventQueue);
|
||||
|
||||
if(gTRKEventQueue.mCurrEvtID == 2){
|
||||
if(gTRKEventQueue.count == 2){
|
||||
res = 0x100;
|
||||
}
|
||||
else{
|
||||
evId = (gTRKEventQueue.mNextSlotToOverwrite + gTRKEventQueue.mCurrEvtID) % 2;
|
||||
TRK_memcpy(&gTRKEventQueue.mEvents[evId], event, sizeof(TRKEvent));
|
||||
gTRKEventQueue.mEvents[evId].mMax = gTRKEventQueue.mMax;
|
||||
gTRKEventQueue.mMax++;
|
||||
if(gTRKEventQueue.mMax < 256){
|
||||
gTRKEventQueue.mMax = 256;
|
||||
evId = (gTRKEventQueue.next + gTRKEventQueue.count) % 2;
|
||||
TRK_memcpy(&gTRKEventQueue.events[evId], event, sizeof(TRKEvent));
|
||||
gTRKEventQueue.events[evId].eventID = gTRKEventQueue.eventID;
|
||||
gTRKEventQueue.eventID++;
|
||||
if(gTRKEventQueue.eventID < 256){
|
||||
gTRKEventQueue.eventID = 256;
|
||||
}
|
||||
gTRKEventQueue.mCurrEvtID++;
|
||||
gTRKEventQueue.count++;
|
||||
}
|
||||
TRKReleaseMutex(&gTRKEventQueue);
|
||||
return res;
|
||||
}
|
||||
void TRKConstructEvent(TRKEvent* event, int type){
|
||||
|
||||
event->mEventType = type;
|
||||
event->mMax = 0;
|
||||
event->mBufferIndex = -1;
|
||||
event->eventType = type;
|
||||
event->eventID = 0;
|
||||
event->msgBufID = -1;
|
||||
}
|
||||
void TRKDestructEvent(TRKEvent* event){
|
||||
TRKReleaseBuffer(event->mBufferIndex);
|
||||
}
|
||||
TRKReleaseBuffer(event->msgBufID);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
#include "TRK/nubinit.h"
|
||||
#include "TRK/usr_put.h"
|
||||
#include "TRK/nubevent.h"
|
||||
#include "TRK/msgbuf.h"
|
||||
#include "TRK/dispatch.h"
|
||||
#include "TRK/dolphin_trk_glue.h"
|
||||
#include "TRK/targimpl.h"
|
||||
#include "TRK/serpoll.h"
|
||||
#include "TRK/dolphin_trk.h"
|
||||
#include "TRK/trk.h"
|
||||
|
||||
BOOL gTRKBigEndian;
|
||||
|
||||
@@ -33,7 +25,7 @@ inline BOOL TRK_InitializeEndian(void)
|
||||
return res;
|
||||
}
|
||||
|
||||
TRKResult TRKInitializeNub (void){
|
||||
DSError TRKInitializeNub (void){
|
||||
int res;
|
||||
res = TRK_InitializeEndian();
|
||||
|
||||
@@ -45,40 +37,39 @@ TRKResult TRKInitializeNub (void){
|
||||
res = TRKInitializeEventQueue();
|
||||
}
|
||||
|
||||
if(res == TRKSuccess){
|
||||
if(res == DS_NoError){
|
||||
res = TRKInitializeMessageBuffers();
|
||||
}
|
||||
|
||||
if(res == TRKSuccess){
|
||||
if(res == DS_NoError){
|
||||
res = TRKInitializeDispatcher();
|
||||
}
|
||||
|
||||
if(res == TRKSuccess){
|
||||
TRKResult ures = TRKInitializeIntDrivenUART(0xE100, 1, 0, &gTRKInputPendingPtr);
|
||||
if(res == DS_NoError){
|
||||
DSError ures = TRKInitializeIntDrivenUART(0xE100, 1, 0, &gTRKInputPendingPtr);
|
||||
TRKTargetSetInputPendingPtr(gTRKInputPendingPtr);
|
||||
if(ures != TRKSuccess){
|
||||
if(ures != DS_NoError){
|
||||
res = ures;
|
||||
}
|
||||
}
|
||||
|
||||
if(res == TRKSuccess){
|
||||
if(res == DS_NoError){
|
||||
res = TRKInitializeSerialHandler();
|
||||
}
|
||||
|
||||
if(res == TRKSuccess){
|
||||
if(res == DS_NoError){
|
||||
res = TRKInitializeTarget();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
TRKResult TRKTerminateNub(void){
|
||||
DSError TRKTerminateNub(void){
|
||||
|
||||
TRKTerminateSerialHandler();
|
||||
return TRKSuccess;
|
||||
return DS_NoError;
|
||||
}
|
||||
|
||||
void TRKNubWelcome(void){
|
||||
TRK_board_display("MetroTRK for GAMECUBE v0.10");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
#include "TRK/usr_put.h"
|
||||
#include "TRK/msghndlr.h"
|
||||
#include "TRK/trk.h"
|
||||
|
||||
extern void OSReport(const char*);
|
||||
|
||||
TRKResult usr_puts_serial(const char* putString) {
|
||||
TRKResult res = 0;
|
||||
BOOL usr_puts_serial(const char* putString) {
|
||||
BOOL res = FALSE;
|
||||
char tstring;
|
||||
char buff[2];
|
||||
int con;
|
||||
while ((res == 0) && (tstring = *putString++) != 0) {
|
||||
while ((res == FALSE) && (tstring = *putString++) != 0) {
|
||||
con = GetTRKConnected();
|
||||
buff[0] = tstring;
|
||||
buff[1] = '\0';
|
||||
SetTRKConnected(0);
|
||||
OSReport(buff);
|
||||
SetTRKConnected(con);
|
||||
res = 0;
|
||||
res = FALSE;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
TRKResult usr_put_initialize() {
|
||||
void usr_put_initialize() {
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "dolphin/os.h"
|
||||
#include "dolphin/db.h"
|
||||
#include "TRK/dolphin_trk.h"
|
||||
#include "TRK/trk.h"
|
||||
#include "dolphin/os/__ppc_eabi_init.h"
|
||||
#include <libc/stdlib.h>
|
||||
|
||||
__declspec(section ".init") void __init_registers(void);
|
||||
__declspec(section ".init") void __init_data(void);
|
||||
|
||||
Reference in New Issue
Block a user