diff --git a/Makefile b/Makefile index bf9e4e0..309dd79 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,6 @@ all: $(MAKE) -C iop/smap all DEBUG=$(DEBUG) $(MAKE) -C iop/imgdrv all DEBUG=$(DEBUG) $(MAKE) -C iop/isofs all DEBUG=$(DEBUG) - $(MAKE) -C iop/resetspu all DEBUG=$(DEBUG) $(MAKE) -C ee/ee_core all $(MAKE) -C ee/loader all DEBUG=$(DEBUG) @@ -22,7 +21,6 @@ clean: $(MAKE) -C iop/smap clean $(MAKE) -C iop/imgdrv clean $(MAKE) -C iop/isofs clean - $(MAKE) -C iop/resetspu clean $(MAKE) -C ee/ee_core clean $(MAKE) -C ee/loader clean diff --git a/README.md b/README.md index 5edc06d..8a12815 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Usage: neutrino.elf -drv= -iso=\n"); Options:\n"); -drv= Select block device driver, supported are: ata, usb, mx4sio(sdc), udpbd(udp) and ilink(sd) -iso= Select iso file (full path!) + -elf= Select elf file inside iso to boot -mt= Select media type, supported are: cd, dvd. Defaults to cd for size<=650MiB, and dvd for size>650MiB -gc= Game compatibility modes, supperted are: - 0: Disable builtin compat flags diff --git a/ee/ee_core/include/modmgr.h b/ee/ee_core/include/modmgr.h index b85def6..1a0f575 100644 --- a/ee/ee_core/include/modmgr.h +++ b/ee/ee_core/include/modmgr.h @@ -86,7 +86,7 @@ typedef struct int LoadFileInit(); void LoadFileExit(); -int LoadModule(const char *path, int arg_len, const char *args); +int LoadModule(const char *path, int mode, int arg_len, const char *args); int LoadMemModule(int mode, void *modptr, unsigned int modsize, int arg_len, const char *args); int GetOPLModInfo(int id, void **pointer, unsigned int *size); int LoadOPLModule(int id, int mode, int arg_len, const char *args); diff --git a/ee/ee_core/src/iopmgr.c b/ee/ee_core/src/iopmgr.c index 6565744..0f246b0 100644 --- a/ee/ee_core/src/iopmgr.c +++ b/ee/ee_core/src/iopmgr.c @@ -74,7 +74,7 @@ static void ResetIopSpecial(const char *args, unsigned int arglen) ee_kmode_exit(); EIntr(); - LoadOPLModule(OPL_MODULE_ID_UDNL, SIF_RPC_M_NOWAIT, CommandLen, command); + LoadModule("rom0:UDNL", SIF_RPC_M_NOWAIT, CommandLen, command); DIntr(); ee_kmode_enter(); @@ -100,9 +100,9 @@ static void ResetIopSpecial(const char *args, unsigned int arglen) DPRINTF("Loading extra IOP modules...\n"); irxtab_t *irxtable = (irxtab_t *)ModStorageStart; - // Skip the first 4 modules + // Skip the first 2 modules: IOPRP.IMG and imgdrv.irx // FIXME: magic number! - for (i = 4; i < irxtable->count; i++) { + for (i = 2; i < irxtable->count; i++) { irxptr_t p = irxtable->modules[i]; // Modules that emulate the sceCdRead function must operate at a higher // priority than the highest possible game priority. diff --git a/ee/ee_core/src/main.c b/ee/ee_core/src/main.c index ae65f4b..402d898 100644 --- a/ee/ee_core/src/main.c +++ b/ee/ee_core/src/main.c @@ -62,7 +62,7 @@ static void set_args_mod(char *arg) ModStorageEnd = (void *)_strtoui(_strtok(NULL, " ")); } -static void set_args_file(const char *arg) +static void set_args_gameid(const char *arg) { strncpy(GameID, arg, sizeof(GameID) - 1); GameID[sizeof(GameID) - 1] = '\0'; @@ -93,8 +93,8 @@ static int eecoreInit(int argc, char **argv) set_args_kernel(&argv[i][8]); if (!_strncmp(argv[i], "-mod=", 5)) set_args_mod(&argv[i][5]); - if (!_strncmp(argv[i], "-file=", 6)) - set_args_file(&argv[i][6]); + if (!_strncmp(argv[i], "-gid=", 5)) + set_args_gameid(&argv[i][5]); if (!_strncmp(argv[i], "-compat=", 8)) set_args_compat(&argv[i][8]); if (!_strncmp(argv[i], "--b", 3)) diff --git a/ee/ee_core/src/modmgr.c b/ee/ee_core/src/modmgr.c index 8cc5602..51e76a6 100644 --- a/ee/ee_core/src/modmgr.c +++ b/ee/ee_core/src/modmgr.c @@ -48,9 +48,9 @@ void LoadFileExit() /*----------------------------------------------------------------------------------------*/ -/* Load an irx module from path with waiting. */ +/* Load an irx module from path. */ /*----------------------------------------------------------------------------------------*/ -int LoadModule(const char *path, int arg_len, const char *args) +int LoadModule(const char *path, int mode, int arg_len, const char *args) { struct _lf_module_load_arg arg; @@ -68,14 +68,14 @@ int LoadModule(const char *path, int arg_len, const char *args) } else arg.p.arg_len = 0; - if (SifCallRpc(&_lf_cd, LF_F_MOD_LOAD, 0x0, &arg, sizeof(arg), &arg, 8, NULL, NULL) < 0) + if (SifCallRpc(&_lf_cd, LF_F_MOD_LOAD, mode, &arg, sizeof(arg), &arg, 8, NULL, NULL) < 0) return -SCE_ECALLMISS; return arg.p.result; } /*----------------------------------------------------------------------------------------*/ -/* Load an irx module from path without waiting. */ +/* Load an irx module from path. */ /*----------------------------------------------------------------------------------------*/ int LoadMemModule(int mode, void *modptr, unsigned int modsize, int arg_len, const char *args) { diff --git a/ee/ee_core/src/patches.c b/ee/ee_core/src/patches.c index 77040f4..afdebc4 100644 --- a/ee/ee_core/src/patches.c +++ b/ee/ee_core/src/patches.c @@ -866,6 +866,10 @@ static void HarvestMoonAWLPatch(int region) void apply_patches(const char *path) { const patchlist_t *p; + // Some patches hack into specific ELF files + // make sure the filename and gameid match for those patches + // This prevents games with multiple ELF's from being corrupted by the patch + int file_eq_gameid = !_strncmp(&path[8], GameID, 11); // starting after 'cdrom0:\' // if there are patches matching game name/mode then fill the patch table for (p = patch_list; p->game; p++) { @@ -878,22 +882,28 @@ void apply_patches(const char *path) AC9B_generic_patches(); break; case PATCH_GENERIC_SLOW_READS: - generic_delayed_cdRead_patches(p->patch.check, p->patch.val); // slow reads generic patch + if (file_eq_gameid) + generic_delayed_cdRead_patches(p->patch.check, p->patch.val); // slow reads generic patch break; case PATCH_SDF_MACROSS: - SDF_Macross_patch(); + if (file_eq_gameid) + SDF_Macross_patch(); break; case PATCH_GENERIC_CAPCOM: - generic_capcom_protection_patches(p->patch.val); // Capcom anti cdvd emulator protection patch + if (file_eq_gameid) + generic_capcom_protection_patches(p->patch.val); // Capcom anti cdvd emulator protection patch break; case PATCH_SRW_IMPACT: - SRWI_IMPACT_patches(); + if (file_eq_gameid) + SRWI_IMPACT_patches(); break; case PATCH_RNC_UYA: - RnC3_UYA_patches((unsigned int *)p->patch.val); + if (file_eq_gameid) + RnC3_UYA_patches((unsigned int *)p->patch.val); break; case PATCH_ZOMBIE_ZONE: - ZombieZone_patches(p->patch.val); + if (file_eq_gameid) + ZombieZone_patches(p->patch.val); break; case PATCH_DOT_HACK: DotHack_patches(path); @@ -904,7 +914,8 @@ void apply_patches(const char *path) #endif break; case PATCH_VIRTUA_QUEST: - VirtuaQuest_patches(); + if (file_eq_gameid) + VirtuaQuest_patches(); break; case PATCH_ULT_PRO_PINBALL: #ifdef APEMOD_PATCH @@ -912,7 +923,8 @@ void apply_patches(const char *path) #endif break; case PATCH_EUTECHNYX_WU_TID: - EutechnyxWakeupTIDPatch(p->patch.val); + if (file_eq_gameid) + EutechnyxWakeupTIDPatch(p->patch.val); break; case PATCH_PRO_SNOWBOARDER: ProSnowboarderPatch(); diff --git a/ee/loader/Makefile b/ee/loader/Makefile index b865856..317a72f 100644 --- a/ee/loader/Makefile +++ b/ee/loader/Makefile @@ -18,9 +18,7 @@ EE_IRX_FILES += \ bdm_cdvdman.irx \ imgdrv.irx \ isofs.irx \ - resetspu.irx \ eesync.irx \ - udnl.irx \ iomanX.irx \ fileXio.irx \ bdm.irx \ @@ -51,7 +49,6 @@ vpath %.irx ../../iop/cdvdman/irx/ vpath %.irx ../../iop/smap/irx/ vpath %.irx ../../iop/imgdrv/irx/ vpath %.irx ../../iop/isofs/irx/ -vpath %.irx ../../iop/resetspu/irx/ vpath %.elf ../ee_core/ vpath %.irx $(PS2SDK)/iop/irx/ @@ -76,6 +73,20 @@ $(EE_BIN_PACKED): $(EE_BIN) all: $(EE_BIN_PACKED) +# ALL : BSOD when returning back to menu +# Game uses differnt ELF files for menu and game +#GAME = 'CD/Densha de Go! 3 - Tsuukin-hen (J).iso' + +# ALL : BSOD +# These CD games use sceCdGetToc and sceCdPosToInt +# Do these functions work as expected? +#GAME = 'CD/Madden NFL 2001 (U).iso' +#GAME = 'CD/Madden NFL 2002 (U).iso' +#GAME = 'CD/NASCAR Thunder 2002 (U).iso' + +# UDPBD: works +#GAME = 'CD/Downforce (U).iso' + # USB : BSOD # UDPBD: works #GAME = 'CD/Super Bust-A-Move (U).iso' @@ -101,7 +112,7 @@ all: $(EE_BIN_PACKED) # Tested, working #GAME = 'CD/ICO (U).iso' -#GAME = 'DVD/DragonBall Z Budokai Tenkaichi 3 (E).iso' +GAME = 'DVD/DragonBall Z Budokai Tenkaichi 3 (E).iso' #GAME = 'DVD/PES 2023 (E).iso' #GAME = 'DVD/Sonic Unleashed (E).iso' #GAME = 'DVD/007 - Agent Under Fire (E).iso' @@ -110,7 +121,8 @@ all: $(EE_BIN_PACKED) #GAME = 'DVD/Ratchet Clank - Going Commando (E).iso' #GAME = 'DVD/Ratchet Clank - Up Your Arsenal (U).iso' #GAME = 'CD/Quake III Revolution (E).iso' -GAME = 'DVD/Super Dragon Ball Z (E).iso' +#GAME = 'DVD/Super Dragon Ball Z (E).iso' +#GAME = 'CD/Tekken Tag Tournament (E) v2.iso' run: all copy @@ -129,10 +141,8 @@ copy: cp ../../iop/smap/irx/smap.irx modules cp ../../iop/imgdrv/irx/imgdrv.irx modules cp ../../iop/isofs/irx/isofs.irx modules - cp ../../iop/resetspu/irx/resetspu.irx modules cp ../ee_core/ee_core.elf modules cp $(PS2SDK)/iop/irx/eesync.irx modules - cp $(PS2SDK)/iop/irx/udnl.irx modules cp $(PS2SDK)/iop/irx/iomanX.irx modules cp $(PS2SDK)/iop/irx/fileXio.irx modules cp $(PS2SDK)/iop/irx/bdm.irx modules diff --git a/ee/loader/src/ee_core_config.c b/ee/loader/src/ee_core_config.c index 4437069..6d7de28 100644 --- a/ee/loader/src/ee_core_config.c +++ b/ee/loader/src/ee_core_config.c @@ -9,6 +9,7 @@ void eecc_init(struct SEECoreConfig *eecc) eecc_setKernelConfig(eecc, 0, 0); eecc_setModStorageConfig(eecc, 0, 0); eecc_setCompatFlags(eecc, 0); + eecc_setGameID(eecc, ""); eecc_setFileName(eecc, ""); eecc_setExitPath(eecc, "Browser"); IP4_ADDR(&eecc->_ethAddr, 192, 168, 1, 10); @@ -70,6 +71,11 @@ void eecc_setCheats(struct SEECoreConfig *eecc, bool enable) eecc->_enableCheats = enable; } +void eecc_setGameID(struct SEECoreConfig *eecc, const char *gameID) +{ + eecc->_sGameID = gameID; +} + void eecc_setFileName(struct SEECoreConfig *eecc, const char *fileName) { eecc->_sFileName = fileName; @@ -102,6 +108,9 @@ bool eecc_valid(struct SEECoreConfig *eecc) if (eecc->_irxptr == 0x0) return false; + if (eecc->_sGameID[0] == 0) + return false; + if (eecc->_sFileName[0] == 0) return false; @@ -155,8 +164,8 @@ const char **eecc_argv(struct SEECoreConfig *eecc) maxStrLen -= strlen(psConfig) + 1; psConfig += strlen(psConfig) + 1; - // Filename - snprintf(psConfig, maxStrLen, "-file=%s", eecc->_sFileName); + // GameID + snprintf(psConfig, maxStrLen, "-gid=%s", eecc->_sGameID); eecc->_argv[eecc->_argc++] = psConfig; maxStrLen -= strlen(psConfig) + 1; psConfig += strlen(psConfig) + 1; diff --git a/ee/loader/src/ee_core_config.h b/ee/loader/src/ee_core_config.h index ceb38f1..055592c 100644 --- a/ee/loader/src/ee_core_config.h +++ b/ee/loader/src/ee_core_config.h @@ -25,6 +25,7 @@ struct SEECoreConfig ip4_addr_t _ethAddr; ip4_addr_t _ethMask; ip4_addr_t _ethGateway; + const char *_sGameID; const char *_sFileName; const char *_sExitPath; @@ -46,6 +47,7 @@ void eecc_setGameMode(struct SEECoreConfig *eecc, u32 gameMode); void eecc_setKernelConfig(struct SEECoreConfig *eecc, u32 eeloadCopy, u32 initUserMemory); void eecc_setModStorageConfig(struct SEECoreConfig *eecc, u32 irxtable, u32 irxptr); void eecc_setCompatFlags(struct SEECoreConfig *eecc, u32 compatFlags); +void eecc_setGameID(struct SEECoreConfig *eecc, const char *gameID); void eecc_setFileName(struct SEECoreConfig *eecc, const char *fileName); void eecc_setExitPath(struct SEECoreConfig *eecc, const char *path); void eecc_setHDDSpindown(struct SEECoreConfig *eecc, u32 minutes); diff --git a/ee/loader/src/main.c b/ee/loader/src/main.c index d33b21a..f9eefea 100644 --- a/ee/loader/src/main.c +++ b/ee/loader/src/main.c @@ -64,9 +64,7 @@ IRX_COMMON_DEFINE(cdvdfsv); IRX_COMMON_DEFINE(bdm_cdvdman); IRX_COMMON_DEFINE(imgdrv); IRX_COMMON_DEFINE(isofs); -IRX_COMMON_DEFINE(resetspu); IRX_COMMON_DEFINE(eesync); -IRX_COMMON_DEFINE(udnl); IRX_COMMON_DEFINE(iomanX); IRX_COMMON_DEFINE(fileXio); IRX_COMMON_DEFINE(bdm); @@ -90,13 +88,11 @@ ELF_DEFINE(ee_core); OPL Module Storage Memory Map: struct irxtab_t; struct irxptr_tab[modcount]; - udnl.irx IOPRP.img, containing: - cdvdman.irx - cdvdfsv.irx - eesync.irx imgdrv.irx - resetspu.irx */ @@ -112,6 +108,7 @@ void print_usage() printf("Options:\n"); printf(" -drv= Select block device driver, supported are: ata, usb, mx4sio(sdc), udpbd(udp) and ilink(sd)\n"); printf(" -iso= Select iso file (full path!)\n"); + printf(" -elf= Select elf file inside iso to boot\n"); printf(" -mt= Select media type, supported are: cd, dvd. Defaults to cd for size<=650MiB, and dvd for size>650MiB\n"); printf(" -gc= Game compatibility modes, supperted are:\n"); printf(" - 0: Disable builtin compat flags\n"); @@ -149,12 +146,10 @@ struct SModule #define SMF_D_ILINK (1 << 14) // clang-format off struct SModule mod[] = { - {"", "udnl.irx" , NULL, 0, SMF_IOPCORE , OPL_MODULE_ID_UDNL}, {"CDVDMAN", "bdm_cdvdman.irx" , NULL, 0, SMF_IOPCORE , 0}, {"CDVDFSV", "cdvdfsv.irx" , NULL, 0, SMF_IOPCORE , 0}, {"EESYNC", "eesync.irx" , NULL, 0, SMF_IOPCORE , 0}, {"", "imgdrv.irx" , NULL, 0, SMF_IOPCORE , OPL_MODULE_ID_IMGDRV}, - {"", "resetspu.irx" , NULL, 0, SMF_IOPCORE , 0}, {"", "iomanX.irx" , NULL, 0, SMF_FIOX , 0}, {"", "fileXio.irx" , NULL, 0, SMF_FIOX , 0}, {"", "isofs.irx" , NULL, 0, SMF_ISO , 0}, @@ -183,26 +178,24 @@ struct SModule mod[] = { void mod_init() { - INIT_MOD( 0, udnl); - INIT_MOD( 1, bdm_cdvdman); - INIT_MOD( 2, cdvdfsv); - INIT_MOD( 3, eesync); - INIT_MOD( 4, imgdrv); - INIT_MOD( 5, resetspu); - INIT_MOD( 6, iomanX); - INIT_MOD( 7, fileXio); - INIT_MOD( 8, isofs); - INIT_MOD( 9, bdm); - INIT_MOD(10, bdmfs_fatfs); - INIT_MOD(11, usbd_mini); - INIT_MOD(12, usbmass_bd_mini); - INIT_MOD(13, mx4sio_bd_mini); - INIT_MOD(14, ps2dev9); - INIT_MOD(15, ata_bd); - INIT_MOD(16, smap); - INIT_MOD(17, iLinkman); - INIT_MOD(18, IEEE1394_bd_mini); - INIT_ELF(19, ee_core); + INIT_MOD( 0, bdm_cdvdman); + INIT_MOD( 1, cdvdfsv); + INIT_MOD( 2, eesync); + INIT_MOD( 3, imgdrv); + INIT_MOD( 4, iomanX); + INIT_MOD( 5, fileXio); + INIT_MOD( 6, isofs); + INIT_MOD( 7, bdm); + INIT_MOD( 8, bdmfs_fatfs); + INIT_MOD( 9, usbd_mini); + INIT_MOD(10, usbmass_bd_mini); + INIT_MOD(11, mx4sio_bd_mini); + INIT_MOD(12, ps2dev9); + INIT_MOD(13, ata_bd); + INIT_MOD(14, smap); + INIT_MOD(15, iLinkman); + INIT_MOD(16, IEEE1394_bd_mini); + INIT_ELF(17, ee_core); } #define MAX_FILENAME 128 @@ -493,7 +486,8 @@ int main(int argc, char *argv[]) printf("----------------------------\n"); const char *sDriver = NULL; - const char *sFileName = NULL; + const char *sFileNameISO = NULL; + const char *sFileNameELF = NULL; const char *sIP = NULL; const char *sMediaType = NULL; const char *sCompat = NULL; @@ -507,7 +501,9 @@ int main(int argc, char *argv[]) if (!strncmp(argv[i], "-drv=", 5)) sDriver = &argv[i][5]; else if (!strncmp(argv[i], "-iso=", 5)) - sFileName = &argv[i][5]; + sFileNameISO = &argv[i][5]; + else if (!strncmp(argv[i], "-elf=", 5)) + sFileNameELF = &argv[i][5]; else if (!strncmp(argv[i], "-ip=", 4)) sIP = &argv[i][4]; else if (!strncmp(argv[i], "-mt=", 4)) @@ -639,9 +635,9 @@ int main(int argc, char *argv[]) * Check if file exists * Give low level drivers 10s to start */ - printf("Loading %s...\n", sFileName); + printf("Loading %s...\n", sFileNameISO); for (i = 0; i < 1000; i++) { - fd = open(sFileName, O_RDONLY); + fd = open(sFileNameISO, O_RDONLY); if (fd >= 0) break; @@ -649,7 +645,7 @@ int main(int argc, char *argv[]) nopdelay(); } if (fd < 0) { - printf("Unable to open %s\n", sFileName); + printf("Unable to open %s\n", sFileNameISO); return -1; } // Get ISO file size @@ -688,11 +684,11 @@ int main(int argc, char *argv[]) printf("- media = %s\n", eMediaType == SCECdPS2DVD ? "DVD" : "CD"); /* - * Mount as ISO so we can get some information + * Mount as ISO so we can get ELF name to boot */ - int fd_isomount = fileXioMount("iso:", sFileName, FIO_MT_RDONLY); + int fd_isomount = fileXioMount("iso:", sFileNameISO, FIO_MT_RDONLY); if (fd_isomount < 0) { - printf("ERROR: Unable to mount %s as iso\n", sFileName); + printf("ERROR: Unable to mount %s as iso\n", sFileNameISO); return -1; } int fd_config = open("iso:\\SYSTEM.CNF;1", O_RDONLY); @@ -714,6 +710,9 @@ int main(int argc, char *argv[]) close(fd_config); fileXioUmount("iso:"); + if (sFileNameELF == NULL) + sFileNameELF = sGameID; + ResetDeckardXParams(); ApplyDeckardXParam(sGameID); @@ -769,6 +768,10 @@ int main(int argc, char *argv[]) printf("Too many fragments (%d)\n", iso_frag->frag_start + iso_frag->frag_count); return -1; } + settings->drvName = (u32)fileXioIoctl2(fd, USBMASS_IOCTL_GET_DRIVERNAME, NULL, 0, NULL, 0); + fileXioIoctl2(fd, USBMASS_IOCTL_GET_DEVICE_NUMBER, NULL, 0, &settings->devNr, 4); + char *drvName = (char *)&settings->drvName; + printf("Using BDM device: %s%d\n", drvName, settings->devNr); close(fd); // @@ -806,12 +809,6 @@ int main(int argc, char *argv[]) irxtable->modules = irxptr_tab; irxtable->count = 0; - // - // Load udnl.irx first - // - irxptr += load_file_mod("udnl.irx", irxptr, irxptr_tab++); - irxtable->count++; - // // Patch IOPRP.img with our own CDVDMAN, CDVDFSV and EESYNC // @@ -831,8 +828,6 @@ int main(int argc, char *argv[]) // irxptr += load_file_mod("imgdrv.irx", irxptr, irxptr_tab++); irxtable->count++; - irxptr += load_file_mod("resetspu.irx", irxptr, irxptr_tab++); - irxtable->count++; #ifdef DEBUG // For debugging (udptty) and also udpbd @@ -914,7 +909,8 @@ int main(int argc, char *argv[]) eecc_setGameMode(&eeconf, iMode); eecc_setKernelConfig(&eeconf, (u32)eeloadCopy, (u32)initUserMemory); eecc_setModStorageConfig(&eeconf, (u32)irxtable, (u32)irxptr); - eecc_setFileName(&eeconf, sGameID); + eecc_setGameID(&eeconf, sGameID); + eecc_setFileName(&eeconf, sFileNameELF); eecc_setCompatFlags(&eeconf, iCompat); eecc_setDebugColors(&eeconf, iEnableDebugColors ? true : false); printf("Starting ee_core with following arguments:\n"); diff --git a/iop/cdvdman/src/cdvdman.c b/iop/cdvdman/src/cdvdman.c index 10d0d42..8ebde4c 100644 --- a/iop/cdvdman/src/cdvdman.c +++ b/iop/cdvdman/src/cdvdman.c @@ -254,15 +254,15 @@ u32 sceCdPosToInt(sceCdlLOCCD *p) { register u32 result; - DPRINTF("%s({%d, %d, %d})\n", __FUNCTION__, p->minute, p->second, p->sector); - - result = ((u32)p->minute >> 16) * 10 + ((u32)p->minute & 0xF); + result = ((u32)p->minute >> 4) * 10 + ((u32)p->minute & 0xF); result *= 60; - result += ((u32)p->second >> 16) * 10 + ((u32)p->second & 0xF); + result += ((u32)p->second >> 4) * 10 + ((u32)p->second & 0xF); result *= 75; - result += ((u32)p->sector >> 16) * 10 + ((u32)p->sector & 0xF); + result += ((u32)p->sector >> 4) * 10 + ((u32)p->sector & 0xF); result -= 150; + DPRINTF("%s({0x%X, 0x%X, 0x%X, 0x%X}) = %d\n", __FUNCTION__, p->minute, p->second, p->sector, p->track, result); + return result; } diff --git a/iop/cdvdman/src/device-bdm.c b/iop/cdvdman/src/device-bdm.c index aca8025..cf45c55 100644 --- a/iop/cdvdman/src/device-bdm.c +++ b/iop/cdvdman/src/device-bdm.c @@ -26,12 +26,25 @@ void bdm_connect_bd(struct block_device *bd) { DPRINTF("connecting device %s%dp%d\n", bd->name, bd->devNr, bd->parNr); - if (g_bd == NULL) { - g_bd = bd; - g_bd_sectors_per_sector = (2048 / bd->sectorSize); - // Free usage of block device - SignalSema(bdm_io_sema); + if (strncmp(bd->name, (char *)&cdvdman_settings.drvName, 4)) { + DPRINTF("- skipping wrong driver\n"); + return; } + + if (bd->devNr != cdvdman_settings.devNr) { + DPRINTF("- skipping wrong device nr\n"); + return; + } + + if (g_bd != NULL) { + DPRINTF("- ERROR: device already connected\n"); + return; + } + + g_bd = bd; + g_bd_sectors_per_sector = (2048 / bd->sectorSize); + // Free usage of block device + SignalSema(bdm_io_sema); } void bdm_disconnect_bd(struct block_device *bd) diff --git a/iop/cdvdman/src/ncmd.c b/iop/cdvdman/src/ncmd.c index 0d3fcdf..1dc5ecf 100644 --- a/iop/cdvdman/src/ncmd.c +++ b/iop/cdvdman/src/ncmd.c @@ -53,13 +53,32 @@ static void lba_to_msf(s32 lba, u8 *m, u8 *s, u8 *f) *f = lba % 75; } +//------------------------------------------------------------------------- +typedef struct { + u8 addr_ctrl; + u8 track_no; + u8 index_no; + u8 reserved[3]; + u8 zero; + u8 abs_min; + u8 abs_sec; + u8 abs_frm; +} __attribute__((packed)) toc_point_t; + +typedef struct { + toc_point_t a0; + toc_point_t a1; + toc_point_t a2; + toc_point_t track[99]; + u32 filler; +} __attribute__((packed)) toc_t; + //------------------------------------------------------------------------- static int cdvdman_fill_toc(u8 *tocBuff) { - u8 discType = cdvdman_stat.disc_type_reg & 0xFF; - DPRINTF("cdvdman_fill_toc tocBuff=%08x discType=%02X\n", (int)tocBuff, discType); + DPRINTF("cdvdman_fill_toc tocBuff=0x%08x discType=0x%02X\n", (int)tocBuff, discType); if (tocBuff == NULL) { return 0; @@ -68,30 +87,37 @@ static int cdvdman_fill_toc(u8 *tocBuff) switch (discType) { case 0x12: // SCECdPS2CD case 0x13: // SCECdPS2CDDA - u8 min; - u8 sec; - u8 frm; - tocBuff[0] = 0x41; - tocBuff[1] = 0x00; + toc_t *t = (toc_t *)tocBuff; + u8 min, sec, frm; memset(tocBuff, 0, 1024); // Number of FirstTrack, // Always 1 until PS2CCDA support get's added. - tocBuff[2] = 0xA0; - tocBuff[7] = itob(1); + t->a0.addr_ctrl = 0x00; + t->a0.track_no = 0x00; + t->a0.index_no = 0xA0; // ??? + t->a0.abs_min = itob(1); + t->a0.abs_min = itob(0); + t->a0.abs_min = itob(0); // Number of LastTrack // Always 1 until PS2CCDA support get's added. - tocBuff[12] = 0xA1; - tocBuff[17] = itob(1); + t->a1.addr_ctrl = 0x00; + t->a1.track_no = 0x00; + t->a1.index_no = 0xA1; // ??? + t->a1.abs_min = itob(1); + t->a1.abs_min = itob(0); + t->a1.abs_min = itob(0); // DiskLength lba_to_msf(mediaLsnCount, &min, &sec, &frm); - tocBuff[22] = 0xA2; - tocBuff[27] = itob(min); - tocBuff[28] = itob(sec); - tocBuff[29] = itob(frm); + t->a2.addr_ctrl = 0x00; + t->a2.track_no = 0x00; + t->a2.index_no = 0xA2; // ??? + t->a2.abs_min = itob(min); + t->a2.abs_sec = itob(sec); + t->a2.abs_frm = itob(frm); // Later when PS2CCDA is added the tracks need to get filled in toc too. break; diff --git a/iop/cdvdman/src/scmd.c b/iop/cdvdman/src/scmd.c index 8dcc789..3b635f4 100644 --- a/iop/cdvdman/src/scmd.c +++ b/iop/cdvdman/src/scmd.c @@ -28,7 +28,7 @@ int sceCdReadClock(sceCdCLOCK *rtc) //------------------------------------------------------------------------- int sceCdGetDiskType(void) { - DPRINTF("%s() = %d\n", __FUNCTION__, cdvdman_stat.disc_type_reg); + DPRINTF("%s() = 0x%02X\n", __FUNCTION__, cdvdman_stat.disc_type_reg); return cdvdman_stat.disc_type_reg; } diff --git a/iop/common/cdvd_config.h b/iop/common/cdvd_config.h index 1683966..964cbe4 100644 --- a/iop/common/cdvd_config.h +++ b/iop/common/cdvd_config.h @@ -46,6 +46,9 @@ struct cdvdman_settings_bdm { struct cdvdman_settings_common common; + u32 drvName; /// Driver name: usb, ata, sdc, etc... + u32 devNr; /// Device number: 0, 1, 2, etc... + // Fragmented files: // 0 = ISO struct cdvdman_fragfile fragfile[BDM_MAX_FILES]; diff --git a/iop/imgdrv/src/imgdrv.c b/iop/imgdrv/src/imgdrv.c index 6b57ab1..9650dce 100644 --- a/iop/imgdrv/src/imgdrv.c +++ b/iop/imgdrv/src/imgdrv.c @@ -3,6 +3,9 @@ #include #include +#define MODNAME "img_driver" +IRX_ID(MODNAME, 1, 1); + unsigned int ioprpimg = 0xDEC1DEC1; int ioprpsiz = 0xDEC2DEC2; diff --git a/iop/resetspu/Makefile b/iop/resetspu/Makefile deleted file mode 100644 index 6109a05..0000000 --- a/iop/resetspu/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -IOP_OBJS = resetspu.o imports.o - -include ../../Defs.make -include ../Rules.bin.make -include ../Rules.make diff --git a/iop/resetspu/src/imports.lst b/iop/resetspu/src/imports.lst deleted file mode 100644 index d893388..0000000 --- a/iop/resetspu/src/imports.lst +++ /dev/null @@ -1,3 +0,0 @@ -intrman_IMPORTS_start -I_EnableIntr -intrman_IMPORTS_end diff --git a/iop/resetspu/src/irx_imports.h b/iop/resetspu/src/irx_imports.h deleted file mode 100644 index 744e120..0000000 --- a/iop/resetspu/src/irx_imports.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef IOP_IRX_IMPORTS_H -#define IOP_IRX_IMPORTS_H - -#include "irx.h" - -/* Please keep these in alphabetical order! */ -#include -#include - -#endif /* IOP_IRX_IMPORTS_H */ diff --git a/iop/resetspu/src/resetspu.c b/iop/resetspu/src/resetspu.c deleted file mode 100644 index 64d4a43..0000000 --- a/iop/resetspu/src/resetspu.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - resetspu.c Open PS2 Loader - - Copyright 2009-2010, Ifcaro, jimmikaelkael & Polo - Copyright 2006-2008 Polo - Licenced under Academic Free License version 3.0 - Review OpenUsbLd README & LICENSE files for further details. - Reset SPU function taken from PS2SDK freesd. - Copyright (c) 2004 TyRaNiD - Copyright (c) 2004,2007 Lukasz Bruun -*/ - -#include -#include -#include -#include - -static void nopdelay(void) -{ - unsigned int i; - - for (i = 0; i < 0x10000; i++) - asm volatile("nop\nnop\nnop\nnop\nnop"); -} - -static void spuReset(void) -{ - int core; - volatile u16 *statx; - - // Initialize SSBUS access to SPU2 - *U32_REGISTER(0x1404) = 0xBF900000; - *U32_REGISTER(0x140C) = 0xBF900800; - *U32_REGISTER(0x10F0) |= 0x80000; - *U32_REGISTER(0x1570) |= 8; - *U32_REGISTER(0x1014) = 0x200B31E1; - *U32_REGISTER(0x1414) = 0x200B31E1; - - // Stop SPU Dma Core 0 - *SD_DMA_CHCR(0) &= ~SD_DMA_START; - *U16_REGISTER(0x1B0) = 0; - - // Stop SPU Dma Core 1 - *SD_DMA_CHCR(1) &= ~SD_DMA_START; - *U16_REGISTER(0x1B0 + 1024) = 0; - - *SD_C_SPDIF_OUT = 0; - nopdelay(); - *SD_C_SPDIF_OUT = 0x8000; - nopdelay(); - - *U32_REGISTER(0x10F0) |= 0xB0000; - - for (core = 0; core < 2; core++) { - *U16_REGISTER(0x1B0) = 0; - *SD_CORE_ATTR(core) = 0; - nopdelay(); - *SD_CORE_ATTR(core) = SD_SPU2_ON; - - *SD_P_MVOLL(core) = 0; - *SD_P_MVOLR(core) = 0; - - statx = U16_REGISTER(0x344 + (core * 1024)); - - int i; - for (i = 0; i <= 0xf00; i++) { - if (!(*statx & 0x7FF)) - break; - } - - *SD_A_KOFF_HI(core) = 0xFFFF; - *SD_A_KOFF_LO(core) = 0xFFFF; // Should probably only be 0xFF - } - - *SD_S_PMON_HI(1) = 0; - *SD_S_PMON_LO(1) = 0; - *SD_S_NON_HI(1) = 0; - *SD_S_NON_LO(1) = 0; -} - -int _start(int argc, char **argv) -{ - spuReset(); - - /* Let the SPU2 assert any interrupt that it needed to assert here. - Otherwise, the IOP may crash when OSDSYS loads CLEARSPU, as its interrupt handler jumps to a NULL pointer. - For reasons, this doesn't seem to work when interrupts are enabled before the SPU reset. */ - EnableIntr(IOP_IRQ_DMA_SPU); - EnableIntr(IOP_IRQ_DMA_SPU2); - EnableIntr(IOP_IRQ_SPU); - - return MODULE_NO_RESIDENT_END; -}