int main (int argc, char *argv []) { SifInitRpc (0); init_scr (); scr_printf (APP_NAME "-" VERSION "\n"); /* decide whether to load TCP/IP or it is already loaded */ SifExitIopHeap (); SifLoadFileExit (); SifExitRpc (); SifIopReset (NULL /* "rom0:UDNL rom0:EELOADCNF" */, 0); while (SifIopSync ()) ; SifInitRpc (0); if (load_modules () == 0) { scr_printf ("Ready\n"); } else scr_printf ("Failed to load\n"); /* our job is done; IOP would handle the rest */ SleepThread (); return (0); }
void Reset() { SifIopReset("rom0:UDNL rom0:EELOADCNF",0); while (SifIopSync()) ; fioExit(); SifExitIopHeap(); SifLoadFileExit(); SifExitRpc(); SifExitCmd(); EI; SifInitRpc(0); FlushCache(0); FlushCache(2); }
void ExecGame(void) { int i; scr_printf(" Installing Engine...\n"); u32 EngineStore = 0x80080000; u32 EngineRead = (void*)Engine; for (i = 0; i < sizeof(Engine); i += 4) { //scr_printf("A"); ee_kmode_enter(); *(u32*)EngineStore = *(u32*)EngineRead; ee_kmode_exit(); EngineStore += 4; EngineRead += 4; } ee_kmode_enter(); *(u32*)0x80081000 = 0x80081010; //Writes the initial storage of the codes ee_kmode_exit(); waitCdReady(); scr_printf(" Loading...\n"); //for (a = 0; a < 40000000; a++) { } if(strlen(bootFileName = parseSystemCnf()) <= 0) { scr_printf(" == Fatal Error ==\n"); SleepThread(); } scr_printf("\n Loaded Game!\n"); u32 HookValue = (0x00080000 / 4) + 0x0C000000; padPortClose(0, 0); //scr_printf(" Shut down PAD, shutting down RPC\n GOODBYE!!!"); SifExitRpc(); ee_kmode_enter(); *(u32*)0x800002FC = HookValue; ee_kmode_exit(); LoadExecPS2((const char *)bootFileName, 0, NULL); SleepThread(); }
int main(int argc, char *argv[]) { #ifdef PS2SDL_ENABLE_MTAP smod_mod_info_t info; if(smod_get_mod_by_name("sio2man",&info)!=0) { printf("PS2SDL: sio2man detected, resetting iop\n"); cdInit(CDVD_INIT_EXIT); SifExitIopHeap(); SifLoadFileExit(); SifExitRpc(); SifIopReset("rom0:UDNL rom0:EELOADCNF", 0); while (SifIopSync()) ; } #endif SifInitRpc(0); return(SDL_main(argc, argv)); }
///////////////////////////////////////////////////////////////////// // reboot IOP ///////////////////////////////////////////////////////////////////// void CD_Reset(int mode) { if(mode==1) SifIopReset("rom0:UDNL rom0:EELOADCNF",0); // normal else {fioOpen("cdrom0:\\SYSTEM.CNF;1",1); // hacking in the night... `_Ž. Prepare SifIopReset("rom0:UDNL cdrom0:\\SYSTEM.CNF;1", 0); // three point!! } while (SifIopSync()) ; fioExit(); SifExitIopHeap(); SifLoadFileExit(); SifExitRpc(); SifExitCmd(); EI(); SifInitRpc(0); FlushCache(0); FlushCache(2); }
int main() { int fd, ret; int i; // Initialise SifInitRpc(0); LoadModules(); #ifdef TYPE_MC if(mcInit(MC_TYPE_MC) < 0) { printf("Failed to initialise memcard server!\n"); SleepThread(); } #else if(mcInit(MC_TYPE_XMC) < 0) { printf("Failed to initialise memcard server!\n"); SleepThread(); } #endif printf("\nMemory card library example code - by Sjeep\n\n"); // int mcGetInfo(int port, int slot, int* type, int* free, int* format); // // mcGetInfo retrieves memcard state info, such as the memcard type, free blocks and // the format status. // // mcGetInfo is passed pointers to three variables, which are filled upon completion // of the getinfo rpc command. The mcGetInfo return values are as follows: // // 0 : The same memory card has been connected since the last mcGetInfo call. // -1 : Switched to a formatted memory card. // -2 : Switched to an unformatted memory card. // -10 or less : The memory card could not be detected. // // NOTE: With the MCMAN/MCSERV, *format is always returned as 0 regardless of if // if the memcard is formatted or not. // Since this is the first call, -1 should be returned. mcGetInfo(0, 0, &mc_Type, &mc_Free, &mc_Format); mcSync(0, NULL, &ret); printf("mcGetInfo returned %d\n",ret); printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format); // Assuming that the same memory card is connected, this should return 0 mcGetInfo(0,0,&mc_Type,&mc_Free,&mc_Format); mcSync(0, NULL, &ret); printf("mcGetInfo returned %d\n",ret); printf("Type: %d Free: %d Format: %d\n\n", mc_Type, mc_Free, mc_Format); // int mcGetDir(int port, int slot, char *name, unsigned mode, int maxent, mcTable* table); // // mcGetDir retrieves the directory structure of a specific path on the memory card. // // The filename is relative to the root of the memory card. Wildcards such as '*' and '?' // may be used. "maxent" is the maximum number of mcTable elements your array specified // by "table" can hold. The mc_getdir return values are as follows: // // 0 or more : The number of file entries that were obtained. // -2 : The memory card is unformatted // -4 : A non-existant path was specified in the "name" parameter // -10 or less : The memory card could not be detected. mcGetDir(0, 0, "/*", 0, ARRAY_ENTRIES - 10, mcDir); mcSync(0, NULL, &ret); printf("mcGetDir returned %d\n\nListing of root directory on memory card:\n\n", ret); for(i=0; i < ret; i++) { if(mcDir[i].attrFile & MC_ATTR_SUBDIR) printf("[DIR] %s\n", mcDir[i].name); else printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte); } // Check if existing save is present fd = fioOpen("mc0:PS2DEV/icon.sys", O_RDONLY); if(fd <= 0) { printf("\nNo previous save exists, creating...\n"); if((ret = CreateSave()) < 0) { printf("Failed to create save! Errorno: %d\n",ret); SleepThread(); } } else { printf("\nPrevious save exists, listing directory\n\n"); ret = mcGetDir(0, 0, "/PS2DEV/*", 0, ARRAY_ENTRIES, mcDir); printf("mcGetDir returned %d\n\n", ret); for(i=0; i < ret; i++) { if(mcDir[i].attrFile & MC_ATTR_SUBDIR) printf("[DIR] %s\n", mcDir[i].name); else printf("%s - %d bytes\n", mcDir[i].name, mcDir[i].fileSizeByte); } } // Return to the browser, so you can see the PS2Dev icon :) SifExitRpc(); return 0; }
int main(int argc, char **argv){ char ElfPath[32]; DINIT(); DPRINTF("OPL EE core start!\n"); SifInitRpc(0); int i = 0; if (!_strncmp(argv[i], "USB_MODE", 8)) GameMode = USB_MODE; else if (!_strncmp(argv[i], "ETH_MODE", 8)) GameMode = ETH_MODE; else if (!_strncmp(argv[i], "HDD_MODE", 8)) GameMode = HDD_MODE; DPRINTF("Game Mode = %d\n", GameMode); DisableDebug = 0; if (!_strncmp(&argv[i][9], "1", 1)) { DisableDebug = 1; DPRINTF("Debug Colors disabled\n"); } PS2Logo = 0; if (!_strncmp(&argv[i][11], "1", 1)) { PS2Logo = 1; DPRINTF("PS2 Logo enabled\n"); } char *p = _strtok(&argv[i][13], " "); if (!_strncmp(p, "Browser", 7)) ExitPath[0] = '\0'; else _strcpy(ExitPath, p); DPRINTF("Exit Path = (%s)\n", ExitPath); p = _strtok(NULL, " "); HDDSpindown = _strtoui(p); DPRINTF("HDD Spindown = %d\n", HDDSpindown); p = _strtok(NULL, " "); _strcpy(g_ps2_ip, p); p = _strtok(NULL, " "); _strcpy(g_ps2_netmask, p); p = _strtok(NULL, " "); _strcpy(g_ps2_gateway, p); g_ps2_ETHOpMode=_strtoui(_strtok(NULL, " ")); DPRINTF("IP=%s NM=%s GW=%s mode: %d\n", g_ps2_ip, g_ps2_netmask, g_ps2_gateway, g_ps2_ETHOpMode); #ifdef CHEAT EnableCheatOp = (gCheatList = (void*)_strtoui(_strtok(NULL, " "))) != NULL; DPRINTF("PS2RD Cheat Engine = %s\n", EnableCheatOp==0?"Disabled":"Enabled"); #endif #ifdef GSM EnableGSMOp = _strtoi(_strtok(NULL, " ")); DPRINTF("GSM = %s\n", EnableGSMOp==0?"Disabled":"Enabled"); #endif i++; ModStorageStart = (void*)_strtoui(_strtok(argv[i], " ")); ModStorageEnd = (void*)_strtoui(_strtok(NULL, " ")); i++; argv[i][11]=0x00; // fix for 8+3 filename. _strcpy(ElfPath, "cdrom0:\\"); _strcat(ElfPath, argv[i]); _strcat(ElfPath, ";1"); strncpy(GameID, argv[i], sizeof(GameID) - 1); GameID[sizeof(GameID) - 1] = '\0'; DPRINTF("Elf path = '%s'\n", ElfPath); DPRINTF("Game ID = '%s'\n", GameID); i++; // bitmask of the compat. settings g_compat_mask = _strtoui(argv[i]); DPRINTF("Compat Mask = 0x%02x\n", g_compat_mask); i++; #ifdef CHEAT if(EnableCheatOp){ EnableCheats(); } #endif #ifdef GSM if(EnableGSMOp){ u32 interlace, mode, ffmd, dx_offset, dy_offset, skip_videos_fix; u64 display, syncv, smode2; interlace=_strtoui(_strtok(argv[i], " ")); mode=_strtoui(_strtok(NULL, " ")); ffmd=_strtoui(_strtok(NULL, " ")); display=_strtoul(_strtok(NULL, " ")); syncv=_strtoul(_strtok(NULL, " ")); smode2=_strtoui(_strtok(NULL, " ")); dx_offset=_strtoui(_strtok(NULL, " ")); dy_offset=_strtoui(_strtok(NULL, " ")); skip_videos_fix=_strtoui(_strtok(NULL, " ")); UpdateGSMParams(interlace, mode, ffmd, display, syncv, smode2, dx_offset, dy_offset, skip_videos_fix); EnableGSM(); } #endif set_ipconfig(); /* installing kernel hooks */ DPRINTF("Installing Kernel Hooks...\n"); Install_Kernel_Hooks(); if(!DisableDebug) GS_BGCOLOUR = 0xff0000; //Blue SifExitRpc(); DPRINTF("Executing '%s'...\n", ElfPath); //PS2LOGO Caller, based on l_oliveira & SP193 tips if (PS2Logo) { char *argvs[1]; argvs[0] = ElfPath; argvs[1] = NULL; LoadExecPS2("rom0:PS2LOGO", 1, argvs); } else { LoadExecPS2(ElfPath, 0, NULL); } if(!DisableDebug) GS_BGCOLOUR = 0x0000ff; //Red DPRINTF("LoadExecPS2 failed!\n"); SleepThread(); return 0; }
int loadLoaderModules(int debug_mode, int disable_cdrom) { static int load_dvd_config = -1; static int load_netsurf_config = -1; static int load_usb_config = -1; int i; int rv; int lrv = -1; if (debug_mode == 1) { /* Network is used by ps2link and can't be used by Linux. */ network_support = 0; } #ifdef RESET_IOP if (debug_mode == -1) { graphic_setStatusMessage("Flushing cache"); FlushCache(0); graphic_setStatusMessage("Exit IOP Heap"); SifExitIopHeap(); graphic_setStatusMessage("Exit LoadFile"); SifLoadFileExit(); graphic_setStatusMessage("Exit FIO"); fioExit(); graphic_setStatusMessage("Exit RPC"); SifExitRpc(); graphic_setStatusMessage("Stop DMA"); SifStopDma(); graphic_setStatusMessage("PreReset Init RPC"); SifInitRpc(0); graphic_setStatusMessage("Reseting IOP"); while(!SifIopReset(s_pUDNL, 0)); graphic_setStatusMessage("IOP Sync"); while (!SifIopSync()); graphic_setStatusMessage("Initialize RPC"); SifInitRpc(0); } #endif graphic_setStatusMessage("Patching enable LMB"); sbv_patch_enable_lmb(); graphic_setStatusMessage("Patching disable prefix check"); sbv_patch_disable_prefix_check(); /* CDVDMAN is loaded by IopReset and NVRAM can be read. */ graphic_setStatusMessage("Read NVRAM from CDVD"); if (!disable_cdrom) { nvram_init(); } eromdrvSupport = 0; /* FIXME: eedebug handler seems to crash the ee graphic_setStatusMessage("Add eedebug handler"); addEEDebugHandler(); */ graphic_setStatusMessage("Loading modules"); for (i = 0; i < moduleLoaderNumberOfModules; i++) { const rom_entry_t *romfile; if (moduleList[i].debug_mode != 0) { if (moduleList[i].debug_mode != debug_mode) { continue; } } /* Load configuration when necessary modules are loaded. */ if (moduleList[i].loadCfg) { checkForMusicSupport(); setDefaultConfiguration(NULL); lrv = loadConfiguration(CONFIG_FILE); changeMode(); /* Load configuration on startup and not on IOP reset. */ moduleList[i].loadCfg = 0; } graphic_setStatusMessage(moduleList[i].path); kprintf("Loading module (%s)\n", moduleList[i].path); if (!network_support) { if (moduleList[i].network) { continue; } } if (moduleList[i].ps2smap) { moduleList[i].args = getPS2MAPParameter(&moduleList[i].argLen); } if (moduleList[i].dns) { moduleList[i].args = getPS2DNS(&moduleList[i].argLen); } if (moduleList[i].checkMc) { static char file[256]; /* Try to load module from MC if available. */ snprintf(file, sizeof(file), CONFIG_DIR "/%s", moduleList[i].path); rv = SifLoadModule(file, moduleList[i].argLen, moduleList[i].args); } else { rv = -1; } if (rv < 0) { if ((moduleList[i].sms_mod == 0) || (isDVDVSupported())) { if (moduleList[i].eromdrv < 0) { /* Try to detect EROM driver only the first time. */ moduleList[i].eromdrv = 1; if (disable_cdrom) { continue; } rv = open("rom1:EROMDRV", O_RDONLY); if (rv >=0 ) { eromdrvpath[12] = 0; /* This is an old fat PS2 (working with SCPH-50004 and SCPH-39004). */ close(rv); } else { const u8 *nvm; nvm = get_nvram(); if (nvm_errors == 0) { /* NVM layout seems to be correct. */ eromdrvpath[12] = nvm[NVM_REAL_REGION]; rv = open(eromdrvpath, O_RDONLY); if (rv >=0 ) { /* Region code seems to be correct. */ close(rv); } else { error_printf("The region code stored in the NVRAM S%02x T%02x F%02x R%02x " "can't be detected by version string %s (%s).", nvm[0x180], nvm[0x181], nvm[NVM_FAKE_REGION], nvm[NVM_REAL_REGION], ps2_rom_version); continue; } } else { error_printf("%d errors when reading NVRAM. Please set path " "to EROMDRV and reload modules.", nvm_errors); continue; } } } if (moduleList[i].eromdrv != 0) { moduleList[i].args = get_eromdrvpath(); moduleList[i].argLen = strlen(moduleList[i].args) + 1; } romfile = rom_getFile(moduleList[i].path); if (romfile != NULL) { int ret; ret = SifExecModuleBuffer((void *) romfile->start, romfile->size, moduleList[i].argLen, moduleList[i].args, &rv); if (ret < 0) { rv = ret; } } else { rv = SifLoadModule(moduleList[i].path, moduleList[i].argLen, moduleList[i].args); } if (rv < 0) { if (moduleList[i].eromdrv != 0) { kprintf("Failed to load module \"%s\".\n", get_eromdrvpath()); } else { kprintf("Failed to load module \"%s\".\n", moduleList[i].path); } if (moduleList[i].ps2smap && !isSlimPSTwo()) { network_support = 0; } else { if (moduleList[i].eromdrv != 0) { error_printf("Failed to load module \"%s\".", get_eromdrvpath()); } else { error_printf("Failed to load module \"%s\".", moduleList[i].path); } } } else { if (moduleList[i].eromdrv != 0) { eromdrvSupport = -1; } } } } } graphic_setStatusMessage(NULL); printAllModules(); fileXioInit(); if (load_netsurf_config) { load_netsurf_config = 0; if (lrv != 0) { graphic_setStatusMessage("Check for NetSurf config"); lrv = loadConfiguration(PS2NS_CONFIG_FILE); graphic_setStatusMessage(NULL); } } if (load_usb_config) { load_usb_config = 0; if (lrv != 0) { graphic_setStatusMessage("Check for USB config"); lrv = loadConfiguration(USB_CONFIG_FILE); graphic_setStatusMessage(NULL); } } if (load_dvd_config && isDVDVSupported()) { load_dvd_config = 0; graphic_setStatusMessage("Init DVD driver"); CDDA_Init(); CDVD_Init(); if (lrv != 0) { DiskType type; graphic_setStatusMessage("Load config from DVD"); type = CDDA_DiskType(); if (type == DiskType_DVDV) { CDVD_SetDVDV(1); } else { CDVD_SetDVDV(0); } kprintf("kloader disc type %u\n", type); switch (type) { case DiskType_CD: case DiskType_DVD: case DiskType_DVDV: /* Load configuration from disc. */ lrv = loadConfiguration(DVD_CONFIG_FILE); changeMode(); #if 0 if (lrv != 0) { error_printf("Failed to load config from \"%s\", using default configuration.", DVD_CONFIG_FILE); } #endif break; default: kprintf("kloader unsupported disc type %u\n", type); break; } /* Stop CD when finished. */ CDVD_Stop(); CDVD_FlushCache(); } graphic_setStatusMessage(NULL); } snprintf(hardware_information, sizeof(hardware_information), "%s with DVD-R %s, %s sound support and %s network adapter", isSlimPSTwo() ? "slim PSTwo" : "fat PS2", disable_cdrom ? "disabled" : (isDVDVSupported() ? "support" : "problem"), (libsd_version <= 0x104) ? "direct" : "indirect", network_support ? "with" : "without"); return 0; }