Events improved

This commit is contained in:
Nekotekina 2015-04-13 16:32:09 +03:00
parent fea6fd1a70
commit 85b63de631
9 changed files with 45 additions and 12 deletions

View file

@ -686,7 +686,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
return ch_in_mbox.push_uncond(CELL_EBUSY); return ch_in_mbox.push_uncond(CELL_EBUSY);
} }
queue->push(SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (value & 0x00ffffff), data); queue->push(lv2_lock, SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (value & 0x00ffffff), data);
return ch_in_mbox.push_uncond(CELL_OK); return ch_in_mbox.push_uncond(CELL_OK);
} }
@ -725,7 +725,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
return; return;
} }
queue->push(SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (value & 0x00ffffff), data); queue->push(lv2_lock, SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (value & 0x00ffffff), data);
return; return;
} }
else if (code == 128) else if (code == 128)

View file

@ -1,5 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "Emu/Memory/Memory.h" #include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "Emu/SysCalls/lv2/sleep_queue.h" #include "Emu/SysCalls/lv2/sleep_queue.h"
#include "Emu/SysCalls/lv2/sys_event.h" #include "Emu/SysCalls/lv2/sys_event.h"

View file

@ -391,7 +391,7 @@ s32 cellAudioInit()
{ {
if (const auto queue = Emu.GetEventManager().GetEventQueue(key)) if (const auto queue = Emu.GetEventManager().GetEventQueue(key))
{ {
queue->push(0, 0, 0, 0); // TODO: check arguments queue->push(lv2_lock, 0, 0, 0, 0); // TODO: check arguments
} }
} }
} }

View file

@ -345,7 +345,7 @@ s32 sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
const u64 source = port->name ? port->name : ((u64)process_getpid() << 32) | (u64)eport_id; const u64 source = port->name ? port->name : ((u64)process_getpid() << 32) | (u64)eport_id;
queue->push(source, data1, data2, data3); queue->push(lv2_lock, source, data1, data2, data3);
return CELL_OK; return CELL_OK;
} }

View file

@ -95,8 +95,10 @@ struct event_queue_t
{ {
} }
void push(u64 source, u64 data1, u64 data2, u64 data3) void push(lv2_lock_type& lv2_lock, u64 source, u64 data1, u64 data2, u64 data3)
{ {
CHECK_LV2_LOCK(lv2_lock);
events.emplace_back(source, data1, data2, data3); events.emplace_back(source, data1, data2, data3);
if (waiters) if (waiters)

View file

@ -329,10 +329,7 @@ s32 sys_spu_thread_group_start(u32 id)
// because SPU_THREAD_GROUP_STATUS_READY is not possible, run event is delivered immediately // because SPU_THREAD_GROUP_STATUS_READY is not possible, run event is delivered immediately
if (auto queue = group->ep_run.lock()) group->send_run_event(lv2_lock, id, 0, 0); // TODO: check data2 and data3
{
queue->push(SYS_SPU_THREAD_GROUP_EVENT_RUN_KEY, id, 0, 0); // TODO: check data2 and data3
}
for (auto& t : group->threads) for (auto& t : group->threads)
{ {

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
struct event_queue_t; #include "sys_event.h"
enum : s32 enum : s32
{ {
@ -172,6 +172,36 @@ struct spu_group_t
, join_state(0) , join_state(0)
{ {
} }
void send_run_event(lv2_lock_type& lv2_lock, u64 data1, u64 data2, u64 data3)
{
CHECK_LV2_LOCK(lv2_lock);
if (const auto queue = ep_run.lock())
{
queue->push(lv2_lock, SYS_SPU_THREAD_GROUP_EVENT_RUN_KEY, data1, data2, data3);
}
}
void send_exception_event(lv2_lock_type& lv2_lock, u64 data1, u64 data2, u64 data3)
{
CHECK_LV2_LOCK(lv2_lock);
if (const auto queue = ep_exception.lock())
{
queue->push(lv2_lock, SYS_SPU_THREAD_GROUP_EVENT_EXCEPTION_KEY, data1, data2, data3);
}
}
void send_sysmodule_event(lv2_lock_type& lv2_lock, u64 data1, u64 data2, u64 data3)
{
CHECK_LV2_LOCK(lv2_lock);
if (const auto queue = ep_sysmodule.lock())
{
queue->push(lv2_lock, SYS_SPU_THREAD_GROUP_EVENT_SYSTEM_MODULE_KEY, data1, data2, data3);
}
}
}; };
class SPUThread; class SPUThread;

View file

@ -32,7 +32,7 @@ s32 sys_timer_create(vm::ptr<u32> timer_id)
if (queue) if (queue)
{ {
queue->push(timer->source, timer->data1, timer->data2, timer->start); queue->push(lv2_lock, timer->source, timer->data1, timer->data2, timer->start);
} }
if (timer->period && queue) if (timer->period && queue)

View file

@ -199,7 +199,10 @@ public:
__forceinline bool IsReady() const { return m_status == Ready; } __forceinline bool IsReady() const { return m_status == Ready; }
}; };
#define LV2_LOCK std::unique_lock<std::mutex> lv2_lock(Emu.GetCoreMutex()) using lv2_lock_type = std::unique_lock<std::mutex>;
#define LV2_LOCK lv2_lock_type lv2_lock(Emu.GetCoreMutex())
#define CHECK_LV2_LOCK(x) assert((x).owns_lock() && (x).mutex() == &Emu.GetCoreMutex())
extern Emulator Emu; extern Emulator Emu;