14static int *p_ThreadID = (
int *)0x800125EC;
15static int *p_ThreadStatus = (
int *)0x800125F4;
16static int (*p_CancelWakeupThread)(
int ThreadID) = (
void *)0x80004970;
17static int (*p_ChangeThreadPriority)(
int ThreadID,
int priority) = (
void *)0x80004288;
18static int (*p_InitPgifHandler2)(void) = (
void *)0x800021b0;
19static int (*p_InitSemaphores)(void) = (
void *)0x80004e68;
20static int (*p_DeleteThread)(
int thread_id) = (
void *)0x80003f00;
21static int (*p_TerminateThread)(
int ThreadID) = (
void *)0x80003e00;
22static struct TCB *p_TCBs = (
struct TCB *)0x80017400;
23static void (*p_InitializeINTC)(
int interrupts) = (
void *)0x8000b8d0;
24static void (*p_InitializeTIMER)(void) = (
void *)0x8000b900;
25static void (*p_InitializeFPU)(void) = (
void *)0x8000b7a8;
26static void (*p_InitializeScratchPad)(void) = (
void *)0x8000b840;
27static int (*p_ResetEE)(
int flags) = (
void *)0x8000ad68;
28static void (*p_InitializeGS)(void) = (
void *)0x8000aa60;
29static void (*p_SetGSCrt)(
unsigned short int interlace,
unsigned short int mode,
unsigned short int ffmd) = (
void *)0x8000a060;
33static void (*p_FlushDCache)(void) = (
void *)0x80002a80;
34static void (*p_FlushICache)(void) = (
void *)0x80002ac0;
35static char *(*p_eestrcpy)(
char *dst,
const char *src) = (
void *)0x80005560;
37static char *p_ArgsBuffer = (
char *)0x80012608;
41static void *(*p_ExecPS2)(
void *entry,
void *gp,
int argc,
char *argv[]) = (
void *)0x800057E8;
51 void (*entry)(
void *);
54 short currentPriority;
61 void (*entry_)(
void *);
70static inline void SoftPeripheralEEReset(
void)
72 *(
volatile unsigned int *)0x1000f000 = 4;
73 while (((*((
volatile unsigned int *)0x1000f000)) & 4) == 0) {};
74 *(
volatile unsigned int *)0x1000f000 = 4;
78 p_InitializeINTC(0xdffd);
82 p_InitializeScratchPad();
85void *ExecPS2Patch(
void *EntryPoint,
void *gp,
int argc,
char *argv[])
87 int i, CurrentThreadID;
93 CurrentThreadID = *p_ThreadID;
94 p_CancelWakeupThread(CurrentThreadID);
95 p_ChangeThreadPriority(CurrentThreadID, 0);
98 for (i = 1, tcb = &p_TCBs[1]; i <
MAX_THREADS; i++, tcb++) {
99 if (tcb->status != 0 && i != CurrentThreadID) {
100 if (tcb->status != THS_DORMANT)
101 p_TerminateThread(i);
108 p_InitPgifHandler2();
111 SoftPeripheralEEReset();
115 return p_ExecPS2(EntryPoint, gp, argc, argv);
117 for (i = 0, ArgsPtr = p_ArgsBuffer; i < argc; i++) {
118 ArgsPtr = p_eestrcpy(ArgsPtr, argv[i]);
121 tcb = &p_TCBs[CurrentThreadID];
122 tcb->argstring = p_ArgsBuffer;
124 tcb->entry = EntryPoint;
125 tcb->entry_ = EntryPoint;
127 tcb->initPriority = 0;
128 tcb->currentPriority = 0;
129 tcb->wakeupCount = 0;