From 66cf864ee06e11dad4ed3a03233e5aa71a43ea47 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Mon, 13 Jul 2015 22:06:16 +0300 Subject: [PATCH 1/4] Fix saving and some more logging Fixes Shin Hayarigami (BLJS10279). --- rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp | 45 +++++++++++++++++---- rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 18 +-------- rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp | 24 ++++++++--- rpcs3/Loader/TRP.cpp | 2 +- 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp index 9556a2da4d..8b6d66b328 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp @@ -57,6 +57,7 @@ never_inline s32 savedata_op( if (!lock) { + cellSysutil.Error("savedata_op(): failed to lock the mutex."); return CELL_SAVEDATA_ERROR_BUSY; } @@ -191,6 +192,7 @@ never_inline s32 savedata_op( if (result->result < 0) { + cellSysutil.Error("savedata_op(): funcList returned result < 0."); return CELL_SAVEDATA_ERROR_CBRESULT; } @@ -302,6 +304,7 @@ never_inline s32 savedata_op( if (result->result < 0) { + cellSysutil.Error("savedata_op(): funcFixed returned result < 0."); return CELL_SAVEDATA_ERROR_CBRESULT; } @@ -343,10 +346,39 @@ never_inline s32 savedata_op( PSFLoader psf; + // Create save directory if necessary + if (save_entry.isNew) + { + if (!Emu.GetVFS().ExistsDir(dir_path) && !Emu.GetVFS().CreateDir(dir_path)) + { + // Let's ignore this error for now + } + else + { + std::string rSfo_path = "/dev_hdd0/game/" + save_entry.dirName.substr(0, 9) + "/PS3_GAME/PARAM.SFO"; // The real SFO path + if (!Emu.GetVFS().ExistsFile(rSfo_path)) + { + rSfo_path = "/dev_hdd0/game/" + save_entry.dirName.substr(0, 9) + "/PARAM.SFO"; + } + + vfsFile rSfo(rSfo_path); + PSFLoader rPsf(rSfo); + psf.Clear(); + psf.SetInteger("ATTRIBUTE", rPsf.GetInteger("ATTRIBUTE")); + psf.SetString("TITLE", rPsf.GetString("TITLE")); + psf.SetString("SUB_TITLE", rPsf.GetString("SUB_TITLE")); + psf.SetString("DETAIL", rPsf.GetString("DETAIL")); + psf.SetString("SAVEDATA_LIST_PARAM", rPsf.GetString("SAVEDATA_LIST_PARAM")); + } + } + // Load PARAM.SFO { - vfsFile f(sfo_path); - psf.Load(f); + if (!save_entry.isNew) + { + vfsFile f(sfo_path); + psf.Load(f); + } } // Get save stats @@ -436,6 +468,7 @@ never_inline s32 savedata_op( if (result->result < 0) { + cellSysutil.Error("savedata_op(): funcStat returned result < 0."); return CELL_SAVEDATA_ERROR_CBRESULT; } @@ -485,12 +518,6 @@ never_inline s32 savedata_op( } } - // Create save directory if necessary - if (save_entry.isNew && !Emu.GetVFS().CreateDir(dir_path)) - { - // Let's ignore this error for now - } - // Enter the loop where the save files are read/created/deleted vm::stackvar fileGet(CPU); vm::stackvar fileSet(CPU); @@ -504,6 +531,7 @@ never_inline s32 savedata_op( if (result->result < 0) { + cellSysutil.Error("savedata_op(): funcFile returned result < 0."); return CELL_SAVEDATA_ERROR_CBRESULT; } @@ -605,6 +633,7 @@ never_inline s32 savedata_op( // Write PARAM.SFO if (psf) { + cellSysutil.Error("psf: true"); vfsFile f(sfo_path, vfsWriteNew); psf.Save(f); } diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index a02614fc34..d96cb33601 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -191,14 +191,7 @@ s32 sceNpDrmGetTimelimit(vm::ptr path, vm::ptr time_remain) s32 sceNpDrmProcessExitSpawn(vm::cptr path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags) { - sceNp.Warning("sceNpDrmProcessExitSpawn()"); - sceNp.Warning("path: %s", path.get_ptr()); - sceNp.Warning("argv: 0x%x", argv_addr); - sceNp.Warning("envp: 0x%x", envp_addr); - sceNp.Warning("data: 0x%x", data_addr); - sceNp.Warning("data_size: 0x%x", data_size); - sceNp.Warning("prio: %d", prio); - sceNp.Warning("flags: %d", flags); + sceNp.Warning("sceNpDrmProcessExitSpawn() -> sys_game_process_exitspawn"); sys_game_process_exitspawn(path, argv_addr, envp_addr, data_addr, data_size, prio, flags); @@ -207,14 +200,7 @@ s32 sceNpDrmProcessExitSpawn(vm::cptr path, u32 argv_addr, u32 envp_addr, s32 sceNpDrmProcessExitSpawn2(vm::cptr path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags) { - sceNp.Warning("sceNpDrmProcessExitSpawn2()"); - sceNp.Warning("path: %s", path.get_ptr()); - sceNp.Warning("argv: 0x%x", argv_addr); - sceNp.Warning("envp: 0x%x", envp_addr); - sceNp.Warning("data: 0x%x", data_addr); - sceNp.Warning("data_size: 0x%x", data_size); - sceNp.Warning("prio: %d", prio); - sceNp.Warning("flags: %d", flags); + sceNp.Warning("sceNpDrmProcessExitSpawn2() -> sys_game_process_exitspawn2"); sys_game_process_exitspawn2(path, argv_addr, envp_addr, data_addr, data_size, prio, flags); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp index be1a709d89..8366138ff3 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp @@ -157,6 +157,7 @@ s32 sceNpTrophyRegisterContext(PPUThread& CPU, u32 context, u32 handle, vm::ptr< if (!ctxt) { + sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT"); return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT; } @@ -164,43 +165,56 @@ s32 sceNpTrophyRegisterContext(PPUThread& CPU, u32 context, u32 handle, vm::ptr< if (!hndl) { + sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE"); return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE; } TRPLoader trp(*ctxt->trp_stream); if (!trp.LoadHeader()) + { + sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE"); return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; + } // Rename or discard certain entries based on the files found const size_t kTargetBufferLength = 31; - char target[kTargetBufferLength+1]; + char target[kTargetBufferLength + 1]; target[kTargetBufferLength] = 0; strcpy_trunc(target, fmt::Format("TROP_%02d.SFM", Ini.SysLanguage.GetValue())); - if (trp.ContainsEntry(target)) { + if (trp.ContainsEntry(target)) + { trp.RemoveEntry("TROPCONF.SFM"); trp.RemoveEntry("TROP.SFM"); trp.RenameEntry(target, "TROPCONF.SFM"); } - else if (trp.ContainsEntry("TROP.SFM")) { + else if (trp.ContainsEntry("TROP.SFM")) + { trp.RemoveEntry("TROPCONF.SFM"); trp.RenameEntry("TROP.SFM", "TROPCONF.SFM"); } - else if (!trp.ContainsEntry("TROPCONF.SFM")) { + else if (!trp.ContainsEntry("TROPCONF.SFM")) + { return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } // Discard unnecessary TROP_XX.SFM files - for (s32 i=0; i<=18; i++) { + for (s32 i = 0; i <= 18; i++) + { strcpy_trunc(target, fmt::Format("TROP_%02d.SFM", i)); if (i != Ini.SysLanguage.GetValue()) + { trp.RemoveEntry(target); + } } // TODO: Get the path of the current user std::string trophyPath = "/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name; if (!trp.Install(trophyPath)) + { + sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE"); return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; + } TROPUSRLoader* tropusr = new TROPUSRLoader(); std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT"; diff --git a/rpcs3/Loader/TRP.cpp b/rpcs3/Loader/TRP.cpp index 4ced4804d6..77b0763061 100644 --- a/rpcs3/Loader/TRP.cpp +++ b/rpcs3/Loader/TRP.cpp @@ -16,7 +16,7 @@ TRPLoader::~TRPLoader() bool TRPLoader::Install(std::string dest, bool show) { - if(!trp_f.IsOpened()) + if (!trp_f.IsOpened()) return false; if (!dest.empty() && dest.back() != '/') From ddcaf4972fc898697c9c045d1560530bd1301509 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Tue, 14 Jul 2015 14:45:31 +0300 Subject: [PATCH 2/4] Better fix for savedata and cellCamera improvements --- rpcs3/Emu/SysCalls/Modules/cellCamera.cpp | 16 ++++++++++----- rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp | 22 +++++++-------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp index 2a62b2a9ea..73b41413ab 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellCamera.cpp @@ -121,25 +121,31 @@ s32 cellCameraGetType(s32 dev_num, vm::ptr type) s32 cellCameraIsAvailable(s32 dev_num) { - UNIMPLEMENTED_FUNC(cellCamera); + cellCamera.Todo("cellCameraIsAvailable(dev_num=%d)", dev_num); return CELL_OK; } s32 cellCameraIsAttached(s32 dev_num) { - UNIMPLEMENTED_FUNC(cellCamera); - return CELL_OK; + cellCamera.Warning("cellCameraIsAttached(dev_num=%d)", dev_num); + + if (Ini.Camera.GetValue() == 1) + { + return 1; + } + + return CELL_OK; // CELL_OK means that no camera is attached } s32 cellCameraIsOpen(s32 dev_num) { - UNIMPLEMENTED_FUNC(cellCamera); + cellCamera.Todo("cellCameraIsOpen(dev_num=%d)", dev_num); return CELL_OK; } s32 cellCameraIsStarted(s32 dev_num) { - UNIMPLEMENTED_FUNC(cellCamera); + cellCamera.Todo("cellCameraIsStarted(dev_num=%d)", dev_num); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp index 8b6d66b328..e093675d72 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp @@ -351,24 +351,16 @@ never_inline s32 savedata_op( { if (!Emu.GetVFS().ExistsDir(dir_path) && !Emu.GetVFS().CreateDir(dir_path)) { - // Let's ignore this error for now + cellSysutil.Error("savedata_op(): Savedata directory creation failed."); } else { - std::string rSfo_path = "/dev_hdd0/game/" + save_entry.dirName.substr(0, 9) + "/PS3_GAME/PARAM.SFO"; // The real SFO path - if (!Emu.GetVFS().ExistsFile(rSfo_path)) - { - rSfo_path = "/dev_hdd0/game/" + save_entry.dirName.substr(0, 9) + "/PARAM.SFO"; - } - - vfsFile rSfo(rSfo_path); - PSFLoader rPsf(rSfo); - psf.Clear(); - psf.SetInteger("ATTRIBUTE", rPsf.GetInteger("ATTRIBUTE")); - psf.SetString("TITLE", rPsf.GetString("TITLE")); - psf.SetString("SUB_TITLE", rPsf.GetString("SUB_TITLE")); - psf.SetString("DETAIL", rPsf.GetString("DETAIL")); - psf.SetString("SAVEDATA_LIST_PARAM", rPsf.GetString("SAVEDATA_LIST_PARAM")); + // Is loading the PARAM.SFO really necessary? Setting empty stuff seems to fix a couple games. + psf.SetInteger("ATTRIBUTE", 0); + psf.SetString("TITLE", ""); + psf.SetString("SUB_TITLE", ""); + psf.SetString("DETAIL", ""); + psf.SetString("SAVEDATA_LIST_PARAM", ""); } } From 80b544aa78def200d5bd0da14c08567fc749ee3b Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Tue, 14 Jul 2015 15:07:23 +0300 Subject: [PATCH 3/4] Add sceNp2 and some sceNpMatching2 functions --- rpcs3/Emu/SysCalls/ModuleManager.cpp | 3 +- rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp | 1 - rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 56 +++---- rpcs3/Emu/SysCalls/Modules/sceNp.h | 137 +++++++++++++-- rpcs3/Emu/SysCalls/Modules/sceNp2.cpp | 174 ++++++++++++++++++++ rpcs3/emucore.vcxproj | 1 + rpcs3/emucore.vcxproj.filters | 3 + 7 files changed, 332 insertions(+), 43 deletions(-) create mode 100644 rpcs3/Emu/SysCalls/Modules/sceNp2.cpp diff --git a/rpcs3/Emu/SysCalls/ModuleManager.cpp b/rpcs3/Emu/SysCalls/ModuleManager.cpp index 1fd79115ed..64c673911c 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.cpp +++ b/rpcs3/Emu/SysCalls/ModuleManager.cpp @@ -46,6 +46,7 @@ extern Module cellVoice; extern Module cellVpost; extern Module libmixer; extern Module sceNp; +extern Module sceNp2; extern Module sceNpClans; extern Module sceNpCommerce2; extern Module sceNpSns; @@ -117,7 +118,7 @@ static const g_module_list[] = { 0x0035, "cellSysutilRec", nullptr }, { 0x0036, "cellVideoExport", nullptr }, { 0x0037, "cellGameExec", nullptr }, - { 0x0038, "sceNp2", nullptr }, + { 0x0038, "sceNp2", &sceNp2 }, { 0x0039, "cellSysutilAp", &cellSysutilAp }, { 0x003a, "cellSysutilNpClans", nullptr }, { 0x003b, "cellSysutilOskExt", nullptr }, diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp index e093675d72..474e400e99 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp @@ -625,7 +625,6 @@ never_inline s32 savedata_op( // Write PARAM.SFO if (psf) { - cellSysutil.Error("psf: true"); vfsFile f(sfo_path, vfsWriteNew); psf.Save(f); } diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index d96cb33601..8b921e77ff 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -15,14 +15,12 @@ extern Module sceNp; struct sceNpInternal { bool m_bSceNpInitialized; - bool m_bSceNp2Initialized; bool m_bScoreInitialized; bool m_bLookupInitialized; bool m_bSceNpUtilBandwidthTestInitialized; sceNpInternal() : m_bSceNpInitialized(false), - m_bSceNp2Initialized(false), m_bScoreInitialized(false), m_bLookupInitialized(false), m_bSceNpUtilBandwidthTestInitialized(false) @@ -32,54 +30,53 @@ struct sceNpInternal sceNpInternal sceNpInstance; -s32 sceNpInit(u32 mem_size, u32 mem_addr) +s32 sceNpInit(u32 poolsize, vm::ptr poolptr) { - sceNp.Warning("sceNpInit(mem_size=0x%x, mem_addr=0x%x)", mem_size, mem_addr); + sceNp.Warning("sceNpInit(poolsize=%d, poolptr=0x%x)", poolsize, poolptr); if (sceNpInstance.m_bSceNpInitialized) + { + sceNp.Error("sceNpInit(): sceNp has been already initialized."); return SCE_NP_ERROR_ALREADY_INITIALIZED; + } + + if (poolsize == 0) + { + sceNp.Error("sceNpInit(): poolsize given is 0."); + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + else if (poolsize < 128 * 1024) + { + sceNp.Error("sceNp2Init(): poolsize given is under 131072 bytes."); + return SCE_NP_ERROR_INSUFFICIENT_BUFFER; + } + + if (!poolptr) + { + sceNp.Error("sceNpInit(): poolptr is invalid."); + return SCE_NP_ERROR_INVALID_ARGUMENT; + } sceNpInstance.m_bSceNpInitialized = true; return CELL_OK; } -s32 sceNp2Init(u32 mem_size, u32 mem_addr) -{ - sceNp.Warning("sceNp2Init(mem_size=0x%x, mem_addr=0x%x)", mem_size, mem_addr); - - if (sceNpInstance.m_bSceNp2Initialized) - return SCE_NP_ERROR_ALREADY_INITIALIZED; - - sceNpInstance.m_bSceNp2Initialized = true; - - return CELL_OK; -} - s32 sceNpTerm() { sceNp.Warning("sceNpTerm()"); if (!sceNpInstance.m_bSceNpInitialized) + { + sceNp.Error("sceNpTerm(): sceNp has not been intialized."); return SCE_NP_ERROR_NOT_INITIALIZED; + } sceNpInstance.m_bSceNpInitialized = false; return CELL_OK; } -s32 sceNp2Term() -{ - sceNp.Warning("sceNp2Term()"); - - if (!sceNpInstance.m_bSceNp2Initialized) - return SCE_NP_ERROR_NOT_INITIALIZED; - - sceNpInstance.m_bSceNp2Initialized = false; - - return CELL_OK; -} - s32 npDrmIsAvailable(u32 k_licensee_addr, vm::cptr drm_path) { if (!Emu.GetVFS().ExistsFile(drm_path.get_ptr())) @@ -1625,16 +1622,13 @@ s32 _sceNpSysutilClientFree() Module sceNp("sceNp", []() { sceNpInstance.m_bSceNpInitialized = false; - sceNpInstance.m_bSceNp2Initialized = false; sceNpInstance.m_bScoreInitialized = false; sceNpInstance.m_bLookupInitialized = false; sceNpInstance.m_bSceNpUtilBandwidthTestInitialized = false; REG_FUNC(sceNp, sceNpInit); - REG_FUNC(sceNp, sceNp2Init); REG_FUNC(sceNp, sceNpUtilBandwidthTestInitStart); REG_FUNC(sceNp, sceNpTerm); - REG_FUNC(sceNp, sceNp2Term); REG_FUNC(sceNp, sceNpUtilBandwidthTestShutdown); REG_FUNC(sceNp, sceNpDrmIsAvailable); REG_FUNC(sceNp, sceNpDrmIsAvailable2); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.h b/rpcs3/Emu/SysCalls/Modules/sceNp.h index b86f1fc805..90530bc7d5 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.h @@ -31,6 +31,7 @@ enum SCE_NP_ERROR_ALREADY_USED = 0x8002aa15, SCE_NP_ERROR_DIFFERENT_USER = 0x8002aa16, SCE_NP_ERROR_ALREADY_DONE = 0x8002aa17, + // NP Basic Utility SCE_NP_BASIC_ERROR_ALREADY_INITIALIZED = 0x8002a661, SCE_NP_BASIC_ERROR_NOT_INITIALIZED = 0x8002a662, @@ -65,6 +66,7 @@ enum SCE_NP_EXT_ERROR_CONTEXT_ALREADY_EXISTS = 0x8002a6a2, SCE_NP_EXT_ERROR_NO_CONTEXT = 0x8002a6a3, SCE_NP_EXT_ERROR_NO_ORIGIN = 0x8002a6a4, + // NP Community Utility SCE_NP_COMMUNITY_ERROR_ALREADY_INITIALIZED = 0x8002a101, SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED = 0x8002a102, @@ -97,6 +99,122 @@ enum SCE_NP_COMMUNITY_ERROR_TOO_LARGE_RANGE = 0x8002a1ae, SCE_NP_COMMUNITY_ERROR_INVALID_PARTITION = 0x8002a1af, SCE_NP_COMMUNITY_ERROR_TOO_MANY_SLOTID = 0x8002a1b1, + + // NP Matching 2 Utility + SCE_NP_MATCHING2_ERROR_OUT_OF_MEMORY = 0x80022301, + SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED = 0x80022302, + SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED = 0x80022303, + SCE_NP_MATCHING2_ERROR_CONTEXT_MAX = 0x80022304, + SCE_NP_MATCHING2_ERROR_CONTEXT_ALREADY_EXISTS = 0x80022305, + SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_FOUND = 0x80022306, + SCE_NP_MATCHING2_ERROR_CONTEXT_ALREADY_STARTED = 0x80022307, + SCE_NP_MATCHING2_ERROR_CONTEXT_NOT_STARTED = 0x80022308, + SCE_NP_MATCHING2_ERROR_SERVER_NOT_FOUND = 0x80022309, + SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT = 0x8002230a, + SCE_NP_MATCHING2_ERROR_INVALID_CONTEXT_ID = 0x8002230b, + SCE_NP_MATCHING2_ERROR_INVALID_SERVER_ID = 0x8002230c, + SCE_NP_MATCHING2_ERROR_INVALID_WORLD_ID = 0x8002230d, + SCE_NP_MATCHING2_ERROR_INVALID_LOBBY_ID = 0x8002230e, + SCE_NP_MATCHING2_ERROR_INVALID_ROOM_ID = 0x8002230f, + SCE_NP_MATCHING2_ERROR_INVALID_MEMBER_ID = 0x80022310, + SCE_NP_MATCHING2_ERROR_INVALID_ATTRIBUTE_ID = 0x80022311, + SCE_NP_MATCHING2_ERROR_INVALID_CASTTYPE = 0x80022312, + SCE_NP_MATCHING2_ERROR_INVALID_SORT_METHOD = 0x80022313, + SCE_NP_MATCHING2_ERROR_INVALID_MAX_SLOT = 0x80022314, + SCE_NP_MATCHING2_ERROR_INVALID_MATCHING_SPACE = 0x80022316, + SCE_NP_MATCHING2_ERROR_INVALID_BLOCK_KICK_FLAG = 0x80022318, + SCE_NP_MATCHING2_ERROR_INVALID_MESSAGE_TARGET = 0x80022319, + SCE_NP_MATCHING2_ERROR_RANGE_FILTER_MAX = 0x8002231a, + SCE_NP_MATCHING2_ERROR_INSUFFICIENT_BUFFER = 0x8002231b, + SCE_NP_MATCHING2_ERROR_DESTINATION_DISAPPEARED = 0x8002231c, + SCE_NP_MATCHING2_ERROR_REQUEST_TIMEOUT = 0x8002231d, + SCE_NP_MATCHING2_ERROR_INVALID_ALIGNMENT = 0x8002231e, + SCE_NP_MATCHING2_ERROR_REQUEST_CB_QUEUE_OVERFLOW = 0x8002231f, + SCE_NP_MATCHING2_ERROR_EVENT_CB_QUEUE_OVERFLOW = 0x80022320, + SCE_NP_MATCHING2_ERROR_MSG_CB_QUEUE_OVERFLOW = 0x80022321, + SCE_NP_MATCHING2_ERROR_CONNECTION_CLOSED_BY_SERVER = 0x80022322, + SCE_NP_MATCHING2_ERROR_SSL_VERIFY_FAILED = 0x80022323, + SCE_NP_MATCHING2_ERROR_SSL_HANDSHAKE = 0x80022324, + SCE_NP_MATCHING2_ERROR_SSL_SEND = 0x80022325, + SCE_NP_MATCHING2_ERROR_SSL_RECV = 0x80022326, + SCE_NP_MATCHING2_ERROR_JOINED_SESSION_MAX = 0x80022327, + SCE_NP_MATCHING2_ERROR_ALREADY_JOINED = 0x80022328, + SCE_NP_MATCHING2_ERROR_INVALID_SESSION_TYPE = 0x80022329, + SCE_NP_MATCHING2_ERROR_CLAN_LOBBY_NOT_EXIST = 0x8002232a, + SCE_NP_MATCHING2_ERROR_NP_SIGNED_OUT = 0x8002232b, + SCE_NP_MATCHING2_ERROR_CONTEXT_UNAVAILABLE = 0x8002232c, + SCE_NP_MATCHING2_ERROR_SERVER_NOT_AVAILABLE = 0x8002232d, + SCE_NP_MATCHING2_ERROR_NOT_ALLOWED = 0x8002232e, + SCE_NP_MATCHING2_ERROR_ABORTED = 0x8002232f, + SCE_NP_MATCHING2_ERROR_REQUEST_NOT_FOUND = 0x80022330, + SCE_NP_MATCHING2_ERROR_SESSION_DESTROYED = 0x80022331, + SCE_NP_MATCHING2_ERROR_CONTEXT_STOPPED = 0x80022332, + SCE_NP_MATCHING2_ERROR_INVALID_REQUEST_PARAMETER = 0x80022333, + SCE_NP_MATCHING2_ERROR_NOT_NP_SIGN_IN = 0x80022334, + SCE_NP_MATCHING2_ERROR_ROOM_NOT_FOUND = 0x80022335, + SCE_NP_MATCHING2_ERROR_ROOM_MEMBER_NOT_FOUND = 0x80022336, + SCE_NP_MATCHING2_ERROR_LOBBY_NOT_FOUND = 0x80022337, + SCE_NP_MATCHING2_ERROR_LOBBY_MEMBER_NOT_FOUND = 0x80022338, + SCE_NP_MATCHING2_ERROR_EVENT_DATA_NOT_FOUND = 0x80022339, + SCE_NP_MATCHING2_ERROR_KEEPALIVE_TIMEOUT = 0x8002233a, + SCE_NP_MATCHING2_ERROR_TIMEOUT_TOO_SHORT = 0x8002233b, + SCE_NP_MATCHING2_ERROR_TIMEDOUT = 0x8002233c, + SCE_NP_MATCHING2_ERROR_CREATE_HEAP = 0x8002233d, + SCE_NP_MATCHING2_ERROR_INVALID_ATTRIBUTE_SIZE = 0x8002233e, + SCE_NP_MATCHING2_ERROR_CANNOT_ABORT = 0x8002233f, + + SCE_NP_MATCHING2_RESOLVER_ERROR_NO_DNS_SERVER = 0x800223a2, + SCE_NP_MATCHING2_RESOLVER_ERROR_INVALID_PACKET = 0x800223ad, + SCE_NP_MATCHING2_RESOLVER_ERROR_TIMEOUT = 0x800223b0, + SCE_NP_MATCHING2_RESOLVER_ERROR_NO_RECORD = 0x800223b1, + SCE_NP_MATCHING2_RESOLVER_ERROR_RES_PACKET_FORMAT = 0x800223b2, + SCE_NP_MATCHING2_RESOLVER_ERROR_RES_SERVER_FAILURE = 0x800223b3, + SCE_NP_MATCHING2_RESOLVER_ERROR_NO_HOST = 0x800223b4, + SCE_NP_MATCHING2_RESOLVER_ERROR_RES_NOT_IMPLEMENTED = 0x800223b5, + SCE_NP_MATCHING2_RESOLVER_ERROR_RES_SERVER_REFUSED = 0x800223b6, + SCE_NP_MATCHING2_RESOLVER_ERROR_RESP_TRUNCATED = 0x800223bc, + + SCE_NP_MATCHING2_SERVER_ERROR_BAD_REQUEST = 0x80022b01, + SCE_NP_MATCHING2_SERVER_ERROR_SERVICE_UNAVAILABLE = 0x80022b02, + SCE_NP_MATCHING2_SERVER_ERROR_BUSY = 0x80022b03, + SCE_NP_MATCHING2_SERVER_ERROR_END_OF_SERVICE = 0x80022b04, + SCE_NP_MATCHING2_SERVER_ERROR_INTERNAL_SERVER_ERROR = 0x80022b05, + SCE_NP_MATCHING2_SERVER_ERROR_PLAYER_BANNED = 0x80022b06, + SCE_NP_MATCHING2_SERVER_ERROR_FORBIDDEN = 0x80022b07, + SCE_NP_MATCHING2_SERVER_ERROR_BLOCKED = 0x80022b08, + SCE_NP_MATCHING2_SERVER_ERROR_UNSUPPORTED_NP_ENV = 0x80022b09, + SCE_NP_MATCHING2_SERVER_ERROR_INVALID_TICKET = 0x80022b0a, + SCE_NP_MATCHING2_SERVER_ERROR_INVALID_SIGNATURE = 0x80022b0b, + SCE_NP_MATCHING2_SERVER_ERROR_EXPIRED_TICKET = 0x80022b0c, + SCE_NP_MATCHING2_SERVER_ERROR_ENTITLEMENT_REQUIRED = 0x80022b0d, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_CONTEXT = 0x80022b0e, + SCE_NP_MATCHING2_SERVER_ERROR_CLOSED = 0x80022b0f, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_TITLE = 0x80022b10, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_WORLD = 0x80022b11, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_LOBBY = 0x80022b12, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_ROOM = 0x80022b13, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_LOBBY_INSTANCE = 0x80022b14, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_ROOM_INSTANCE = 0x80022b15, + SCE_NP_MATCHING2_SERVER_ERROR_PASSWORD_MISMATCH = 0x80022b17, + SCE_NP_MATCHING2_SERVER_ERROR_LOBBY_FULL = 0x80022b18, + SCE_NP_MATCHING2_SERVER_ERROR_ROOM_FULL = 0x80022b19, + SCE_NP_MATCHING2_SERVER_ERROR_GROUP_FULL = 0x80022b1b, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_USER = 0x80022b1c, + SCE_NP_MATCHING2_SERVER_ERROR_TITLE_PASSPHRASE_MISMATCH = 0x80022b1e, + SCE_NP_MATCHING2_SERVER_ERROR_DUPLICATE_LOBBY = 0x80022b25, + SCE_NP_MATCHING2_SERVER_ERROR_DUPLICATE_ROOM = 0x80022b26, + SCE_NP_MATCHING2_SERVER_ERROR_NO_JOIN_GROUP_LABEL = 0x80022b29, + SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_GROUP = 0x80022b2a, + SCE_NP_MATCHING2_SERVER_ERROR_NO_PASSWORD = 0x80022b2b, + SCE_NP_MATCHING2_SERVER_ERROR_MAX_OVER_SLOT_GROUP = 0x80022b2c, + SCE_NP_MATCHING2_SERVER_ERROR_MAX_OVER_PASSWORD_MASK = 0x80022b2d, + SCE_NP_MATCHING2_SERVER_ERROR_DUPLICATE_GROUP_LABEL = 0x80022b2e, + SCE_NP_MATCHING2_SERVER_ERROR_REQUEST_OVERFLOW = 0x80022b2f, + SCE_NP_MATCHING2_SERVER_ERROR_ALREADY_JOINED = 0x80022b30, + SCE_NP_MATCHING2_SERVER_ERROR_NAT_TYPE_MISMATCH = 0x80022b31, + SCE_NP_MATCHING2_SERVER_ERROR_ROOM_INCONSISTENCY = 0x80022b32, + // SCE_NP_MATCHING2_NET_ERRNO_BASE = 0x800224XX, + // SCE_NP_MATCHING2_NET_H_ERRNO_BASE = 0x800225XX, }; using SceNpBasicEventHandler = func_def arg)>; @@ -874,8 +992,7 @@ typedef void(SceNpManagerCallback)(s32 event, s32 result, u32 arg_addr); // Request callback function typedef void(*SceNpMatching2RequestCallback)(u16 ctxId, u32 reqId, u16 event, - u32 eventKey, s32 errorCode, u32 dataSize, u32 *arg - ); + u32 eventKey, s32 errorCode, u32 dataSize, u32 *arg); // NOTE: Use SceNpCommunicationPassphrase instead // Np communication passphrase @@ -1237,7 +1354,7 @@ struct SceNpMatching2SignalingOptParam u8 type; u8 reserved1[1]; be_t hubMemberId; - //u8 reserved2[4]; + u8 reserved2[4]; }; // Option parameters for requests @@ -1698,7 +1815,7 @@ struct SceNpMatching2GetLobbyMemberDataInternalListResponse struct SceNpMatching2SignalingGetPingInfoRequest { be_t roomId; - //u8 reserved[16]; + u8 reserved[16]; }; // Response data for obtaining Ping information @@ -1709,7 +1826,7 @@ struct SceNpMatching2SignalingGetPingInfoResponse be_t worldId; be_t roomId; be_t rtt; - //u8 reserved[20]; + u8 reserved[20]; }; // Join request parameters for room in prohibitive mode @@ -1852,7 +1969,7 @@ struct SceNpMatching2UtilityInitParam be_t requestCbQueueLen; be_t sessionEventCbQueueLen;; be_t sessionMsgCbQueueLen;; - //u8 reserved[16]; + u8 reserved[16]; }; // Matching2 memory information @@ -1861,7 +1978,7 @@ struct SceNpMatching2MemoryInfo be_t totalMemSize; be_t curMemUsage;; be_t maxMemUsage;; - //u8 reserved[12]; + u8 reserved[12]; }; // Matching2 information on the event data queues in the system @@ -1876,7 +1993,7 @@ struct SceNpMatching2CbQueueInfo be_t sessionMsgCbQueueLen;; be_t curSessionMsgCbQueueLen;; be_t maxSessionMsgCbQueueLen;; - //u8 reserved[12]; + u8 reserved[12]; }; // Score data unique to the application @@ -1934,7 +2051,7 @@ struct SceNpScoreNpIdPcId { SceNpId npId; be_t pcId; - //u8 pad[4]; + u8 pad[4]; }; // Basic clan information to be used in raking @@ -1942,7 +2059,7 @@ struct SceNpScoreClanBasicInfo { s8 clanName[SCE_NP_CLANS_CLAN_NAME_MAX_LENGTH + 1]; s8 clanTag[SCE_NP_CLANS_CLAN_TAG_MAX_LENGTH + 1]; - //u8 reserved[10]; + u8 reserved[10]; }; // Clan member information handled in ranking diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp new file mode 100644 index 0000000000..784e42deb7 --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp @@ -0,0 +1,174 @@ +#include "stdafx.h" +#include "Emu/Memory/Memory.h" +#include "Emu/SysCalls/Modules.h" + +#include "sceNp.cpp" + +extern Module sceNp2; + +struct sceNp2Internal +{ + bool m_bSceNp2Initialized; + bool m_bSceNp2Matching2Initialized; + bool m_bSceNp2Matching2Initialized2; + + sceNp2Internal() + : m_bSceNp2Initialized(false), + m_bSceNp2Matching2Initialized(false), + m_bSceNp2Matching2Initialized2(false) + { + } +}; + +sceNp2Internal sceNp2Instance; + +s32 sceNp2Init(u32 poolsize, vm::ptr poolptr) +{ + sceNp2.Warning("sceNp2Init(poolsize=%d, poolptr=0x%x)", poolsize, poolptr); + + if (sceNp2Instance.m_bSceNp2Initialized) + { + sceNp2.Error("sceNp2Init(): sceNp2 has been already initialized."); + return SCE_NP_ERROR_ALREADY_INITIALIZED; + } + + if (poolsize == 0) + { + sceNp2.Error("sceNp2Init(): poolsize given is 0."); + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + else if (poolsize < 128 * 1024) + { + sceNp2.Error("sceNp2Init(): poolsize given is under 131072 bytes."); + return SCE_NP_ERROR_INSUFFICIENT_BUFFER; + } + + if (!poolptr) + { + sceNp2.Error("sceNp2Init(): poolptr is invalid."); + return SCE_NP_ERROR_INVALID_ARGUMENT; + } + + sceNpInstance.m_bSceNpInitialized = true; + sceNp2Instance.m_bSceNp2Initialized = true; + + return CELL_OK; +} + +s32 sceNpMatching2Init(u32 poolsize, s32 priority) +{ + sceNp2.Todo("sceNpMatching2Init(poolsize=%d, priority=%d)", poolsize, priority); + + if (!sceNp2Instance.m_bSceNp2Initialized) + { + sceNp2.Error("sceNpMatching2Init(): sceNp2 has not been intialized."); + return SCE_NP_ERROR_NOT_INITIALIZED; + } + + if (sceNp2Instance.m_bSceNp2Matching2Initialized) + { + sceNp2.Error("sceNpMatching2Init(): sceNpMatching2 has already been intialized."); + return SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED; + } + + sceNp2Instance.m_bSceNp2Matching2Initialized = true; + + return CELL_OK; +} + +s32 sceNpMatching2Init2(u32 poolsize, s32 priority, vm::ptr param) +{ + sceNp2.Todo("sceNpMatching2Init2(poolsize=%d, priority=%d, param_addr=0x%x)", poolsize, priority, param.addr()); + + if (!sceNp2Instance.m_bSceNp2Initialized) + { + sceNp2.Error("sceNpMatching2Init2(): sceNp2 has not been intialized."); + return SCE_NP_ERROR_NOT_INITIALIZED; + } + + if (sceNp2Instance.m_bSceNp2Matching2Initialized2) + { + sceNp2.Error("sceNpMatching2Init2(): new sceNpMatching2 has already been intialized."); + return SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED; + } + + sceNp2Instance.m_bSceNp2Matching2Initialized2 = true; + + // TODO: + // 1. Create an internal thread + // 2. Create heap area to be used by the NP matching 2 utility + // 3. Set maximum lengths for the event data queues in the system + + return CELL_OK; +} + +s32 sceNp2Term() +{ + sceNp2.Warning("sceNp2Term()"); + + if (!sceNp2Instance.m_bSceNp2Initialized) + { + sceNp2.Error("sceNp2Term(): sceNp2 has not been intialized."); + return SCE_NP_ERROR_NOT_INITIALIZED; + } + + sceNp2Instance.m_bSceNp2Initialized = false; + + return CELL_OK; +} + +s32 sceNpMatching2Term(PPUThread& ppu) +{ + sceNp2.Warning("sceNpMatching2Term()"); + + if (!sceNp2Instance.m_bSceNp2Initialized) + { + sceNp2.Error("sceNpMatching2Term(): sceNp2 has not been intialized."); + return SCE_NP_ERROR_NOT_INITIALIZED; + } + + if (!sceNp2Instance.m_bSceNp2Matching2Initialized) + { + sceNp2.Error("sceNpMatching2Term(): sceNpMatching2 has not been intialized."); + return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; + } + + sceNp2Instance.m_bSceNp2Matching2Initialized = false; + + return CELL_OK; +} + +s32 sceNpMatching2Term2() +{ + sceNp2.Warning("sceNpMatching2Term2()"); + + if (!sceNp2Instance.m_bSceNp2Initialized) + { + sceNp2.Error("sceNpMatching2Term2(): sceNp2 has not been intialized."); + return SCE_NP_ERROR_NOT_INITIALIZED; + } + + if (!sceNp2Instance.m_bSceNp2Matching2Initialized2) + { + sceNp2.Error("sceNpMatching2Term(): new sceNpMatching2 has not been intialized."); + return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; + } + + sceNp2Instance.m_bSceNp2Matching2Initialized2 = false; + + return CELL_OK; +} + +Module sceNp2("sceNp2", []() +{ + sceNp2Instance.m_bSceNp2Initialized = false; + sceNp2Instance.m_bSceNp2Matching2Initialized = false; + sceNp2Instance.m_bSceNp2Matching2Initialized2 = false; + + REG_FUNC(sceNp2, sceNp2Init); + REG_FUNC(sceNp2, sceNpMatching2Init); + REG_FUNC(sceNp2, sceNpMatching2Init2); + REG_FUNC(sceNp2, sceNp2Term); + REG_FUNC(sceNp2, sceNpMatching2Term); + REG_FUNC(sceNp2, sceNpMatching2Term2); +}); \ No newline at end of file diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 04e6797157..c1a0fcc257 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -267,6 +267,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 9c08d40ad2..e7f70bcdce 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -269,6 +269,9 @@ Emu\SysCalls\Modules + + Emu\SysCalls\Modules + Emu\SysCalls\Modules From 2e3113b5f2f23550a45ff5d5e074ef1b76ba4d4d Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Tue, 14 Jul 2015 18:59:10 +0300 Subject: [PATCH 4/4] Fix Travis compiling --- rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 16 ---------------- rpcs3/Emu/SysCalls/Modules/sceNp.h | 18 ++++++++++++++++++ rpcs3/Emu/SysCalls/Modules/sceNp2.cpp | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index 8b921e77ff..7d69bbf725 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -12,22 +12,6 @@ extern Module sceNp; -struct sceNpInternal -{ - bool m_bSceNpInitialized; - bool m_bScoreInitialized; - bool m_bLookupInitialized; - bool m_bSceNpUtilBandwidthTestInitialized; - - sceNpInternal() - : m_bSceNpInitialized(false), - m_bScoreInitialized(false), - m_bLookupInitialized(false), - m_bSceNpUtilBandwidthTestInitialized(false) - { - } -}; - sceNpInternal sceNpInstance; s32 sceNpInit(u32 poolsize, vm::ptr poolptr) diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.h b/rpcs3/Emu/SysCalls/Modules/sceNp.h index 90530bc7d5..eee17a67b8 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.h @@ -219,6 +219,24 @@ enum using SceNpBasicEventHandler = func_def arg)>; +struct sceNpInternal +{ + bool m_bSceNpInitialized; + bool m_bScoreInitialized; + bool m_bLookupInitialized; + bool m_bSceNpUtilBandwidthTestInitialized; + + sceNpInternal() + : m_bSceNpInitialized(false), + m_bScoreInitialized(false), + m_bLookupInitialized(false), + m_bSceNpUtilBandwidthTestInitialized(false) + { + } +}; + +extern sceNpInternal sceNpInstance; + // NP Manager Utility statuses enum { diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp index 784e42deb7..9299293258 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp2.cpp @@ -2,7 +2,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" -#include "sceNp.cpp" +#include "sceNp.h" extern Module sceNp2;