Skip to content

Commit f1c3747

Browse files
authored
ios: some ios' load slower than others, brute force a few attempts to reinit subsystems (#171)
1 parent a0b4b56 commit f1c3747

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

gc/ogc/ipc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ distribution.
3333

3434
#include <gctypes.h>
3535

36+
#define HW_IPC_PPCBASE 0xCD000000
37+
#define HW_IPC_PPCMSG (*(vu32*)HW_IPC_PPCBASE)
38+
#define HW_IPC_PPCCTRL (*(vu32*)(HW_IPC_PPCBASE + 4))
39+
#define HW_IPC_PPC_SEND 1
40+
#define HW_IPC_PPC_MSG_ACK 2
41+
#define HW_IPC_PPC_CTRL_ACK 4
42+
#define HW_IPC_PPC_CTRL_REGS (HW_IPC_PPC_MSG_ACK|HW_IPC_PPC_CTRL_ACK)
3643
#define IPC_HEAP -1
3744

3845
#define IPC_OPEN_NONE 0

libogc/ios.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ distribution.
4141
#include "ios.h"
4242
#include "irq.h"
4343

44-
#define IOS_HEAP_SIZE 0x1000
45-
#define MAX_IPC_RETRIES 400
44+
#define IOS_HEAP_SIZE 0x1000
45+
#define MAX_IPC_RETRIES 400
4646

4747
//#define DEBUG_IOS
4848

49-
#define IOS_MAX_VERSION 61
50-
#define IOS_MIN_VERSION 28
49+
#define IOS_MAX_VERSION 61
50+
#define IOS_MIN_VERSION 28
5151

5252
static s32 __ios_hid = -1;
5353
extern void udelay(int us);
@@ -298,10 +298,16 @@ s32 __IOS_LaunchNewIOS(int version)
298298
#ifdef DEBUG_IOS
299299
printf("Waiting for IPC ...\n");
300300
#endif
301-
for (counter = 0; !(read32(0x0d000004) & 2); counter++) {
301+
302+
//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.
303+
//from testing this seems to usually take ~650000µs
304+
//this is very time sensitive though. if we check IPC CTRL regs to soon, they still contain the values from before IOS' setup IPC
305+
//wait too long, and __IOS_LaunchNewIOS will take too long. we attempt to skip the old values by always waiting at least 1000µs
306+
//to improve reload time we will only check 400000µs as other code will run while IOS starts up the other modules
307+
for (counter = 0; counter <= MAX_IPC_RETRIES; counter++) {
302308
udelay(1000);
303309

304-
if (counter >= MAX_IPC_RETRIES)
310+
if (HW_IPC_PPCCTRL & HW_IPC_PPC_CTRL_REGS)
305311
break;
306312
}
307313

libogc/ipc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static struct _ipcheap _ipc_heaps[IPC_NUMHEAPS] =
169169
{NULL, 0, {}} // all other elements should be inited to zero, says C standard, so this should do
170170
};
171171

172-
static vu32* const _ipcReg = (u32*)0xCD000000;
172+
static vu32* const _ipcReg = (u32*)(HW_IPC_PPCBASE);
173173

174174
extern void __MaskIrq(u32 nMask);
175175
extern void __UnmaskIrq(u32 nMask);

0 commit comments

Comments
 (0)