diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp index 63bdd7861c..7236e46fea 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.cpp @@ -15,32 +15,33 @@ u32 libsync2; u32 libsync2_rtoc; #endif -s64 _cellSync2MutexAttributeInitialize(vm::ptr attr) +s64 _cellSync2MutexAttributeInitialize(vm::ptr attr, u32 sdkVersion) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x16A0, libsync2_rtoc); #else - cellSync2->Warning("_cellSync2MutexAttributeInitialize(attr_addr=0x%x)", attr.addr()); + cellSync2->Warning("_cellSync2MutexAttributeInitialize(attr_addr=0x%x, sdkVersion=0x%x)", attr.addr(), sdkVersion); + attr->sdkVersion = sdkVersion; 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"); + strcpy_trunc(attr->name, "CellSync2Mutex"); return CELL_OK; #endif } -s64 cellSync2MutexEstimateBufferSize(vm::ptr attr, u64 bufferSize) +s64 cellSync2MutexEstimateBufferSize(vm::ptr attr, vm::ptr bufferSize) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0xC3C, libsync2_rtoc); #else - cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize=%d)", attr.addr(), bufferSize); + cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize_addr=0x%x)", attr.addr(), bufferSize.addr()); if (attr->maxWaiters > 32768) return CELL_SYNC2_ERROR_INVAL; @@ -104,28 +105,29 @@ s64 cellSync2MutexUnlock() #endif } -s64 _cellSync2CondAttributeInitialize(vm::ptr attr) +s64 _cellSync2CondAttributeInitialize(vm::ptr attr, u32 sdkVersion) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x26DC, libsync2_rtoc); #else - cellSync2->Warning("_cellSync2CondAttributeInitialize(attr_addr=0x%x)", attr.addr()); + cellSync2->Warning("_cellSync2CondAttributeInitialize(attr_addr=0x%x, sdkVersion=0x%x)", attr.addr(), sdkVersion); + attr->sdkVersion = sdkVersion; attr->maxWaiters = 15; - strcpy(attr->name, "CellSync2Cond"); + strcpy_trunc(attr->name, "CellSync2Cond"); return CELL_OK; #endif } -s64 cellSync2CondEstimateBufferSize(vm::ptr attr, u64 bufferSize) +s64 cellSync2CondEstimateBufferSize(vm::ptr attr, vm::ptr bufferSize) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x1B90, libsync2_rtoc); #else - cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize=%d)", attr.addr(), bufferSize); + cellSync2->Todo("cellSync2CondEstimateBufferSize(attr_addr=0x%x, bufferSize_addr=0x%x)", attr.addr(), bufferSize.addr()); if (attr->maxWaiters == 0 || attr->maxWaiters > 32768) return CELL_SYNC2_ERROR_INVAL; @@ -189,31 +191,32 @@ s64 cellSync2CondSignalAll() #endif } -s64 _cellSync2SemaphoreAttributeInitialize(vm::ptr attr) +s64 _cellSync2SemaphoreAttributeInitialize(vm::ptr attr, u32 sdkVersion) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x5644, libsync2_rtoc); #else - cellSync2->Warning("_cellSync2SemaphoreAttributeInitialize(attr_addr=0x%x)", attr.addr()); + cellSync2->Warning("_cellSync2SemaphoreAttributeInitialize(attr_addr=0x%x, sdkVersion=0x%x)", attr.addr(), sdkVersion); + attr->sdkVersion = sdkVersion; 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"); + strcpy_trunc(attr->name, "CellSync2Semaphore"); return CELL_OK; #endif } -s64 cellSync2SemaphoreEstimateBufferSize(vm::ptr attr, u64 bufferSize) +s64 cellSync2SemaphoreEstimateBufferSize(vm::ptr attr, vm::ptr bufferSize) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x4AC4, libsync2_rtoc); #else - cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize=%d)", attr.addr(), bufferSize); + cellSync2->Todo("cellSync2SemaphoreEstimateBufferSize(attr_addr=0x%x, bufferSize_addr=0x%x)", attr.addr(), bufferSize.addr()); if (attr->maxWaiters == 0 || attr->maxWaiters > 32768) return CELL_SYNC2_ERROR_INVAL; @@ -288,14 +291,15 @@ s64 cellSync2SemaphoreGetCount() #endif } -s64 _cellSync2QueueAttributeInitialize(vm::ptr attr) +s64 _cellSync2QueueAttributeInitialize(vm::ptr attr, u32 sdkVersion) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x3C5C, libsync2_rtoc); #else - cellSync2->Warning("_cellSync2QueueAttributeInitialize(attr_addr=0x%x)", attr.addr()); + cellSync2->Warning("_cellSync2QueueAttributeInitialize(attr_addr=0x%x, sdkVersion=0x%x)", attr.addr(), sdkVersion); + attr->sdkVersion = sdkVersion; 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; @@ -303,21 +307,21 @@ s64 _cellSync2QueueAttributeInitialize(vm::ptr attr) attr->depth = 1024; attr->maxPushWaiters = 15; attr->maxPopWaiters = 15; - strcpy(attr->name, "CellSync2Queue"); + strcpy_trunc(attr->name, "CellSync2Queue"); return CELL_OK; #endif } -s64 cellSync2QueueEstimateBufferSize(vm::ptr attr, u64 bufferSize) +s64 cellSync2QueueEstimateBufferSize(vm::ptr attr, vm::ptr bufferSize) { #ifdef PRX_DEBUG cellSync2->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsync2 + 0x2A98, libsync2_rtoc); #else - cellSync2->Todo("cellSync2MutexEstimateBufferSize(attr_addr=0x%x, bufferSize=%d)", attr.addr(), bufferSize); + cellSync2->Todo("cellSync2QueueEstimateBufferSize(attr_addr=0x%x, bufferSize_addr=0x%x)", attr.addr(), bufferSize.addr()); - if (attr->elementSize == 0 || attr->elementSize > 16384 || !attr->elementSize % 16 || attr->depth == 0 || attr->depth > 4294967292 || + 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; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.h b/rpcs3/Emu/SysCalls/Modules/cellSync2.h index 22083cb88a..b18c3d69a2 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.h @@ -30,35 +30,48 @@ enum struct CellSync2MutexAttribute { + be_t sdkVersion; be_t threadTypes; be_t maxWaiters; bool recursive; + u8 padding; char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; - u8 reserved[]; + u8 reserved[86]; }; +static_assert(sizeof(CellSync2MutexAttribute) == 128, "Wrong CellSync2MutexAttribute size"); + struct CellSync2CondAttribute { + be_t sdkVersion; be_t maxWaiters; char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; - u8 reserved[]; + u8 reserved[90]; }; +static_assert(sizeof(CellSync2CondAttribute) == 128, "Wrong CellSync2CondAttribute size"); + struct CellSync2SemaphoreAttribute { + be_t sdkVersion; be_t threadTypes; be_t maxWaiters; char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; - u8 reserved[]; + u8 reserved[88]; }; +static_assert(sizeof(CellSync2SemaphoreAttribute) == 128, "Wrong CellSync2SemaphoreAttribute size"); + struct CellSync2QueueAttribute { + be_t sdkVersion; be_t threadTypes; - be_t elementSize; + 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 + u8 reserved[76]; +}; + +static_assert(sizeof(CellSync2QueueAttribute) == 128, "Wrong CellSync2QueueAttribute size");