From 605d57c541ee63c8f7f633f9c29a012ddf7ebf75 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 30 Oct 2020 17:43:09 +0300 Subject: [PATCH] sys_event: cleanup (replace vm::temporary_unlock) Also made minor changes in sys_rsx.cpp. Removed unused exception std headers. --- Utilities/StrFmt.h | 2 -- rpcs3/Emu/Cell/Modules/cellAudio.cpp | 14 +++++++------- rpcs3/Emu/Cell/Modules/cellSpurs.cpp | 10 +++++----- rpcs3/Emu/Cell/Modules/cellVoice.cpp | 6 +++--- rpcs3/Emu/Cell/lv2/sys_event.cpp | 17 ++++++++++------- rpcs3/Emu/Cell/lv2/sys_event.h | 6 +++--- rpcs3/Emu/Cell/lv2/sys_mmapper.cpp | 4 ++-- rpcs3/Emu/Cell/lv2/sys_rsx.cpp | 12 +++++++----- rpcs3/Emu/Cell/lv2/sys_rsx.h | 4 +++- rpcs3/Emu/RSX/Capture/rsx_replay.cpp | 3 +-- rpcs3/Emu/RSX/GL/GLHelpers.h | 1 - rpcs3/Emu/RSX/GL/GLTextureCache.h | 1 - rpcs3/Emu/RSX/RSXThread.cpp | 1 - rpcs3/Emu/RSX/VK/VKHelpers.h | 1 - rpcs3/stdafx.h | 2 -- 15 files changed, 41 insertions(+), 43 deletions(-) diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 62cc732f52..33b4b6473e 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -2,8 +2,6 @@ #include "types.h" -#include -#include #include namespace fmt diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index 1229d0ce7f..7cb5640421 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -1220,7 +1220,7 @@ error_code cellAudioPortOpen(vm::ptr audioParam, vm::ptr(1, num_channels); @@ -1491,7 +1491,7 @@ error_code cellAudioSetPortLevel(u32 portNum, float level) return CELL_OK; } -static error_code AudioCreateNotifyEventQueue(vm::ptr id, vm::ptr key, u32 queue_type) +static error_code AudioCreateNotifyEventQueue(ppu_thread& ppu, vm::ptr id, vm::ptr key, u32 queue_type) { vm::var attr; attr->protocol = SYS_SYNC_FIFO; @@ -1507,7 +1507,7 @@ static error_code AudioCreateNotifyEventQueue(vm::ptr id, vm::ptr key, // So check initialization as well const u32 queue_depth = g_fxo->get()->init && g_ps3_process_info.sdk_ver <= 0x35FFFF ? 2 : 8; - if (CellError res{sys_event_queue_create(id, attr, key_value, queue_depth) + 0u}) + if (CellError res{sys_event_queue_create(ppu, id, attr, key_value, queue_depth) + 0u}) { if (res != CELL_EEXIST) { @@ -1524,14 +1524,14 @@ static error_code AudioCreateNotifyEventQueue(vm::ptr id, vm::ptr key, return CELL_AUDIO_ERROR_EVENT_QUEUE; } -error_code cellAudioCreateNotifyEventQueue(vm::ptr id, vm::ptr key) +error_code cellAudioCreateNotifyEventQueue(ppu_thread& ppu, vm::ptr id, vm::ptr key) { cellAudio.warning("cellAudioCreateNotifyEventQueue(id=*0x%x, key=*0x%x)", id, key); - return AudioCreateNotifyEventQueue(id, key, SYS_PPU_QUEUE); + return AudioCreateNotifyEventQueue(ppu, id, key, SYS_PPU_QUEUE); } -error_code cellAudioCreateNotifyEventQueueEx(vm::ptr id, vm::ptr key, u32 iFlags) +error_code cellAudioCreateNotifyEventQueueEx(ppu_thread& ppu, vm::ptr id, vm::ptr key, u32 iFlags) { cellAudio.warning("cellAudioCreateNotifyEventQueueEx(id=*0x%x, key=*0x%x, iFlags=0x%x)", id, key, iFlags); @@ -1541,7 +1541,7 @@ error_code cellAudioCreateNotifyEventQueueEx(vm::ptr id, vm::ptr key, } const u32 queue_type = (iFlags & CELL_AUDIO_CREATEEVENTFLAG_SPU) ? SYS_SPU_QUEUE : SYS_PPU_QUEUE; - return AudioCreateNotifyEventQueue(id, key, queue_type); + return AudioCreateNotifyEventQueue(ppu, id, key, queue_type); } error_code AudioSetNotifyEventQueue(u64 key, u32 iFlags) diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index ed4a37897f..eb54870031 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -509,7 +509,7 @@ bool _spurs::is_libprof_loaded() s32 _spurs::create_lv2_eq(ppu_thread& ppu, vm::ptr spurs, vm::ptr queueId, vm::ptr port, s32 size, const sys_event_queue_attribute_t& attr) { - if (s32 rc = sys_event_queue_create(queueId, vm::make_var(attr), SYS_EVENT_QUEUE_LOCAL, size)) + if (s32 rc = sys_event_queue_create(ppu, queueId, vm::make_var(attr), SYS_EVENT_QUEUE_LOCAL, size)) { return rc; } @@ -895,7 +895,7 @@ s32 _spurs::create_event_helper(ppu_thread& ppu, vm::ptr spurs, u32 p return rc; } - if (s32 rc = sys_event_port_create(spurs.ptr(&CellSpurs::eventPort), SYS_EVENT_PORT_LOCAL, SYS_EVENT_PORT_NO_NAME)) + if (s32 rc = sys_event_port_create(ppu, spurs.ptr(&CellSpurs::eventPort), SYS_EVENT_PORT_LOCAL, SYS_EVENT_PORT_NO_NAME)) { if (s32 rc2 = _spurs::detach_lv2_eq(spurs, spurs->spuPort, true)) { @@ -906,7 +906,7 @@ s32 _spurs::create_event_helper(ppu_thread& ppu, vm::ptr spurs, u32 p return CELL_SPURS_CORE_ERROR_AGAIN; } - if (s32 rc = sys_event_port_connect_local(spurs->eventPort, spurs->eventQueue)) + if (s32 rc = sys_event_port_connect_local(ppu, spurs->eventPort, spurs->eventQueue)) { sys_event_port_destroy(ppu, spurs->eventPort); @@ -3523,10 +3523,10 @@ s32 cellSpursEventFlagAttachLv2EventQueue(ppu_thread& ppu, vm::ptr eventPortId; - s32 rc = sys_event_port_create(eventPortId, SYS_EVENT_PORT_LOCAL, 0); + s32 rc = sys_event_port_create(ppu, eventPortId, SYS_EVENT_PORT_LOCAL, 0); if (rc == CELL_OK) { - rc = sys_event_port_connect_local(*eventPortId, *eventQueueId); + rc = sys_event_port_connect_local(ppu, *eventPortId, *eventQueueId); if (rc == CELL_OK) { eventFlag->eventPortId = *eventPortId; diff --git a/rpcs3/Emu/Cell/Modules/cellVoice.cpp b/rpcs3/Emu/Cell/Modules/cellVoice.cpp index 4bee87023b..97ae4752d7 100644 --- a/rpcs3/Emu/Cell/Modules/cellVoice.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVoice.cpp @@ -70,7 +70,7 @@ error_code cellVoiceConnectIPortToOPort(u32 ips, u32 ops) return CELL_OK; } -error_code cellVoiceCreateNotifyEventQueue(vm::ptr id, vm::ptr key) +error_code cellVoiceCreateNotifyEventQueue(ppu_thread& ppu, vm::ptr id, vm::ptr key) { cellVoice.warning("cellVoiceCreateNotifyEventQueue(id=*0x%x, key=*0x%x)", id, key); @@ -90,7 +90,7 @@ error_code cellVoiceCreateNotifyEventQueue(vm::ptr id, vm::ptr key) { // Create an event queue "bruteforcing" an available key const u64 key_value = 0x80004d494f323285ull + i; - if (CellError res{sys_event_queue_create(id, attr, key_value, 0x40) + 0u}) + if (CellError res{sys_event_queue_create(ppu, id, attr, key_value, 0x40) + 0u}) { if (res != CELL_EEXIST) { @@ -858,7 +858,7 @@ error_code cellVoiceReadFromOPort(u32 ops, vm::ptr data, vm::ptr size if (!oport || oport->info.portType <= CELLVOICE_PORTTYPE_IN_VOICE) return CELL_VOICE_ERROR_TOPOLOGY; - + if (size) *size = 0; diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index 52a273548f..bddb8bb836 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -93,9 +93,9 @@ CellError lv2_event_queue::send(lv2_event event) return {}; } -error_code sys_event_queue_create(vm::ptr equeue_id, vm::ptr attr, u64 event_queue_key, s32 size) +error_code sys_event_queue_create(cpu_thread& cpu, vm::ptr equeue_id, vm::ptr attr, u64 event_queue_key, s32 size) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; 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); @@ -365,9 +365,9 @@ error_code sys_event_queue_drain(ppu_thread& ppu, u32 equeue_id) return CELL_OK; } -error_code sys_event_port_create(vm::ptr eport_id, s32 port_type, u64 name) +error_code sys_event_port_create(cpu_thread& cpu, vm::ptr eport_id, s32 port_type, u64 name) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_event.warning("sys_event_port_create(eport_id=*0x%x, port_type=%d, name=0x%llx)", eport_id, port_type, name); @@ -415,9 +415,9 @@ error_code sys_event_port_destroy(ppu_thread& ppu, u32 eport_id) return CELL_OK; } -error_code sys_event_port_connect_local(u32 eport_id, u32 equeue_id) +error_code sys_event_port_connect_local(cpu_thread& cpu, u32 eport_id, u32 equeue_id) { - vm::temporary_unlock(); + cpu.state += cpu_flag::wait; sys_event.warning("sys_event_port_connect_local(eport_id=0x%x, equeue_id=0x%x)", eport_id, equeue_id); @@ -511,7 +511,10 @@ error_code sys_event_port_disconnect(ppu_thread& ppu, u32 eport_id) error_code sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3) { - vm::temporary_unlock(); + if (auto cpu = get_current_cpu_thread()) + { + cpu->state += cpu_flag::wait; + } sys_event.trace("sys_event_port_send(eport_id=0x%x, data1=0x%llx, data2=0x%llx, data3=0x%llx)", eport_id, data1, data2, data3); diff --git a/rpcs3/Emu/Cell/lv2/sys_event.h b/rpcs3/Emu/Cell/lv2/sys_event.h index f423e18aed..febf7eb251 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.h +++ b/rpcs3/Emu/Cell/lv2/sys_event.h @@ -140,15 +140,15 @@ class ppu_thread; // Syscalls -error_code sys_event_queue_create(vm::ptr equeue_id, vm::ptr attr, u64 event_queue_key, s32 size); +error_code sys_event_queue_create(cpu_thread& cpu, vm::ptr equeue_id, vm::ptr attr, u64 event_queue_key, s32 size); error_code sys_event_queue_destroy(ppu_thread& ppu, u32 equeue_id, s32 mode); error_code sys_event_queue_receive(ppu_thread& ppu, u32 equeue_id, vm::ptr dummy_event, u64 timeout); error_code sys_event_queue_tryreceive(ppu_thread& ppu, u32 equeue_id, vm::ptr event_array, s32 size, vm::ptr number); error_code sys_event_queue_drain(ppu_thread& ppu, u32 event_queue_id); -error_code sys_event_port_create(vm::ptr eport_id, s32 port_type, u64 name); +error_code sys_event_port_create(cpu_thread& cpu, vm::ptr eport_id, s32 port_type, u64 name); error_code sys_event_port_destroy(ppu_thread& ppu, u32 eport_id); -error_code sys_event_port_connect_local(u32 event_port_id, u32 event_queue_id); +error_code sys_event_port_connect_local(cpu_thread& cpu, u32 event_port_id, u32 event_queue_id); error_code sys_event_port_connect_ipc(ppu_thread& ppu, u32 eport_id, u64 ipc_key); error_code sys_event_port_disconnect(ppu_thread& ppu, u32 eport_id); error_code sys_event_port_send(u32 event_port_id, u64 data1, u64 data2, u64 data3); diff --git a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp index d04a1a9c26..1949dab61c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mmapper.cpp @@ -709,8 +709,8 @@ error_code sys_mmapper_enable_page_fault_notification(ppu_thread& ppu, u32 start } vm::var port_id(0); - error_code res = sys_event_port_create(port_id, SYS_EVENT_PORT_LOCAL, SYS_MEMORY_PAGE_FAULT_EVENT_KEY); - sys_event_port_connect_local(*port_id, event_queue_id); + error_code res = sys_event_port_create(ppu, port_id, SYS_EVENT_PORT_LOCAL, SYS_MEMORY_PAGE_FAULT_EVENT_KEY); + sys_event_port_connect_local(ppu, *port_id, event_queue_id); if (res + 0u == CELL_EAGAIN) { diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp index f20503faac..d5c3a95449 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.cpp @@ -68,7 +68,7 @@ void lv2_rsx_config::send_event(u64 data1, u64 event_flags, u64 data3) const { rsx->on_semaphore_acquire_wait(); } - + // Wait a bit before resending event thread_ctrl::wait_for(100); @@ -161,8 +161,10 @@ error_code sys_rsx_memory_free(u32 mem_handle) * @param mem_ctx (IN): mem_ctx given by sys_rsx_memory_allocate * @param system_mode (IN): */ -error_code sys_rsx_context_allocate(vm::ptr context_id, vm::ptr lpar_dma_control, vm::ptr lpar_driver_info, vm::ptr lpar_reports, u64 mem_ctx, u64 system_mode) +error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr context_id, vm::ptr lpar_dma_control, vm::ptr lpar_driver_info, vm::ptr lpar_reports, u64 mem_ctx, u64 system_mode) { + cpu.state += cpu_flag::wait; + sys_rsx.warning("sys_rsx_context_allocate(context_id=*0x%x, lpar_dma_control=*0x%x, lpar_driver_info=*0x%x, lpar_reports=*0x%x, mem_ctx=0x%llx, system_mode=0x%llx)", context_id, lpar_dma_control, lpar_driver_info, lpar_reports, mem_ctx, system_mode); @@ -247,10 +249,10 @@ error_code sys_rsx_context_allocate(vm::ptr context_id, vm::ptr lpar_d attr->type = SYS_PPU_QUEUE; attr->name_u64 = 0; - sys_event_port_create(vm::get_addr(&driverInfo.handler_queue), SYS_EVENT_PORT_LOCAL, 0); + sys_event_port_create(cpu, vm::get_addr(&driverInfo.handler_queue), SYS_EVENT_PORT_LOCAL, 0); rsx_cfg->rsx_event_port = driverInfo.handler_queue; - sys_event_queue_create(vm::get_addr(&driverInfo.handler_queue), attr, 0, 0x20); - sys_event_port_connect_local(rsx_cfg->rsx_event_port, driverInfo.handler_queue); + sys_event_queue_create(cpu, vm::get_addr(&driverInfo.handler_queue), attr, 0, 0x20); + sys_event_port_connect_local(cpu, rsx_cfg->rsx_event_port, driverInfo.handler_queue); rsx_cfg->dma_address = vm::cast(*lpar_dma_control, HERE); diff --git a/rpcs3/Emu/Cell/lv2/sys_rsx.h b/rpcs3/Emu/Cell/lv2/sys_rsx.h index c9bc97723b..40b1a8a38e 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rsx.h +++ b/rpcs3/Emu/Cell/lv2/sys_rsx.h @@ -3,6 +3,8 @@ #include "Utilities/mutex.h" #include "Emu/Memory/vm_ptr.h" +class cpu_thread; + struct RsxDriverInfo { be_t version_driver; // 0x0 @@ -141,7 +143,7 @@ error_code sys_rsx_device_open(); error_code sys_rsx_device_close(); error_code sys_rsx_memory_allocate(vm::ptr mem_handle, vm::ptr mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7); error_code sys_rsx_memory_free(u32 mem_handle); -error_code sys_rsx_context_allocate(vm::ptr context_id, vm::ptr lpar_dma_control, vm::ptr lpar_driver_info, vm::ptr lpar_reports, u64 mem_ctx, u64 system_mode); +error_code sys_rsx_context_allocate(cpu_thread& cpu, vm::ptr context_id, vm::ptr lpar_dma_control, vm::ptr lpar_driver_info, vm::ptr lpar_reports, u64 mem_ctx, u64 system_mode); error_code sys_rsx_context_free(u32 context_id); error_code sys_rsx_context_iomap(u32 context_id, u32 io, u32 ea, u32 size, u64 flags); error_code sys_rsx_context_iounmap(u32 context_id, u32 io, u32 size); diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp index e8f16c04c0..aeff739b15 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp @@ -7,7 +7,6 @@ #include #include -#include namespace rsx { @@ -43,7 +42,7 @@ namespace rsx if (sys_rsx_memory_allocate(contextInfo.ptr(&rsx_context::mem_handle), contextInfo.ptr(&rsx_context::mem_addr), 0x0F900000, 0, 0, 0, 0) != CELL_OK) fmt::throw_exception("Capture Replay: sys_rsx_memory_allocate failed!"); - if (sys_rsx_context_allocate(contextInfo.ptr(&rsx_context::context_id), contextInfo.ptr(&rsx_context::dma_addr), contextInfo.ptr(&rsx_context::driver_info), contextInfo.ptr(&rsx_context::reports_addr), contextInfo->mem_handle, 0) != CELL_OK) + if (sys_rsx_context_allocate(*this, contextInfo.ptr(&rsx_context::context_id), contextInfo.ptr(&rsx_context::dma_addr), contextInfo.ptr(&rsx_context::driver_info), contextInfo.ptr(&rsx_context::reports_addr), contextInfo->mem_handle, 0) != CELL_OK) fmt::throw_exception("Capture Replay: sys_rsx_context_allocate failed!"); get_current_renderer()->main_mem_size = buffer_size; diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.h b/rpcs3/Emu/RSX/GL/GLHelpers.h index c106943e3e..b215df7f30 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.h +++ b/rpcs3/Emu/RSX/GL/GLHelpers.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include diff --git a/rpcs3/Emu/RSX/GL/GLTextureCache.h b/rpcs3/Emu/RSX/GL/GLTextureCache.h index 5e204c3f95..e88400a257 100644 --- a/rpcs3/Emu/RSX/GL/GLTextureCache.h +++ b/rpcs3/Emu/RSX/GL/GLTextureCache.h @@ -2,7 +2,6 @@ #include "stdafx.h" -#include #include #include #include diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 3991f786bb..55036fdff8 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include class GSRender; diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index 639b4beec2..b35908b9e1 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -1,7 +1,6 @@ #pragma once #include "stdafx.h" -#include #include #include #include diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index d156ee0f84..72c10af94f 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -30,8 +30,6 @@ namespace std { inline namespace literals { inline namespace chrono_literals {}} #include #include #include -#include -#include #include #include #include