diff --git a/README.md b/README.md index 7c88937..3cabaf2 100644 --- a/README.md +++ b/README.md @@ -100,8 +100,10 @@ Options: - 5: IOP: Emulate DVD-DL Multiple options possible, for example -gc=23 - -eC Enable debug colors - -eL Enable logo (adds rom0:PS2LOGO to arguments) + -cfg= Load extra user/game specific config file (without .toml extension) + + -dbc Enable debug colors + -logo Enable logo (adds rom0:PS2LOGO to arguments) --b Break, all following parameters are passed to the ELF diff --git a/ee/ee_core/src/iopmgr.c b/ee/ee_core/src/iopmgr.c index 06090aa..79a0331 100644 --- a/ee/ee_core/src/iopmgr.c +++ b/ee/ee_core/src/iopmgr.c @@ -19,6 +19,35 @@ extern int _iop_reboot_count; extern void *ModStorageStart; +#ifdef __EESIO_DEBUG +static void print_iop_args(int arg_len, const char *args) +{ + // Multiple null terminated strings together + int args_idx = 0; + int was_null = 1; + + if (arg_len == 0) + return; + + DPRINTF("IOP reboot arguments (arg_len=%d):\n", arg_len); + + // Search strings + while(args_idx < arg_len) { + if (args[args_idx] == 0) { + if (was_null == 1) { + DPRINTF("- args[%d]=0\n", args_idx); + } + was_null = 1; + } + else if (was_null == 1) { + DPRINTF("- args[%d]='%s'\n", args_idx, &args[args_idx]); + was_null = 0; + } + args_idx++; + } +} +#endif + /*----------------------------------------------------------------*/ /* Reset IOP to include our modules. */ /*----------------------------------------------------------------*/ @@ -33,7 +62,11 @@ int New_Reset_Iop(const char *arg, int arglen) irxtab_t *irxtable = (irxtab_t *)ModStorageStart; static int imgdrv_offset = 0; - DPRINTF("New_Reset_Iop start!\n"); + DPRINTF("%s()\n", __FUNCTION__); +#ifdef __EESIO_DEBUG + print_iop_args(arglen, arg); +#endif + if (EnableDebug) GS_BGCOLOUR = 0xFF00FF; // Purple @@ -45,20 +78,20 @@ int New_Reset_Iop(const char *arg, int arglen) sbv_patch_enable_lmb(); udnl_cmdlen = 0; - if (arglen > 0) { + if (arglen >= 10) { // Copy: rom0:UDNL or rom1:UDNL // - Are these the only update modules? Always 9 chars long? strncpy(udnl_mod, &arg[0], 10); // Make sure it's 0 terminated - udnl_mod[9] = '\0'; + udnl_mod[10-1] = '\0'; if (arglen > 10) { // Copy: arguments udnl_cmdlen = arglen-10; // length, including terminating 0 strncpy(udnl_cmd, &arg[10], udnl_cmdlen); - // Fix if 0 is not included - if (udnl_cmd[udnl_cmdlen-1] != 0) { + // Fix if 0 is not included in length + if (udnl_cmd[udnl_cmdlen-1] != '\0') { udnl_cmd[udnl_cmdlen] = '\0'; udnl_cmdlen++; } diff --git a/ee/ee_core/src/loadfile.c b/ee/ee_core/src/loadfile.c index 4448c81..4ebc2fa 100644 --- a/ee/ee_core/src/loadfile.c +++ b/ee/ee_core/src/loadfile.c @@ -370,14 +370,19 @@ int SifExecModuleBuffer(void *ptr, u32 size, u32 arg_len, const char *args, int /* Round the size up to the nearest 16 bytes. */ size = (size + 15) & -16; - // Estimate free IOP RAM + // Estimate largest free IOP RAM block up to 256 byte accuracy + // 12 iterations are needed void *ptemp = NULL; - u32 freemem = 1800*1024; - do { - freemem -= 4*1024; - ptemp = SifAllocIopHeap(freemem); - } while (ptemp == NULL); - SifFreeIopHeap(ptemp); + u32 freemem = 0; + u32 freecheck = 1024*1024; + while (freecheck > 256) { + ptemp = SifAllocIopHeap(freemem+freecheck); + if (ptemp != NULL) { + freemem += freecheck; + SifFreeIopHeap(ptemp); + } + freecheck /= 2; + } // Allocate large buffer, forcing the module buffer to be allocated in 'middle' memory ptemp = SifAllocIopHeap((freemem - size) / 2); diff --git a/ee/loader/config/system.toml b/ee/loader/config/system.toml index 5fe75b4..0cf7547 100644 --- a/ee/loader/config/system.toml +++ b/ee/loader/config/system.toml @@ -1,6 +1,27 @@ # Name of loaded config, to show to user name = "System settings and drivers" +# Default argument values +# Overwrite these from the command line +default_bsd = "no" +default_dvd = "no" +#default_ata0 = "mass:mydrive0.bin" +#default_ata0id = "mass:mydrive0_id.bin" +#default_ata1 = "mass:mydrive1.bin" +#default_mc0 = "mass:mymc0.bin" +#default_mc1 = "mass:mymc1.bin" +default_elf = "auto" +#default_mt = "dvd" +#default_gc = "12" +default_dbc = false +default_logo = false + +# Select the number of sectors for the FS buffer +# A small value can increase game compatibility +# A large value can increase performce +# Min=2, Max=128, Default=8 +cdvdman_fs_sectors = 8 + # Override the 8-byte string returned by: # - sceCdRI # This string is also used by: diff --git a/ee/loader/src/main.c b/ee/loader/src/main.c index a0340d5..d639c61 100644 --- a/ee/loader/src/main.c +++ b/ee/loader/src/main.c @@ -104,8 +104,10 @@ void print_usage() printf(" - 5: IOP: Emulate DVD-DL\n"); printf(" Multiple options possible, for example -gc=23\n"); printf("\n"); - printf(" -eC Enable debug colors\n"); - printf(" -eL Enable logo (adds rom0:PS2LOGO to arguments)\n"); + printf(" -cfg= Load extra user/game specific config file (without .toml extension)\n"); + printf("\n"); + printf(" -dbc Enable debug colors\n"); + printf(" -logo Enable logo (adds rom0:PS2LOGO to arguments)\n"); printf("\n"); printf(" --b Break, all following parameters are passed to the ELF\n"); printf("\n"); @@ -139,6 +141,22 @@ struct SFakeList { }; struct SSystemSettings { + char *sBSD; + char *sDVDMode; + char *sATA0File; + char *sATA0IDFile; + char *sATA1File; + char *sMC0File; + char *sMC1File; + char *sELFFile; + char *sMT; + char *sGC; + char *sCFGFile; + int bDebugColors; + int bLogo; + + uint8_t fs_sectors; + union { uint8_t ilink_id[8]; uint64_t ilink_id_int; @@ -277,7 +295,7 @@ struct SModule *modlist_get_by_udnlname(struct SModList *ml, const char *name) return NULL; } -static void print_iop_args(int arg_len, char *args) +static void print_iop_args(int arg_len, const char *args) { // Multiple null terminated strings together int args_idx = 0; @@ -586,6 +604,9 @@ int fakelist_add_array(struct SFakeList *fl, toml_table_t *tbl_root) void driver_init() { + // Initialize system structure + memset(&sys, 0, sizeof(struct SSystemSettings)); + // Initialize driver structure memset(&drv, 0, sizeof(struct SDriver)); drv.mod_all_env.mod = malloc(DRV_MAX_MOD * sizeof(struct SModule)); // NOTE: never freed, but we don't care @@ -598,6 +619,23 @@ void driver_init() memset(drv.fake.fake, 0, MODULE_SETTINGS_MAX_FAKE_COUNT * sizeof(struct FakeModule)); } +void toml_string_in_overwrite(toml_table_t *t, const char *name, char **dest) +{ + toml_datum_t v = toml_string_in(t, name); + if (v.ok) { + if (*dest != NULL) + free (*dest); + *dest = v.u.s; + } +} + +void toml_bool_in_overwrite(toml_table_t *t, const char *name, int *dest) +{ + toml_datum_t v = toml_bool_in(t, name); + if (v.ok) + *dest = v.u.b; +} + int load_driver(const char * type, const char * subtype) { FILE* fp; @@ -638,6 +676,25 @@ int load_driver(const char * type, const char * subtype) free(v.u.s); } + toml_string_in_overwrite(tbl_root, "default_bsd", &sys.sBSD); + toml_string_in_overwrite(tbl_root, "default_dvd", &sys.sDVDMode); + toml_string_in_overwrite(tbl_root, "default_ata0", &sys.sATA0File); + toml_string_in_overwrite(tbl_root, "default_ata0id", &sys.sATA0IDFile); + toml_string_in_overwrite(tbl_root, "default_ata1", &sys.sATA1File); + toml_string_in_overwrite(tbl_root, "default_mc0", &sys.sMC0File); + toml_string_in_overwrite(tbl_root, "default_mc1", &sys.sMC1File); + toml_string_in_overwrite(tbl_root, "default_elf", &sys.sELFFile); + toml_string_in_overwrite(tbl_root, "default_mt", &sys.sMT); + toml_string_in_overwrite(tbl_root, "default_gc", &sys.sGC); + toml_string_in_overwrite(tbl_root, "default_cfg", &sys.sCFGFile); + toml_bool_in_overwrite (tbl_root, "default_dbc", &sys.bDebugColors); + toml_bool_in_overwrite (tbl_root, "default_logo", &sys.bLogo); + + // Number of sectors for fs buffer in cdvdman_emu + v = toml_int_in(tbl_root, "cdvdman_fs_sectors"); + if (v.ok) + sys.fs_sectors = v.u.i; + arr = toml_array_in(tbl_root, "ilink_id"); if (arr != NULL) { if (toml_array_nelem(arr) == 8) { @@ -781,50 +838,54 @@ int main(int argc, char *argv[]) printf("- By Maximus32 -\n"); printf("--------------------------------\n"); - const char *sBSD = "no"; - const char *sDVDMode = "no"; + /* + * Initialiaze main driver structure before filling it from config files + */ + driver_init(); + + /* + * Load system settings + */ + if (load_driver("system", NULL) < 0) { + printf("ERROR: failed to load system settings\n"); + return -1; + } + + /* + * Parse user commands + */ const char *sDVDFile = NULL; const char *sATAMode = "no"; - const char *sATA0File = NULL; - const char *sATA0IDFile = NULL; - const char *sATA1File = NULL; const char *sMCMode = "no"; - const char *sMC0File = NULL; - const char *sMC1File = NULL; - const char *sELFFile = "auto"; int iELFArgcStart = -1; - const char *sMediaType = NULL; - const char *sCompat = NULL; u32 iCompat = 0; enum SCECdvdMediaType eMediaType = SCECdNODISC; - bool bEnableDebugColors = false; - bool bEnablePS2Logo = false; for (i=1; imedia = eMediaType; set_cdvdman->layer1_start = layer1_lba_start; + set_cdvdman->fs_sectors = sys.fs_sectors; if (sys.ilink_id_int != 0) { printf("Overriding i.Link ID: %2x %2x %2x %2x %2x %2x %2x %2x\n" , sys.ilink_id[0] @@ -1258,7 +1317,7 @@ int main(int argc, char *argv[]) /* * Figure out the the elf file to start automatically from the SYSTEM.CNF */ - if (strcmp(sELFFile, "auto") == 0) { + if (strcmp(sys.sELFFile, "auto") == 0) { if (sDVDFile != NULL) { /* * Mount as ISO so we can get ELF name to boot @@ -1282,16 +1341,16 @@ int main(int argc, char *argv[]) read(fd_system_cnf, system_cnf_data, 128); // Locate and set ELF file name - sELFFile = strstr(system_cnf_data, "cdrom0:"); + sys.sELFFile = strstr(system_cnf_data, "cdrom0:"); char *fname_end = strstr(system_cnf_data, ";1"); - if (sELFFile == NULL || fname_end == NULL) { + if (sys.sELFFile == NULL || fname_end == NULL) { printf("ERROR: file name not found in SYSTEM.CNF\n"); return -1; } fname_end[2] = '\0'; // Locate and set GameID - memcpy(sGameID, &sELFFile[8], 11); + memcpy(sGameID, &sys.sELFFile[8], 11); sGameID[11] = '\0'; close(fd_system_cnf); @@ -1333,7 +1392,7 @@ int main(int argc, char *argv[]) /* * Enable ATA0 emulation */ - if (sATA0File != NULL) { + if (sys.sATA0File != NULL) { // Check for FHI backing store if (set_fhi_bdm == NULL || mod_fhi == NULL) { printf("ERROR: ATA emulator needs FHI backing store!\n"); @@ -1342,11 +1401,11 @@ int main(int argc, char *argv[]) // Make sure the FHI module gets loaded mod_fhi->sUDNL = NULL; // Load fragfile - if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_ATA0, sATA0File) < 0) + if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_ATA0, sys.sATA0File) < 0) return -1; // if ata 0 is ok, load HDD ID file - if (sATA0IDFile != NULL) { - if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_ATA0ID, sATA0IDFile) < 0) + if (sys.sATA0IDFile != NULL) { + if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_ATA0ID, sys.sATA0IDFile) < 0) return -1; } } @@ -1354,7 +1413,7 @@ int main(int argc, char *argv[]) /* * Enable ATA1 emulation */ - if (sATA1File != NULL) { + if (sys.sATA1File != NULL) { // Check for FHI backing store if (set_fhi_bdm == NULL || mod_fhi == NULL) { printf("ERROR: ATA emulator needs FHI backing store!\n"); @@ -1363,14 +1422,14 @@ int main(int argc, char *argv[]) // Make sure the FHI module gets loaded mod_fhi->sUDNL = NULL; // Load fragfile - if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_ATA1, sATA1File) < 0) + if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_ATA1, sys.sATA1File) < 0) return -1; } /* * Enable MC0 emulation */ - if (sMC0File != NULL) { + if (sys.sMC0File != NULL) { // Check for FHI backing store if (set_fhi_bdm == NULL || mod_fhi == NULL) { printf("ERROR: ATA emulator needs FHI backing store!\n"); @@ -1379,14 +1438,14 @@ int main(int argc, char *argv[]) // Make sure the FHI module gets loaded mod_fhi->sUDNL = NULL; // Load fragfile - if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_MC0, sMC0File) < 0) + if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_MC0, sys.sMC0File) < 0) return -1; } /* * Enable MC1 emulation */ - if (sMC1File != NULL) { + if (sys.sMC1File != NULL) { // Check for FHI backing store if (set_fhi_bdm == NULL || mod_fhi == NULL) { printf("ERROR: ATA emulator needs FHI backing store!\n"); @@ -1395,11 +1454,11 @@ int main(int argc, char *argv[]) // Make sure the FHI module gets loaded mod_fhi->sUDNL = NULL; // Load fragfile - if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_MC1, sMC1File) < 0) + if (fhi_bdm_add_file(set_fhi_bdm, FHI_FID_MC1, sys.sMC1File) < 0) return -1; } - printf("ELF file: %s\n", sELFFile); + printf("ELF file: %s\n", sys.sELFFile); printf("GameID: %s\n", sGameID); /* @@ -1542,13 +1601,13 @@ int main(int argc, char *argv[]) //eecc_setGameMode(&eeconf, "-"); // FIXME: implement or remove if (sGameID[0] != 0) eecc_setGameID(&eeconf, sGameID); - eecc_setELFName(&eeconf, sELFFile); + eecc_setELFName(&eeconf, sys.sELFFile); eecc_setELFArgs(&eeconf, argc-iELFArgcStart, (const char **)&argv[iELFArgcStart]); eecc_setKernelConfig(&eeconf, eeloadCopy, initUserMemory); eecc_setModStorageConfig(&eeconf, irxtable, irxptr); eecc_setCompatFlags(&eeconf, iCompat); - eecc_setDebugColors(&eeconf, bEnableDebugColors); - eecc_setPS2Logo(&eeconf, bEnablePS2Logo); + eecc_setDebugColors(&eeconf, sys.bDebugColors); + eecc_setPS2Logo(&eeconf, sys.bLogo); printf("Starting ee_core with following arguments:\n"); eecc_print(&eeconf); diff --git a/iop/cdvdfsv/src/cdvdfsv-internal.h b/iop/cdvdfsv/src/cdvdfsv-internal.h index fdfd5af..28b5427 100644 --- a/iop/cdvdfsv/src/cdvdfsv-internal.h +++ b/iop/cdvdfsv/src/cdvdfsv-internal.h @@ -28,6 +28,9 @@ extern void cdvdfsv_register_ncmd_rpc(SifRpcDataQueue_t *rpc_DQ); extern void cdvdfsv_register_searchfile_rpc(SifRpcDataQueue_t *rpc_DQ); extern void sysmemSendEE(void *buf, void *EE_addr, int size); extern int sceCdChangeThreadPriority(int priority); + extern u8 *cdvdfsv_buf; +extern int cdvdfsv_size; +extern int cdvdfsv_sectors; #endif diff --git a/iop/cdvdfsv/src/cdvdfsv.c b/iop/cdvdfsv/src/cdvdfsv.c index 844eec7..f383381 100644 --- a/iop/cdvdfsv/src/cdvdfsv.c +++ b/iop/cdvdfsv/src/cdvdfsv.c @@ -28,6 +28,8 @@ static void *cbrpc_cddiskready2(int fno, void *buf, int size); static void *cbrpc_S596(int fno, void *buf, int size); u8 *cdvdfsv_buf; +int cdvdfsv_size; +int cdvdfsv_sectors; static SifRpcDataQueue_t rpc0_DQ; static SifRpcDataQueue_t rpc1_DQ; @@ -133,7 +135,9 @@ static void init_thread(void *args) { sceSifInitRpc(0); - cdvdfsv_buf = sceGetFsvRbuf(); + cdvdfsv_size = 4096; + cdvdfsv_buf = sceGetFsvRbuf2(&cdvdfsv_size); + cdvdfsv_sectors = cdvdfsv_size / 2048; cdvdfsv_startrpcthreads(); ExitDeleteThread(); diff --git a/iop/cdvdfsv/src/imports.lst b/iop/cdvdfsv/src/imports.lst index c4b99dd..8443d17 100644 --- a/iop/cdvdfsv/src/imports.lst +++ b/iop/cdvdfsv/src/imports.lst @@ -17,7 +17,7 @@ I_sceCdApplySCmd I_sceCdPause I_sceCdBreak I_sceCdGetReadPos -I_sceGetFsvRbuf +I_sceGetFsvRbuf2 I_sceCdSC I_sceCdStInit I_sceCdStRead diff --git a/iop/cdvdfsv/src/irx_imports.h b/iop/cdvdfsv/src/irx_imports.h index b840862..8bd3342 100644 --- a/iop/cdvdfsv/src/irx_imports.h +++ b/iop/cdvdfsv/src/irx_imports.h @@ -3,6 +3,7 @@ #include +#define I_sceGetFsvRbuf2 DECLARE_IMPORT(47, sceGetFsvRbuf2) #include #include #include diff --git a/iop/cdvdfsv/src/ncmd.c b/iop/cdvdfsv/src/ncmd.c index 65fabcb..6552a94 100644 --- a/iop/cdvdfsv/src/ncmd.c +++ b/iop/cdvdfsv/src/ncmd.c @@ -175,16 +175,16 @@ static inline void cdvd_readee(void *buf) if (flag_64b == 0) { // not 64 bytes aligned buf // The data of the last sector of the chunk will be used to correct buffer alignment. - if (sectors_to_read < CDVDMAN_FS_SECTORS - 1) + if (sectors_to_read < cdvdfsv_sectors - 1) nsectors = sectors_to_read; else - nsectors = CDVDMAN_FS_SECTORS - 1; + nsectors = cdvdfsv_sectors - 1; temp = nsectors + 1; } else { // 64 bytes aligned buf - if (sectors_to_read < CDVDMAN_FS_SECTORS) + if (sectors_to_read < cdvdfsv_sectors) nsectors = sectors_to_read; else - nsectors = CDVDMAN_FS_SECTORS; + nsectors = cdvdfsv_sectors; temp = nsectors; } @@ -346,7 +346,7 @@ static inline void cdvd_readchain(void *buf) readpos += tsectors * 2048; } else { // EE addr while (tsectors > 0) { - nsectors = (tsectors > CDVDMAN_FS_SECTORS) ? CDVDMAN_FS_SECTORS : tsectors; + nsectors = (tsectors > cdvdfsv_sectors) ? cdvdfsv_sectors : tsectors; if (sceCdRead(lsn, nsectors, cdvdfsv_buf, NULL) == 0) { if (sceCdGetError() == SCECdErNO) { diff --git a/iop/cdvdman_emu/src/cdvdman.c b/iop/cdvdman_emu/src/cdvdman.c index 7fa30d8..da131f1 100644 --- a/iop/cdvdman_emu/src/cdvdman.c +++ b/iop/cdvdman_emu/src/cdvdman.c @@ -43,6 +43,7 @@ static iop_sys_clock_t gCallbackSysClock; // buffers u8 cdvdman_buf[CDVDMAN_BUF_SECTORS * 2048]; +u8 *cdvdman_fs_buf; #define CDVDMAN_MODULE_VERSION 0x225 static int cdvdman_debug_print_flag = 0; @@ -624,6 +625,13 @@ int _start(int argc, char **argv) // Setup the callback timer. USec2SysClock((cdvdman_settings.flags & IOPCORE_COMPAT_ACCU_READS) ? 5000 : 0, &gCallbackSysClock); + // Limit min/max sectors + if (cdvdman_settings.fs_sectors < 2) + cdvdman_settings.fs_sectors = 2; + if (cdvdman_settings.fs_sectors > 128) + cdvdman_settings.fs_sectors = 128; + cdvdman_fs_buf = AllocSysMemory(0, cdvdman_settings.fs_sectors * 2048 + CDVDMAN_FS_BUF_ALIGNMENT, NULL); + // create SCMD/searchfile semaphores cdvdman_create_semaphores(); diff --git a/iop/cdvdman_emu/src/exports.tab b/iop/cdvdman_emu/src/exports.tab index 40a5898..4064e25 100644 --- a/iop/cdvdman_emu/src/exports.tab +++ b/iop/cdvdman_emu/src/exports.tab @@ -58,7 +58,7 @@ DECLARE_EXPORT_TABLE(cdvdman, 1, 1) DECLARE_EXPORT(sceCdGetReadPos) DECLARE_EXPORT(_dummy) // sceCdCtrlADout DECLARE_EXPORT(_dummy) // sceCdNop - DECLARE_EXPORT(sceGetFsvRbuf) + DECLARE_EXPORT(sceGetFsvRbuf2) DECLARE_EXPORT(_dummy) // sceCdstm0Cb DECLARE_EXPORT(_dummy) // sceCdstm1Cb DECLARE_EXPORT(sceCdSC) // 50 diff --git a/iop/cdvdman_emu/src/imports.lst b/iop/cdvdman_emu/src/imports.lst index 9dda96d..4760d3f 100644 --- a/iop/cdvdman_emu/src/imports.lst +++ b/iop/cdvdman_emu/src/imports.lst @@ -22,11 +22,10 @@ I_EnableIntr I_RegisterIntrHandler intrman_IMPORTS_end -//#ifdef DEBUG sysmem_IMPORTS_start +I_AllocSysMemory I_QueryTotalFreeMemSize sysmem_IMPORTS_end -//#endif loadcore_IMPORTS_start I_FlushDcache diff --git a/iop/cdvdman_emu/src/internal.h b/iop/cdvdman_emu/src/internal.h index 69c0d43..c22478d 100644 --- a/iop/cdvdman_emu/src/internal.h +++ b/iop/cdvdman_emu/src/internal.h @@ -116,6 +116,8 @@ extern struct cdvdman_settings_common cdvdman_settings; // Normally this buffer is only used by 'searchfile', only 1 sector used #define CDVDMAN_BUF_SECTORS 1 extern u8 cdvdman_buf[CDVDMAN_BUF_SECTORS * 2048]; +#define CDVDMAN_FS_BUF_ALIGNMENT 64 +extern u8 *cdvdman_fs_buf; extern int cdrom_io_sema; extern int cdvdman_searchfilesema; diff --git a/iop/cdvdman_emu/src/ioops.c b/iop/cdvdman_emu/src/ioops.c index f6ab17a..4e33ed5 100644 --- a/iop/cdvdman_emu/src/ioops.c +++ b/iop/cdvdman_emu/src/ioops.c @@ -17,9 +17,6 @@ typedef struct #define MAX_FDHANDLES 64 FHANDLE cdvdman_fdhandles[MAX_FDHANDLES]; -#define CDVDFSV_ALIGNMENT 64 -static u8 cdvdman_fs_buf[CDVDMAN_FS_SECTORS * 2048 + CDVDFSV_ALIGNMENT]; - // for "cdrom" ioctl2 #define CIOCSTREAMPAUSE 0x630D #define CIOCSTREAMRESUME 0x630E @@ -575,8 +572,9 @@ static int cdrom_ioctl2(iop_file_t *f, int cmd, void *args, unsigned int arglen, } //------------------------------------------------------------------------- -void *sceGetFsvRbuf(void) +void *sceGetFsvRbuf2(int *size) { + *size = cdvdman_settings.fs_sectors * 2048 + CDVDMAN_FS_BUF_ALIGNMENT; return cdvdman_fs_buf; } diff --git a/iop/common/cdvd_config.h b/iop/common/cdvd_config.h index bce7445..4d90621 100644 --- a/iop/common/cdvd_config.h +++ b/iop/common/cdvd_config.h @@ -17,6 +17,7 @@ struct cdvdman_settings_common u32 magic; u8 media; + u8 fs_sectors; // Number of sectors to allocate for sector buffer u16 flags; u32 layer1_start; diff --git a/iop/common/cdvdman_opl.h b/iop/common/cdvdman_opl.h index 591579b..b4a6324 100644 --- a/iop/common/cdvdman_opl.h +++ b/iop/common/cdvdman_opl.h @@ -62,9 +62,7 @@ enum CDIOC_CODE { CDIOC_GETINTREVENTFLG = CDIOC_FNUM(0x91), }; -// DMA/reading alignment correction buffer. Used by CDVDMAN and CDVDFSV. -// The minimum size is 2, as one sector may be used for buffer alignment correction. -#define CDVDMAN_FS_SECTORS 8 +void *sceGetFsvRbuf2(int *size); // Codes for use with sceCdSC() #define CDSC_GET_DEBUG_STATUS 0xFFFFFFF0 // Get debug status flag.