/* Get a pointer to a register based on its name */ unsigned int *exceptionGetReg(const char *reg) { static unsigned int modaddr = 0; if(g_currex == NULL) { return NULL; } if(strcmp(reg, "epc") == 0) { return &g_currex->regs.epc; } else if(strcmp(reg, "fsr") == 0) { return &g_currex->regs.fsr; } else if(strcmp(reg, "mod") == 0) { SceModule *pMod; SceKernelModuleInfo mod; modaddr = 0; pMod = sceKernelFindModuleByAddress(g_currex->regs.epc); if(pMod) { memset(&mod, 0, sizeof(mod)); mod.size = sizeof(mod); enable_kprintf(0); if(!g_QueryModuleInfo(pMod->modid, &mod)) { modaddr = mod.text_addr; } enable_kprintf(1); } return &modaddr; } else { int reg_loop; for(reg_loop = 0; reg_loop < 32; reg_loop++) { if(strcmp(regName[reg_loop], reg) == 0) { return &g_currex->regs.r[reg_loop]; } } } return NULL; }
void initialise(SceSize args, void *argp) { struct ConfigContext ctx; const char *init_dir = "host0:/"; int (*g_sceUmdActivate)(int, const char *); int argc; char *argv[MAX_ARGS]; memset(&g_context, 0, sizeof(g_context)); map_firmwarerev(); exceptionInit(); g_context.thevent = -1; parse_sceargs(args, argp, &argc, argv); if(argc > 0) { char *lastdir; g_context.bootfile = argv[0]; lastdir = strrchr(argv[0], '/'); if(lastdir != NULL) { memcpy(g_context.bootpath, argv[0], lastdir - argv[0] + 1); } } configLoad(g_context.bootpath, &ctx); if(ctx.pid) { g_context.pid = ctx.pid; } else { g_context.pid = HOSTFSDRIVER_PID; } ttyInit(); init_usbhost(g_context.bootpath); #if _PSP_FW_VERSION >= 200 if(argc > 1) { init_dir = argv[1]; } #else { struct SavedContext *save = (struct SavedContext *) SAVED_ADDR; if(save->magic == SAVED_MAGIC) { init_dir = save->currdir; save->magic = 0; g_context.rebootkey = save->rebootkey; } } #endif if(shellInit(init_dir) < 0) { sceKernelExitGame(); } g_sceUmdActivate = (void*) libsFindExportByNid(refer_module_by_name("sceUmd_driver", NULL), "sceUmdUser", 0xC6183D47); if(g_sceUmdActivate) { g_sceUmdActivate(1, "disc0:"); } /* Hook sceKernelExitGame */ apiHookByNid(refer_module_by_name("sceLoadExec", NULL), "LoadExecForUser", 0x05572A5F, exit_reset); unload_loader(); psplinkPatchException(); if(ctx.enableuser) { load_psplink_user(g_context.bootpath); } g_context.resetonexit = ctx.resetonexit; sceKernelRegisterDebugPutchar(NULL); enable_kprintf(1); debugHwInit(); modLoad(g_context.bootpath); }