1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

sys_event: Save ID of self event queue

This commit is contained in:
Eladash 2021-05-07 20:48:26 +03:00 committed by Ivan
parent b09970f159
commit 363cc60c82
4 changed files with 18 additions and 19 deletions

View File

@ -11,6 +11,16 @@
LOG_CHANNEL(sys_event);
lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, u64 name, u64 ipc_key, s32 size) noexcept
: protocol{protocol}
, id(idm::last_id())
, type(type)
, name(name)
, key(ipc_key)
, size(size)
{
}
std::shared_ptr<lv2_event_queue> lv2_event_queue::find(u64 ipc_key)
{
if (ipc_key == SYS_EVENT_QUEUE_LOCAL)
@ -112,7 +122,7 @@ error_code sys_event_queue_create(cpu_thread& cpu, vm::ptr<u32> equeue_id, vm::p
}
const u32 pshared = ipc_key == SYS_EVENT_QUEUE_LOCAL ? SYS_SYNC_NOT_PROCESS_SHARED : SYS_SYNC_PROCESS_SHARED;
constexpr u32 flags = SYS_SYNC_NEWLY_CREATED; // NOTE: This is inaccurate for multi-process
constexpr u32 flags = SYS_SYNC_NEWLY_CREATED;
const u64 name = attr->name_u64;
if (const auto error = lv2_obj::create<lv2_event_queue>(pshared, ipc_key, flags, [&]()
@ -409,7 +419,6 @@ error_code sys_event_port_connect_local(cpu_thread& cpu, u32 eport_id, u32 equeu
}
port->queue = idm::get_unlocked<lv2_obj, lv2_event_queue>(equeue_id);
port->queue_id = equeue_id;
return CELL_OK;
}

View File

@ -81,6 +81,7 @@ struct lv2_event_queue final : public lv2_obj
static const u32 id_base = 0x8d000000;
const lv2_protocol protocol;
const u32 id;
const s32 type;
const u64 name;
const u64 key;
@ -90,14 +91,7 @@ struct lv2_event_queue final : public lv2_obj
std::deque<lv2_event> events;
std::deque<cpu_thread*> sq;
lv2_event_queue(u32 protocol, s32 type, u64 name, u64 ipc_key, s32 size)
: protocol{protocol}
, type(type)
, name(name)
, key(ipc_key)
, size(size)
{
}
lv2_event_queue(u32 protocol, s32 type, u64 name, u64 ipc_key, s32 size) noexcept;
CellError send(lv2_event);
@ -120,7 +114,6 @@ struct lv2_event_port final : lv2_obj
const s32 type; // Port type, either IPC or local
const u64 name; // Event source (generated from id and process id if not set)
u32 queue_id = 0; // Event queue ID (if IPC is used this value is meaningless)
std::shared_ptr<lv2_event_queue> queue; // Event queue this port is connected to

View File

@ -224,13 +224,13 @@ public:
default: return CELL_EINVAL;
}
std::shared_ptr<T> result = make();
// EAGAIN for IDM IDs shortage
CellError error = CELL_EAGAIN;
if (!idm::import<lv2_obj, T>([&]() -> std::shared_ptr<T>
{
std::shared_ptr<T> result = make();
auto finalize_construct = [&]() -> std::shared_ptr<T>
{
if ((error = result->on_id_create()))

View File

@ -372,18 +372,15 @@ void kernel_explorer::Update()
if (const auto queue = ep.queue.get(); queue && queue->exists)
{
if (queue == idm::check_unlocked<lv2_obj, lv2_event_queue>(ep.queue_id))
if (queue == idm::check_unlocked<lv2_obj, lv2_event_queue>(queue->id))
{
// Type must be LOCAL here, but refer to the note below for why it is showed
add_leaf(node, qstr(fmt::format("Event Port 0x%08x: %s, Name: %#llx, Event Queue (ID): 0x%08x", id, type, ep.name, ep.queue_id)));
add_leaf(node, qstr(fmt::format("Event Port 0x%08x: %s, Name: %#llx, Event Queue (ID): 0x%08x", id, type, ep.name, queue->id)));
break;
}
// This code is unused until multi-process is implemented
if (queue == lv2_event_queue::find(queue->key).get())
{
// There are cases in which the attached queue by ID also has an IPC
// And the ID was destroyed but another was created for that same IPC
// So show event port type as well here because it not guaranteed to be IPC
add_leaf(node, qstr(fmt::format("Event Port 0x%08x: %s, Name: %#llx, Event Queue (IPC): %s", id, type, ep.name, queue->key)));
break;
}