Skip to content

Commit

Permalink
ios: some ios' load slower than others, brute force a few attempts to…
Browse files Browse the repository at this point in the history
… reinit subsystems (#171)
  • Loading branch information
DacoTaco authored Apr 15, 2024
1 parent a0b4b56 commit f1c3747
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
7 changes: 7 additions & 0 deletions gc/ogc/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ distribution.

#include <gctypes.h>

#define HW_IPC_PPCBASE 0xCD000000
#define HW_IPC_PPCMSG (*(vu32*)HW_IPC_PPCBASE)
#define HW_IPC_PPCCTRL (*(vu32*)(HW_IPC_PPCBASE + 4))
#define HW_IPC_PPC_SEND 1
#define HW_IPC_PPC_MSG_ACK 2
#define HW_IPC_PPC_CTRL_ACK 4
#define HW_IPC_PPC_CTRL_REGS (HW_IPC_PPC_MSG_ACK|HW_IPC_PPC_CTRL_ACK)
#define IPC_HEAP -1

#define IPC_OPEN_NONE 0
Expand Down
18 changes: 12 additions & 6 deletions libogc/ios.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ distribution.
#include "ios.h"
#include "irq.h"

#define IOS_HEAP_SIZE 0x1000
#define MAX_IPC_RETRIES 400
#define IOS_HEAP_SIZE 0x1000
#define MAX_IPC_RETRIES 400

//#define DEBUG_IOS

#define IOS_MAX_VERSION 61
#define IOS_MIN_VERSION 28
#define IOS_MAX_VERSION 61
#define IOS_MIN_VERSION 28

static s32 __ios_hid = -1;
extern void udelay(int us);
Expand Down Expand Up @@ -298,10 +298,16 @@ s32 __IOS_LaunchNewIOS(int version)
#ifdef DEBUG_IOS
printf("Waiting for IPC ...\n");
#endif
for (counter = 0; !(read32(0x0d000004) & 2); counter++) {

//while IOS is starting up, we will check the IPC registers to see when it has started IPC and is therefor starting up other ios modules.
//from testing this seems to usually take ~650000µs
//this is very time sensitive though. if we check IPC CTRL regs to soon, they still contain the values from before IOS' setup IPC
//wait too long, and __IOS_LaunchNewIOS will take too long. we attempt to skip the old values by always waiting at least 1000µs
//to improve reload time we will only check 400000µs as other code will run while IOS starts up the other modules
for (counter = 0; counter <= MAX_IPC_RETRIES; counter++) {
udelay(1000);

if (counter >= MAX_IPC_RETRIES)
if (HW_IPC_PPCCTRL & HW_IPC_PPC_CTRL_REGS)
break;
}

Expand Down
2 changes: 1 addition & 1 deletion libogc/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static struct _ipcheap _ipc_heaps[IPC_NUMHEAPS] =
{NULL, 0, {}} // all other elements should be inited to zero, says C standard, so this should do
};

static vu32* const _ipcReg = (u32*)0xCD000000;
static vu32* const _ipcReg = (u32*)(HW_IPC_PPCBASE);

extern void __MaskIrq(u32 nMask);
extern void __UnmaskIrq(u32 nMask);
Expand Down

0 comments on commit f1c3747

Please sign in to comment.