mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-16 11:48:36 +12:00
PPU thread scheduler
This commit is contained in:
parent
e4962054a4
commit
598c90f376
41 changed files with 699 additions and 259 deletions
|
@ -84,7 +84,7 @@ namespace _spurs
|
|||
s32 add_default_syswkl(vm::ptr<CellSpurs> spurs, vm::cptr<u8> swlPriority, u32 swlMaxSpu, u32 swlIsPreem);
|
||||
|
||||
// Destroy the SPURS SPU threads and thread group
|
||||
s32 finalize_spu(vm::ptr<CellSpurs> spurs);
|
||||
s32 finalize_spu(ppu_thread&, vm::ptr<CellSpurs> spurs);
|
||||
|
||||
// Stop the event helper thread
|
||||
s32 stop_event_helper(ppu_thread& ppu, vm::ptr<CellSpurs> spurs);
|
||||
|
@ -276,7 +276,7 @@ namespace _spurs
|
|||
//s32 cellSpursEventFlagWait(ppu_thread& ppu, vm::ptr<CellSpursEventFlag> eventFlag, vm::ptr<u16> mask, u32 mode);
|
||||
//s32 cellSpursEventFlagTryWait(ppu_thread& ppu, vm::ptr<CellSpursEventFlag> eventFlag, vm::ptr<u16> mask, u32 mode);
|
||||
//s32 cellSpursEventFlagAttachLv2EventQueue(ppu_thread& ppu, vm::ptr<CellSpursEventFlag> eventFlag);
|
||||
//s32 cellSpursEventFlagDetachLv2EventQueue(vm::ptr<CellSpursEventFlag> eventFlag);
|
||||
//s32 cellSpursEventFlagDetachLv2EventQueue(ppu_thread& ppu, vm::ptr<CellSpursEventFlag> eventFlag);
|
||||
//s32 cellSpursEventFlagGetDirection(vm::ptr<CellSpursEventFlag> eventFlag, vm::ptr<u32> direction);
|
||||
//s32 cellSpursEventFlagGetClearMode(vm::ptr<CellSpursEventFlag> eventFlag, vm::ptr<u32> clear_mode);
|
||||
//s32 cellSpursEventFlagGetTasksetAddress(vm::ptr<CellSpursEventFlag> eventFlag, vm::pptr<CellSpursTaskset> taskset);
|
||||
|
@ -380,7 +380,7 @@ s32 _spurs::create_lv2_eq(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, vm::ptr<u32
|
|||
|
||||
if (s32 rc = _spurs::attach_lv2_eq(ppu, spurs, *queueId, port, 1, true))
|
||||
{
|
||||
sys_event_queue_destroy(*queueId, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
sys_event_queue_destroy(ppu, *queueId, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
|
@ -574,7 +574,7 @@ void _spurs::handler_entry(ppu_thread& ppu, vm::ptr<CellSpurs> spurs)
|
|||
|
||||
CHECK_SUCCESS(sys_spu_thread_group_start(spurs->spuTG));
|
||||
|
||||
if (s32 rc = sys_spu_thread_group_join(spurs->spuTG, vm::null, vm::null))
|
||||
if (s32 rc = sys_spu_thread_group_join(ppu, spurs->spuTG, vm::null, vm::null))
|
||||
{
|
||||
if (rc == CELL_ESTAT)
|
||||
{
|
||||
|
@ -674,7 +674,7 @@ s32 _spurs::wakeup_shutdown_completion_waiter(ppu_thread& ppu, vm::ptr<CellSpurs
|
|||
if (!wklF->hook || wklEvent->load() & 0x10)
|
||||
{
|
||||
verify(HERE), (wklF->x28 == 2);
|
||||
rc = sys_semaphore_post((u32)wklF->sem, 1);
|
||||
rc = sys_semaphore_post(ppu, (u32)wklF->sem, 1);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -712,11 +712,11 @@ void _spurs::event_helper_entry(ppu_thread& ppu, vm::ptr<CellSpurs> spurs)
|
|||
|
||||
for (u32 i = 0; i < CELL_SPURS_MAX_WORKLOAD; i++)
|
||||
{
|
||||
sys_semaphore_post((u32)spurs->wklF1[i].sem, 1);
|
||||
sys_semaphore_post(ppu, (u32)spurs->wklF1[i].sem, 1);
|
||||
|
||||
if (spurs->flags1 & SF1_32_WORKLOADS)
|
||||
{
|
||||
sys_semaphore_post((u32)spurs->wklF2[i].sem, 1);
|
||||
sys_semaphore_post(ppu, (u32)spurs->wklF2[i].sem, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ void _spurs::event_helper_entry(ppu_thread& ppu, vm::ptr<CellSpurs> spurs)
|
|||
}
|
||||
else if (data0 == 2)
|
||||
{
|
||||
CHECK_SUCCESS(sys_semaphore_post((u32)spurs->semPrv, 1));
|
||||
CHECK_SUCCESS(sys_semaphore_post(ppu, (u32)spurs->semPrv, 1));
|
||||
}
|
||||
else if (data0 == 3)
|
||||
{
|
||||
|
@ -775,7 +775,7 @@ s32 _spurs::create_event_helper(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 p
|
|||
return CELL_SPURS_CORE_ERROR_AGAIN;
|
||||
}
|
||||
|
||||
sys_event_queue_destroy(spurs->eventQueue, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
sys_event_queue_destroy(ppu, spurs->eventQueue, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
return CELL_SPURS_CORE_ERROR_AGAIN;
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,7 @@ s32 _spurs::create_event_helper(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 p
|
|||
return CELL_SPURS_CORE_ERROR_STAT;
|
||||
}
|
||||
|
||||
sys_event_queue_destroy(spurs->eventQueue, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
sys_event_queue_destroy(ppu, spurs->eventQueue, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
return CELL_SPURS_CORE_ERROR_STAT;
|
||||
}
|
||||
|
||||
|
@ -814,7 +814,7 @@ s32 _spurs::create_event_helper(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 p
|
|||
return CELL_SPURS_CORE_ERROR_STAT;
|
||||
}
|
||||
|
||||
sys_event_queue_destroy(spurs->eventQueue, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
sys_event_queue_destroy(ppu, spurs->eventQueue, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
return CELL_SPURS_CORE_ERROR_STAT;
|
||||
}
|
||||
|
||||
|
@ -839,13 +839,13 @@ s32 _spurs::add_default_syswkl(vm::ptr<CellSpurs> spurs, vm::cptr<u8> swlPriorit
|
|||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 _spurs::finalize_spu(vm::ptr<CellSpurs> spurs)
|
||||
s32 _spurs::finalize_spu(ppu_thread& ppu, vm::ptr<CellSpurs> spurs)
|
||||
{
|
||||
if (spurs->flags & SAF_UNKNOWN_FLAG_7 || spurs->flags & SAF_UNKNOWN_FLAG_8)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
CHECK_SUCCESS(sys_spu_thread_group_join(spurs->spuTG, vm::null, vm::null));
|
||||
CHECK_SUCCESS(sys_spu_thread_group_join(ppu, spurs->spuTG, vm::null, vm::null));
|
||||
|
||||
if (s32 rc = sys_spu_thread_group_destroy(spurs->spuTG))
|
||||
{
|
||||
|
@ -880,7 +880,7 @@ s32 _spurs::stop_event_helper(ppu_thread& ppu, vm::ptr<CellSpurs> spurs)
|
|||
return CELL_SPURS_CORE_ERROR_STAT;
|
||||
}
|
||||
|
||||
if (sys_event_port_send(spurs->eventPort, 0, 1, 0) != CELL_OK)
|
||||
if (sys_event_port_send(ppu, spurs->eventPort, 0, 1, 0) != CELL_OK)
|
||||
{
|
||||
return CELL_SPURS_CORE_ERROR_STAT;
|
||||
}
|
||||
|
@ -895,7 +895,7 @@ s32 _spurs::stop_event_helper(ppu_thread& ppu, vm::ptr<CellSpurs> spurs)
|
|||
CHECK_SUCCESS(sys_event_port_disconnect(spurs->eventPort));
|
||||
CHECK_SUCCESS(sys_event_port_destroy(spurs->eventPort));
|
||||
CHECK_SUCCESS(_spurs::detach_lv2_eq(spurs, spurs->spuPort, true));
|
||||
CHECK_SUCCESS(sys_event_queue_destroy(spurs->eventQueue, SYS_EVENT_QUEUE_DESTROY_FORCE));
|
||||
CHECK_SUCCESS(sys_event_queue_destroy(ppu, spurs->eventQueue, SYS_EVENT_QUEUE_DESTROY_FORCE));
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -1141,7 +1141,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
|||
// Create a mutex to protect access to SPURS handler thread data
|
||||
if (s32 rc = sys_lwmutex_create(lwMutex, vm::make_var(sys_lwmutex_attribute_t{ SYS_SYNC_PRIORITY, SYS_SYNC_NOT_RECURSIVE, "_spuPrv" })))
|
||||
{
|
||||
_spurs::finalize_spu(spurs);
|
||||
_spurs::finalize_spu(ppu, spurs);
|
||||
return rollback(), rc;
|
||||
}
|
||||
|
||||
|
@ -1149,7 +1149,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
|||
if (s32 rc = sys_lwcond_create(lwCond, lwMutex, vm::make_var(sys_lwcond_attribute_t{ "_spuPrv" })))
|
||||
{
|
||||
sys_lwmutex_destroy(ppu, lwMutex);
|
||||
_spurs::finalize_spu(spurs);
|
||||
_spurs::finalize_spu(ppu, spurs);
|
||||
return rollback(), rc;
|
||||
}
|
||||
|
||||
|
@ -1166,7 +1166,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
|||
{
|
||||
sys_lwcond_destroy(lwCond);
|
||||
sys_lwmutex_destroy(ppu, lwMutex);
|
||||
_spurs::finalize_spu(spurs);
|
||||
_spurs::finalize_spu(ppu, spurs);
|
||||
return rollback(), rc;
|
||||
}
|
||||
|
||||
|
@ -1176,7 +1176,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
|||
_spurs::stop_event_helper(ppu, spurs);
|
||||
sys_lwcond_destroy(lwCond);
|
||||
sys_lwmutex_destroy(ppu, lwMutex);
|
||||
_spurs::finalize_spu(spurs);
|
||||
_spurs::finalize_spu(ppu, spurs);
|
||||
return rollback(), rc;
|
||||
}
|
||||
|
||||
|
@ -1188,7 +1188,7 @@ s32 _spurs::initialize(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, u32 revision,
|
|||
_spurs::stop_event_helper(ppu, spurs);
|
||||
sys_lwcond_destroy(lwCond);
|
||||
sys_lwmutex_destroy(ppu, lwMutex);
|
||||
_spurs::finalize_spu(spurs);
|
||||
_spurs::finalize_spu(ppu, spurs);
|
||||
return rollback(), rc;
|
||||
}
|
||||
|
||||
|
@ -2787,7 +2787,7 @@ s32 cellSpursEventFlagSet(ppu_thread& ppu, vm::ptr<CellSpursEventFlag> eventFlag
|
|||
// Signal the PPU thread to be woken up
|
||||
eventFlag->pendingRecvTaskEvents[ppuWaitSlot] = ppuEvents;
|
||||
|
||||
CHECK_SUCCESS(sys_event_port_send(eventFlag->eventPortId, 0, 0, 0));
|
||||
CHECK_SUCCESS(sys_event_port_send(ppu, eventFlag->eventPortId, 0, 0, 0));
|
||||
}
|
||||
|
||||
if (pendingRecv)
|
||||
|
@ -3067,7 +3067,7 @@ s32 cellSpursEventFlagAttachLv2EventQueue(ppu_thread& ppu, vm::ptr<CellSpursEven
|
|||
|
||||
if (_spurs::detach_lv2_eq(spurs, *port, true) == CELL_OK)
|
||||
{
|
||||
sys_event_queue_destroy(*eventQueueId, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
sys_event_queue_destroy(ppu, *eventQueueId, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
}
|
||||
|
||||
return failure(rc);
|
||||
|
@ -3077,7 +3077,7 @@ s32 cellSpursEventFlagAttachLv2EventQueue(ppu_thread& ppu, vm::ptr<CellSpursEven
|
|||
}
|
||||
|
||||
/// Detach an LV2 event queue from SPURS event flag
|
||||
s32 cellSpursEventFlagDetachLv2EventQueue(vm::ptr<CellSpursEventFlag> eventFlag)
|
||||
s32 cellSpursEventFlagDetachLv2EventQueue(ppu_thread& ppu, vm::ptr<CellSpursEventFlag> eventFlag)
|
||||
{
|
||||
cellSpurs.warning("cellSpursEventFlagDetachLv2EventQueue(eventFlag=*0x%x)", eventFlag);
|
||||
|
||||
|
@ -3131,7 +3131,7 @@ s32 cellSpursEventFlagDetachLv2EventQueue(vm::ptr<CellSpursEventFlag> eventFlag)
|
|||
|
||||
if (rc == CELL_OK)
|
||||
{
|
||||
rc = sys_event_queue_destroy(eventFlag->eventQueueId, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
rc = sys_event_queue_destroy(ppu, eventFlag->eventQueueId, SYS_EVENT_QUEUE_DESTROY_FORCE);
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue