mirror of
https://github.com/fail0verflow/mini.git
synced 2024-11-24 04:09:18 +01:00
panic if the boot2 patch to launch a title fails make the patch more generic so it works on boot2v4
This commit is contained in:
parent
cdf5a3c623
commit
950adf002f
17
boot2.c
17
boot2.c
@ -19,6 +19,7 @@ Copyright (C) 2009 Andre Heider "dhewg" <dhewg@wiibrew.org>
|
|||||||
#include "gecko.h"
|
#include "gecko.h"
|
||||||
#include "powerpc.h"
|
#include "powerpc.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "panic.h"
|
||||||
|
|
||||||
static u8 boot2[0x80000] MEM2_BSS ALIGNED(64);
|
static u8 boot2[0x80000] MEM2_BSS ALIGNED(64);
|
||||||
static u8 boot2_key[32] MEM2_BSS ALIGNED(32);
|
static u8 boot2_key[32] MEM2_BSS ALIGNED(32);
|
||||||
@ -305,14 +306,12 @@ void boot2_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static u32 match[] = {
|
static u32 match[] = {
|
||||||
0xF7FFFFB8,
|
|
||||||
0xBC024708,
|
0xBC024708,
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
};
|
};
|
||||||
|
|
||||||
static u32 patch[] = {
|
static u32 patch[] = {
|
||||||
0xF7FFFFB8,
|
|
||||||
0xBC024708,
|
0xBC024708,
|
||||||
0x10001,
|
0x10001,
|
||||||
0x48415858,
|
0x48415858,
|
||||||
@ -320,11 +319,11 @@ static u32 patch[] = {
|
|||||||
|
|
||||||
u32 boot2_run(u32 tid_hi, u32 tid_lo) {
|
u32 boot2_run(u32 tid_hi, u32 tid_lo) {
|
||||||
u8 *ptr;
|
u8 *ptr;
|
||||||
u32 i;
|
u32 i, num_matches=0;
|
||||||
ioshdr *hdr;
|
ioshdr *hdr;
|
||||||
|
|
||||||
patch[2] = tid_hi;
|
patch[1] = tid_hi;
|
||||||
patch[3] = tid_lo;
|
patch[2] = tid_lo;
|
||||||
|
|
||||||
gecko_printf("booting boot2 with title %08x-%08x\n", tid_hi, tid_lo);
|
gecko_printf("booting boot2 with title %08x-%08x\n", tid_hi, tid_lo);
|
||||||
mem_protect(1, (void *)0x11000000, (void *)0x13FFFFFF);
|
mem_protect(1, (void *)0x11000000, (void *)0x13FFFFFF);
|
||||||
@ -336,11 +335,17 @@ u32 boot2_run(u32 tid_hi, u32 tid_lo) {
|
|||||||
ptr = (u8 *)0x11000000 + hdr->hdrsize + hdr->loadersize;
|
ptr = (u8 *)0x11000000 + hdr->hdrsize + hdr->loadersize;
|
||||||
for (i = 0; i < sizeof(boot2); i += 1) {
|
for (i = 0; i < sizeof(boot2); i += 1) {
|
||||||
if (memcmp(ptr+i, match, sizeof(match)) == 0) {
|
if (memcmp(ptr+i, match, sizeof(match)) == 0) {
|
||||||
|
num_matches++;
|
||||||
memcpy(ptr+i, patch, sizeof(patch));
|
memcpy(ptr+i, patch, sizeof(patch));
|
||||||
gecko_printf("patched data @%08x\n", (u32)ptr+i);
|
gecko_printf("patched data @%08x\n", (u32)ptr+i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (num_matches != 1) {
|
||||||
|
gecko_printf("Wrong number of patches (matched %d times, expected 1), panicking\n", num_matches);
|
||||||
|
panic2(0, PANIC_PATCHFAIL);
|
||||||
|
}
|
||||||
|
|
||||||
hdr->argument = 0x42;
|
hdr->argument = 0x42;
|
||||||
|
|
||||||
u32 vector = 0x11000000 + hdr->hdrsize;
|
u32 vector = 0x11000000 + hdr->hdrsize;
|
||||||
|
1
panic.h
1
panic.h
@ -14,6 +14,7 @@ Copyright (C) 2008, 2009 Hector Martin "marcan" <marcan@marcansoft.com>
|
|||||||
#define PANIC_MOUNT 1,1,-1
|
#define PANIC_MOUNT 1,1,-1
|
||||||
#define PANIC_EXCEPTION 1,3,1,-1
|
#define PANIC_EXCEPTION 1,3,1,-1
|
||||||
#define PANIC_IPCOVF 1,3,3,-1
|
#define PANIC_IPCOVF 1,3,3,-1
|
||||||
|
#define PANIC_PATCHFAIL 1,3,3,3,-1
|
||||||
|
|
||||||
void panic2(int mode, ...) __attribute__ ((noreturn));
|
void panic2(int mode, ...) __attribute__ ((noreturn));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user