2016-03-21 20:43:03 +01:00
|
|
|
#include "Emu/Cell/PPUModule.h"
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "stdafx.h"
|
2014-08-27 00:44:32 +02:00
|
|
|
|
|
|
|
|
#include "cellSync2.h"
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
#include "util/StrUtil.h"
|
2016-04-27 00:27:24 +02:00
|
|
|
|
2018-08-25 14:39:00 +02:00
|
|
|
LOG_CHANNEL(cellSync2);
|
2015-09-08 15:53:28 +02:00
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
vm::gvar<CellSync2CallerThreadType> gCellSync2CallerThreadTypePpuThread;
|
|
|
|
|
vm::gvar<CellSync2Notifier> gCellSync2NotifierPpuThread;
|
|
|
|
|
vm::gvar<CellSync2CallerThreadType> gCellSync2CallerThreadTypePpuFiber;
|
|
|
|
|
vm::gvar<CellSync2Notifier> gCellSync2NotifierPpuFiber;
|
|
|
|
|
vm::gvar<CellSync2Notifier> gCellSync2NotifierSpursTask;
|
|
|
|
|
vm::gvar<CellSync2Notifier> gCellSync2NotifierSpursJobQueueJob;
|
2014-08-27 00:44:32 +02:00
|
|
|
|
2025-04-05 21:50:45 +02:00
|
|
|
template <>
|
2018-04-29 10:50:12 +02:00
|
|
|
void fmt_class_string<CellSync2Error>::format(std::string& out, u64 arg)
|
|
|
|
|
{
|
|
|
|
|
format_enum(out, arg, [](auto error)
|
|
|
|
|
{
|
2025-04-05 21:50:45 +02:00
|
|
|
switch (error)
|
|
|
|
|
{
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_AGAIN);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_INVAL);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_NOMEM);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_DEADLK);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_PERM);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_BUSY);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_STAT);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_ALIGN);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_NULL_POINTER);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_NOT_SUPPORTED_THREAD);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_NO_NOTIFIER);
|
|
|
|
|
STR_CASE(CELL_SYNC2_ERROR_NO_SPU_CONTEXT_STORAGE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return unknown;
|
|
|
|
|
});
|
2018-04-29 10:50:12 +02:00
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
_cellSync2MutexAttributeInitialize(vm::ptr<CellSync2MutexAttribute> attr,
|
|
|
|
|
u32 sdkVersion)
|
2015-02-18 23:54:31 +01:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.warning(
|
|
|
|
|
"_cellSync2MutexAttributeInitialize(attr=*0x%x, sdkVersion=0x%x)", attr,
|
|
|
|
|
sdkVersion);
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
if (!attr)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2014-09-06 12:52:22 +02:00
|
|
|
attr->sdkVersion = sdkVersion;
|
2025-04-08 18:46:57 +02:00
|
|
|
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;
|
2014-09-04 17:27:19 +02:00
|
|
|
attr->maxWaiters = 15;
|
|
|
|
|
attr->recursive = false;
|
2014-09-06 12:52:22 +02:00
|
|
|
strcpy_trunc(attr->name, "CellSync2Mutex");
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellSync2MutexEstimateBufferSize(vm::cptr<CellSync2MutexAttribute> attr,
|
|
|
|
|
vm::ptr<u32> bufferSize)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2MutexEstimateBufferSize(attr=*0x%x, bufferSize=*0x%x)", attr,
|
|
|
|
|
bufferSize);
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
if (!attr || !bufferSize)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if (attr->maxWaiters > 0x8000)
|
2014-09-04 17:27:19 +02:00
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2MutexInitialize(vm::ptr<CellSync2Mutex> mutex,
|
|
|
|
|
vm::ptr<void> buffer,
|
|
|
|
|
vm::cptr<CellSync2MutexAttribute> attr)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2MutexInitialize(mutex=*0x%x, buffer=*0x%x, attr=*0x%x)", mutex,
|
|
|
|
|
buffer, attr);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!mutex || !attr)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if ((attr->maxWaiters > 0) && !buffer)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if (attr->maxWaiters > 0x8000)
|
|
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
error_code cellSync2MutexFinalize(vm::ptr<CellSync2Mutex> mutex)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2018-04-29 10:50:12 +02:00
|
|
|
cellSync2.todo("cellSync2MutexFinalize(mutex=*0x%x)", mutex);
|
|
|
|
|
|
|
|
|
|
if (!mutex)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2MutexLock(vm::ptr<CellSync2Mutex> mutex,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2MutexLock(mutex=*0x%x, config=*0x%x)", mutex,
|
|
|
|
|
config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!mutex)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2MutexTryLock(vm::ptr<CellSync2Mutex> mutex,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2MutexTryLock(mutex=*0x%x, config=*0x%x)", mutex,
|
|
|
|
|
config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!mutex)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2MutexUnlock(vm::ptr<CellSync2Mutex> mutex,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2MutexUnlock(mutex=*0x%x, config=*0x%x)", mutex,
|
|
|
|
|
config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!mutex)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
_cellSync2CondAttributeInitialize(vm::ptr<CellSync2CondAttribute> attr,
|
|
|
|
|
u32 sdkVersion)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.warning(
|
|
|
|
|
"_cellSync2CondAttributeInitialize(attr=*0x%x, sdkVersion=0x%x)", attr,
|
|
|
|
|
sdkVersion);
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
if (!attr)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2014-09-06 12:52:22 +02:00
|
|
|
attr->sdkVersion = sdkVersion;
|
2014-09-04 17:27:19 +02:00
|
|
|
attr->maxWaiters = 15;
|
2014-09-06 12:52:22 +02:00
|
|
|
strcpy_trunc(attr->name, "CellSync2Cond");
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellSync2CondEstimateBufferSize(vm::cptr<CellSync2CondAttribute> attr,
|
|
|
|
|
vm::ptr<u32> bufferSize)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2CondEstimateBufferSize(attr=*0x%x, bufferSize=*0x%x)", attr,
|
|
|
|
|
bufferSize);
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
if (!attr || !bufferSize)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if (attr->maxWaiters == 0 || attr->maxWaiters > 0x8000)
|
2014-09-04 17:27:19 +02:00
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2CondInitialize(vm::ptr<CellSync2Cond> cond,
|
|
|
|
|
vm::ptr<CellSync2Mutex> mutex,
|
|
|
|
|
vm::ptr<void> buffer,
|
|
|
|
|
vm::cptr<CellSync2CondAttribute> attr)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2CondInitialize(cond=*0x%x, mutex=*0x%x, "
|
|
|
|
|
"buffer=*0x%x, attr=*0x%x)",
|
|
|
|
|
cond, mutex, buffer, attr);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!cond || !mutex || !buffer || !attr)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if (attr->maxWaiters == 0)
|
|
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
error_code cellSync2CondFinalize(vm::ptr<CellSync2Cond> cond)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2018-04-29 10:50:12 +02:00
|
|
|
cellSync2.todo("cellSync2CondFinalize(cond=*0x%x)", cond);
|
|
|
|
|
|
|
|
|
|
if (!cond)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2CondWait(vm::ptr<CellSync2Cond> cond,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2018-04-29 10:50:12 +02:00
|
|
|
cellSync2.todo("cellSync2CondWait(cond=*0x%x, config=*0x%x)", cond, config);
|
|
|
|
|
|
|
|
|
|
if (!cond)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2CondSignal(vm::ptr<CellSync2Cond> cond,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2018-04-29 10:50:12 +02:00
|
|
|
cellSync2.todo("cellSync2CondSignal(cond=*0x%x, config=*0x%x)", cond, config);
|
|
|
|
|
|
|
|
|
|
if (!cond)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2CondSignalAll(vm::ptr<CellSync2Cond> cond,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2CondSignalAll(cond=*0x%x, config=*0x%x)", cond,
|
|
|
|
|
config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!cond)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code _cellSync2SemaphoreAttributeInitialize(
|
|
|
|
|
vm::ptr<CellSync2SemaphoreAttribute> attr, u32 sdkVersion)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.warning(
|
|
|
|
|
"_cellSync2SemaphoreAttributeInitialize(attr=*0x%x, sdkVersion=0x%x)",
|
|
|
|
|
attr, sdkVersion);
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
if (!attr)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2014-09-06 12:52:22 +02:00
|
|
|
attr->sdkVersion = sdkVersion;
|
2025-04-08 18:46:57 +02:00
|
|
|
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;
|
2014-09-04 17:27:19 +02:00
|
|
|
attr->maxWaiters = 1;
|
2014-09-06 12:52:22 +02:00
|
|
|
strcpy_trunc(attr->name, "CellSync2Semaphore");
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellSync2SemaphoreEstimateBufferSize(vm::cptr<CellSync2SemaphoreAttribute> attr,
|
|
|
|
|
vm::ptr<u32> bufferSize)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2SemaphoreEstimateBufferSize(attr=*0x%x, bufferSize=*0x%x)",
|
|
|
|
|
attr, bufferSize);
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
if (!attr || !bufferSize)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if (attr->maxWaiters == 0 || attr->maxWaiters > 0x8000)
|
2014-09-04 17:27:19 +02:00
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellSync2SemaphoreInitialize(vm::ptr<CellSync2Semaphore> semaphore,
|
|
|
|
|
vm::ptr<void> buffer, s32 initialValue,
|
|
|
|
|
vm::cptr<CellSync2SemaphoreAttribute> attr)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2SemaphoreInitialize(semaphore=*0x%x, buffer=*0x%x, "
|
|
|
|
|
"initialValue=0x%x, attr=*0x%x)",
|
|
|
|
|
semaphore, buffer, initialValue, attr);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!semaphore || !attr || ((attr->maxWaiters >= 2) && !buffer))
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
if ((initialValue > s32{0x7FFFFF}) || (initialValue < s32{-0x800000}) ||
|
|
|
|
|
(attr->maxWaiters == 0) || ((attr->maxWaiters == 1) && buffer))
|
2018-04-29 10:50:12 +02:00
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
error_code cellSync2SemaphoreFinalize(vm::ptr<CellSync2Semaphore> semaphore)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2018-04-29 10:50:12 +02:00
|
|
|
cellSync2.todo("cellSync2SemaphoreFinalize(semaphore=*0x%x)", semaphore);
|
|
|
|
|
|
|
|
|
|
if (!semaphore)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2SemaphoreAcquire(vm::ptr<CellSync2Semaphore> semaphore,
|
|
|
|
|
u32 count,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2SemaphoreAcquire(semaphore=*0x%x, count=0x%x, config=*0x%x)",
|
|
|
|
|
semaphore, count, config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!semaphore)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if (count > 0x7FFFFF)
|
|
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellSync2SemaphoreTryAcquire(vm::ptr<CellSync2Semaphore> semaphore, u32 count,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2SemaphoreTryAcquire(semaphore=*0x%x, count=0x%x, config=*0x%x)",
|
|
|
|
|
semaphore, count, config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!semaphore)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if (count > 0x7FFFFF)
|
|
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2SemaphoreRelease(vm::ptr<CellSync2Semaphore> semaphore,
|
|
|
|
|
u32 count,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2SemaphoreRelease(semaphore=*0x%x, count=0x%x, config=*0x%x)",
|
|
|
|
|
semaphore, count, config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!semaphore)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
|
|
if (count > 0x7FFFFF)
|
|
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2SemaphoreGetCount(vm::ptr<CellSync2Semaphore> semaphore,
|
|
|
|
|
vm::ptr<s32> count)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2SemaphoreGetCount(semaphore=*0x%x, count=*0x%x)",
|
|
|
|
|
semaphore, count);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!semaphore || !count)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
_cellSync2QueueAttributeInitialize(vm::ptr<CellSync2QueueAttribute> attr,
|
|
|
|
|
u32 sdkVersion)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.warning(
|
|
|
|
|
"_cellSync2QueueAttributeInitialize(attr=*0x%x, sdkVersion=0x%x)", attr,
|
|
|
|
|
sdkVersion);
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
if (!attr)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2014-09-06 12:52:22 +02:00
|
|
|
attr->sdkVersion = sdkVersion;
|
2025-04-08 18:46:57 +02:00
|
|
|
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;
|
2014-09-04 17:27:19 +02:00
|
|
|
attr->elementSize = 16;
|
|
|
|
|
attr->depth = 1024;
|
|
|
|
|
attr->maxPushWaiters = 15;
|
|
|
|
|
attr->maxPopWaiters = 15;
|
2014-09-06 12:52:22 +02:00
|
|
|
strcpy_trunc(attr->name, "CellSync2Queue");
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code
|
|
|
|
|
cellSync2QueueEstimateBufferSize(vm::cptr<CellSync2QueueAttribute> attr,
|
|
|
|
|
vm::ptr<u32> bufferSize)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2QueueEstimateBufferSize(attr=*0x%x, bufferSize=*0x%x)", attr,
|
|
|
|
|
bufferSize);
|
2014-09-04 17:27:19 +02:00
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
if (!attr || !bufferSize)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
if (attr->elementSize == 0u || attr->elementSize > 0x4000u ||
|
|
|
|
|
attr->elementSize % 16u || attr->depth == 0u ||
|
|
|
|
|
attr->depth > 0xFFFFFFFCu || attr->maxPushWaiters > 0x8000u ||
|
|
|
|
|
attr->maxPopWaiters > 0x8000u)
|
2014-09-04 17:27:19 +02:00
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2QueueInitialize(vm::ptr<CellSync2Queue> queue,
|
|
|
|
|
vm::ptr<void> buffer,
|
|
|
|
|
vm::cptr<CellSync2QueueAttribute> attr)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2QueueInitialize(queue=*0x%x, buffer=*0x%x, attr=*0x%x)", queue,
|
|
|
|
|
buffer, attr);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!queue || !buffer || !attr)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
if (attr->elementSize == 0u || attr->elementSize > 0x4000u ||
|
|
|
|
|
attr->elementSize % 16u || attr->depth == 0u ||
|
|
|
|
|
attr->depth > 0xFFFFFFFCu || attr->maxPushWaiters > 0x8000u ||
|
|
|
|
|
attr->maxPopWaiters > 0x8000u)
|
2018-04-29 10:50:12 +02:00
|
|
|
return CELL_SYNC2_ERROR_INVAL;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 10:50:12 +02:00
|
|
|
error_code cellSync2QueueFinalize(vm::ptr<CellSync2Queue> queue)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2018-04-29 10:50:12 +02:00
|
|
|
cellSync2.todo("cellSync2QueueFinalize(queue=*0x%x)", queue);
|
|
|
|
|
|
|
|
|
|
if (!queue)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2QueuePush(vm::ptr<CellSync2Queue> queue,
|
|
|
|
|
vm::cptr<void> data,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2QueuePush(queue=*0x%x, data=*0x%x, config=*0x%x)",
|
|
|
|
|
queue, data, config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!queue || !data)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2QueueTryPush(vm::ptr<CellSync2Queue> queue,
|
|
|
|
|
vm::cpptr<void> data, u32 numData,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2QueueTryPush(queue=*0x%x, data=**0x%x, "
|
|
|
|
|
"numData=0x%x, config=*0x%x)",
|
|
|
|
|
queue, data, numData, config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!queue || !data)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2QueuePop(vm::ptr<CellSync2Queue> queue,
|
|
|
|
|
vm::ptr<void> buffer,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2QueuePop(queue=*0x%x, buffer=*0x%x, config=*0x%x)",
|
|
|
|
|
queue, buffer, config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!queue || !buffer)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2QueueTryPop(vm::ptr<CellSync2Queue> queue,
|
|
|
|
|
vm::ptr<void> buffer,
|
|
|
|
|
vm::cptr<CellSync2ThreadConfig> config)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo(
|
|
|
|
|
"cellSync2QueueTryPop(queue=*0x%x, buffer=*0x%x, config=*0x%x)", queue,
|
|
|
|
|
buffer, config);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!queue || !buffer)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2QueueGetSize(vm::ptr<CellSync2Queue> queue,
|
|
|
|
|
vm::ptr<u32> size)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2018-04-29 10:50:12 +02:00
|
|
|
cellSync2.todo("cellSync2QueueGetSize(queue=*0x%x, size=*0x%x)", queue, size);
|
|
|
|
|
|
|
|
|
|
if (!queue || !size)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-08 18:46:57 +02:00
|
|
|
error_code cellSync2QueueGetDepth(vm::ptr<CellSync2Queue> queue,
|
|
|
|
|
vm::ptr<u32> depth)
|
2013-09-28 04:36:57 +02:00
|
|
|
{
|
2025-04-08 18:46:57 +02:00
|
|
|
cellSync2.todo("cellSync2QueueGetDepth(queue=*0x%x, depth=*0x%x)", queue,
|
|
|
|
|
depth);
|
2018-04-29 10:50:12 +02:00
|
|
|
|
|
|
|
|
if (!queue || !depth)
|
|
|
|
|
return CELL_SYNC2_ERROR_NULL_POINTER;
|
|
|
|
|
|
2013-09-28 04:36:57 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-21 20:43:03 +01:00
|
|
|
DECLARE(ppu_module_manager::cellSync2)("cellSync2", []()
|
2025-04-05 21:50:45 +02:00
|
|
|
{
|
|
|
|
|
REG_VAR(cellSync2, gCellSync2CallerThreadTypePpuThread);
|
|
|
|
|
REG_VAR(cellSync2, gCellSync2NotifierPpuThread);
|
|
|
|
|
REG_VAR(cellSync2, gCellSync2CallerThreadTypePpuFiber);
|
|
|
|
|
REG_VAR(cellSync2, gCellSync2NotifierPpuFiber);
|
|
|
|
|
REG_VAR(cellSync2, gCellSync2NotifierSpursTask);
|
|
|
|
|
REG_VAR(cellSync2, gCellSync2NotifierSpursJobQueueJob);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellSync2, _cellSync2MutexAttributeInitialize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2MutexEstimateBufferSize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2MutexInitialize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2MutexFinalize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2MutexLock);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2MutexTryLock);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2MutexUnlock);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellSync2, _cellSync2CondAttributeInitialize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2CondEstimateBufferSize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2CondInitialize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2CondFinalize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2CondWait);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2CondSignal);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2CondSignalAll);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellSync2, _cellSync2SemaphoreAttributeInitialize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2SemaphoreEstimateBufferSize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2SemaphoreInitialize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2SemaphoreFinalize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2SemaphoreAcquire);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2SemaphoreTryAcquire);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2SemaphoreRelease);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2SemaphoreGetCount);
|
|
|
|
|
|
|
|
|
|
REG_FUNC(cellSync2, _cellSync2QueueAttributeInitialize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueueEstimateBufferSize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueueInitialize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueueFinalize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueuePush);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueueTryPush);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueuePop);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueueTryPop);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueueGetSize);
|
|
|
|
|
REG_FUNC(cellSync2, cellSync2QueueGetDepth);
|
|
|
|
|
});
|