static const unsigned int g_cfm_island_template[] = { /* header */ 0xDEADBABE, // cfm island signature 0x0, // lr as it is when coming from the original function 0x0, // tvector function pointer 0x0, // tvector rtoc 0x0, // mach-o function pointer 0x0, // ape reentry function pointer 0x0, // pointer to previous island /* re-entry island */ 0x7C0802A6, // mflr r0 -- store current lr in r0 0x48000005, // bl +1 -- branch to next instruction, setting lr 0x7D8802A6, // mflr r12 -- store address of this instruction in r12 0x7C0803A6, // mtlr r0 -- restore lr from r0 0x398CFFE4, // addi r12, r12, -28 -- subtract 28 from r12, putting us at the tvector function pointer 0x800C000C, // lwz r0, 12(r12) -- load the ape reentry function pointer into r0 0x804C0004, // lwz r2, 4(r12) -- load the tvector rtoc into r2 0x7C0903A6, // mtctr r0 0x4E800420, // bctr -- branch to the ape reentry function pointer /* jump island */ 0x7C0802A6, // mflr r0 -- store current lr in r0 0x48000005, // bl +1 0x7D8802A6, // mflr r12 -- store address of this instruction in r12 0x398CFFC0, // addi r12, r12, -64 -- subtract 64 from r12, putting us at tvector function pointer 0x900CFFFC, // stw r0, -4(r12) -- store the lr in the "lr as it is..." field 0x800C0008, // lwz r0, 8(r12) -- load the mach-o function pointer into r0 0x7C0903A6, // mtctr r0 0x4E800421, // bctrl -- branch to the mach-o function pointer 0x7D8802A6, // mflr r12 -- move the address of this instruction into r12 0x398CFFA8, // addi r12, r12, -88 -- subtract 88 from it, putting us at the tvector rtoc field 0x800CFFFC, // lwz r0, -4(r12) -- load the "lr as it is..." into r0 0x804C0004, // lwz r2, 4(r12) -- load the tvector rtoc into r2 0x7C0803A6, // mtlr r0 -- restore the lr 0x4E800020 // blr -- branch to it };