From e6595f05bca7584c2f93abe39442792ca4e232f9 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Tue, 2 Sep 2014 19:58:42 +0300 Subject: [PATCH 1/4] Removed cellSaveDataListAutoSave and cellSaveDataListAutoLoad until they can be fixed Also added a lot of TODO printouts for other save data functions. --- .../SysCalls/Modules/cellSysutil_SaveData.cpp | 217 ++++-------------- 1 file changed, 40 insertions(+), 177 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp index e698e65be9..a75f76e87c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil_SaveData.cpp @@ -700,231 +700,94 @@ int cellSaveDataAutoLoad2(u32 version, u32 dirName_addr, u32 errDialog, vm::ptr< int cellSaveDataListAutoSave(u32 version, u32 errDialog, vm::ptr setList, vm::ptr setBuf, vm::ptr funcFixed, vm::ptr funcStat, vm::ptr funcFile, u32 container, u32 userdata_addr) { - cellSysutil->Warning("cellSaveDataListAutoSave(version=%d, errDialog=%d, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", + cellSysutil->Todo("cellSaveDataListAutoSave(version=%d, errDialog=%d, setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); - - vm::var result; - vm::var listGet; - vm::var fixedSet; - vm::var statGet; - vm::var statSet; - - std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user - vfsDir dir(saveBaseDir); - - if (!dir.IsOpened()) - return CELL_SAVEDATA_ERROR_INTERNAL; - - std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr); - std::vector saveEntries; - - for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) - { - if (entry->flags & DirEntry_TypeDir && entry->name.substr(0, dirNamePrefix.size()) == dirNamePrefix) - { - // Count the amount of matches and the amount of listed directories - listGet->dirListNum++; - if (listGet->dirListNum > setBuf->dirListMax) - continue; - listGet->dirNum++; - - std::string saveDir = saveBaseDir + entry->name; - addSaveDataEntry(saveEntries, saveDir); - } - } - - // Sort the entries and fill the listGet->dirList array - std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); - listGet->dirList = vm::bptr::make(setBuf->buf_addr); - CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr()); - - for (u32 i = 0; iresult < 0) { - cellSysutil->Error("cellSaveDataListAutoSave: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. - return CELL_SAVEDATA_ERROR_CBRESULT; - } - - /*setSaveDataList(saveEntries, (u32)listSet->fixedList.addr(), listSet->fixedListNum); - if (listSet->newData) - addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr()); - if (saveEntries.size() == 0) { - cellSysutil->Warning("cellSaveDataListAutoSave: No save entries found!"); // TODO: Find a better way to handle this error - return CELL_SAVEDATA_RET_OK; - } - - u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition); - // TODO: Display the dialog here - u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry - getSaveDataStat(saveEntries[selectedIndex], statGet.addr()); - result->userdata_addr = userdata_addr; - - funcStat(result, statGet, statSet); - Memory.Free(statGet->fileList.addr()); - if (result->result < 0) { - cellSysutil->Error("cellSaveDataListAutoSave: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. - return CELL_SAVEDATA_ERROR_CBRESULT; - }*/ - - /*if (statSet->setParam) - addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr()); // TODO: This *is* wrong - */ - - // Enter the loop where the save files are read/created/deleted. - s32 ret = modifySaveDataFiles(funcFile, result, saveBaseDir + (char*)statGet->dir.dirName); - return CELL_SAVEDATA_RET_OK; } int cellSaveDataListAutoLoad(u32 version, u32 errDialog, vm::ptr setList, vm::ptr setBuf, vm::ptr funcFixed, vm::ptr funcStat, vm::ptr funcFile, u32 container, u32 userdata_addr) { - cellSysutil->Warning("cellSaveDataListAutoLoad(version=%d, errDialog=%d, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", + cellSysutil->Todo("cellSaveDataListAutoLoad(version=%d, errDialog=%d, setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); - - vm::var result; - vm::var listGet; - vm::var fixedSet; - vm::var statGet; - vm::var statSet; - - std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user - vfsDir dir(saveBaseDir); - - if (!dir.IsOpened()) - return CELL_SAVEDATA_ERROR_INTERNAL; - - std::string dirNamePrefix = Memory.ReadString(setList->dirNamePrefix_addr); - std::vector saveEntries; - - for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) - { - if (entry->flags & DirEntry_TypeDir && entry->name.substr(0, dirNamePrefix.size()) == dirNamePrefix) - { - // Count the amount of matches and the amount of listed directories - listGet->dirListNum++; - if (listGet->dirListNum > setBuf->dirListMax) - continue; - listGet->dirNum++; - - std::string saveDir = saveBaseDir + entry->name; - addSaveDataEntry(saveEntries, saveDir); - } - } - - // Sort the entries and fill the listGet->dirList array - std::sort(saveEntries.begin(), saveEntries.end(), sortSaveDataEntry(setList->sortType, setList->sortOrder)); - listGet->dirList = vm::bptr::make(setBuf->buf_addr); - CellSaveDataDirList* dirList = (CellSaveDataDirList*)Memory.VirtualToRealAddr(listGet->dirList.addr()); - - for (u32 i = 0; iresult < 0) { - cellSysutil->Error("cellSaveDataListAutoLoad: CellSaveDataListCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. - return CELL_SAVEDATA_ERROR_CBRESULT; - } - - /*setSaveDataList(saveEntries, (u32)listSet->fixedList.addr(), listSet->fixedListNum); - if (listSet->newData) - addNewSaveDataEntry(saveEntries, (u32)listSet->newData.addr()); - if (saveEntries.size() == 0) { - cellSysutil->Warning("cellSaveDataListAutoLoad: No save entries found!"); // TODO: Find a better way to handle this error - return CELL_SAVEDATA_RET_OK; - } - - u32 focusIndex = focusSaveDataEntry(saveEntries, listSet->focusPosition); - // TODO: Display the dialog here - u32 selectedIndex = focusIndex; // TODO: Until the dialog is implemented, select always the focused entry - getSaveDataStat(saveEntries[selectedIndex], statGet.addr()); - result->userdata_addr = userdata_addr; - - funcStat(result.addr(), statGet.addr(), statSet.addr()); - Memory.Free(statGet->fileList.addr()); - - if (result->result < 0) { - cellSysutil->Error("cellSaveDataListAutoLoad: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. - return CELL_SAVEDATA_ERROR_CBRESULT; - }*/ - - /*if (statSet->setParam) - // TODO: Write PARAM.SFO file - */ - - // Enter the loop where the save files are read/created/deleted. - s32 ret = modifySaveDataFiles(funcFile, result, saveBaseDir + (char*)statGet->dir.dirName); - return CELL_SAVEDATA_RET_OK; } -int cellSaveDataDelete2() //sys_memory_container_t container +int cellSaveDataDelete2(u32 container) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataDelete2(container=0x%x)", container); return CELL_SAVEDATA_RET_CANCEL; } -int cellSaveDataFixedDelete() //CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataDoneCallback funcDone, sys_memory_container_t container, void *userdata +int cellSaveDataFixedDelete(vm::ptr setList, vm::ptr setBuf, vm::ptr funcFixed, vm::ptr funcDone, + u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataFixedDelete(setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcDone=0x%x, container=0x%x, userdata_addr=0x%x)", setList.addr(), setBuf.addr(), funcFixed.addr(), + funcDone.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserListSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataUserListSave(u32 version, u32 userId, vm::ptr setList, vm::ptr setBuf, vm::ptr funcList, + vm::ptr funcStat, vm::ptr funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataUserListSave(version=%d, userId=%d, setList=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, + userId, setList.addr(), setBuf.addr(), funcList.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserListLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataListCallback funcList, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataUserListLoad(u32 version, u32 userId, vm::ptr setList, vm::ptr setBuf, vm::ptr funcList, + vm::ptr funcStat, vm::ptr funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataUserListLoad(version=%d, userId=%d, setList=0x%x, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, + userId, setList.addr(), setBuf.addr(), funcList.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserFixedSave() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataUserFixedSave(u32 version, u32 userId, vm::ptr setList, vm::ptr setBuf, vm::ptr funcFixed, + vm::ptr funcStat, vm::ptr funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataUserFixedSave(version=%d, userId=%d, setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, + userId, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserFixedLoad() //u32 version, CellSysutilUserId userId, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataUserFixedLoad(u32 version, u32 userId, vm::ptr setList, vm::ptr setBuf, vm::ptr funcFixed, + vm::ptr funcStat, vm::ptr funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataUserFixedLoad(version=%d, userId=%d, setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, + userId, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserAutoSave() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataUserAutoSave(u32 version, u32 userId, u32 dirName_addr, u32 errDialog, vm::ptr setBuf, vm::ptr funcStat, + vm::ptr funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataUserAutoSave(version=%d, userId=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, + userId, dirName_addr, errDialog, setBuf.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserAutoLoad() //u32 version, CellSysutilUserId userId, const char *dirName, u32 errDialog, CellSaveDataSetBuf *setBuf, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataUserAutoLoad(u32 version, u32 userId, u32 dirName_addr, u32 errDialog, vm::ptr setBuf, vm::ptr funcStat, + vm::ptr funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataUserAutoLoad(version=%d, userId=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", version, + userId, dirName_addr, errDialog, setBuf.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserListAutoSave() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataUserListAutoSave(u32 version, u32 userId, u32 errDialog, vm::ptr setList, vm::ptr setBuf, vm::ptr funcFixed, + vm::ptr funcStat, vm::ptr funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataUserListAutoSave(version=%d, userId=%d, errDialog=%d, setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", + version, userId, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } -int cellSaveDataUserListAutoLoad() //u32 version, CellSysutilUserId userId, u32 errDialog, CellSaveDataSetList *setList, CellSaveDataSetBuf *setBuf, CellSaveDataFixedCallback funcFixed, CellSaveDataStatCallback funcStat, CellSaveDataFileCallback funcFile, sys_memory_container_t container, void *userdata +int cellSaveDataUserListAutoLoad(u32 version, u32 userId, u32 errDialog, vm::ptr setList, vm::ptr setBuf, vm::ptr funcFixed, + vm::ptr funcStat, vm::ptr funcFile, u32 container, u32 userdata_addr) { - UNIMPLEMENTED_FUNC(cellSysutil); + cellSysutil->Todo("cellSaveDataUserListAutoLoad(version=%d, userId=%d, errDialog=%D, setList=0x%x, setBuf=0x%x, funcFixed=0x%x, funcStat=0x%x, funcFile=0x%x, container=0x%x, userdata_addr=0x%x)", + version, userId, errDialog, setList.addr(), setBuf.addr(), funcFixed.addr(), funcStat.addr(), funcFile.addr(), container, userdata_addr); return CELL_SAVEDATA_RET_OK; } From 383f6aff2bf22a47b9b20f483e9b60c991dde87c Mon Sep 17 00:00:00 2001 From: Peter Tissen Date: Wed, 3 Sep 2014 12:06:11 +0200 Subject: [PATCH 2/4] unix preprocessor define typo fixed --- rpcs3/Emu/RSX/GL/OpenGL.cpp | 2 +- rpcs3/rpcs3.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/OpenGL.cpp b/rpcs3/Emu/RSX/GL/OpenGL.cpp index d87d7349f6..7309fe1d7e 100644 --- a/rpcs3/Emu/RSX/GL/OpenGL.cpp +++ b/rpcs3/Emu/RSX/GL/OpenGL.cpp @@ -11,7 +11,7 @@ void InitProcTable() #undef OPENGL_PROC #undef OPENGL_PROC2 #endif -#ifdef __UNIX__ +#ifdef __unix__ glewExperimental = true; glewInit(); #endif diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index c5fb281606..09da440a9c 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -31,7 +31,7 @@ #include #endif -#ifdef __UNIX__ +#ifdef __unix__ #include #endif @@ -180,7 +180,7 @@ void Rpcs3App::SendDbgCommand(DbgCommand id, CPUThread* thr) Rpcs3App::Rpcs3App() { - #if defined(__UNIX__) && !defined(__APPLE__) + #if defined(__unix__) && !defined(__APPLE__) XInitThreads(); #endif } From e6ab29346ec4ba01eb4458728ea5a0afb4a54b89 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Thu, 4 Sep 2014 18:27:19 +0300 Subject: [PATCH 3/4] Added cellSync2 attribute initilization Also added checks for EstimateBufferSize functions --- rpcs3/Emu/SysCalls/Modules/cellSync2.cpp | 78 +++++++++++++++++++----- rpcs3/Emu/SysCalls/Modules/cellSync2.h | 46 ++++++++++++++ 2 files changed, 108 insertions(+), 16 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp index b5045f0cad..081f507ee8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp @@ -15,24 +15,36 @@ u32 libsync2; u32 libsync2_rtoc; #endif -s64 _cellSync2MutexAttributeInitialize() +s64 _cellSync2MutexAttributeInitialize(vm::ptr attr) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x16A0, libsync2_rtoc); #else - UNIMPLEMENTED_FUNC(cellSync2); + cellSync2->Warning("_cellSync2MutexAttributeInitialize(attr_addr=0x%x)", attr.addr()); + + attr->threadTypes = CELL_SYNC2_THREAD_TYPE_PPU_THREAD | CELL_SYNC2_THREAD_TYPE_PPU_FIBER | + CELL_SYNC2_THREAD_TYPE_SPURS_TASK | CELL_SYNC2_THREAD_TYPE_SPURS_JOB | + CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB; + attr->maxWaiters = 15; + attr->recursive = false; + strcpy(attr->name, "CellSync2Mutex"); + return CELL_OK; #endif } -s64 cellSync2MutexEstimateBufferSize() +s64 cellSync2MutexEstimateBufferSize(vm::ptr attr, u64 bufferSize) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0xC3C, libsync2_rtoc); #else - UNIMPLEMENTED_FUNC(cellSync2); + cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize=%d)", attr.addr(), bufferSize); + + if (attr->maxWaiters > 32768) + return CELL_SYNC2_ERROR_INVAL; + return CELL_OK; #endif } @@ -92,24 +104,32 @@ s64 cellSync2MutexUnlock() #endif } -s64 _cellSync2CondAttributeInitialize() +s64 _cellSync2CondAttributeInitialize(vm::ptr attr) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x26DC, libsync2_rtoc); #else - UNIMPLEMENTED_FUNC(cellSync2); + cellSync2->Warning("_cellSync2CondAttributeInitialize(attr_addr=0x%x)", attr.addr()); + + attr->maxWaiters = 15; + strcpy(attr->name, "CellSync2Cond"); + return CELL_OK; #endif } -s64 cellSync2CondEstimateBufferSize() +s64 cellSync2CondEstimateBufferSize(vm::ptr attr, u64 bufferSize) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x1B90, libsync2_rtoc); #else - UNIMPLEMENTED_FUNC(cellSync2); + cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize=%d)", attr.addr(), bufferSize); + + if (attr->maxWaiters == 0 || attr->maxWaiters > 32768) + return CELL_SYNC2_ERROR_INVAL; + return CELL_OK; #endif } @@ -169,24 +189,35 @@ s64 cellSync2CondSignalAll() #endif } -s64 _cellSync2SemaphoreAttributeInitialize() +s64 _cellSync2SemaphoreAttributeInitialize(vm::ptr attr) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x5644, libsync2_rtoc); #else - UNIMPLEMENTED_FUNC(cellSync2); + cellSync2->Warning("_cellSync2SemaphoreAttributeInitialize(attr_addr=0x%x)", attr.addr()); + + attr->threadTypes = CELL_SYNC2_THREAD_TYPE_PPU_THREAD | CELL_SYNC2_THREAD_TYPE_PPU_FIBER | + CELL_SYNC2_THREAD_TYPE_SPURS_TASK | CELL_SYNC2_THREAD_TYPE_SPURS_JOB | + CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB; + attr->maxWaiters = 1; + strcpy(attr->name, "CellSync2Semaphore"); + return CELL_OK; #endif } -s64 cellSync2SemaphoreEstimateBufferSize() +s64 cellSync2SemaphoreEstimateBufferSize(vm::ptr attr, u64 bufferSize) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x4AC4, libsync2_rtoc); #else - UNIMPLEMENTED_FUNC(cellSync2); + cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize=%d)", attr.addr(), bufferSize); + + if (attr->maxWaiters == 0 || attr->maxWaiters > 32768) + return CELL_SYNC2_ERROR_INVAL; + return CELL_OK; #endif } @@ -257,24 +288,39 @@ s64 cellSync2SemaphoreGetCount() #endif } -s64 _cellSync2QueueAttributeInitialize() +s64 _cellSync2QueueAttributeInitialize(vm::ptr attr) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x3C5C, libsync2_rtoc); #else - UNIMPLEMENTED_FUNC(cellSync2); + cellSync2->Warning("_cellSync2QueueAttributeInitialize(attr_addr=0x%x)", attr.addr()); + + attr->threadTypes = CELL_SYNC2_THREAD_TYPE_PPU_THREAD | CELL_SYNC2_THREAD_TYPE_PPU_FIBER | + CELL_SYNC2_THREAD_TYPE_SPURS_TASK | CELL_SYNC2_THREAD_TYPE_SPURS_JOB | + CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB; + attr->elementSize = 16; + attr->depth = 1024; + attr->maxPushWaiters = 15; + attr->maxPopWaiters = 15; + strcpy(attr->name, "CellSync2Queue"); + return CELL_OK; #endif } -s64 cellSync2QueueEstimateBufferSize() +s64 cellSync2QueueEstimateBufferSize(vm::ptr attr, u64 bufferSize) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x2A98, libsync2_rtoc); #else - UNIMPLEMENTED_FUNC(cellSync2); + cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize=%d)", attr.addr(), bufferSize); + + if (attr->elementSize == 0 || attr->elementSize > 16384 || !attr->elementSize % 16 || attr->depth == 0 || attr->depth > 4294967292 || + attr->maxPushWaiters > 32768 || attr->maxPopWaiters > 32768) + return CELL_SYNC2_ERROR_INVAL; + return CELL_OK; #endif } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.h b/rpcs3/Emu/SysCalls/Modules/cellSync2.h index 1db88a8f76..22083cb88a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.h @@ -15,4 +15,50 @@ enum CELL_SYNC2_ERROR_NOT_SUPPORTED_THREAD = 0x80410C12, CELL_SYNC2_ERROR_NO_NOTIFIER = 0x80410C13, CELL_SYNC2_ERROR_NO_SPU_CONTEXT_STORAGE = 0x80410C14, +}; + +// Constants +enum +{ + CELL_SYNC2_NAME_MAX_LENGTH = 31, + CELL_SYNC2_THREAD_TYPE_PPU_THREAD = 1 << 0, + CELL_SYNC2_THREAD_TYPE_PPU_FIBER = 1 << 1, + CELL_SYNC2_THREAD_TYPE_SPURS_TASK = 1 << 2, + CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB = 1 << 3, + CELL_SYNC2_THREAD_TYPE_SPURS_JOB = 1 << 8, +}; + +struct CellSync2MutexAttribute +{ + be_t threadTypes; + be_t maxWaiters; + bool recursive; + char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; + u8 reserved[]; +}; + +struct CellSync2CondAttribute +{ + be_t maxWaiters; + char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; + u8 reserved[]; +}; + +struct CellSync2SemaphoreAttribute +{ + be_t threadTypes; + be_t maxWaiters; + char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; + u8 reserved[]; +}; + +struct CellSync2QueueAttribute +{ + be_t threadTypes; + be_t elementSize; + be_t depth; + be_t maxPushWaiters; + be_t maxPopWaiters; + char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; + u8 reserved[]; }; \ No newline at end of file From cef2c59ae24869e4a7c1c68a881ce743b9bf7ac6 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Thu, 4 Sep 2014 22:39:08 +0300 Subject: [PATCH 4/4] Fix cellPamfReaderGetPresentationStartTime access violation Should also fix access violations for other cellPamf functions --- rpcs3/Emu/SysCalls/Modules/cellPamf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp index 361768451b..b45fa3a16b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPamf.cpp @@ -181,7 +181,8 @@ int cellPamfReaderInitialize(vm::ptr pSelf, vm::ptr { pSelf->fileSize = ((u64)pAddr->data_offset << 11) + ((u64)pAddr->data_size << 11); } - pSelf->pAddr = vm::ptr::make(pAddr.addr()); + + pSelf->pAddr = pAddr; if (attribute & CELL_PAMF_ATTRIBUTE_VERIFY_ON) {