mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 03:25:16 +00:00
SPURS: Fix some bugs
Conflicts: rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp
This commit is contained in:
parent
fe67504ffc
commit
a800d21a31
10 changed files with 53 additions and 61 deletions
|
@ -295,6 +295,13 @@ s32 spursCreateLv2EventQueue(PPUThread& CPU, vm::ptr<CellSpurs> spurs, vm::ptr<u
|
|||
{
|
||||
vm::stackvar<sys_event_queue_attr> attr(CPU);
|
||||
|
||||
auto sys_event_queue_attribute_initialize = [](vm::ptr<sys_event_queue_attr> attr)
|
||||
{
|
||||
attr->protocol = SYS_SYNC_PRIORITY;
|
||||
attr->type = SYS_PPU_QUEUE;
|
||||
attr->name[0] = '\0';
|
||||
};
|
||||
|
||||
sys_event_queue_attribute_initialize(attr);
|
||||
memcpy(attr->name, name.get_ptr(), sizeof(attr->name));
|
||||
auto rc = sys_event_queue_create(queueId, attr, SYS_EVENT_QUEUE_LOCAL, size);
|
||||
|
@ -954,9 +961,7 @@ s32 spursInit(
|
|||
vm::stackvar<be_t<u32>> sem(CPU);
|
||||
vm::stackvar<sys_semaphore_attribute_t> semAttr(CPU);
|
||||
vm::stackvar<sys_lwcond_attribute_t> lwCondAttr(CPU);
|
||||
vm::stackvar<sys_lwcond_t> lwCond(CPU);
|
||||
vm::stackvar<sys_lwmutex_attribute_t> lwMutextAttr(CPU);
|
||||
vm::stackvar<sys_lwmutex_t> lwMutex(CPU);
|
||||
vm::stackvar<sys_lwmutex_attribute_t> lwMutexAttr(CPU);
|
||||
vm::stackvar<be_t<u32>> spuTgId(CPU);
|
||||
vm::stackvar<char> spuTgName(CPU, 128);
|
||||
vm::stackvar<sys_spu_thread_group_attribute> spuTgAttr(CPU);
|
||||
|
@ -1041,6 +1046,14 @@ s32 spursInit(
|
|||
spurs->wklInfoSysSrv.uniqueId.write_relaxed(0xff);
|
||||
|
||||
|
||||
auto sys_semaphore_attribute_initialize = [](vm::ptr<sys_semaphore_attribute_t> attr)
|
||||
{
|
||||
attr->protocol = SYS_SYNC_PRIORITY;
|
||||
attr->pshared = SYS_SYNC_NOT_PROCESS_SHARED;
|
||||
attr->ipc_key = 0;
|
||||
attr->flags = 0;
|
||||
attr->name[0] = '\0';
|
||||
};
|
||||
|
||||
// Create semaphores for each workload
|
||||
// TODO: Find out why these semaphores are needed
|
||||
|
@ -1093,6 +1106,13 @@ s32 spursInit(
|
|||
spuTgName[spurs->prefixSize] = '\0';
|
||||
strcat(spuTgName.get_ptr(), "CellSpursKernelGroup");
|
||||
|
||||
auto sys_spu_thread_group_attribute_initialize = [](vm::ptr<sys_spu_thread_group_attribute> attr)
|
||||
{
|
||||
attr->name = vm::null;
|
||||
attr->nsize = 0;
|
||||
attr->type = SYS_SPU_THREAD_GROUP_TYPE_NORMAL;
|
||||
};
|
||||
|
||||
sys_spu_thread_group_attribute_initialize(spuTgAttr);
|
||||
spuTgAttr->name = spuTgName;
|
||||
spuTgAttr->nsize = (u32)strlen(spuTgAttr->name.get_ptr()) + 1;
|
||||
|
@ -1173,17 +1193,25 @@ s32 spursInit(
|
|||
}
|
||||
}
|
||||
|
||||
const auto lwMutex = spurs.of(&CellSpurs::mutex);
|
||||
const auto lwCond = spurs.of(&CellSpurs::cond);
|
||||
|
||||
auto sys_lwmutex_attribute_initialize = [](vm::ptr<sys_lwmutex_attribute_t> attr)
|
||||
{
|
||||
attr->protocol = SYS_SYNC_PRIORITY;
|
||||
attr->recursive = SYS_SYNC_NOT_RECURSIVE;
|
||||
attr->name[0] = '\0';
|
||||
};
|
||||
|
||||
// Create a mutex to protect access to SPURS handler thread data
|
||||
sys_lwmutex_attribute_initialize(lwMutextAttr);
|
||||
memcpy(lwMutextAttr->name, "_spuPrv", 8);
|
||||
if (s32 rc = sys_lwmutex_create(lwMutex, lwMutextAttr))
|
||||
sys_lwmutex_attribute_initialize(lwMutexAttr);
|
||||
memcpy(lwMutexAttr->name, "_spuPrv", 8);
|
||||
if (s32 rc = sys_lwmutex_create(lwMutex, lwMutexAttr))
|
||||
{
|
||||
spursFinalizeSpu(spurs);
|
||||
return rollback(), rc;
|
||||
}
|
||||
|
||||
spurs->mutex = lwMutex.value();
|
||||
|
||||
// Create condition variable to signal the SPURS handler thread
|
||||
memcpy(lwCondAttr->name, "_spuPrv", 8);
|
||||
if (s32 rc = sys_lwcond_create(lwCond, lwMutex, lwCondAttr))
|
||||
|
@ -1193,8 +1221,6 @@ s32 spursInit(
|
|||
return rollback(), rc;
|
||||
}
|
||||
|
||||
spurs->cond = lwCond;
|
||||
|
||||
spurs->flags1 = (flags & SAF_EXIT_IF_NO_WORK ? SF1_EXIT_IF_NO_WORK : 0) | (isSecond ? SF1_32_WORKLOADS : 0);
|
||||
spurs->wklFlagReceiver.write_relaxed(0xff);
|
||||
spurs->wklFlag.flag.write_relaxed(be_t<u32>::make(-1));
|
||||
|
@ -3638,7 +3664,7 @@ s32 cellSpursCreateTask(PPUThread& CPU, vm::ptr<CellSpursTaskset> taskset, vm::p
|
|||
return rc;
|
||||
}
|
||||
|
||||
rc = spursTaskStart(CPU, taskset, tmpTaskId->value());
|
||||
rc = spursTaskStart(CPU, taskset, tmpTaskId.value());
|
||||
if (rc != CELL_OK)
|
||||
{
|
||||
return rc;
|
||||
|
|
|
@ -1115,19 +1115,24 @@ bool spursTasksetEntry(SPUThread & spu) {
|
|||
bool spursTasksetSyscallEntry(SPUThread & spu) {
|
||||
auto ctxt = vm::get_ptr<SpursTasksetContext>(spu.offset + 0x2700);
|
||||
|
||||
// Save task context
|
||||
ctxt->savedContextLr = spu.GPR[0];
|
||||
ctxt->savedContextSp = spu.GPR[1];
|
||||
for (auto i = 0; i < 48; i++) {
|
||||
ctxt->savedContextR80ToR127[i] = spu.GPR[80 + i];
|
||||
try {
|
||||
// Save task context
|
||||
ctxt->savedContextLr = spu.GPR[0];
|
||||
ctxt->savedContextSp = spu.GPR[1];
|
||||
for (auto i = 0; i < 48; i++) {
|
||||
ctxt->savedContextR80ToR127[i] = spu.GPR[80 + i];
|
||||
}
|
||||
|
||||
// Handle the syscall
|
||||
spu.GPR[3]._u32[3] = spursTasksetProcessSyscall(spu, spu.GPR[3]._u32[3], spu.GPR[4]._u32[3]);
|
||||
|
||||
// Resume the previously executing task if the syscall did not cause a context switch
|
||||
if (spu.m_is_branch == false) {
|
||||
spursTasksetResumeTask(spu);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle the syscall
|
||||
spu.GPR[3]._u32[3] = spursTasksetProcessSyscall(spu, spu.GPR[3]._u32[3], spu.GPR[4]._u32[3]);
|
||||
|
||||
// Resume the previously executing task if the syscall did not cause a context switch
|
||||
if (spu.m_is_branch == false) {
|
||||
spursTasksetResumeTask(spu);
|
||||
catch (SpursModuleExit) {
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -13,13 +13,6 @@
|
|||
|
||||
SysCallBase sys_event("sys_event");
|
||||
|
||||
void sys_event_queue_attribute_initialize(vm::ptr<sys_event_queue_attr> attr)
|
||||
{
|
||||
attr->protocol = SYS_SYNC_PRIORITY;
|
||||
attr->type = SYS_PPU_QUEUE;
|
||||
attr->name[0] = '\0';
|
||||
}
|
||||
|
||||
s32 sys_event_queue_create(vm::ptr<u32> equeue_id, vm::ptr<sys_event_queue_attr> attr, u64 event_queue_key, s32 size)
|
||||
{
|
||||
sys_event.Warning("sys_event_queue_create(equeue_id=*0x%x, attr=*0x%x, event_queue_key=0x%llx, size=%d)", equeue_id, attr, event_queue_key, size);
|
||||
|
|
|
@ -142,8 +142,6 @@ REG_ID_TYPE(lv2_event_port_t, 0x0E); // SYS_EVENT_PORT_OBJECT
|
|||
|
||||
class PPUThread;
|
||||
|
||||
void sys_event_queue_attribute_initialize(vm::ptr<sys_event_queue_attr> attr);
|
||||
|
||||
// SysCalls
|
||||
s32 sys_event_queue_create(vm::ptr<u32> equeue_id, vm::ptr<sys_event_queue_attr> attr, u64 event_queue_key, s32 size);
|
||||
s32 sys_event_queue_destroy(u32 equeue_id, s32 mode);
|
||||
|
|
|
@ -12,13 +12,6 @@
|
|||
|
||||
SysCallBase sys_lwmutex("sys_lwmutex");
|
||||
|
||||
void sys_lwmutex_attribute_initialize(vm::ptr<sys_lwmutex_attribute_t> attr)
|
||||
{
|
||||
attr->protocol = SYS_SYNC_PRIORITY;
|
||||
attr->recursive = SYS_SYNC_NOT_RECURSIVE;
|
||||
attr->name[0] = '\0';
|
||||
}
|
||||
|
||||
s32 _sys_lwmutex_create(vm::ptr<u32> lwmutex_id, u32 protocol, vm::ptr<sys_lwmutex_t> control, u32 arg4, u64 name, u32 arg6)
|
||||
{
|
||||
sys_lwmutex.Warning("_sys_lwmutex_create(lwmutex_id=*0x%x, protocol=0x%x, control=*0x%x, arg4=0x%x, name=0x%llx, arg6=0x%x)", lwmutex_id, protocol, control, arg4, name, arg6);
|
||||
|
|
|
@ -89,9 +89,6 @@ struct lv2_lwmutex_t
|
|||
|
||||
REG_ID_TYPE(lv2_lwmutex_t, 0x95); // SYS_LWMUTEX_OBJECT
|
||||
|
||||
// Aux
|
||||
void sys_lwmutex_attribute_initialize(vm::ptr<sys_lwmutex_attribute_t> attr);
|
||||
|
||||
// SysCalls
|
||||
s32 _sys_lwmutex_create(vm::ptr<u32> lwmutex_id, u32 protocol, vm::ptr<sys_lwmutex_t> control, u32 arg4, u64 name, u32 arg6);
|
||||
s32 _sys_lwmutex_destroy(u32 lwmutex_id);
|
||||
|
|
|
@ -12,15 +12,6 @@
|
|||
|
||||
SysCallBase sys_semaphore("sys_semaphore");
|
||||
|
||||
void sys_semaphore_attribute_initialize(vm::ptr<sys_semaphore_attribute_t> attr)
|
||||
{
|
||||
attr->protocol = SYS_SYNC_PRIORITY;
|
||||
attr->pshared = SYS_SYNC_NOT_PROCESS_SHARED;
|
||||
attr->ipc_key = 0;
|
||||
attr->flags = 0;
|
||||
attr->name[0] = '\0';
|
||||
}
|
||||
|
||||
s32 sys_semaphore_create(vm::ptr<u32> sem, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val)
|
||||
{
|
||||
sys_semaphore.Warning("sys_semaphore_create(sem=*0x%x, attr=*0x%x, initial_val=%d, max_val=%d)", sem, attr, initial_val, max_val);
|
||||
|
|
|
@ -41,9 +41,6 @@ struct lv2_sema_t
|
|||
|
||||
REG_ID_TYPE(lv2_sema_t, 0x96); // SYS_SEMAPHORE_OBJECT
|
||||
|
||||
// Aux
|
||||
void sys_semaphore_attribute_initialize(vm::ptr<sys_semaphore_attribute_t> attr);
|
||||
|
||||
// SysCalls
|
||||
s32 sys_semaphore_create(vm::ptr<u32> sem, vm::ptr<sys_semaphore_attribute_t> attr, s32 initial_val, s32 max_val);
|
||||
s32 sys_semaphore_destroy(u32 sem);
|
||||
|
|
|
@ -465,13 +465,6 @@ s32 sys_spu_thread_group_yield(u32 id)
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
void sys_spu_thread_group_attribute_initialize(vm::ptr<sys_spu_thread_group_attribute> attr)
|
||||
{
|
||||
attr->name = vm::null;
|
||||
attr->nsize = 0;
|
||||
attr->type = SYS_SPU_THREAD_GROUP_TYPE_NORMAL;
|
||||
}
|
||||
|
||||
s32 sys_spu_thread_group_terminate(u32 id, s32 value)
|
||||
{
|
||||
sys_spu.Warning("sys_spu_thread_group_terminate(id=0x%x, value=0x%x)", id, value);
|
||||
|
|
|
@ -216,7 +216,6 @@ u32 LoadSpuImage(vfsStream& stream, u32& spu_ep);
|
|||
s32 spu_image_import(sys_spu_image& img, u32 src, u32 type);
|
||||
u32 spu_thread_group_create(const std::string& name, u32 num, s32 prio, s32 type, u32 container);
|
||||
u32 spu_thread_initialize(u32 group, u32 spu_num, vm::ptr<sys_spu_image> img, const std::string& name, u32 option, u64 a1, u64 a2, u64 a3, u64 a4, std::function<void(SPUThread&)> task = nullptr);
|
||||
void sys_spu_thread_group_attribute_initialize(vm::ptr<sys_spu_thread_group_attribute> attr);
|
||||
|
||||
// SysCalls
|
||||
s32 sys_spu_initialize(u32 max_usable_spu, u32 max_raw_spu);
|
||||
|
|
Loading…
Add table
Reference in a new issue