From c73302f7150822b82789d18c045ce5dc9cdbdc41 Mon Sep 17 00:00:00 2001 From: brian218 Date: Mon, 10 Jun 2024 11:13:45 +0800 Subject: [PATCH] sys_ppu_thread: Fixed up sys_ppu_thread_join()'s check for detached threads sys_game: Corrected sys_game_set_system_sw_version()'s error code --- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 4 +-- rpcs3/Emu/Cell/lv2/sys_fs.h | 2 +- rpcs3/Emu/Cell/lv2/sys_game.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp | 46 ++++++++++----------------- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index acc04fd45a..9fe295894a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -3264,11 +3264,11 @@ error_code sys_fs_newfs(ppu_thread& ppu, vm::cptr dev_name, vm::cptr return CELL_OK; } -error_code sys_fs_mount(ppu_thread& ppu, vm::cptr dev_name, vm::cptr file_system, vm::cptr path, s32 unk1, s32 prot, s32 unk3, vm::cptr str1, u32 str_len) +error_code sys_fs_mount(ppu_thread& ppu, vm::cptr dev_name, vm::cptr file_system, vm::cptr path, s32 unk1, s32 prot, s32 unk2, vm::cptr str1, u32 str_len) { ppu.state += cpu_flag::wait; - sys_fs.warning("sys_fs_mount(dev_name=%s, file_system=%s, path=%s, unk1=0x%x, prot=%d, unk3=0x%x, str1=%s, str_len=%d)", dev_name, file_system, path, unk1, prot, unk3, str1, str_len); + sys_fs.warning("sys_fs_mount(dev_name=%s, file_system=%s, path=%s, unk1=0x%x, prot=%d, unk3=0x%x, str1=%s, str_len=%d)", dev_name, file_system, path, unk1, prot, unk2, str1, str_len); const auto [dev_error, device_name] = translate_to_str(dev_name, false); diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index 66ba0a2b2c..32aa6010a6 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -678,7 +678,7 @@ error_code sys_fs_mapped_allocate(ppu_thread& ppu, u32 fd, u64, vm::pptr o error_code sys_fs_mapped_free(ppu_thread& ppu, u32 fd, vm::ptr ptr); error_code sys_fs_truncate2(ppu_thread& ppu, u32 fd, u64 size); error_code sys_fs_newfs(ppu_thread& ppu, vm::cptr dev_name, vm::cptr file_system, s32 unk1, vm::cptr str1); -error_code sys_fs_mount(ppu_thread& ppu, vm::cptr dev_name, vm::cptr file_system, vm::cptr path, s32 unk1, s32 prot, s32 unk3, vm::cptr str1, u32 str_len); +error_code sys_fs_mount(ppu_thread& ppu, vm::cptr dev_name, vm::cptr file_system, vm::cptr path, s32 unk1, s32 prot, s32 unk2, vm::cptr str1, u32 str_len); error_code sys_fs_unmount(ppu_thread& ppu, vm::cptr path, s32 unk1, s32 force); error_code sys_fs_get_mount_info_size(ppu_thread& ppu, vm::ptr len); error_code sys_fs_get_mount_info(ppu_thread& ppu, vm::ptr info, u64 len, vm::ptr out_len); diff --git a/rpcs3/Emu/Cell/lv2/sys_game.cpp b/rpcs3/Emu/Cell/lv2/sys_game.cpp index e4f48af141..6e69b9175f 100644 --- a/rpcs3/Emu/Cell/lv2/sys_game.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_game.cpp @@ -235,7 +235,7 @@ error_code _sys_game_set_system_sw_version(u64 version) sys_game.trace("sys_game_set_system_sw_version(version=%d)", version); if (!g_ps3_process_info.has_root_perm()) - return CELL_EPERM; + return CELL_ENOSYS; g_fxo->get().version = version; diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index 7c97c3e679..0f1c487741 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -185,24 +185,20 @@ error_code sys_ppu_thread_join(ppu_thread& ppu, u32 thread_id, vm::ptr vptr { CellError result = thread.joiner.atomic_op([&](ppu_join_status& value) -> CellError { - if (value == ppu_join_status::zombie) + switch (value) { + case ppu_join_status::joinable: + value = ppu_join_status{ppu.id}; + return {}; + case ppu_join_status::zombie: value = ppu_join_status::exited; return CELL_EAGAIN; - } - - if (value == ppu_join_status::exited) - { + case ppu_join_status::exited: return CELL_ESRCH; - } - - if (value >= ppu_join_status::max) - { + case ppu_join_status::detached: + default: return CELL_EINVAL; } - - value = ppu_join_status{ppu.id}; - return {}; }); if (!result) @@ -273,29 +269,21 @@ error_code sys_ppu_thread_detach(ppu_thread& ppu, u32 thread_id) { result = thread.joiner.atomic_op([](ppu_join_status& value) -> CellError { - if (value == ppu_join_status::zombie) + switch (value) { + case ppu_join_status::joinable: + value = ppu_join_status::detached; + return {}; + case ppu_join_status::detached: + return CELL_EINVAL; + case ppu_join_status::zombie: value = ppu_join_status::exited; return CELL_EAGAIN; - } - - if (value == ppu_join_status::exited) - { + case ppu_join_status::exited: return CELL_ESRCH; - } - - if (value == ppu_join_status::detached) - { - return CELL_EINVAL; - } - - if (value >= ppu_join_status::max) - { + default: return CELL_EBUSY; } - - value = ppu_join_status::detached; - return {}; }); // Remove ID on EAGAIN