Ejemplo n.º 1
0
void cache_hacks(void) {
	flush_caches();

	// lock the caches so nobody replaces our hacks
	cache_lock();

	// prevent the OFW from clearing the caches
	disable_cache_clearing();

	// OFW allocates main heap from addr:0x200000 to addr:0x800000
	// we place our hack at the last 128kb (0x20000) of this space, at addr: 0x7E0000 (see hack_relocate())
	// the original instruction was: MOV R1, #0x800000
	// we change it to: MOV R1, #0x7E0000 (in binary the instruction looks like: 0xE3A0187E)
	cache_fake(0xFF811318, 0xE3A0187E, TYPE_ICACHE);

	// hookup to dmProcInit(), so we can enable massive debug and run our hack_pre_init_hook
	cache_fake(0xFF8111AC, ASM_BL(0xFF8111AC, &hack_dmProcInit), TYPE_ICACHE);

	// hookup our MainCtrlInit
	//cache_fake(0xFF8110E4, ASM_BL(0xFF8110E4, &hack_MainCtrlInit), TYPE_ICACHE);

#ifdef ENABLE_DEBUG
	// hookup our GUI_IdleHandler
	cache_fake(0xFF82A4F0, ASM_BL(0xFF82A4F0, &hack_register_gui_idle_handler), TYPE_ICACHE);
#endif

	// hookup our Intercom
	cache_fake(0xFFA5D590, ASM_BL(0xFFA5D590, &hack_init_intercom_data), TYPE_ICACHE);

	// hookup StartConsole, so we can run our hack_post_init_hook
	cache_fake(0xFF8112E8, ASM_BL(0xFF8112E8, &hack_StartConsole), TYPE_ICACHE);
}
Ejemplo n.º 2
0
// we can run extra code at the end of the OFW's task init
void hack_post_init_hook(void) {
	// Inject our hacked_TransferScreen
	//TransferScreen = hack_TransferScreen;

	//cache_fake(0xFF92DA50, ASM_BL(0xFF92DA50, &hack_FF92E704), TYPE_ICACHE);
	//cache_fake(0xFF92DA88, ASM_BL(0xFF92DA88, &hack_FF92E4C4), TYPE_ICACHE);

	// Intercept JUMP and TRASH buttons
	SetSendButtonProc(&hack_jump_trash_events, 0);

	// take over the vram copy locations, so we can invert the screen
	//cache_fake(0xFF92C5D8, ASM_BL(0xFF92C5D8, &hack_invert_olc_screen), TYPE_ICACHE);
	//cache_fake(0xFF92C5FC, ASM_BL(0xFF92C5FC, &hack_invert_olc_screen), TYPE_ICACHE);

	// prevent screen turn off on ptp (to see the debug on lcd)
	//cache_fake(0xFF9DE0DC, ASM_MOV_R0_INT(0), TYPE_ICACHE);

	// these freezes the usb communication
	//cache_fake(0xFF81B9D0, ASM_MOV_R0_INT(0), TYPE_ICACHE); // prevent ui lock
	//cache_fake(0xFF81B400, ASM_MOV_R0_INT(0), TYPE_ICACHE); // prevent ui lock
	//cache_fake(0xFF9DDB24, ASM_MOV_R0_INT(0), TYPE_ICACHE); // prevent ui lock

	// Hack redraw on some dialogs, to prevent flickering when entering our menu
	cache_fake(0xFF916434, ASM_B(0xFF916434, &hack_dialog_redraw), TYPE_ICACHE);

	// Hack items in dialogs
	cache_fake(0xFF838300, ASM_BL(0xFF838300, &hack_item_set_label_int), TYPE_ICACHE);
	cache_fake(0xFF837FEC, ASM_BL(0xFF837FEC, &hack_item_set_label_str), TYPE_ICACHE);
}
Ejemplo n.º 3
0
int cpu_post_test_b (void)
{
    int ret = 0;
    unsigned int i;
    int flag = disable_interrupts();

    if (ret == 0)
    {
	ulong code[] =
	{
	   ASM_MFLR(4),
	   ASM_MTLR(3),
	   ASM_B(4),
	   ASM_MFLR(3),
	   ASM_MTLR(4),
	   ASM_BLR,
	};
	ulong res;

	cpu_post_exec_11 (code, &res, 0);

	ret = res == 0 ? 0 : -1;

	if (ret != 0)
	{
	    post_log ("Error at b1 test !\n");
	}
    }

    if (ret == 0)
    {
	ulong code[] =
	{
	   ASM_MFLR(4),
	   ASM_MTLR(3),
	   ASM_BL(4),
	   ASM_MFLR(3),
	   ASM_MTLR(4),
	   ASM_BLR,
	};
	ulong res;

	cpu_post_exec_11 (code, &res, 0);

	ret = res == (ulong)code + 12 ? 0 : -1;

	if (ret != 0)
	{
	    post_log ("Error at b2 test !\n");
	}
    }

    if (ret == 0)
    {
	ulong cc, cd;
	int cond;
	ulong ctr;
	int link;

	i = 0;

	for (cc = 0; cc < 4 && ret == 0; cc++)
	{
	    for (cd = 0; cd < 4 && ret == 0; cd++)
	    {
		for (link = 0; link <= 1 && ret == 0; link++)
		{
		    for (cond = 0; cond <= 1 && ret == 0; cond++)
		    {
			for (ctr = 1; ctr <= 2 && ret == 0; ctr++)
			{
			    int decr = cd < 2;
			    int cr = cond ? 0x80000000 : 0x00000000;
			    int jumpc = cc >= 2 ||
					(cc == 0 && !cond) ||
					(cc == 1 && cond);
			    int jumpd = cd >= 2 ||
					(cd == 0 && ctr != 1) ||
					(cd == 1 && ctr == 1);
			    int jump = jumpc && jumpd;

			    ret = cpu_post_test_bc (link ? OP_BCL : OP_BC,
				(cc << 3) + (cd << 1), 0, jump, decr, link,
				ctr, cr);

			    if (ret != 0)
			    {
				post_log ("Error at b3 test %d !\n", i);
			    }

			    i++;
			}
		    }
		}
	    }
	}
    }

    if (flag)
	enable_interrupts();

    return ret;
}