Merge pull request #792 from Nekotekina/master

cellSync2* fixes
This commit is contained in:
B1ackDaemon 2014-09-06 14:10:53 +03:00
commit 1b499a6fd5
2 changed files with 44 additions and 27 deletions

View File

@ -15,32 +15,33 @@ u32 libsync2;
u32 libsync2_rtoc; u32 libsync2_rtoc;
#endif #endif
s64 _cellSync2MutexAttributeInitialize(vm::ptr<CellSync2MutexAttribute> attr) s64 _cellSync2MutexAttributeInitialize(vm::ptr<CellSync2MutexAttribute> attr, u32 sdkVersion)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__); cellSync2->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsync2 + 0x16A0, libsync2_rtoc); return GetCurrentPPUThread().FastCall2(libsync2 + 0x16A0, libsync2_rtoc);
#else #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 | 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_TASK | CELL_SYNC2_THREAD_TYPE_SPURS_JOB |
CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB; CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB;
attr->maxWaiters = 15; attr->maxWaiters = 15;
attr->recursive = false; attr->recursive = false;
strcpy(attr->name, "CellSync2Mutex"); strcpy_trunc(attr->name, "CellSync2Mutex");
return CELL_OK; return CELL_OK;
#endif #endif
} }
s64 cellSync2MutexEstimateBufferSize(vm::ptr<CellSync2MutexAttribute> attr, u64 bufferSize) s64 cellSync2MutexEstimateBufferSize(vm::ptr<const CellSync2MutexAttribute> attr, vm::ptr<u32> bufferSize)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__); cellSync2->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsync2 + 0xC3C, libsync2_rtoc); return GetCurrentPPUThread().FastCall2(libsync2 + 0xC3C, libsync2_rtoc);
#else #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) if (attr->maxWaiters > 32768)
return CELL_SYNC2_ERROR_INVAL; return CELL_SYNC2_ERROR_INVAL;
@ -104,28 +105,29 @@ s64 cellSync2MutexUnlock()
#endif #endif
} }
s64 _cellSync2CondAttributeInitialize(vm::ptr<CellSync2CondAttribute> attr) s64 _cellSync2CondAttributeInitialize(vm::ptr<CellSync2CondAttribute> attr, u32 sdkVersion)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__); cellSync2->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsync2 + 0x26DC, libsync2_rtoc); return GetCurrentPPUThread().FastCall2(libsync2 + 0x26DC, libsync2_rtoc);
#else #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; attr->maxWaiters = 15;
strcpy(attr->name, "CellSync2Cond"); strcpy_trunc(attr->name, "CellSync2Cond");
return CELL_OK; return CELL_OK;
#endif #endif
} }
s64 cellSync2CondEstimateBufferSize(vm::ptr<CellSync2CondAttribute> attr, u64 bufferSize) s64 cellSync2CondEstimateBufferSize(vm::ptr<const CellSync2CondAttribute> attr, vm::ptr<u32> bufferSize)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__); cellSync2->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsync2 + 0x1B90, libsync2_rtoc); return GetCurrentPPUThread().FastCall2(libsync2 + 0x1B90, libsync2_rtoc);
#else #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) if (attr->maxWaiters == 0 || attr->maxWaiters > 32768)
return CELL_SYNC2_ERROR_INVAL; return CELL_SYNC2_ERROR_INVAL;
@ -189,31 +191,32 @@ s64 cellSync2CondSignalAll()
#endif #endif
} }
s64 _cellSync2SemaphoreAttributeInitialize(vm::ptr<CellSync2SemaphoreAttribute> attr) s64 _cellSync2SemaphoreAttributeInitialize(vm::ptr<CellSync2SemaphoreAttribute> attr, u32 sdkVersion)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__); cellSync2->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsync2 + 0x5644, libsync2_rtoc); return GetCurrentPPUThread().FastCall2(libsync2 + 0x5644, libsync2_rtoc);
#else #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 | 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_TASK | CELL_SYNC2_THREAD_TYPE_SPURS_JOB |
CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB; CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB;
attr->maxWaiters = 1; attr->maxWaiters = 1;
strcpy(attr->name, "CellSync2Semaphore"); strcpy_trunc(attr->name, "CellSync2Semaphore");
return CELL_OK; return CELL_OK;
#endif #endif
} }
s64 cellSync2SemaphoreEstimateBufferSize(vm::ptr<CellSync2SemaphoreAttribute> attr, u64 bufferSize) s64 cellSync2SemaphoreEstimateBufferSize(vm::ptr<const CellSync2SemaphoreAttribute> attr, vm::ptr<u32> bufferSize)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__); cellSync2->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsync2 + 0x4AC4, libsync2_rtoc); return GetCurrentPPUThread().FastCall2(libsync2 + 0x4AC4, libsync2_rtoc);
#else #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) if (attr->maxWaiters == 0 || attr->maxWaiters > 32768)
return CELL_SYNC2_ERROR_INVAL; return CELL_SYNC2_ERROR_INVAL;
@ -288,14 +291,15 @@ s64 cellSync2SemaphoreGetCount()
#endif #endif
} }
s64 _cellSync2QueueAttributeInitialize(vm::ptr<CellSync2QueueAttribute> attr) s64 _cellSync2QueueAttributeInitialize(vm::ptr<CellSync2QueueAttribute> attr, u32 sdkVersion)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__); cellSync2->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsync2 + 0x3C5C, libsync2_rtoc); return GetCurrentPPUThread().FastCall2(libsync2 + 0x3C5C, libsync2_rtoc);
#else #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 | 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_TASK | CELL_SYNC2_THREAD_TYPE_SPURS_JOB |
CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB; CELL_SYNC2_THREAD_TYPE_SPURS_JOBQUEUE_JOB;
@ -303,21 +307,21 @@ s64 _cellSync2QueueAttributeInitialize(vm::ptr<CellSync2QueueAttribute> attr)
attr->depth = 1024; attr->depth = 1024;
attr->maxPushWaiters = 15; attr->maxPushWaiters = 15;
attr->maxPopWaiters = 15; attr->maxPopWaiters = 15;
strcpy(attr->name, "CellSync2Queue"); strcpy_trunc(attr->name, "CellSync2Queue");
return CELL_OK; return CELL_OK;
#endif #endif
} }
s64 cellSync2QueueEstimateBufferSize(vm::ptr<CellSync2QueueAttribute> attr, u64 bufferSize) s64 cellSync2QueueEstimateBufferSize(vm::ptr<const CellSync2QueueAttribute> attr, vm::ptr<u32> bufferSize)
{ {
#ifdef PRX_DEBUG #ifdef PRX_DEBUG
cellSync2->Warning("%s()", __FUNCTION__); cellSync2->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsync2 + 0x2A98, libsync2_rtoc); return GetCurrentPPUThread().FastCall2(libsync2 + 0x2A98, libsync2_rtoc);
#else #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) attr->maxPushWaiters > 32768 || attr->maxPopWaiters > 32768)
return CELL_SYNC2_ERROR_INVAL; return CELL_SYNC2_ERROR_INVAL;

View File

@ -30,35 +30,48 @@ enum
struct CellSync2MutexAttribute struct CellSync2MutexAttribute
{ {
be_t<u32> sdkVersion;
be_t<u16> threadTypes; be_t<u16> threadTypes;
be_t<u16> maxWaiters; be_t<u16> maxWaiters;
bool recursive; bool recursive;
u8 padding;
char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; char name[CELL_SYNC2_NAME_MAX_LENGTH + 1];
u8 reserved[]; u8 reserved[86];
}; };
static_assert(sizeof(CellSync2MutexAttribute) == 128, "Wrong CellSync2MutexAttribute size");
struct CellSync2CondAttribute struct CellSync2CondAttribute
{ {
be_t<u32> sdkVersion;
be_t<u16> maxWaiters; be_t<u16> maxWaiters;
char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; char name[CELL_SYNC2_NAME_MAX_LENGTH + 1];
u8 reserved[]; u8 reserved[90];
}; };
static_assert(sizeof(CellSync2CondAttribute) == 128, "Wrong CellSync2CondAttribute size");
struct CellSync2SemaphoreAttribute struct CellSync2SemaphoreAttribute
{ {
be_t<u32> sdkVersion;
be_t<u16> threadTypes; be_t<u16> threadTypes;
be_t<u16> maxWaiters; be_t<u16> maxWaiters;
char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; char name[CELL_SYNC2_NAME_MAX_LENGTH + 1];
u8 reserved[]; u8 reserved[88];
}; };
static_assert(sizeof(CellSync2SemaphoreAttribute) == 128, "Wrong CellSync2SemaphoreAttribute size");
struct CellSync2QueueAttribute struct CellSync2QueueAttribute
{ {
be_t<u32> sdkVersion;
be_t<u32> threadTypes; be_t<u32> threadTypes;
be_t<u64> elementSize; be_t<u32> elementSize;
be_t<u32> depth; be_t<u32> depth;
be_t<u16> maxPushWaiters; be_t<u16> maxPushWaiters;
be_t<u16> maxPopWaiters; be_t<u16> maxPopWaiters;
char name[CELL_SYNC2_NAME_MAX_LENGTH + 1]; char name[CELL_SYNC2_NAME_MAX_LENGTH + 1];
u8 reserved[]; u8 reserved[76];
}; };
static_assert(sizeof(CellSync2QueueAttribute) == 128, "Wrong CellSync2QueueAttribute size");