diff --git a/cube/patches/alt/base.S b/cube/patches/alt/base.S index 632d6fe3..a3abb3f9 100644 --- a/cube/patches/alt/base.S +++ b/cube/patches/alt/base.S @@ -113,6 +113,7 @@ realmode: .globl _start _start: + b exi_probe b exi_trylock b set_di_handler b set_breakpoint diff --git a/cube/patches/alt/blockdevice.c b/cube/patches/alt/blockdevice.c index 6b94394f..6500fe9d 100644 --- a/cube/patches/alt/blockdevice.c +++ b/cube/patches/alt/blockdevice.c @@ -8,10 +8,21 @@ #include "../base/common.h" #include "../base/exi.h" +bool exi_probe(int32_t chan) +{ + if (chan == EXI_CHANNEL_2) + return false; + if (chan == *(uint8_t *)VAR_EXI_SLOT) + return false; + return true; +} + bool exi_trylock(int32_t chan, uint32_t dev, EXIControl *exi) { if (!(exi->state & EXI_STATE_LOCKED) || exi->dev != dev) return false; + if (chan == *(uint8_t *)VAR_EXI_SLOT && dev == EXI_DEVICE_0) + return false; if (chan == *(uint8_t *)VAR_EXI_SLOT) end_read(); return true; diff --git a/cube/patches/bba/bba.c b/cube/patches/bba/bba.c index d8211eb6..9430dc0d 100644 --- a/cube/patches/bba/bba.c +++ b/cube/patches/bba/bba.c @@ -247,12 +247,23 @@ void exi_interrupt_handler(OSInterrupt interrupt, OSContext *context) bba_cmd_out8(0x02, BBA_CMD_IRMASKNONE); } +bool exi_probe(int32_t chan) +{ + if (chan == EXI_CHANNEL_2) + return false; + if (chan == *(uint8_t *)VAR_EXI_SLOT) + return false; + return true; +} + bool exi_trylock(int32_t chan, uint32_t dev, EXIControl *exi) { if (!(exi->state & EXI_STATE_LOCKED) || exi->dev != dev) return false; if (chan == EXI_CHANNEL_0 && dev == EXI_DEVICE_2) return false; + if (chan == *(uint8_t *)VAR_EXI_SLOT && dev == EXI_DEVICE_0) + return false; return true; } diff --git a/cube/patches/usbgecko/usbgecko.c b/cube/patches/usbgecko/usbgecko.c index c0e364e2..4e8c301d 100644 --- a/cube/patches/usbgecko/usbgecko.c +++ b/cube/patches/usbgecko/usbgecko.c @@ -121,10 +121,21 @@ void usb_request(uint32_t offset, uint32_t size) usb_transmit(&request, sizeof(request), sizeof(request)); } +bool exi_probe(int32_t chan) +{ + if (chan == EXI_CHANNEL_2) + return false; + if (chan == *(uint8_t *)VAR_EXI_SLOT) + return false; + return true; +} + bool exi_trylock(int32_t chan, uint32_t dev, EXIControl *exi) { if (!(exi->state & EXI_STATE_LOCKED) || exi->dev != dev) return false; + if (chan == *(uint8_t *)VAR_EXI_SLOT && dev == EXI_DEVICE_0) + return false; return true; } diff --git a/cube/swiss/include/patcher.h b/cube/swiss/include/patcher.h index 9cdd74d6..bf4915be 100644 --- a/cube/swiss/include/patcher.h +++ b/cube/swiss/include/patcher.h @@ -189,14 +189,15 @@ enum patchIds { #define IGR_EXIT_WKF (void*)(LO_RESERVE | 0x0C) /* Function jump locations for the SD/IDE/USBGecko/BBA patch */ -#define EXI_TRYLOCK (void*)(LO_RESERVE_ALT | 0x158) -#define SET_DI_HANDLER (void*)(LO_RESERVE_ALT | 0x15C) -#define SET_BREAKPOINT (void*)(LO_RESERVE_ALT | 0x160) -#define UNSET_BREAKPOINT (void*)(LO_RESERVE_ALT | 0x164) -#define IDLE_THREAD (void*)(LO_RESERVE_ALT | 0x168) -#define TRICKLE_READ (void*)(LO_RESERVE_ALT | 0x16C) -#define CHECK_PAD_ALT (void*)(LO_RESERVE_ALT | 0x170) -#define IGR_EXIT_ALT (void*)(LO_RESERVE_ALT | 0x174) +#define EXI_PROBE (void*)(LO_RESERVE_ALT | 0x158) +#define EXI_TRYLOCK (void*)(LO_RESERVE_ALT | 0x15C) +#define SET_DI_HANDLER (void*)(LO_RESERVE_ALT | 0x160) +#define SET_BREAKPOINT (void*)(LO_RESERVE_ALT | 0x164) +#define UNSET_BREAKPOINT (void*)(LO_RESERVE_ALT | 0x168) +#define IDLE_THREAD (void*)(LO_RESERVE_ALT | 0x16C) +#define TRICKLE_READ (void*)(LO_RESERVE_ALT | 0x170) +#define CHECK_PAD_ALT (void*)(LO_RESERVE_ALT | 0x174) +#define IGR_EXIT_ALT (void*)(LO_RESERVE_ALT | 0x178) #define READ_PATCHED_ALL (0x111) diff --git a/cube/swiss/source/patcher.c b/cube/swiss/source/patcher.c index 4ae21303..54c86d6c 100644 --- a/cube/swiss/source/patcher.c +++ b/cube/swiss/source/patcher.c @@ -3125,6 +3125,66 @@ int Patch_DVDLowLevelReadAlt(u32 *data, u32 length, int dataType) } } + for (j = 0; j < sizeof(__EXIProbeSigs) / sizeof(FuncPattern); j++) + if (__EXIProbeSigs[j].offsetFoundAt) break; + + if (j < sizeof(__EXIProbeSigs) / sizeof(FuncPattern) && (i = __EXIProbeSigs[j].offsetFoundAt)) { + u32 *__EXIProbe = Calc_ProperAddress(data, dataType, i * sizeof(u32)); + + if (__EXIProbe) { + switch (j) { + case 0: + data[i + 19] = 0x387F0000; // addi r3, r31, 0 + data[i + 20] = branchAndLink(EXI_PROBE, __EXIProbe + 20); + data[i + 21] = 0x2C030000; // cmpwi r3, 0 + data[i + 22] = 0x41820144; // beq +81 + break; + case 1: + data[i + 19] = 0x387F0000; // addi r3, r31, 0 + data[i + 20] = branchAndLink(EXI_PROBE, __EXIProbe + 20); + data[i + 21] = 0x2C030000; // cmpwi r3, 0 + data[i + 22] = 0x41820150; // beq +84 + break; + case 2: + data[i + 20] = 0x387F0000; // addi r3, r31, 0 + data[i + 21] = branchAndLink(EXI_PROBE, __EXIProbe + 21); + data[i + 22] = 0x2C030000; // cmpwi r3, 0 + data[i + 23] = 0x41820150; // beq +84 + break; + case 3: + data[i + 8] = data[i + 9]; + data[i + 9] = 0x387D0000; // addi r3, r29, 0 + data[i + 10] = branchAndLink(EXI_PROBE, __EXIProbe + 10); + data[i + 11] = 0x2C030000; // cmpwi r3, 0 + data[i + 12] = 0x41820124; // beq +73 + break; + case 4: + data[i + 6] = data[i + 7]; + data[i + 7] = data[i + 8]; + data[i + 8] = data[i + 9]; + data[i + 9] = 0x387C0000; // addi r3, r28, 0 + data[i + 10] = branchAndLink(EXI_PROBE, __EXIProbe + 10); + data[i + 11] = 0x2C030000; // cmpwi r3, 0 + data[i + 12] = 0x41820130; // beq +76 + break; + case 5: + data[i + 9] = 0x387C0000; // addi r3, r28, 0 + data[i + 10] = branchAndLink(EXI_PROBE, __EXIProbe + 10); + data[i + 11] = 0x2C030000; // cmpwi r3, 0 + data[i + 12] = 0x41820130; // beq +76 + break; + case 6: + data[i + 9] = 0x387F0000; // addi r3, r31, 0 + data[i + 10] = branchAndLink(EXI_PROBE, __EXIProbe + 10); + data[i + 11] = 0x2C030000; // cmpwi r3, 0 + data[i + 12] = 0x41820170; // beq +92 + break; + } + print_gecko("Found:[%s] @ %08X\n", __EXIProbeSigs[j].Name, __EXIProbe); + patched++; + } + } + if ((i = EXISelectSDSig.offsetFoundAt)) { u32 *EXISelectSD = Calc_ProperAddress(data, dataType, i * sizeof(u32));