From 87af90501811b7d3432ce5bafa70d7eaac4f5cb6 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 5 Mar 2021 22:05:37 +0300 Subject: [PATCH] Enable -Wunused-parameter --- Utilities/BitField.h | 4 +- Utilities/File.cpp | 8 +- Utilities/JIT.cpp | 23 +- Utilities/JIT.h | 2 + Utilities/Thread.cpp | 2 +- Utilities/lockless.h | 2 +- rpcs3/Crypto/unedat.cpp | 2000 ++++++++--------- rpcs3/Crypto/unedat.h | 264 +-- rpcs3/Crypto/utils.cpp | 2 +- rpcs3/Emu/CPU/CPUDisAsm.h | 2 +- rpcs3/Emu/CPU/CPUThread.cpp | 6 +- rpcs3/Emu/CPU/CPUThread.h | 2 +- rpcs3/Emu/CPU/CPUTranslator.h | 7 +- rpcs3/Emu/Cell/Modules/cellAudio.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellCamera.cpp | 5 + rpcs3/Emu/Cell/Modules/cellDaisy.cpp | 5 + rpcs3/Emu/Cell/Modules/cellDmux.cpp | 4 +- rpcs3/Emu/Cell/Modules/cellFont.cpp | 7 +- rpcs3/Emu/Cell/Modules/cellGifDec.cpp | 5 + rpcs3/Emu/Cell/Modules/cellJpgDec.cpp | 5 + rpcs3/Emu/Cell/Modules/cellL10n.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellMic.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellPngDec.cpp | 5 + rpcs3/Emu/Cell/Modules/cellResc.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellRtc.cpp | 3 +- rpcs3/Emu/Cell/Modules/cellRudp.cpp | 4 +- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 7 +- rpcs3/Emu/Cell/Modules/cellSpurs.cpp | 5 + rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp | 10 +- rpcs3/Emu/Cell/Modules/cellSync.cpp | 8 +- rpcs3/Emu/Cell/Modules/cellSysCache.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellVdec.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellVideoOut.cpp | 5 + rpcs3/Emu/Cell/Modules/libsnd3.cpp | 5 + rpcs3/Emu/Cell/Modules/sceNp.cpp | 2 +- rpcs3/Emu/Cell/Modules/sceNp2.cpp | 6 +- rpcs3/Emu/Cell/Modules/sceNpMatchingInt.cpp | 5 + rpcs3/Emu/Cell/Modules/sys_libc_.cpp | 4 +- rpcs3/Emu/Cell/Modules/sys_lv2dbg.cpp | 5 + rpcs3/Emu/Cell/Modules/sys_net_.cpp | 5 + rpcs3/Emu/Cell/Modules/sys_prx_.cpp | 4 +- rpcs3/Emu/Cell/Modules/sys_spu_.cpp | 2 +- rpcs3/Emu/Cell/PPUAnalyser.cpp | 5 + rpcs3/Emu/Cell/PPUCallback.h | 4 +- rpcs3/Emu/Cell/PPUDisAsm.cpp | 8 +- rpcs3/Emu/Cell/PPUFunction.h | 4 +- rpcs3/Emu/Cell/PPUInterpreter.cpp | 28 +- rpcs3/Emu/Cell/PPUThread.cpp | 15 +- rpcs3/Emu/Cell/PPUTranslator.cpp | 32 +- rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 20 +- rpcs3/Emu/Cell/SPUInterpreter.cpp | 34 +- rpcs3/Emu/Cell/SPURecompiler.cpp | 33 +- rpcs3/Emu/Cell/SPUThread.cpp | 32 +- rpcs3/Emu/Cell/lv2/sys_config.cpp | 9 +- rpcs3/Emu/Cell/lv2/sys_fs.cpp | 60 +- rpcs3/Emu/Cell/lv2/sys_net.cpp | 4 +- rpcs3/Emu/Cell/lv2/sys_overlay.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_process.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_prx.cpp | 4 +- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_usbd.cpp | 2 +- rpcs3/Emu/GDB.cpp | 20 +- rpcs3/Emu/Io/Buzz.cpp | 2 +- rpcs3/Emu/Io/GHLtar.cpp | 2 +- rpcs3/Emu/Io/Skylander.cpp | 2 +- rpcs3/Emu/Io/usb_device.cpp | 11 +- rpcs3/Emu/Memory/vm.cpp | 4 +- rpcs3/Emu/Memory/vm_reservation.h | 16 +- rpcs3/Emu/Memory/vm_var.h | 2 +- rpcs3/Emu/NP/np_handler.cpp | 14 +- rpcs3/Emu/RSX/Capture/rsx_replay.cpp | 2 +- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 2 +- rpcs3/Emu/RSX/Common/texture_cache.h | 8 +- rpcs3/Emu/RSX/Common/texture_cache_helpers.h | 4 +- rpcs3/Emu/RSX/GL/GLHelpers.cpp | 6 +- rpcs3/Emu/RSX/GL/GLRenderTargets.cpp | 2 +- rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp | 4 +- rpcs3/Emu/RSX/GL/GLVertexProgram.cpp | 8 +- rpcs3/Emu/RSX/GSRender.cpp | 2 +- .../Shaders/shader_loading_dialog.cpp | 2 +- rpcs3/Emu/RSX/Overlays/overlay_osk.cpp | 2 +- rpcs3/Emu/RSX/RSXThread.cpp | 6 +- rpcs3/Emu/RSX/RSXThread.h | 6 +- rpcs3/Emu/RSX/VK/VKDMA.cpp | 6 +- rpcs3/Emu/RSX/VK/VKMemAlloc.cpp | 1 + rpcs3/Emu/RSX/VK/VKTexture.cpp | 4 +- rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp | 4 +- rpcs3/Emu/RSX/VK/VKVertexProgram.cpp | 6 +- rpcs3/Emu/RSX/VK/vkutils/memory.cpp | 2 +- rpcs3/Emu/RSX/VK/vkutils/shared.cpp | 17 +- rpcs3/Emu/RSX/gcm_printing.cpp | 2 +- rpcs3/Emu/RSX/rsx_methods.cpp | 78 +- rpcs3/Emu/RSX/rsx_utils.h | 4 +- rpcs3/Emu/System.cpp | 4 +- rpcs3/Emu/VFS.cpp | 8 +- rpcs3/Input/keyboard_pad_handler.cpp | 2 +- rpcs3/Loader/TRP.cpp | 2 +- rpcs3/cmake_modules/ConfigureCompiler.cmake | 1 + rpcs3/rpcs3qt/save_manager_dialog.cpp | 2 +- rpcs3/util/atomic.cpp | 8 +- rpcs3/util/logs.cpp | 2 +- rpcs3/util/types.hpp | 2 +- 102 files changed, 1571 insertions(+), 1463 deletions(-) diff --git a/Utilities/BitField.h b/Utilities/BitField.h index 3c72319099..8c3536e745 100644 --- a/Utilities/BitField.h +++ b/Utilities/BitField.h @@ -217,7 +217,7 @@ struct cf_t } template - static constexpr auto extract(const T& data) -> decltype(+T()) + static constexpr auto extract(const T&) -> decltype(+T()) { return 0; } @@ -237,7 +237,7 @@ struct ff_t : bf_base using vtype = typename ff_t::vtype; // Return constant value - static constexpr vtype extract(const type& data) + static constexpr vtype extract(const type&) { static_assert((V & ff_t::vmask) == V, "ff_t<> error: V out of bounds"); return V; diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 9c521f635d..fc45364d49 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -1328,7 +1328,7 @@ fs::file::file(const void* ptr, usz size) { } - bool trunc(u64 length) override + bool trunc(u64) override { return false; } @@ -1349,7 +1349,7 @@ fs::file::file(const void* ptr, usz size) return 0; } - u64 write(const void* buffer, u64 count) override + u64 write(const void*, u64) override { return 0; } @@ -1854,7 +1854,7 @@ fs::file fs::make_gather(std::vector files) return result; } - bool trunc(u64 length) override + bool trunc(u64) override { return false; } @@ -1897,7 +1897,7 @@ fs::file fs::make_gather(std::vector files) return 0; } - u64 write(const void* buffer, u64 size) override + u64 write(const void*, u64) override { return 0; } diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index 5727afa8c1..fbf00feaa8 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -143,7 +143,7 @@ asmjit::Error jit_runtime::_add(void** dst, asmjit::CodeHolder* code) noexcept return asmjit::kErrorOk; } -asmjit::Error jit_runtime::_release(void* ptr) noexcept +asmjit::Error jit_runtime::_release(void*) noexcept { return asmjit::kErrorOk; } @@ -249,7 +249,7 @@ asmjit::Runtime& asmjit::get_global_runtime() return asmjit::kErrorOk; } - asmjit::Error _release(void* ptr) noexcept override + asmjit::Error _release(void*) noexcept override { return asmjit::kErrorOk; } @@ -281,6 +281,7 @@ asmjit::Runtime& asmjit::get_global_runtime() #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #include "llvm/Support/TargetSelect.h" #include "llvm/Support/FormattedStream.h" @@ -294,12 +295,6 @@ asmjit::Runtime& asmjit::get_global_runtime() #pragma GCC diagnostic pop #endif -#ifdef _WIN32 -#include -#else -#include -#endif - const bool jit_initialize = []() -> bool { llvm::InitializeNativeTarget(); @@ -439,12 +434,12 @@ struct MemoryManager1 : llvm::RTDyldMemoryManager return this->ptr + olda; } - u8* allocateCodeSection(uptr size, uint align, uint sec_id, llvm::StringRef sec_name) override + u8* allocateCodeSection(uptr size, uint align, uint /*sec_id*/, llvm::StringRef /*sec_name*/) override { return allocate(code_ptr, size, align, utils::protection::wx); } - u8* allocateDataSection(uptr size, uint align, uint sec_id, llvm::StringRef sec_name, bool is_ro) override + u8* allocateDataSection(uptr size, uint align, uint /*sec_id*/, llvm::StringRef /*sec_name*/, bool /*is_ro*/) override { return allocate(data_ptr, size, align, utils::protection::rw); } @@ -454,7 +449,7 @@ struct MemoryManager1 : llvm::RTDyldMemoryManager return false; } - void registerEHFrames(u8* addr, u64 load_addr, usz size) override + void registerEHFrames(u8*, u64, usz) override { } @@ -489,12 +484,12 @@ struct MemoryManager2 : llvm::RTDyldMemoryManager return {addr, llvm::JITSymbolFlags::Exported}; } - u8* allocateCodeSection(uptr size, uint align, uint sec_id, llvm::StringRef sec_name) override + u8* allocateCodeSection(uptr size, uint align, uint /*sec_id*/, llvm::StringRef /*sec_name*/) override { return jit_runtime::alloc(size, align, true); } - u8* allocateDataSection(uptr size, uint align, uint sec_id, llvm::StringRef sec_name, bool is_ro) override + u8* allocateDataSection(uptr size, uint align, uint /*sec_id*/, llvm::StringRef /*sec_name*/, bool /*is_ro*/) override { return jit_runtime::alloc(size, align, false); } @@ -504,7 +499,7 @@ struct MemoryManager2 : llvm::RTDyldMemoryManager return false; } - void registerEHFrames(u8* addr, u64 load_addr, usz size) override + void registerEHFrames(u8*, u64, usz) override { } diff --git a/Utilities/JIT.h b/Utilities/JIT.h index bcc041ca22..2106565509 100644 --- a/Utilities/JIT.h +++ b/Utilities/JIT.h @@ -13,6 +13,7 @@ #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wunused-parameter" #include #pragma GCC diagnostic pop #endif @@ -178,6 +179,7 @@ inline FT build_function_asm(F&& builder) #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wsuggest-override" +#pragma GCC diagnostic ignored "-Wunused-parameter" #ifdef __clang__ #pragma clang diagnostic ignored "-Winconsistent-missing-override" #endif diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index be1ebe3982..92d2ffcf69 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1752,7 +1752,7 @@ const bool s_exception_handler_set = []() -> bool #else -static void signal_handler(int sig, siginfo_t* info, void* uct) noexcept +static void signal_handler(int /*sig*/, siginfo_t* info, void* uct) noexcept { x64_context* context = static_cast(uct); diff --git a/Utilities/lockless.h b/Utilities/lockless.h index 350b6f4b59..d3df6d9710 100644 --- a/Utilities/lockless.h +++ b/Utilities/lockless.h @@ -308,7 +308,7 @@ public: } template - void wait(std::nullptr_t null = nullptr) noexcept + void wait(std::nullptr_t /*null*/ = nullptr) noexcept { if (m_head == nullptr) { diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 2b3d64df3a..1bd3492194 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -1,1000 +1,1000 @@ -#include "stdafx.h" -#include "key_vault.h" -#include "unedat.h" -#include "sha1.h" -#include "lz.h" -#include "ec.h" - -#include "Utilities/mutex.h" -#include - -#include "util/asm.hpp" - -LOG_CHANNEL(edat_log, "EDAT"); - -// Static variables are being modified concurrently in ec.cpp, for now use a mutex -static shared_mutex ec_mtx; - -void generate_key(int crypto_mode, int version, unsigned char *key_final, unsigned char *iv_final, unsigned char *key, unsigned char *iv) -{ - int mode = crypto_mode & 0xF0000000; - uchar temp_iv[16]{}; - switch (mode) - { - case 0x10000000: - // Encrypted ERK. - // Decrypt the key with EDAT_KEY + EDAT_IV and copy the original IV. - memcpy(temp_iv, EDAT_IV, 0x10); - aescbc128_decrypt(const_cast(version ? EDAT_KEY_1 : EDAT_KEY_0), temp_iv, key, key_final, 0x10); - memcpy(iv_final, iv, 0x10); - break; - case 0x20000000: - // Default ERK. - // Use EDAT_KEY and EDAT_IV. - memcpy(key_final, version ? EDAT_KEY_1 : EDAT_KEY_0, 0x10); - memcpy(iv_final, EDAT_IV, 0x10); - break; - case 0x00000000: - // Unencrypted ERK. - // Use the original key and iv. - memcpy(key_final, key, 0x10); - memcpy(iv_final, iv, 0x10); - break; - }; -} - -void generate_hash(int hash_mode, int version, unsigned char *hash_final, unsigned char *hash) -{ - int mode = hash_mode & 0xF0000000; - uchar temp_iv[16]{}; - switch (mode) - { - case 0x10000000: - // Encrypted HASH. - // Decrypt the hash with EDAT_KEY + EDAT_IV. - memcpy(temp_iv, EDAT_IV, 0x10); - aescbc128_decrypt(const_cast(version ? EDAT_KEY_1 : EDAT_KEY_0), temp_iv, hash, hash_final, 0x10); - break; - case 0x20000000: - // Default HASH. - // Use EDAT_HASH. - memcpy(hash_final, version ? EDAT_HASH_1 : EDAT_HASH_0, 0x10); - break; - case 0x00000000: - // Unencrypted ERK. - // Use the original hash. - memcpy(hash_final, hash, 0x10); - break; - }; -} - -bool decrypt(int hash_mode, int crypto_mode, int version, unsigned char *in, unsigned char *out, int length, unsigned char *key, unsigned char *iv, unsigned char *hash, unsigned char *test_hash) -{ - // Setup buffers for key, iv and hash. - unsigned char key_final[0x10] = {}; - unsigned char iv_final[0x10] = {}; - unsigned char hash_final_10[0x10] = {}; - unsigned char hash_final_14[0x14] = {}; - - // Generate crypto key and hash. - generate_key(crypto_mode, version, key_final, iv_final, key, iv); - if ((hash_mode & 0xFF) == 0x01) - generate_hash(hash_mode, version, hash_final_14, hash); - else - generate_hash(hash_mode, version, hash_final_10, hash); - - if ((crypto_mode & 0xFF) == 0x01) // No algorithm. - { - memcpy(out, in, length); - } - else if ((crypto_mode & 0xFF) == 0x02) // AES128-CBC - { - aescbc128_decrypt(key_final, iv_final, in, out, length); - } - else - { - edat_log.error("EDAT: Unknown crypto algorithm!"); - return false; - } - - if ((hash_mode & 0xFF) == 0x01) // 0x14 SHA1-HMAC - { - return hmac_hash_compare(hash_final_14, 0x14, in, length, test_hash, 0x14); - } - else if ((hash_mode & 0xFF) == 0x02) // 0x10 AES-CMAC - { - return cmac_hash_compare(hash_final_10, 0x10, in, length, test_hash, 0x10); - } - else if ((hash_mode & 0xFF) == 0x04) //0x10 SHA1-HMAC - { - return hmac_hash_compare(hash_final_10, 0x10, in, length, test_hash, 0x10); - } - else - { - edat_log.error("EDAT: Unknown hashing algorithm!"); - return false; - } -} - -// EDAT/SDAT functions. -std::tuple dec_section(unsigned char* metadata) -{ - std::array dec; - dec[0x00] = (metadata[0xC] ^ metadata[0x8] ^ metadata[0x10]); - dec[0x01] = (metadata[0xD] ^ metadata[0x9] ^ metadata[0x11]); - dec[0x02] = (metadata[0xE] ^ metadata[0xA] ^ metadata[0x12]); - dec[0x03] = (metadata[0xF] ^ metadata[0xB] ^ metadata[0x13]); - dec[0x04] = (metadata[0x4] ^ metadata[0x8] ^ metadata[0x14]); - dec[0x05] = (metadata[0x5] ^ metadata[0x9] ^ metadata[0x15]); - dec[0x06] = (metadata[0x6] ^ metadata[0xA] ^ metadata[0x16]); - dec[0x07] = (metadata[0x7] ^ metadata[0xB] ^ metadata[0x17]); - dec[0x08] = (metadata[0xC] ^ metadata[0x0] ^ metadata[0x18]); - dec[0x09] = (metadata[0xD] ^ metadata[0x1] ^ metadata[0x19]); - dec[0x0A] = (metadata[0xE] ^ metadata[0x2] ^ metadata[0x1A]); - dec[0x0B] = (metadata[0xF] ^ metadata[0x3] ^ metadata[0x1B]); - dec[0x0C] = (metadata[0x4] ^ metadata[0x0] ^ metadata[0x1C]); - dec[0x0D] = (metadata[0x5] ^ metadata[0x1] ^ metadata[0x1D]); - dec[0x0E] = (metadata[0x6] ^ metadata[0x2] ^ metadata[0x1E]); - dec[0x0F] = (metadata[0x7] ^ metadata[0x3] ^ metadata[0x1F]); - - u64 offset = swap64(*reinterpret_cast(&dec[0])); - s32 length = swap32(*reinterpret_cast(&dec[8])); - s32 compression_end = swap32(*reinterpret_cast(&dec[12])); - - return std::make_tuple(offset, length, compression_end); -} - -u128 get_block_key(int block, NPD_HEADER *npd) -{ - unsigned char empty_key[0x10] = {}; - unsigned char *src_key = (npd->version <= 1) ? empty_key : npd->dev_hash; - u128 dest_key{}; - std::memcpy(&dest_key, src_key, 0xC); - - s32 swappedBlock = swap32(block); - std::memcpy(reinterpret_cast(&dest_key) + 0xC, &swappedBlock, sizeof(swappedBlock)); - return dest_key; -} - -// for out data, allocate a buffer the size of 'edat->block_size' -// Also, set 'in file' to the beginning of the encrypted data, which may be offset if inside another file, but normally just reset to beginning of file -// returns number of bytes written, -1 for error -s64 decrypt_block(const fs::file* in, u8* out, EDAT_HEADER *edat, NPD_HEADER *npd, u8* crypt_key, u32 block_num, u32 total_blocks, u64 size_left) -{ - // Get metadata info and setup buffers. - const int metadata_section_size = ((edat->flags & EDAT_COMPRESSED_FLAG) != 0 || (edat->flags & EDAT_FLAG_0x20) != 0) ? 0x20 : 0x10; - const int metadata_offset = 0x100; - - std::unique_ptr enc_data; - std::unique_ptr dec_data; - u8 hash[0x10] = { 0 }; - u8 key_result[0x10] = { 0 }; - u8 hash_result[0x14] = { 0 }; - - u64 offset = 0; - u64 metadata_sec_offset = 0; - s32 length = 0; - s32 compression_end = 0; - unsigned char empty_iv[0x10] = {}; - - const u64 file_offset = in->pos(); - memset(hash_result, 0, 0x14); - - // Decrypt the metadata. - if ((edat->flags & EDAT_COMPRESSED_FLAG) != 0) - { - metadata_sec_offset = metadata_offset + u64{block_num} * metadata_section_size; - - in->seek(file_offset + metadata_sec_offset); - - unsigned char metadata[0x20]; - memset(metadata, 0, 0x20); - in->read(metadata, 0x20); - - // If the data is compressed, decrypt the metadata. - // NOTE: For NPD version 1 the metadata is not encrypted. - if (npd->version <= 1) - { - offset = swap64(*reinterpret_cast(&metadata[0x10])); - length = swap32(*reinterpret_cast(&metadata[0x18])); - compression_end = swap32(*reinterpret_cast(&metadata[0x1C])); - } - else - { - std::tie(offset, length, compression_end) = dec_section(metadata); - } - - memcpy(hash_result, metadata, 0x10); - } - else if ((edat->flags & EDAT_FLAG_0x20) != 0) - { - // If FLAG 0x20, the metadata precedes each data block. - metadata_sec_offset = metadata_offset + u64{block_num} * (metadata_section_size + edat->block_size); - in->seek(file_offset + metadata_sec_offset); - - unsigned char metadata[0x20]; - memset(metadata, 0, 0x20); - in->read(metadata, 0x20); - memcpy(hash_result, metadata, 0x14); - - // If FLAG 0x20 is set, apply custom xor. - for (int j = 0; j < 0x10; j++) - hash_result[j] = metadata[j] ^ metadata[j + 0x10]; - - offset = metadata_sec_offset + 0x20; - length = edat->block_size; - - if ((block_num == (total_blocks - 1)) && (edat->file_size % edat->block_size)) - length = static_cast(edat->file_size % edat->block_size); - } - else - { - metadata_sec_offset = metadata_offset + u64{block_num} * metadata_section_size; - in->seek(file_offset + metadata_sec_offset); - - in->read(hash_result, 0x10); - offset = metadata_offset + u64{block_num} * edat->block_size + total_blocks * metadata_section_size; - length = edat->block_size; - - if ((block_num == (total_blocks - 1)) && (edat->file_size % edat->block_size)) - length = static_cast(edat->file_size % edat->block_size); - } - - // Locate the real data. - const int pad_length = length; - length = (pad_length + 0xF) & 0xFFFFFFF0; - - // Setup buffers for decryption and read the data. - enc_data.reset(new u8[length]{ 0 }); - dec_data.reset(new u8[length]{ 0 }); - memset(hash, 0, 0x10); - memset(key_result, 0, 0x10); - - in->seek(file_offset + offset); - in->read(enc_data.get(), length); - - // Generate a key for the current block. - auto b_key = get_block_key(block_num, npd); - - // Encrypt the block key with the crypto key. - aesecb128_encrypt(crypt_key, reinterpret_cast(&b_key), key_result); - if ((edat->flags & EDAT_FLAG_0x10) != 0) - aesecb128_encrypt(crypt_key, key_result, hash); // If FLAG 0x10 is set, encrypt again to get the final hash. - else - memcpy(hash, key_result, 0x10); - - // Setup the crypto and hashing mode based on the extra flags. - int crypto_mode = ((edat->flags & EDAT_FLAG_0x02) == 0) ? 0x2 : 0x1; - int hash_mode; - - if ((edat->flags & EDAT_FLAG_0x10) == 0) - hash_mode = 0x02; - else if ((edat->flags & EDAT_FLAG_0x20) == 0) - hash_mode = 0x04; - else - hash_mode = 0x01; - - if ((edat->flags & EDAT_ENCRYPTED_KEY_FLAG) != 0) - { - crypto_mode |= 0x10000000; - hash_mode |= 0x10000000; - } - - if ((edat->flags & EDAT_DEBUG_DATA_FLAG) != 0) - { - // Reset the flags. - crypto_mode |= 0x01000000; - hash_mode |= 0x01000000; - // Simply copy the data without the header or the footer. - memcpy(dec_data.get(), enc_data.get(), length); - } - else - { - // IV is null if NPD version is 1 or 0. - u8* iv = (npd->version <= 1) ? empty_iv : npd->digest; - // Call main crypto routine on this data block. - if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), enc_data.get(), dec_data.get(), length, key_result, iv, hash, hash_result)) - { - edat_log.error("EDAT: Block at offset 0x%llx has invalid hash!", offset); - return -1; - } - } - - // Apply additional de-compression if needed and write the decrypted data. - if (((edat->flags & EDAT_COMPRESSED_FLAG) != 0) && compression_end) - { - const int res = decompress(out, dec_data.get(), edat->block_size); - - size_left -= res; - - if (size_left == 0) - { - if (res < 0) - { - edat_log.error("EDAT: Decompression failed!"); - return -1; - } - } - return res; - } - else - { - memcpy(out, dec_data.get(), pad_length); - return pad_length; - } -} - -// EDAT/SDAT decryption. -// reset file to beginning of data before calling -int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD_HEADER *npd, unsigned char* crypt_key, bool verbose) -{ - const int total_blocks = static_cast((edat->file_size + edat->block_size - 1) / edat->block_size); - u64 size_left = edat->file_size; - std::unique_ptr data(new u8[edat->block_size]); - - for (int i = 0; i < total_blocks; i++) - { - in->seek(0); - memset(data.get(), 0, edat->block_size); - u64 res = decrypt_block(in, data.get(), edat, npd, crypt_key, i, total_blocks, size_left); - if (res == umax) - { - edat_log.error("EDAT: Decrypt Block failed!"); - return 1; - } - size_left -= res; - out->write(data.get(), res); - } - - return 0; -} - -// set file offset to beginning before calling -int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs::file* f, bool verbose) -{ - u8 header[0xA0] = { 0 }; - u8 empty_header[0xA0] = { 0 }; - u8 header_hash[0x10] = { 0 }; - u8 metadata_hash[0x10] = { 0 }; - - const u64 file_offset = f->pos(); - - // Check NPD version and flags. - if ((npd->version == 0) || (npd->version == 1)) - { - if (edat->flags & 0x7EFFFFFE) - { - edat_log.error("EDAT: Bad header flags!"); - return 1; - } - } - else if (npd->version == 2) - { - if (edat->flags & 0x7EFFFFE0) - { - edat_log.error("EDAT: Bad header flags!"); - return 1; - } - } - else if ((npd->version == 3) || (npd->version == 4)) - { - if (edat->flags & 0x7EFFFFC0) - { - edat_log.error("EDAT: Bad header flags!"); - return 1; - } - } - else - { - edat_log.error("EDAT: Unknown version!"); - return 1; - } - - // Read in the file header. - f->read(header, 0xA0); - - // Read in the header and metadata section hashes. - f->seek(file_offset + 0x90); - f->read(metadata_hash, 0x10); - f->read(header_hash, 0x10); - - // Setup the hashing mode and the crypto mode used in the file. - const int crypto_mode = 0x1; - int hash_mode = ((edat->flags & EDAT_ENCRYPTED_KEY_FLAG) == 0) ? 0x00000002 : 0x10000002; - if ((edat->flags & EDAT_DEBUG_DATA_FLAG) != 0) - { - hash_mode |= 0x01000000; - - if (verbose) - edat_log.warning("EDAT: DEBUG data detected!"); - } - - // Setup header key and iv buffers. - unsigned char header_key[0x10] = { 0 }; - unsigned char header_iv[0x10] = { 0 }; - - // Test the header hash (located at offset 0xA0). - if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), header, empty_header, 0xA0, header_key, header_iv, key, header_hash)) - { - if (verbose) - edat_log.warning("EDAT: Header hash is invalid!"); - - // If the header hash test fails and the data is not DEBUG, then RAP/RIF/KLIC key is invalid. - if ((edat->flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG) - { - edat_log.error("EDAT: RAP/RIF/KLIC key is invalid!"); - return 1; - } - } - - // Parse the metadata info. - const int metadata_section_size = ((edat->flags & EDAT_COMPRESSED_FLAG) != 0 || (edat->flags & EDAT_FLAG_0x20) != 0) ? 0x20 : 0x10; - if (((edat->flags & EDAT_COMPRESSED_FLAG) != 0)) - { - if (verbose) - edat_log.warning("EDAT: COMPRESSED data detected!"); - } - - const int block_num = static_cast((edat->file_size + edat->block_size - 1) / edat->block_size); - const int metadata_offset = 0x100; - const int metadata_size = metadata_section_size * block_num; - u64 metadata_section_offset = metadata_offset; - - long bytes_read = 0; - long bytes_to_read = metadata_size; - std::unique_ptr metadata(new u8[metadata_size]); - std::unique_ptr empty_metadata(new u8[metadata_size]); - - while (bytes_to_read > 0) - { - // Locate the metadata blocks. - f->seek(file_offset + metadata_section_offset); - - // Read in the metadata. - f->read(metadata.get() + bytes_read, metadata_section_size); - - // Adjust sizes. - bytes_read += metadata_section_size; - bytes_to_read -= metadata_section_size; - - if (((edat->flags & EDAT_FLAG_0x20) != 0)) // Metadata block before each data block. - metadata_section_offset += (metadata_section_size + edat->block_size); - else - metadata_section_offset += metadata_section_size; - } - - // Test the metadata section hash (located at offset 0x90). - if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), metadata.get(), empty_metadata.get(), metadata_size, header_key, header_iv, key, metadata_hash)) - { - if (verbose) - edat_log.warning("EDAT: Metadata section hash is invalid!"); - } - - // Checking ECDSA signatures. - if ((edat->flags & EDAT_DEBUG_DATA_FLAG) == 0) - { - // Setup buffers. - unsigned char metadata_signature[0x28] = { 0 }; - unsigned char header_signature[0x28] = { 0 }; - unsigned char signature_hash[20] = { 0 }; - unsigned char signature_r[0x15] = { 0 }; - unsigned char signature_s[0x15] = { 0 }; - unsigned char zero_buf[0x15] = { 0 }; - - std::lock_guard lock(ec_mtx); - - // Setup ECDSA curve and public key. - ecdsa_set_curve(VSH_CURVE_P, VSH_CURVE_A, VSH_CURVE_B, VSH_CURVE_N, VSH_CURVE_GX, VSH_CURVE_GY); - ecdsa_set_pub(VSH_PUB); - - // Read in the metadata and header signatures. - f->seek(file_offset + 0xB0); - f->read(metadata_signature, 0x28); - f->read(header_signature, 0x28); - - // Checking metadata signature. - // Setup signature r and s. - memcpy(signature_r + 01, metadata_signature, 0x14); - memcpy(signature_s + 01, metadata_signature + 0x14, 0x14); - if ((!memcmp(signature_r, zero_buf, 0x15)) || (!memcmp(signature_s, zero_buf, 0x15))) - edat_log.warning("EDAT: Metadata signature is invalid!"); - else - { - // Setup signature hash. - if ((edat->flags & EDAT_FLAG_0x20) != 0) //Sony failed again, they used buffer from 0x100 with half size of real metadata. - { - int metadata_buf_size = block_num * 0x10; - std::unique_ptr metadata_buf(new u8[metadata_buf_size]); - f->seek(file_offset + metadata_offset); - f->read(metadata_buf.get(), metadata_buf_size); - sha1(metadata_buf.get(), metadata_buf_size, signature_hash); - } - else - sha1(metadata.get(), metadata_size, signature_hash); - - if (!ecdsa_verify(signature_hash, signature_r, signature_s)) - { - edat_log.warning("EDAT: Metadata signature is invalid!"); - if (((edat->block_size + 0ull) * block_num) > 0x100000000) - edat_log.warning("EDAT: *Due to large file size, metadata signature status may be incorrect!"); - } - } - - // Checking header signature. - // Setup header signature r and s. - memset(signature_r, 0, 0x15); - memset(signature_s, 0, 0x15); - memcpy(signature_r + 01, header_signature, 0x14); - memcpy(signature_s + 01, header_signature + 0x14, 0x14); - - if ((!memcmp(signature_r, zero_buf, 0x15)) || (!memcmp(signature_s, zero_buf, 0x15))) - edat_log.warning("EDAT: Header signature is invalid!"); - else - { - // Setup header signature hash. - memset(signature_hash, 0, 20); - u8 header_buf[0xD8]; - f->seek(file_offset); - f->read(header_buf, 0xD8); - sha1(header_buf, 0xD8, signature_hash); - - if (!ecdsa_verify(signature_hash, signature_r, signature_s)) - edat_log.warning("EDAT: Header signature is invalid!"); - } - } - - return 0; -} - -bool validate_dev_klic(const u8* klicensee, NPD_HEADER *npd) -{ - unsigned char dev[0x60] = { 0 }; - - // Build the dev buffer (first 0x60 bytes of NPD header in big-endian). - memcpy(dev, npd, 0x60); - - // Fix endianness. - int version = swap32(npd->version); - int license = swap32(npd->license); - int type = swap32(npd->type); - memcpy(dev + 0x4, &version, 4); - memcpy(dev + 0x8, &license, 4); - memcpy(dev + 0xC, &type, 4); - - // Check for an empty dev_hash (can't validate if devklic is NULL); - u128 klic; - std::memcpy(&klic, klicensee, sizeof(klic)); - - if (!klic) - { - // Allow empty dev hash. - return true; - } - - // Generate klicensee xor key. - u128 key = klic ^ std::bit_cast(NP_OMAC_KEY_2); - - // Hash with generated key and compare with dev_hash. - return cmac_hash_compare(reinterpret_cast(&key), 0x10, dev, 0x60, npd->dev_hash, 0x10); -} - -bool validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *npd, bool verbose) -{ - if (!file_name) - { - fmt::throw_exception("Empty filename"); - } - - const usz file_name_length = std::strlen(file_name); - const usz buf_len = 0x30 + file_name_length; - - std::unique_ptr buf(new u8[buf_len]); - std::unique_ptr buf_lower(new u8[buf_len]); - std::unique_ptr buf_upper(new u8[buf_len]); - - // Build the title buffer (content_id + file_name). - std::memcpy(buf.get(), npd->content_id, 0x30); - std::memcpy(buf.get() + 0x30, file_name, file_name_length); - - std::memcpy(buf_lower.get(), buf.get(), buf_len); - std::memcpy(buf_upper.get(), buf.get(), buf_len); - - for (usz i = std::basic_string_view(buf.get() + 0x30, file_name_length).find_last_of('.'); i < buf_len; i++) - { - const u8 c = static_cast(buf[i]); - buf_upper[i] = std::toupper(c); - buf_lower[i] = std::tolower(c); - } - - // Hash with NPDRM_OMAC_KEY_3 and compare with title_hash. - // Try to ignore case sensivity with file extension - const bool title_hash_result = - cmac_hash_compare(const_cast(NP_OMAC_KEY_3), 0x10, buf.get(), buf_len, npd->title_hash, 0x10) || - cmac_hash_compare(const_cast(NP_OMAC_KEY_3), 0x10, buf_lower.get(), buf_len, npd->title_hash, 0x10) || - cmac_hash_compare(const_cast(NP_OMAC_KEY_3), 0x10, buf_upper.get(), buf_len, npd->title_hash, 0x10); - - if (verbose) - { - if (title_hash_result) - edat_log.notice("EDAT: NPD title hash is valid!"); - else - edat_log.warning("EDAT: NPD title hash is invalid!"); - } - - const bool dev_hash_result = validate_dev_klic(klicensee, npd); - - return title_hash_result && dev_hash_result; -} - -void read_npd_edat_header(const fs::file* input, NPD_HEADER& NPD, EDAT_HEADER& EDAT) -{ - char npd_header[0x80]; - char edat_header[0x10]; - input->read(npd_header, sizeof(npd_header)); - input->read(edat_header, sizeof(edat_header)); - - memcpy(&NPD.magic, npd_header, 4); - NPD.version = swap32(*reinterpret_cast(&npd_header[4])); - NPD.license = swap32(*reinterpret_cast(&npd_header[8])); - NPD.type = swap32(*reinterpret_cast(&npd_header[12])); - memcpy(NPD.content_id, &npd_header[16], 0x30); - memcpy(NPD.digest, &npd_header[64], 0x10); - memcpy(NPD.title_hash, &npd_header[80], 0x10); - memcpy(NPD.dev_hash, &npd_header[96], 0x10); - NPD.unk1 = swap64(*reinterpret_cast(&npd_header[112])); - NPD.unk2 = swap64(*reinterpret_cast(&npd_header[120])); - - EDAT.flags = swap32(*reinterpret_cast(&edat_header[0])); - EDAT.block_size = swap32(*reinterpret_cast(&edat_header[4])); - EDAT.file_size = swap64(*reinterpret_cast(&edat_header[8])); -} - -bool extract_all_data(const fs::file* input, const fs::file* output, const char* input_file_name, unsigned char* devklic, unsigned char* rifkey, bool verbose) -{ - // Setup NPD and EDAT/SDAT structs. - NPD_HEADER NPD; - EDAT_HEADER EDAT; - - // Read in the NPD and EDAT/SDAT headers. - read_npd_edat_header(input, NPD, EDAT); - - unsigned char npd_magic[4] = {0x4E, 0x50, 0x44, 0x00}; //NPD0 - if (memcmp(&NPD.magic, npd_magic, 4)) - { - edat_log.error("EDAT: %s has invalid NPD header or already decrypted.", input_file_name); - return 1; - } - - if (verbose) - { - edat_log.notice("NPD HEADER"); - edat_log.notice("NPD version: %d", NPD.version); - edat_log.notice("NPD license: %d", NPD.license); - edat_log.notice("NPD type: %d", NPD.type); - } - - // Set decryption key. - u128 key{}; - - // Check EDAT/SDAT flag. - if ((EDAT.flags & SDAT_FLAG) == SDAT_FLAG) - { - if (verbose) - { - edat_log.notice("SDAT HEADER"); - edat_log.notice("SDAT flags: 0x%08X", EDAT.flags); - edat_log.notice("SDAT block size: 0x%08X", EDAT.block_size); - edat_log.notice("SDAT file size: 0x%08X", EDAT.file_size); - } - - // Generate SDAT key. - key = std::bit_cast(NPD.dev_hash) ^ std::bit_cast(SDAT_KEY); - } - else - { - if (verbose) - { - edat_log.notice("EDAT HEADER"); - edat_log.notice("EDAT flags: 0x%08X", EDAT.flags); - edat_log.notice("EDAT block size: 0x%08X", EDAT.block_size); - edat_log.notice("EDAT file size: 0x%08X", EDAT.file_size); - } - - // Perform header validation (EDAT only). - char real_file_name[CRYPTO_MAX_PATH]; - extract_file_name(input_file_name, real_file_name); - if (!validate_npd_hashes(real_file_name, devklic, &NPD, verbose)) - { - // Ignore header validation in DEBUG data. - if ((EDAT.flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG) - { - edat_log.error("EDAT: NPD hash validation failed!"); - return 1; - } - } - - // Select EDAT key. - if ((NPD.license & 0x3) == 0x3) // Type 3: Use supplied devklic. - memcpy(&key, devklic, 0x10); - else if ((NPD.license & 0x2) == 0x2) // Type 2: Use key from RAP file (RIF key). - { - memcpy(&key, rifkey, 0x10); - - // Make sure we don't have an empty RIF key. - if (!key) - { - edat_log.error("EDAT: A valid RAP file is needed for this EDAT file! (local activation)"); - return 1; - } - } - else if ((NPD.license & 0x1) == 0x1) // Type 1: Use network activation. - { - memcpy(&key, rifkey, 0x10); - - // Make sure we don't have an empty RIF key. - if (!key) - { - edat_log.error("EDAT: A valid RAP file is needed for this EDAT file! (network activation)"); - return 1; - } - } - - if (verbose) - { - be_t data; - - std::memcpy(&data, devklic, sizeof(data)); - edat_log.notice("DEVKLIC: %s", data); - std::memcpy(&data, rifkey, sizeof(data)); - edat_log.notice("RIF KEY: %s", data); - } - } - - if (verbose) - { - edat_log.notice("DECRYPTION KEY: %s", std::bit_cast>(key)); - } - - input->seek(0); - if (check_data(reinterpret_cast(&key), &EDAT, &NPD, input, verbose)) - { - edat_log.error("EDAT: Data parsing failed!"); - return 1; - } - - input->seek(0); - if (decrypt_data(input, output, &EDAT, &NPD, reinterpret_cast(&key), verbose)) - { - edat_log.error("EDAT: Data decryption failed!"); - return 1; - } - - return 0; -} - -u128 GetEdatRifKeyFromRapFile(const fs::file& rap_file) -{ - u128 rapkey{}; - u128 rifkey{}; - - rap_file.read(rapkey); - - rap_to_rif(reinterpret_cast(&rapkey), reinterpret_cast(&rifkey)); - - return rifkey; -} - -bool VerifyEDATHeaderWithKLicense(const fs::file& input, const std::string& input_file_name, const u8* custom_klic, std::string* contentID) -{ - // Setup NPD and EDAT/SDAT structs. - NPD_HEADER NPD; - EDAT_HEADER EDAT; - - // Read in the NPD and EDAT/SDAT headers. - read_npd_edat_header(&input, NPD, EDAT); - - unsigned char npd_magic[4] = { 0x4E, 0x50, 0x44, 0x00 }; //NPD0 - if (memcmp(&NPD.magic, npd_magic, 4)) - { - edat_log.error("EDAT: %s has invalid NPD header or already decrypted.", input_file_name); - return false; - } - - if ((EDAT.flags & SDAT_FLAG) == SDAT_FLAG) - { - edat_log.error("EDAT: SDATA file given to edat function"); - return false; - } - - // Perform header validation (EDAT only). - char real_file_name[CRYPTO_MAX_PATH]; - extract_file_name(input_file_name.c_str(), real_file_name); - if (!validate_npd_hashes(real_file_name, custom_klic, &NPD, false)) - { - // Ignore header validation in DEBUG data. - if ((EDAT.flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG) - { - edat_log.error("EDAT: NPD hash validation failed!"); - return false; - } - } - - *contentID = std::string(reinterpret_cast(NPD.content_id)); - return true; -} - -// Decrypts full file -fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name, int mode, const std::string& rap_file_name, u8 *custom_klic, bool verbose) -{ - // Prepare the files. - input.seek(0); - - // Set keys (RIF and DEVKLIC). - u128 rifKey{}; - u128 devklic{}; - - // Select the EDAT key mode. - switch (mode) - { - case 0: - break; - case 1: - memcpy(&devklic, NP_KLIC_FREE, 0x10); - break; - case 2: - memcpy(&devklic, NP_OMAC_KEY_2, 0x10); - break; - case 3: - memcpy(&devklic, NP_OMAC_KEY_3, 0x10); - break; - case 4: - memcpy(&devklic, NP_KLIC_KEY, 0x10); - break; - case 5: - memcpy(&devklic, NP_PSX_KEY, 0x10); - break; - case 6: - memcpy(&devklic, NP_PSP_KEY_1, 0x10); - break; - case 7: - memcpy(&devklic, NP_PSP_KEY_2, 0x10); - break; - case 8: - { - if (custom_klic != NULL) - memcpy(&devklic, custom_klic, 0x10); - else - { - edat_log.error("EDAT: Invalid custom klic!"); - return fs::file{}; - } - break; - } - default: - edat_log.error("EDAT: Invalid mode!"); - return fs::file{}; - } - - // Read the RAP file, if provided. - if (!rap_file_name.empty()) - { - fs::file rap(rap_file_name); - - rifKey = GetEdatRifKeyFromRapFile(rap); - } - - // Delete the bad output file if any errors arise. - fs::file output = fs::make_stream>(); - if (extract_all_data(&input, &output, input_file_name.c_str(), reinterpret_cast(&devklic), reinterpret_cast(&rifKey), verbose)) - { - output.release(); - return fs::file{}; - } - - output.seek(0); - return output; -} - -bool EDATADecrypter::ReadHeader() -{ - edata_file.seek(0); - // Read in the NPD and EDAT/SDAT headers. - read_npd_edat_header(&edata_file, npdHeader, edatHeader); - - unsigned char npd_magic[4] = { 0x4E, 0x50, 0x44, 0x00 }; //NPD0 - if (memcmp(&npdHeader.magic, npd_magic, 4)) - { - return false; - } - - // Check for SDAT flag. - if ((edatHeader.flags & SDAT_FLAG) == SDAT_FLAG) - { - // Generate SDAT key. - dec_key = std::bit_cast(npdHeader.dev_hash) ^ std::bit_cast(SDAT_KEY); - } - else - { - // verify key - if (!validate_dev_klic(reinterpret_cast(&dev_key), &npdHeader)) - { - edat_log.error("EDAT: Failed validating klic"); - return false; - } - - // Select EDAT key. - if ((npdHeader.license & 0x3) == 0x3) // Type 3: Use supplied devklic. - dec_key = std::move(dev_key); - else if ((npdHeader.license & 0x2) == 0x2) // Type 2: Use key from RAP file (RIF key). - { - dec_key = std::move(rif_key); - - if (!dec_key) - { - edat_log.warning("EDAT: Empty Dec key for local activation!"); - } - } - else if ((npdHeader.license & 0x1) == 0x1) // Type 1: Use network activation. - { - dec_key = std::move(rif_key); - - if (!dec_key) - { - edat_log.warning("EDAT: Empty Dec key for network activation!"); - } - } - } - - edata_file.seek(0); - - // k the ecdsa_verify function in this check_data function takes a ridiculous amount of time - // like it slows down load time by a factor of x20, at least, so its ignored for now - - /*if (check_data(dec_key._bytes, &edatHeader, &npdHeader, &sdata_file, false)) - { - return false; - }*/ - - file_size = edatHeader.file_size; - total_blocks = utils::aligned_div(edatHeader.file_size, edatHeader.block_size); - - return true; -} - -u64 EDATADecrypter::ReadData(u64 pos, u8* data, u64 size) -{ - if (pos > edatHeader.file_size) - return 0; - - // now we need to offset things to account for the actual 'range' requested - const u64 startOffset = pos % edatHeader.block_size; - - const u32 num_blocks = static_cast(utils::aligned_div(startOffset + size, edatHeader.block_size)); - const u64 bufSize = num_blocks*edatHeader.block_size; - if (data_buf_size < (bufSize)) - { - data_buf.reset(new u8[bufSize]); - data_buf_size = bufSize; - } - - // find and decrypt block range covering pos + size - const u32 starting_block = static_cast(pos / edatHeader.block_size); - const u32 ending_block = std::min(starting_block + num_blocks, total_blocks); - u64 writeOffset = 0; - for (u32 i = starting_block; i < ending_block; ++i) - { - edata_file.seek(0); - u64 res = decrypt_block(&edata_file, &data_buf[writeOffset], &edatHeader, &npdHeader, reinterpret_cast(&dec_key), i, total_blocks, edatHeader.file_size); - if (res == umax) - { - edat_log.error("Error Decrypting data"); - return 0; - } - writeOffset += res; - } - - const u64 bytesWrote = std::min(writeOffset - startOffset, size); - - memcpy(data, &data_buf[startOffset], bytesWrote); - return bytesWrote; -} +#include "stdafx.h" +#include "key_vault.h" +#include "unedat.h" +#include "sha1.h" +#include "lz.h" +#include "ec.h" + +#include "Utilities/mutex.h" +#include + +#include "util/asm.hpp" + +LOG_CHANNEL(edat_log, "EDAT"); + +// Static variables are being modified concurrently in ec.cpp, for now use a mutex +static shared_mutex ec_mtx; + +void generate_key(int crypto_mode, int version, unsigned char *key_final, unsigned char *iv_final, unsigned char *key, unsigned char *iv) +{ + int mode = crypto_mode & 0xF0000000; + uchar temp_iv[16]{}; + switch (mode) + { + case 0x10000000: + // Encrypted ERK. + // Decrypt the key with EDAT_KEY + EDAT_IV and copy the original IV. + memcpy(temp_iv, EDAT_IV, 0x10); + aescbc128_decrypt(const_cast(version ? EDAT_KEY_1 : EDAT_KEY_0), temp_iv, key, key_final, 0x10); + memcpy(iv_final, iv, 0x10); + break; + case 0x20000000: + // Default ERK. + // Use EDAT_KEY and EDAT_IV. + memcpy(key_final, version ? EDAT_KEY_1 : EDAT_KEY_0, 0x10); + memcpy(iv_final, EDAT_IV, 0x10); + break; + case 0x00000000: + // Unencrypted ERK. + // Use the original key and iv. + memcpy(key_final, key, 0x10); + memcpy(iv_final, iv, 0x10); + break; + }; +} + +void generate_hash(int hash_mode, int version, unsigned char *hash_final, unsigned char *hash) +{ + int mode = hash_mode & 0xF0000000; + uchar temp_iv[16]{}; + switch (mode) + { + case 0x10000000: + // Encrypted HASH. + // Decrypt the hash with EDAT_KEY + EDAT_IV. + memcpy(temp_iv, EDAT_IV, 0x10); + aescbc128_decrypt(const_cast(version ? EDAT_KEY_1 : EDAT_KEY_0), temp_iv, hash, hash_final, 0x10); + break; + case 0x20000000: + // Default HASH. + // Use EDAT_HASH. + memcpy(hash_final, version ? EDAT_HASH_1 : EDAT_HASH_0, 0x10); + break; + case 0x00000000: + // Unencrypted ERK. + // Use the original hash. + memcpy(hash_final, hash, 0x10); + break; + }; +} + +bool decrypt(int hash_mode, int crypto_mode, int version, unsigned char *in, unsigned char *out, int length, unsigned char *key, unsigned char *iv, unsigned char *hash, unsigned char *test_hash) +{ + // Setup buffers for key, iv and hash. + unsigned char key_final[0x10] = {}; + unsigned char iv_final[0x10] = {}; + unsigned char hash_final_10[0x10] = {}; + unsigned char hash_final_14[0x14] = {}; + + // Generate crypto key and hash. + generate_key(crypto_mode, version, key_final, iv_final, key, iv); + if ((hash_mode & 0xFF) == 0x01) + generate_hash(hash_mode, version, hash_final_14, hash); + else + generate_hash(hash_mode, version, hash_final_10, hash); + + if ((crypto_mode & 0xFF) == 0x01) // No algorithm. + { + memcpy(out, in, length); + } + else if ((crypto_mode & 0xFF) == 0x02) // AES128-CBC + { + aescbc128_decrypt(key_final, iv_final, in, out, length); + } + else + { + edat_log.error("EDAT: Unknown crypto algorithm!"); + return false; + } + + if ((hash_mode & 0xFF) == 0x01) // 0x14 SHA1-HMAC + { + return hmac_hash_compare(hash_final_14, 0x14, in, length, test_hash, 0x14); + } + else if ((hash_mode & 0xFF) == 0x02) // 0x10 AES-CMAC + { + return cmac_hash_compare(hash_final_10, 0x10, in, length, test_hash, 0x10); + } + else if ((hash_mode & 0xFF) == 0x04) //0x10 SHA1-HMAC + { + return hmac_hash_compare(hash_final_10, 0x10, in, length, test_hash, 0x10); + } + else + { + edat_log.error("EDAT: Unknown hashing algorithm!"); + return false; + } +} + +// EDAT/SDAT functions. +std::tuple dec_section(unsigned char* metadata) +{ + std::array dec; + dec[0x00] = (metadata[0xC] ^ metadata[0x8] ^ metadata[0x10]); + dec[0x01] = (metadata[0xD] ^ metadata[0x9] ^ metadata[0x11]); + dec[0x02] = (metadata[0xE] ^ metadata[0xA] ^ metadata[0x12]); + dec[0x03] = (metadata[0xF] ^ metadata[0xB] ^ metadata[0x13]); + dec[0x04] = (metadata[0x4] ^ metadata[0x8] ^ metadata[0x14]); + dec[0x05] = (metadata[0x5] ^ metadata[0x9] ^ metadata[0x15]); + dec[0x06] = (metadata[0x6] ^ metadata[0xA] ^ metadata[0x16]); + dec[0x07] = (metadata[0x7] ^ metadata[0xB] ^ metadata[0x17]); + dec[0x08] = (metadata[0xC] ^ metadata[0x0] ^ metadata[0x18]); + dec[0x09] = (metadata[0xD] ^ metadata[0x1] ^ metadata[0x19]); + dec[0x0A] = (metadata[0xE] ^ metadata[0x2] ^ metadata[0x1A]); + dec[0x0B] = (metadata[0xF] ^ metadata[0x3] ^ metadata[0x1B]); + dec[0x0C] = (metadata[0x4] ^ metadata[0x0] ^ metadata[0x1C]); + dec[0x0D] = (metadata[0x5] ^ metadata[0x1] ^ metadata[0x1D]); + dec[0x0E] = (metadata[0x6] ^ metadata[0x2] ^ metadata[0x1E]); + dec[0x0F] = (metadata[0x7] ^ metadata[0x3] ^ metadata[0x1F]); + + u64 offset = swap64(*reinterpret_cast(&dec[0])); + s32 length = swap32(*reinterpret_cast(&dec[8])); + s32 compression_end = swap32(*reinterpret_cast(&dec[12])); + + return std::make_tuple(offset, length, compression_end); +} + +u128 get_block_key(int block, NPD_HEADER *npd) +{ + unsigned char empty_key[0x10] = {}; + unsigned char *src_key = (npd->version <= 1) ? empty_key : npd->dev_hash; + u128 dest_key{}; + std::memcpy(&dest_key, src_key, 0xC); + + s32 swappedBlock = swap32(block); + std::memcpy(reinterpret_cast(&dest_key) + 0xC, &swappedBlock, sizeof(swappedBlock)); + return dest_key; +} + +// for out data, allocate a buffer the size of 'edat->block_size' +// Also, set 'in file' to the beginning of the encrypted data, which may be offset if inside another file, but normally just reset to beginning of file +// returns number of bytes written, -1 for error +s64 decrypt_block(const fs::file* in, u8* out, EDAT_HEADER *edat, NPD_HEADER *npd, u8* crypt_key, u32 block_num, u32 total_blocks, u64 size_left) +{ + // Get metadata info and setup buffers. + const int metadata_section_size = ((edat->flags & EDAT_COMPRESSED_FLAG) != 0 || (edat->flags & EDAT_FLAG_0x20) != 0) ? 0x20 : 0x10; + const int metadata_offset = 0x100; + + std::unique_ptr enc_data; + std::unique_ptr dec_data; + u8 hash[0x10] = { 0 }; + u8 key_result[0x10] = { 0 }; + u8 hash_result[0x14] = { 0 }; + + u64 offset = 0; + u64 metadata_sec_offset = 0; + s32 length = 0; + s32 compression_end = 0; + unsigned char empty_iv[0x10] = {}; + + const u64 file_offset = in->pos(); + memset(hash_result, 0, 0x14); + + // Decrypt the metadata. + if ((edat->flags & EDAT_COMPRESSED_FLAG) != 0) + { + metadata_sec_offset = metadata_offset + u64{block_num} * metadata_section_size; + + in->seek(file_offset + metadata_sec_offset); + + unsigned char metadata[0x20]; + memset(metadata, 0, 0x20); + in->read(metadata, 0x20); + + // If the data is compressed, decrypt the metadata. + // NOTE: For NPD version 1 the metadata is not encrypted. + if (npd->version <= 1) + { + offset = swap64(*reinterpret_cast(&metadata[0x10])); + length = swap32(*reinterpret_cast(&metadata[0x18])); + compression_end = swap32(*reinterpret_cast(&metadata[0x1C])); + } + else + { + std::tie(offset, length, compression_end) = dec_section(metadata); + } + + memcpy(hash_result, metadata, 0x10); + } + else if ((edat->flags & EDAT_FLAG_0x20) != 0) + { + // If FLAG 0x20, the metadata precedes each data block. + metadata_sec_offset = metadata_offset + u64{block_num} * (metadata_section_size + edat->block_size); + in->seek(file_offset + metadata_sec_offset); + + unsigned char metadata[0x20]; + memset(metadata, 0, 0x20); + in->read(metadata, 0x20); + memcpy(hash_result, metadata, 0x14); + + // If FLAG 0x20 is set, apply custom xor. + for (int j = 0; j < 0x10; j++) + hash_result[j] = metadata[j] ^ metadata[j + 0x10]; + + offset = metadata_sec_offset + 0x20; + length = edat->block_size; + + if ((block_num == (total_blocks - 1)) && (edat->file_size % edat->block_size)) + length = static_cast(edat->file_size % edat->block_size); + } + else + { + metadata_sec_offset = metadata_offset + u64{block_num} * metadata_section_size; + in->seek(file_offset + metadata_sec_offset); + + in->read(hash_result, 0x10); + offset = metadata_offset + u64{block_num} * edat->block_size + total_blocks * metadata_section_size; + length = edat->block_size; + + if ((block_num == (total_blocks - 1)) && (edat->file_size % edat->block_size)) + length = static_cast(edat->file_size % edat->block_size); + } + + // Locate the real data. + const int pad_length = length; + length = (pad_length + 0xF) & 0xFFFFFFF0; + + // Setup buffers for decryption and read the data. + enc_data.reset(new u8[length]{ 0 }); + dec_data.reset(new u8[length]{ 0 }); + memset(hash, 0, 0x10); + memset(key_result, 0, 0x10); + + in->seek(file_offset + offset); + in->read(enc_data.get(), length); + + // Generate a key for the current block. + auto b_key = get_block_key(block_num, npd); + + // Encrypt the block key with the crypto key. + aesecb128_encrypt(crypt_key, reinterpret_cast(&b_key), key_result); + if ((edat->flags & EDAT_FLAG_0x10) != 0) + aesecb128_encrypt(crypt_key, key_result, hash); // If FLAG 0x10 is set, encrypt again to get the final hash. + else + memcpy(hash, key_result, 0x10); + + // Setup the crypto and hashing mode based on the extra flags. + int crypto_mode = ((edat->flags & EDAT_FLAG_0x02) == 0) ? 0x2 : 0x1; + int hash_mode; + + if ((edat->flags & EDAT_FLAG_0x10) == 0) + hash_mode = 0x02; + else if ((edat->flags & EDAT_FLAG_0x20) == 0) + hash_mode = 0x04; + else + hash_mode = 0x01; + + if ((edat->flags & EDAT_ENCRYPTED_KEY_FLAG) != 0) + { + crypto_mode |= 0x10000000; + hash_mode |= 0x10000000; + } + + if ((edat->flags & EDAT_DEBUG_DATA_FLAG) != 0) + { + // Reset the flags. + crypto_mode |= 0x01000000; + hash_mode |= 0x01000000; + // Simply copy the data without the header or the footer. + memcpy(dec_data.get(), enc_data.get(), length); + } + else + { + // IV is null if NPD version is 1 or 0. + u8* iv = (npd->version <= 1) ? empty_iv : npd->digest; + // Call main crypto routine on this data block. + if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), enc_data.get(), dec_data.get(), length, key_result, iv, hash, hash_result)) + { + edat_log.error("EDAT: Block at offset 0x%llx has invalid hash!", offset); + return -1; + } + } + + // Apply additional de-compression if needed and write the decrypted data. + if (((edat->flags & EDAT_COMPRESSED_FLAG) != 0) && compression_end) + { + const int res = decompress(out, dec_data.get(), edat->block_size); + + size_left -= res; + + if (size_left == 0) + { + if (res < 0) + { + edat_log.error("EDAT: Decompression failed!"); + return -1; + } + } + return res; + } + else + { + memcpy(out, dec_data.get(), pad_length); + return pad_length; + } +} + +// EDAT/SDAT decryption. +// reset file to beginning of data before calling +int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD_HEADER *npd, unsigned char* crypt_key, bool /*verbose*/) +{ + const int total_blocks = static_cast((edat->file_size + edat->block_size - 1) / edat->block_size); + u64 size_left = edat->file_size; + std::unique_ptr data(new u8[edat->block_size]); + + for (int i = 0; i < total_blocks; i++) + { + in->seek(0); + memset(data.get(), 0, edat->block_size); + u64 res = decrypt_block(in, data.get(), edat, npd, crypt_key, i, total_blocks, size_left); + if (res == umax) + { + edat_log.error("EDAT: Decrypt Block failed!"); + return 1; + } + size_left -= res; + out->write(data.get(), res); + } + + return 0; +} + +// set file offset to beginning before calling +int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs::file* f, bool verbose) +{ + u8 header[0xA0] = { 0 }; + u8 empty_header[0xA0] = { 0 }; + u8 header_hash[0x10] = { 0 }; + u8 metadata_hash[0x10] = { 0 }; + + const u64 file_offset = f->pos(); + + // Check NPD version and flags. + if ((npd->version == 0) || (npd->version == 1)) + { + if (edat->flags & 0x7EFFFFFE) + { + edat_log.error("EDAT: Bad header flags!"); + return 1; + } + } + else if (npd->version == 2) + { + if (edat->flags & 0x7EFFFFE0) + { + edat_log.error("EDAT: Bad header flags!"); + return 1; + } + } + else if ((npd->version == 3) || (npd->version == 4)) + { + if (edat->flags & 0x7EFFFFC0) + { + edat_log.error("EDAT: Bad header flags!"); + return 1; + } + } + else + { + edat_log.error("EDAT: Unknown version!"); + return 1; + } + + // Read in the file header. + f->read(header, 0xA0); + + // Read in the header and metadata section hashes. + f->seek(file_offset + 0x90); + f->read(metadata_hash, 0x10); + f->read(header_hash, 0x10); + + // Setup the hashing mode and the crypto mode used in the file. + const int crypto_mode = 0x1; + int hash_mode = ((edat->flags & EDAT_ENCRYPTED_KEY_FLAG) == 0) ? 0x00000002 : 0x10000002; + if ((edat->flags & EDAT_DEBUG_DATA_FLAG) != 0) + { + hash_mode |= 0x01000000; + + if (verbose) + edat_log.warning("EDAT: DEBUG data detected!"); + } + + // Setup header key and iv buffers. + unsigned char header_key[0x10] = { 0 }; + unsigned char header_iv[0x10] = { 0 }; + + // Test the header hash (located at offset 0xA0). + if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), header, empty_header, 0xA0, header_key, header_iv, key, header_hash)) + { + if (verbose) + edat_log.warning("EDAT: Header hash is invalid!"); + + // If the header hash test fails and the data is not DEBUG, then RAP/RIF/KLIC key is invalid. + if ((edat->flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG) + { + edat_log.error("EDAT: RAP/RIF/KLIC key is invalid!"); + return 1; + } + } + + // Parse the metadata info. + const int metadata_section_size = ((edat->flags & EDAT_COMPRESSED_FLAG) != 0 || (edat->flags & EDAT_FLAG_0x20) != 0) ? 0x20 : 0x10; + if (((edat->flags & EDAT_COMPRESSED_FLAG) != 0)) + { + if (verbose) + edat_log.warning("EDAT: COMPRESSED data detected!"); + } + + const int block_num = static_cast((edat->file_size + edat->block_size - 1) / edat->block_size); + const int metadata_offset = 0x100; + const int metadata_size = metadata_section_size * block_num; + u64 metadata_section_offset = metadata_offset; + + long bytes_read = 0; + long bytes_to_read = metadata_size; + std::unique_ptr metadata(new u8[metadata_size]); + std::unique_ptr empty_metadata(new u8[metadata_size]); + + while (bytes_to_read > 0) + { + // Locate the metadata blocks. + f->seek(file_offset + metadata_section_offset); + + // Read in the metadata. + f->read(metadata.get() + bytes_read, metadata_section_size); + + // Adjust sizes. + bytes_read += metadata_section_size; + bytes_to_read -= metadata_section_size; + + if (((edat->flags & EDAT_FLAG_0x20) != 0)) // Metadata block before each data block. + metadata_section_offset += (metadata_section_size + edat->block_size); + else + metadata_section_offset += metadata_section_size; + } + + // Test the metadata section hash (located at offset 0x90). + if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), metadata.get(), empty_metadata.get(), metadata_size, header_key, header_iv, key, metadata_hash)) + { + if (verbose) + edat_log.warning("EDAT: Metadata section hash is invalid!"); + } + + // Checking ECDSA signatures. + if ((edat->flags & EDAT_DEBUG_DATA_FLAG) == 0) + { + // Setup buffers. + unsigned char metadata_signature[0x28] = { 0 }; + unsigned char header_signature[0x28] = { 0 }; + unsigned char signature_hash[20] = { 0 }; + unsigned char signature_r[0x15] = { 0 }; + unsigned char signature_s[0x15] = { 0 }; + unsigned char zero_buf[0x15] = { 0 }; + + std::lock_guard lock(ec_mtx); + + // Setup ECDSA curve and public key. + ecdsa_set_curve(VSH_CURVE_P, VSH_CURVE_A, VSH_CURVE_B, VSH_CURVE_N, VSH_CURVE_GX, VSH_CURVE_GY); + ecdsa_set_pub(VSH_PUB); + + // Read in the metadata and header signatures. + f->seek(file_offset + 0xB0); + f->read(metadata_signature, 0x28); + f->read(header_signature, 0x28); + + // Checking metadata signature. + // Setup signature r and s. + memcpy(signature_r + 01, metadata_signature, 0x14); + memcpy(signature_s + 01, metadata_signature + 0x14, 0x14); + if ((!memcmp(signature_r, zero_buf, 0x15)) || (!memcmp(signature_s, zero_buf, 0x15))) + edat_log.warning("EDAT: Metadata signature is invalid!"); + else + { + // Setup signature hash. + if ((edat->flags & EDAT_FLAG_0x20) != 0) //Sony failed again, they used buffer from 0x100 with half size of real metadata. + { + int metadata_buf_size = block_num * 0x10; + std::unique_ptr metadata_buf(new u8[metadata_buf_size]); + f->seek(file_offset + metadata_offset); + f->read(metadata_buf.get(), metadata_buf_size); + sha1(metadata_buf.get(), metadata_buf_size, signature_hash); + } + else + sha1(metadata.get(), metadata_size, signature_hash); + + if (!ecdsa_verify(signature_hash, signature_r, signature_s)) + { + edat_log.warning("EDAT: Metadata signature is invalid!"); + if (((edat->block_size + 0ull) * block_num) > 0x100000000) + edat_log.warning("EDAT: *Due to large file size, metadata signature status may be incorrect!"); + } + } + + // Checking header signature. + // Setup header signature r and s. + memset(signature_r, 0, 0x15); + memset(signature_s, 0, 0x15); + memcpy(signature_r + 01, header_signature, 0x14); + memcpy(signature_s + 01, header_signature + 0x14, 0x14); + + if ((!memcmp(signature_r, zero_buf, 0x15)) || (!memcmp(signature_s, zero_buf, 0x15))) + edat_log.warning("EDAT: Header signature is invalid!"); + else + { + // Setup header signature hash. + memset(signature_hash, 0, 20); + u8 header_buf[0xD8]; + f->seek(file_offset); + f->read(header_buf, 0xD8); + sha1(header_buf, 0xD8, signature_hash); + + if (!ecdsa_verify(signature_hash, signature_r, signature_s)) + edat_log.warning("EDAT: Header signature is invalid!"); + } + } + + return 0; +} + +bool validate_dev_klic(const u8* klicensee, NPD_HEADER *npd) +{ + unsigned char dev[0x60] = { 0 }; + + // Build the dev buffer (first 0x60 bytes of NPD header in big-endian). + memcpy(dev, npd, 0x60); + + // Fix endianness. + int version = swap32(npd->version); + int license = swap32(npd->license); + int type = swap32(npd->type); + memcpy(dev + 0x4, &version, 4); + memcpy(dev + 0x8, &license, 4); + memcpy(dev + 0xC, &type, 4); + + // Check for an empty dev_hash (can't validate if devklic is NULL); + u128 klic; + std::memcpy(&klic, klicensee, sizeof(klic)); + + if (!klic) + { + // Allow empty dev hash. + return true; + } + + // Generate klicensee xor key. + u128 key = klic ^ std::bit_cast(NP_OMAC_KEY_2); + + // Hash with generated key and compare with dev_hash. + return cmac_hash_compare(reinterpret_cast(&key), 0x10, dev, 0x60, npd->dev_hash, 0x10); +} + +bool validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *npd, bool verbose) +{ + if (!file_name) + { + fmt::throw_exception("Empty filename"); + } + + const usz file_name_length = std::strlen(file_name); + const usz buf_len = 0x30 + file_name_length; + + std::unique_ptr buf(new u8[buf_len]); + std::unique_ptr buf_lower(new u8[buf_len]); + std::unique_ptr buf_upper(new u8[buf_len]); + + // Build the title buffer (content_id + file_name). + std::memcpy(buf.get(), npd->content_id, 0x30); + std::memcpy(buf.get() + 0x30, file_name, file_name_length); + + std::memcpy(buf_lower.get(), buf.get(), buf_len); + std::memcpy(buf_upper.get(), buf.get(), buf_len); + + for (usz i = std::basic_string_view(buf.get() + 0x30, file_name_length).find_last_of('.'); i < buf_len; i++) + { + const u8 c = static_cast(buf[i]); + buf_upper[i] = std::toupper(c); + buf_lower[i] = std::tolower(c); + } + + // Hash with NPDRM_OMAC_KEY_3 and compare with title_hash. + // Try to ignore case sensivity with file extension + const bool title_hash_result = + cmac_hash_compare(const_cast(NP_OMAC_KEY_3), 0x10, buf.get(), buf_len, npd->title_hash, 0x10) || + cmac_hash_compare(const_cast(NP_OMAC_KEY_3), 0x10, buf_lower.get(), buf_len, npd->title_hash, 0x10) || + cmac_hash_compare(const_cast(NP_OMAC_KEY_3), 0x10, buf_upper.get(), buf_len, npd->title_hash, 0x10); + + if (verbose) + { + if (title_hash_result) + edat_log.notice("EDAT: NPD title hash is valid!"); + else + edat_log.warning("EDAT: NPD title hash is invalid!"); + } + + const bool dev_hash_result = validate_dev_klic(klicensee, npd); + + return title_hash_result && dev_hash_result; +} + +void read_npd_edat_header(const fs::file* input, NPD_HEADER& NPD, EDAT_HEADER& EDAT) +{ + char npd_header[0x80]; + char edat_header[0x10]; + input->read(npd_header, sizeof(npd_header)); + input->read(edat_header, sizeof(edat_header)); + + memcpy(&NPD.magic, npd_header, 4); + NPD.version = swap32(*reinterpret_cast(&npd_header[4])); + NPD.license = swap32(*reinterpret_cast(&npd_header[8])); + NPD.type = swap32(*reinterpret_cast(&npd_header[12])); + memcpy(NPD.content_id, &npd_header[16], 0x30); + memcpy(NPD.digest, &npd_header[64], 0x10); + memcpy(NPD.title_hash, &npd_header[80], 0x10); + memcpy(NPD.dev_hash, &npd_header[96], 0x10); + NPD.unk1 = swap64(*reinterpret_cast(&npd_header[112])); + NPD.unk2 = swap64(*reinterpret_cast(&npd_header[120])); + + EDAT.flags = swap32(*reinterpret_cast(&edat_header[0])); + EDAT.block_size = swap32(*reinterpret_cast(&edat_header[4])); + EDAT.file_size = swap64(*reinterpret_cast(&edat_header[8])); +} + +bool extract_all_data(const fs::file* input, const fs::file* output, const char* input_file_name, unsigned char* devklic, unsigned char* rifkey, bool verbose) +{ + // Setup NPD and EDAT/SDAT structs. + NPD_HEADER NPD; + EDAT_HEADER EDAT; + + // Read in the NPD and EDAT/SDAT headers. + read_npd_edat_header(input, NPD, EDAT); + + unsigned char npd_magic[4] = {0x4E, 0x50, 0x44, 0x00}; //NPD0 + if (memcmp(&NPD.magic, npd_magic, 4)) + { + edat_log.error("EDAT: %s has invalid NPD header or already decrypted.", input_file_name); + return 1; + } + + if (verbose) + { + edat_log.notice("NPD HEADER"); + edat_log.notice("NPD version: %d", NPD.version); + edat_log.notice("NPD license: %d", NPD.license); + edat_log.notice("NPD type: %d", NPD.type); + } + + // Set decryption key. + u128 key{}; + + // Check EDAT/SDAT flag. + if ((EDAT.flags & SDAT_FLAG) == SDAT_FLAG) + { + if (verbose) + { + edat_log.notice("SDAT HEADER"); + edat_log.notice("SDAT flags: 0x%08X", EDAT.flags); + edat_log.notice("SDAT block size: 0x%08X", EDAT.block_size); + edat_log.notice("SDAT file size: 0x%08X", EDAT.file_size); + } + + // Generate SDAT key. + key = std::bit_cast(NPD.dev_hash) ^ std::bit_cast(SDAT_KEY); + } + else + { + if (verbose) + { + edat_log.notice("EDAT HEADER"); + edat_log.notice("EDAT flags: 0x%08X", EDAT.flags); + edat_log.notice("EDAT block size: 0x%08X", EDAT.block_size); + edat_log.notice("EDAT file size: 0x%08X", EDAT.file_size); + } + + // Perform header validation (EDAT only). + char real_file_name[CRYPTO_MAX_PATH]; + extract_file_name(input_file_name, real_file_name); + if (!validate_npd_hashes(real_file_name, devklic, &NPD, verbose)) + { + // Ignore header validation in DEBUG data. + if ((EDAT.flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG) + { + edat_log.error("EDAT: NPD hash validation failed!"); + return 1; + } + } + + // Select EDAT key. + if ((NPD.license & 0x3) == 0x3) // Type 3: Use supplied devklic. + memcpy(&key, devklic, 0x10); + else if ((NPD.license & 0x2) == 0x2) // Type 2: Use key from RAP file (RIF key). + { + memcpy(&key, rifkey, 0x10); + + // Make sure we don't have an empty RIF key. + if (!key) + { + edat_log.error("EDAT: A valid RAP file is needed for this EDAT file! (local activation)"); + return 1; + } + } + else if ((NPD.license & 0x1) == 0x1) // Type 1: Use network activation. + { + memcpy(&key, rifkey, 0x10); + + // Make sure we don't have an empty RIF key. + if (!key) + { + edat_log.error("EDAT: A valid RAP file is needed for this EDAT file! (network activation)"); + return 1; + } + } + + if (verbose) + { + be_t data; + + std::memcpy(&data, devklic, sizeof(data)); + edat_log.notice("DEVKLIC: %s", data); + std::memcpy(&data, rifkey, sizeof(data)); + edat_log.notice("RIF KEY: %s", data); + } + } + + if (verbose) + { + edat_log.notice("DECRYPTION KEY: %s", std::bit_cast>(key)); + } + + input->seek(0); + if (check_data(reinterpret_cast(&key), &EDAT, &NPD, input, verbose)) + { + edat_log.error("EDAT: Data parsing failed!"); + return 1; + } + + input->seek(0); + if (decrypt_data(input, output, &EDAT, &NPD, reinterpret_cast(&key), verbose)) + { + edat_log.error("EDAT: Data decryption failed!"); + return 1; + } + + return 0; +} + +u128 GetEdatRifKeyFromRapFile(const fs::file& rap_file) +{ + u128 rapkey{}; + u128 rifkey{}; + + rap_file.read(rapkey); + + rap_to_rif(reinterpret_cast(&rapkey), reinterpret_cast(&rifkey)); + + return rifkey; +} + +bool VerifyEDATHeaderWithKLicense(const fs::file& input, const std::string& input_file_name, const u8* custom_klic, std::string* contentID) +{ + // Setup NPD and EDAT/SDAT structs. + NPD_HEADER NPD; + EDAT_HEADER EDAT; + + // Read in the NPD and EDAT/SDAT headers. + read_npd_edat_header(&input, NPD, EDAT); + + unsigned char npd_magic[4] = { 0x4E, 0x50, 0x44, 0x00 }; //NPD0 + if (memcmp(&NPD.magic, npd_magic, 4)) + { + edat_log.error("EDAT: %s has invalid NPD header or already decrypted.", input_file_name); + return false; + } + + if ((EDAT.flags & SDAT_FLAG) == SDAT_FLAG) + { + edat_log.error("EDAT: SDATA file given to edat function"); + return false; + } + + // Perform header validation (EDAT only). + char real_file_name[CRYPTO_MAX_PATH]; + extract_file_name(input_file_name.c_str(), real_file_name); + if (!validate_npd_hashes(real_file_name, custom_klic, &NPD, false)) + { + // Ignore header validation in DEBUG data. + if ((EDAT.flags & EDAT_DEBUG_DATA_FLAG) != EDAT_DEBUG_DATA_FLAG) + { + edat_log.error("EDAT: NPD hash validation failed!"); + return false; + } + } + + *contentID = std::string(reinterpret_cast(NPD.content_id)); + return true; +} + +// Decrypts full file +fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name, int mode, const std::string& rap_file_name, u8 *custom_klic, bool verbose) +{ + // Prepare the files. + input.seek(0); + + // Set keys (RIF and DEVKLIC). + u128 rifKey{}; + u128 devklic{}; + + // Select the EDAT key mode. + switch (mode) + { + case 0: + break; + case 1: + memcpy(&devklic, NP_KLIC_FREE, 0x10); + break; + case 2: + memcpy(&devklic, NP_OMAC_KEY_2, 0x10); + break; + case 3: + memcpy(&devklic, NP_OMAC_KEY_3, 0x10); + break; + case 4: + memcpy(&devklic, NP_KLIC_KEY, 0x10); + break; + case 5: + memcpy(&devklic, NP_PSX_KEY, 0x10); + break; + case 6: + memcpy(&devklic, NP_PSP_KEY_1, 0x10); + break; + case 7: + memcpy(&devklic, NP_PSP_KEY_2, 0x10); + break; + case 8: + { + if (custom_klic != NULL) + memcpy(&devklic, custom_klic, 0x10); + else + { + edat_log.error("EDAT: Invalid custom klic!"); + return fs::file{}; + } + break; + } + default: + edat_log.error("EDAT: Invalid mode!"); + return fs::file{}; + } + + // Read the RAP file, if provided. + if (!rap_file_name.empty()) + { + fs::file rap(rap_file_name); + + rifKey = GetEdatRifKeyFromRapFile(rap); + } + + // Delete the bad output file if any errors arise. + fs::file output = fs::make_stream>(); + if (extract_all_data(&input, &output, input_file_name.c_str(), reinterpret_cast(&devklic), reinterpret_cast(&rifKey), verbose)) + { + output.release(); + return fs::file{}; + } + + output.seek(0); + return output; +} + +bool EDATADecrypter::ReadHeader() +{ + edata_file.seek(0); + // Read in the NPD and EDAT/SDAT headers. + read_npd_edat_header(&edata_file, npdHeader, edatHeader); + + unsigned char npd_magic[4] = { 0x4E, 0x50, 0x44, 0x00 }; //NPD0 + if (memcmp(&npdHeader.magic, npd_magic, 4)) + { + return false; + } + + // Check for SDAT flag. + if ((edatHeader.flags & SDAT_FLAG) == SDAT_FLAG) + { + // Generate SDAT key. + dec_key = std::bit_cast(npdHeader.dev_hash) ^ std::bit_cast(SDAT_KEY); + } + else + { + // verify key + if (!validate_dev_klic(reinterpret_cast(&dev_key), &npdHeader)) + { + edat_log.error("EDAT: Failed validating klic"); + return false; + } + + // Select EDAT key. + if ((npdHeader.license & 0x3) == 0x3) // Type 3: Use supplied devklic. + dec_key = std::move(dev_key); + else if ((npdHeader.license & 0x2) == 0x2) // Type 2: Use key from RAP file (RIF key). + { + dec_key = std::move(rif_key); + + if (!dec_key) + { + edat_log.warning("EDAT: Empty Dec key for local activation!"); + } + } + else if ((npdHeader.license & 0x1) == 0x1) // Type 1: Use network activation. + { + dec_key = std::move(rif_key); + + if (!dec_key) + { + edat_log.warning("EDAT: Empty Dec key for network activation!"); + } + } + } + + edata_file.seek(0); + + // k the ecdsa_verify function in this check_data function takes a ridiculous amount of time + // like it slows down load time by a factor of x20, at least, so its ignored for now + + /*if (check_data(dec_key._bytes, &edatHeader, &npdHeader, &sdata_file, false)) + { + return false; + }*/ + + file_size = edatHeader.file_size; + total_blocks = utils::aligned_div(edatHeader.file_size, edatHeader.block_size); + + return true; +} + +u64 EDATADecrypter::ReadData(u64 pos, u8* data, u64 size) +{ + if (pos > edatHeader.file_size) + return 0; + + // now we need to offset things to account for the actual 'range' requested + const u64 startOffset = pos % edatHeader.block_size; + + const u32 num_blocks = static_cast(utils::aligned_div(startOffset + size, edatHeader.block_size)); + const u64 bufSize = num_blocks*edatHeader.block_size; + if (data_buf_size < (bufSize)) + { + data_buf.reset(new u8[bufSize]); + data_buf_size = bufSize; + } + + // find and decrypt block range covering pos + size + const u32 starting_block = static_cast(pos / edatHeader.block_size); + const u32 ending_block = std::min(starting_block + num_blocks, total_blocks); + u64 writeOffset = 0; + for (u32 i = starting_block; i < ending_block; ++i) + { + edata_file.seek(0); + u64 res = decrypt_block(&edata_file, &data_buf[writeOffset], &edatHeader, &npdHeader, reinterpret_cast(&dec_key), i, total_blocks, edatHeader.file_size); + if (res == umax) + { + edat_log.error("Error Decrypting data"); + return 0; + } + writeOffset += res; + } + + const u64 bytesWrote = std::min(writeOffset - startOffset, size); + + memcpy(data, &data_buf[startOffset], bytesWrote); + return bytesWrote; +} diff --git a/rpcs3/Crypto/unedat.h b/rpcs3/Crypto/unedat.h index 312baef986..5db9da8a6b 100644 --- a/rpcs3/Crypto/unedat.h +++ b/rpcs3/Crypto/unedat.h @@ -1,130 +1,134 @@ -#pragma once - -#include - -#include "utils.h" - -#include "Utilities/File.h" - -constexpr u32 SDAT_FLAG = 0x01000000; -constexpr u32 EDAT_COMPRESSED_FLAG = 0x00000001; -constexpr u32 EDAT_FLAG_0x02 = 0x00000002; -constexpr u32 EDAT_ENCRYPTED_KEY_FLAG = 0x00000008; -constexpr u32 EDAT_FLAG_0x10 = 0x00000010; -constexpr u32 EDAT_FLAG_0x20 = 0x00000020; -constexpr u32 EDAT_DEBUG_DATA_FLAG = 0x80000000; - -struct loaded_npdrm_keys -{ - atomic_t devKlic{}; - atomic_t rifKey{}; - atomic_t npdrm_fds{0}; -}; - -struct NPD_HEADER -{ - u32 magic; - s32 version; - s32 license; - s32 type; - u8 content_id[0x30]; - u8 digest[0x10]; - u8 title_hash[0x10]; - u8 dev_hash[0x10]; - u64 unk1; - u64 unk2; -}; - -struct EDAT_HEADER -{ - s32 flags; - s32 block_size; - u64 file_size; -}; - -// Decrypts full file, or null/empty file -extern fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name, int mode, const std::string& rap_file_name, u8 *custom_klic, bool verbose); - -extern bool VerifyEDATHeaderWithKLicense(const fs::file& input, const std::string& input_file_name, const u8* custom_klic, std::string* contentID); - -u128 GetEdatRifKeyFromRapFile(const fs::file& rap_file); - -struct EDATADecrypter final : fs::file_base -{ - // file stream - const fs::file edata_file; - u64 file_size{0}; - u32 total_blocks{0}; - u64 pos{0}; - - NPD_HEADER npdHeader; - EDAT_HEADER edatHeader; - - // Internal data buffers. - std::unique_ptr data_buf; - u64 data_buf_size{0}; - - u128 dec_key{}; - - // edat usage - u128 rif_key{}; - u128 dev_key{}; -public: - // SdataByFd usage - EDATADecrypter(fs::file&& input) - : edata_file(std::move(input)) {} - // Edat usage - EDATADecrypter(fs::file&& input, const u128& dev_key, const u128& rif_key) - : edata_file(std::move(input)) - , rif_key(rif_key) - , dev_key(dev_key) {} - - ~EDATADecrypter() override {} - // false if invalid - bool ReadHeader(); - u64 ReadData(u64 pos, u8* data, u64 size); - - fs::stat_t stat() override - { - fs::stat_t stats; - stats.is_directory = false; - stats.is_writable = false; - stats.size = file_size; - stats.atime = -1; - stats.ctime = -1; - stats.mtime = -1; - return stats; - } - bool trunc(u64 length) override - { - return true; - } - u64 read(void* buffer, u64 size) override - { - u64 bytesRead = ReadData(pos, static_cast(buffer), size); - pos += bytesRead; - return bytesRead; - } - u64 write(const void* buffer, u64 size) override - { - return 0; - } - - u64 seek(s64 offset, fs::seek_mode whence) override - { - const s64 new_pos = - whence == fs::seek_set ? offset : - whence == fs::seek_cur ? offset + pos : - whence == fs::seek_end ? offset + size() : -1; - - if (new_pos < 0) - { - fs::g_tls_error = fs::error::inval; - return -1; - } - - pos = new_pos; - return pos; - } - u64 size() override { return file_size; } -}; +#pragma once + +#include + +#include "utils.h" + +#include "Utilities/File.h" + +constexpr u32 SDAT_FLAG = 0x01000000; +constexpr u32 EDAT_COMPRESSED_FLAG = 0x00000001; +constexpr u32 EDAT_FLAG_0x02 = 0x00000002; +constexpr u32 EDAT_ENCRYPTED_KEY_FLAG = 0x00000008; +constexpr u32 EDAT_FLAG_0x10 = 0x00000010; +constexpr u32 EDAT_FLAG_0x20 = 0x00000020; +constexpr u32 EDAT_DEBUG_DATA_FLAG = 0x80000000; + +struct loaded_npdrm_keys +{ + atomic_t devKlic{}; + atomic_t rifKey{}; + atomic_t npdrm_fds{0}; +}; + +struct NPD_HEADER +{ + u32 magic; + s32 version; + s32 license; + s32 type; + u8 content_id[0x30]; + u8 digest[0x10]; + u8 title_hash[0x10]; + u8 dev_hash[0x10]; + u64 unk1; + u64 unk2; +}; + +struct EDAT_HEADER +{ + s32 flags; + s32 block_size; + u64 file_size; +}; + +// Decrypts full file, or null/empty file +extern fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name, int mode, const std::string& rap_file_name, u8 *custom_klic, bool verbose); + +extern bool VerifyEDATHeaderWithKLicense(const fs::file& input, const std::string& input_file_name, const u8* custom_klic, std::string* contentID); + +u128 GetEdatRifKeyFromRapFile(const fs::file& rap_file); + +struct EDATADecrypter final : fs::file_base +{ + // file stream + const fs::file edata_file; + u64 file_size{0}; + u32 total_blocks{0}; + u64 pos{0}; + + NPD_HEADER npdHeader; + EDAT_HEADER edatHeader; + + // Internal data buffers. + std::unique_ptr data_buf; + u64 data_buf_size{0}; + + u128 dec_key{}; + + // edat usage + u128 rif_key{}; + u128 dev_key{}; +public: + // SdataByFd usage + EDATADecrypter(fs::file&& input) + : edata_file(std::move(input)) {} + // Edat usage + EDATADecrypter(fs::file&& input, const u128& dev_key, const u128& rif_key) + : edata_file(std::move(input)) + , rif_key(rif_key) + , dev_key(dev_key) {} + + ~EDATADecrypter() override {} + // false if invalid + bool ReadHeader(); + u64 ReadData(u64 pos, u8* data, u64 size); + + fs::stat_t stat() override + { + fs::stat_t stats; + stats.is_directory = false; + stats.is_writable = false; + stats.size = file_size; + stats.atime = -1; + stats.ctime = -1; + stats.mtime = -1; + return stats; + } + + bool trunc(u64) override + { + return false; + } + + u64 read(void* buffer, u64 size) override + { + u64 bytesRead = ReadData(pos, static_cast(buffer), size); + pos += bytesRead; + return bytesRead; + } + + u64 write(const void*, u64) override + { + return 0; + } + + u64 seek(s64 offset, fs::seek_mode whence) override + { + const s64 new_pos = + whence == fs::seek_set ? offset : + whence == fs::seek_cur ? offset + pos : + whence == fs::seek_end ? offset + size() : -1; + + if (new_pos < 0) + { + fs::g_tls_error = fs::error::inval; + return -1; + } + + pos = new_pos; + return pos; + } + + u64 size() override { return file_size; } +}; diff --git a/rpcs3/Crypto/utils.cpp b/rpcs3/Crypto/utils.cpp index f86a8b0ee8..7b71c44d78 100644 --- a/rpcs3/Crypto/utils.cpp +++ b/rpcs3/Crypto/utils.cpp @@ -116,7 +116,7 @@ bool cmac_hash_compare(unsigned char *key, int key_len, unsigned char *in, int i return std::memcmp(out.get(), hash, hash_len) == 0; } -void cmac_hash_forge(unsigned char *key, int key_len, unsigned char *in, int in_len, unsigned char *hash) +void cmac_hash_forge(unsigned char *key, int /*key_len*/, unsigned char *in, int in_len, unsigned char *hash) { aes_context ctx; aes_setkey_enc(&ctx, key, 128); diff --git a/rpcs3/Emu/CPU/CPUDisAsm.h b/rpcs3/Emu/CPU/CPUDisAsm.h index 33c9a465b0..5358a41707 100644 --- a/rpcs3/Emu/CPU/CPUDisAsm.h +++ b/rpcs3/Emu/CPU/CPUDisAsm.h @@ -79,7 +79,7 @@ protected: { } - virtual u32 DisAsmBranchTarget(const s32 imm) { return 0; }; + virtual u32 DisAsmBranchTarget(s32 /*imm*/) { return 0; }; // TODO: Add builtin fmt helpper for best performance template , int> = 0> diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 0fbe0bc8dc..63dc0063c4 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -485,7 +485,7 @@ void cpu_thread::operator()() } }); - g_tls_log_control = [](const char* fmt, u64 progress) + g_tls_log_control = [](const char*, u64 progress) { static thread_local bool wait_set = false; @@ -1006,7 +1006,7 @@ bool cpu_thread::suspend_work::push(cpu_thread* _this) noexcept // Copy snapshot for finalization u128 copy2 = copy; - copy = cpu_counter::for_all_cpu(copy, [&](cpu_thread* cpu, u32 index) + copy = cpu_counter::for_all_cpu(copy, [&](cpu_thread* cpu, u32 /*index*/) { if (cpu->state.fetch_add(cpu_flag::pause) & cpu_flag::wait) { @@ -1020,7 +1020,7 @@ bool cpu_thread::suspend_work::push(cpu_thread* _this) noexcept while (copy) { // Check only CPUs which haven't acknowledged their waiting state yet - copy = cpu_counter::for_all_cpu(copy, [&](cpu_thread* cpu, u32 index) + copy = cpu_counter::for_all_cpu(copy, [&](cpu_thread* cpu, u32 /*index*/) { if (cpu->state & cpu_flag::wait) { diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index 087c35f944..7924a2ac90 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -208,7 +208,7 @@ public: } template - static suspend_work suspend_post(cpu_thread* _this, std::initializer_list hints, F& op) + static suspend_work suspend_post(cpu_thread* /*_this*/, std::initializer_list hints, F& op) { constexpr u8 prio = Prio > 3 ? 3 : Prio; diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index 102b30307a..94a8c13602 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -9,6 +9,7 @@ #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #include "llvm/IR/LLVMContext.h" #include "llvm/IR/IRBuilder.h" @@ -66,7 +67,7 @@ struct llvm_value_t return llvm::Type::getVoidTy(context); } - llvm::Value* eval(llvm::IRBuilder<>* ir) const + llvm::Value* eval(llvm::IRBuilder<>*) const { return value; } @@ -421,7 +422,7 @@ struct llvm_match_t return value && ((value == args.value) && ...); } - llvm::Value* eval(llvm::IRBuilder<>* ir) const + llvm::Value* eval(llvm::IRBuilder<>*) const { return value; } @@ -444,7 +445,7 @@ struct llvm_placeholder_t using type = T; - llvm::Value* eval(llvm::IRBuilder<>* ir) const + llvm::Value* eval(llvm::IRBuilder<>*) const { return nullptr; } diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index 88a6113cc6..f7bcd4d833 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -1125,7 +1125,7 @@ error_code cellAudioInit() return CELL_OK; } -error_code cellAudioQuit(ppu_thread& ppu) +error_code cellAudioQuit() { cellAudio.warning("cellAudioQuit()"); diff --git a/rpcs3/Emu/Cell/Modules/cellCamera.cpp b/rpcs3/Emu/Cell/Modules/cellCamera.cpp index 2cd1722a77..0f5b402051 100644 --- a/rpcs3/Emu/Cell/Modules/cellCamera.cpp +++ b/rpcs3/Emu/Cell/Modules/cellCamera.cpp @@ -36,6 +36,11 @@ void fmt_class_string::format(std::string& out, u64 arg) }); } +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + // ************** // * Prototypes * // ************** diff --git a/rpcs3/Emu/Cell/Modules/cellDaisy.cpp b/rpcs3/Emu/Cell/Modules/cellDaisy.cpp index 19cf182b87..e0d2926b91 100644 --- a/rpcs3/Emu/Cell/Modules/cellDaisy.cpp +++ b/rpcs3/Emu/Cell/Modules/cellDaisy.cpp @@ -26,6 +26,11 @@ void fmt_class_string::format(std::string& out, u64 arg) }); } +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + using LFQueue2 = struct CellDaisyLFQueue2; using Lock = struct CellDaisyLock; using ScatterGatherInterlock = struct CellDaisyScatterGatherInterlock; diff --git a/rpcs3/Emu/Cell/Modules/cellDmux.cpp b/rpcs3/Emu/Cell/Modules/cellDmux.cpp index 0303794eb3..b9bbe1f511 100644 --- a/rpcs3/Emu/Cell/Modules/cellDmux.cpp +++ b/rpcs3/Emu/Cell/Modules/cellDmux.cpp @@ -938,14 +938,14 @@ void ElementaryStream::reset() raw_pos = 0; } -void dmuxQueryAttr(u32 info_addr /* may be 0 */, vm::ptr attr) +void dmuxQueryAttr(u32 /* info_addr, may be 0 */, vm::ptr attr) { attr->demuxerVerLower = 0x280000; // TODO: check values attr->demuxerVerUpper = 0x260000; attr->memSize = 0x10000; // 0x3e8e6 from ps3 } -void dmuxQueryEsAttr(u32 info /* may be 0 */, vm::cptr esFilterId, u32 esSpecificInfo, vm::ptr attr) +void dmuxQueryEsAttr(u32 /* info, may be 0 */, vm::cptr esFilterId, u32 /*esSpecificInfo*/, vm::ptr attr) { if (esFilterId->filterIdMajor >= 0xe0) { diff --git a/rpcs3/Emu/Cell/Modules/cellFont.cpp b/rpcs3/Emu/Cell/Modules/cellFont.cpp index dd659d60d8..612a27e6e0 100644 --- a/rpcs3/Emu/Cell/Modules/cellFont.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFont.cpp @@ -66,7 +66,8 @@ error_code cellFontInitializeWithRevision(u64 revisionFlags, vm::ptr revisionFlags) { - UNIMPLEMENTED_FUNC(cellFont); + cellFont.todo("cellFontGetRevisionFlags(*0x%x)", revisionFlags); + return CELL_OK; } @@ -118,7 +119,7 @@ error_code cellFontOpenFontFile(vm::ptr library, vm::cptr return ret; } -error_code cellFontOpenFontset(ppu_thread& ppu, vm::ptr library, vm::ptr fontType, vm::ptr font) +error_code cellFontOpenFontset(vm::ptr library, vm::ptr fontType, vm::ptr font) { cellFont.warning("cellFontOpenFontset(library=*0x%x, fontType=*0x%x, font=*0x%x)", library, fontType, font); @@ -458,7 +459,7 @@ error_code cellFontGraphicsSetFontRGBA() return CELL_OK; } -error_code cellFontOpenFontsetOnMemory(ppu_thread& ppu, vm::ptr library, vm::ptr fontType, vm::ptr font) +error_code cellFontOpenFontsetOnMemory(vm::ptr library, vm::ptr fontType, vm::ptr font) { cellFont.todo("cellFontOpenFontsetOnMemory(library=*0x%x, fontType=*0x%x, font=*0x%x)", library, fontType, font); diff --git a/rpcs3/Emu/Cell/Modules/cellGifDec.cpp b/rpcs3/Emu/Cell/Modules/cellGifDec.cpp index b3bd0e0567..3211feafcd 100644 --- a/rpcs3/Emu/Cell/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGifDec.cpp @@ -11,6 +11,11 @@ LOG_CHANNEL(cellGifDec); +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + template <> void fmt_class_string::format(std::string& out, u64 arg) { diff --git a/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp b/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp index 6bad8da26a..7f25a2fe14 100644 --- a/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellJpgDec.cpp @@ -11,6 +11,11 @@ LOG_CHANNEL(cellJpgDec); +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + template <> void fmt_class_string::format(std::string& out, u64 arg) { diff --git a/rpcs3/Emu/Cell/Modules/cellL10n.cpp b/rpcs3/Emu/Cell/Modules/cellL10n.cpp index 75e45e921d..826cdd5657 100644 --- a/rpcs3/Emu/Cell/Modules/cellL10n.cpp +++ b/rpcs3/Emu/Cell/Modules/cellL10n.cpp @@ -343,7 +343,7 @@ s32 JISstoUTF8s(vm::cptr src, vm::cptr src_len, vm::ptr dst, vm::pt s32 SjisZen2Han(vm::cptr src) { - cellL10n.todo("SjisZen2Han()"); + cellL10n.todo("SjisZen2Han(src=*0x%x)", src); return ConversionOK; } diff --git a/rpcs3/Emu/Cell/Modules/cellMic.cpp b/rpcs3/Emu/Cell/Modules/cellMic.cpp index 5bee6482e6..d5a626db56 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMic.cpp @@ -514,7 +514,7 @@ error_code cellMicInit() return CELL_OK; } -error_code cellMicEnd(ppu_thread& ppu) +error_code cellMicEnd() { cellMic.notice("cellMicEnd()"); diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp index 3e05451535..f2cf5eb780 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp @@ -19,6 +19,11 @@ typedef png_bytep iCCP_profile_type; typedef png_charp iCCP_profile_type; #endif +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + LOG_CHANNEL(cellPngDec); template <> diff --git a/rpcs3/Emu/Cell/Modules/cellResc.cpp b/rpcs3/Emu/Cell/Modules/cellResc.cpp index 55ebe14f7b..a3cc052d6f 100644 --- a/rpcs3/Emu/Cell/Modules/cellResc.cpp +++ b/rpcs3/Emu/Cell/Modules/cellResc.cpp @@ -272,7 +272,7 @@ error_code cellRescSetSrc(s32 idx, vm::cptr src) return CELL_OK; } -error_code cellRescSetConvertAndFlip(ppu_thread& ppu, vm::ptr con, s32 idx) +error_code cellRescSetConvertAndFlip(vm::ptr con, s32 idx) { cellResc.todo("cellRescSetConvertAndFlip(con=*0x%x, idx=0x%x)", con, idx); diff --git a/rpcs3/Emu/Cell/Modules/cellRtc.cpp b/rpcs3/Emu/Cell/Modules/cellRtc.cpp index 250d657366..0bccdc9f66 100644 --- a/rpcs3/Emu/Cell/Modules/cellRtc.cpp +++ b/rpcs3/Emu/Cell/Modules/cellRtc.cpp @@ -1129,7 +1129,8 @@ error_code cellRtcConvertLocalTimeToUtc(vm::cptr pLocalTime, vm::pt error_code cellRtcGetCurrentSecureTick(vm::ptr tick) { - UNIMPLEMENTED_FUNC(cellRtc); + cellRtc.todo("cellRtcGetCurrentSecureTick(*0x%x)", tick); + return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellRudp.cpp b/rpcs3/Emu/Cell/Modules/cellRudp.cpp index 983d41a1b4..a4f6f2122e 100644 --- a/rpcs3/Emu/Cell/Modules/cellRudp.cpp +++ b/rpcs3/Emu/Cell/Modules/cellRudp.cpp @@ -88,12 +88,12 @@ error_code cellRudpInit(vm::ptr allocator) } else { - rudp.malloc = [](ppu_thread& ppu, u32 size) + rudp.malloc = [](ppu_thread&, u32 size) { return vm::ptr::make(vm::alloc(size, vm::main)); }; - rudp.free = [](ppu_thread& ppu, vm::ptr ptr) + rudp.free = [](ppu_thread&, vm::ptr ptr) { if (!vm::dealloc(ptr.addr(), vm::main)) { diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 81702972bc..f7b097131f 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -334,7 +334,7 @@ static std::string get_confirmation_message(u32 operation, const SaveDataEntry& static s32 savedata_check_args(u32 operation, u32 version, vm::cptr dirName, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncFixed funcFixed, PFuncStat funcStat, - PFuncFile funcFile, u32 container, u32 unk_op_flags, vm::ptr userdata, u32 userId, PFuncDone funcDone) + PFuncFile funcFile, u32 /*container*/, u32 unk_op_flags, vm::ptr /*userdata*/, u32 userId, PFuncDone /*funcDone*/) { if (version > CELL_SAVEDATA_VERSION_420) { @@ -2296,6 +2296,11 @@ error_code cellSaveDataListDelete(ppu_thread& ppu, PSetList setList, PSetBuf set return savedata_op(ppu, SAVEDATA_OP_LIST_DELETE, 0, vm::null, 0, setList, setBuf, funcList, vm::null, vm::null, vm::null, container, 0x40, userdata, 0, funcDone); } +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + error_code cellSaveDataListImport(ppu_thread& ppu, PSetList setList, u32 maxSizeKB, PFuncDone funcDone, u32 container, vm::ptr userdata) { UNIMPLEMENTED_FUNC(cellSaveData); diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index 1374d86f78..cf3876eb3f 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -160,6 +160,11 @@ void fmt_class_string::format(std::string& out, u64 arg) error_code sys_spu_image_close(ppu_thread&, vm::ptr img); +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + //---------------------------------------------------------------------------- // Function prototypes //---------------------------------------------------------------------------- diff --git a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp index b1df02dd8c..aa82423578 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp @@ -19,8 +19,10 @@ LOG_CHANNEL(cellSpurs); +// Temporarily #ifndef _MSC_VER #pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif //---------------------------------------------------------------------------- @@ -775,7 +777,7 @@ void spursSysServiceIdleHandler(spu_thread& spu, SpursKernelContext* ctxt) while (true) { const auto spurs = spu._ptr(0x100); - //vm::reservation_acquire(spurs, vm::cast(ctxt->spurs.addr()), 128); + //vm::reservation_acquire(ctxt->spurs.addr()); // Find the number of SPUs that are idling in this SPURS instance u32 nIdlingSpus = 0; @@ -891,9 +893,9 @@ void spursSysServiceMain(spu_thread& spu, u32 pollStatus) { ctxt->sysSrvInitialised = 1; - //vm::reservation_acquire(ctxt, vm::cast(ctxt->spurs.addr()), 128); + //vm::reservation_acquire(ctxt->spurs.addr()); - //vm::reservation_op(ctxt->spurs.ptr(&CellSpurs::wklState1).addr(), 128, [&]() + //vm::reservation_op(ctxt->spurs.ptr(&CellSpurs::wklState1).addr(), [&]() { auto spurs = ctxt->spurs.get_ptr(); @@ -1215,7 +1217,7 @@ void spursSysServiceTraceUpdate(spu_thread& spu, SpursKernelContext* ctxt, u32 a // Get trace parameters from CellSpurs and store them in the LS if (((sysSrvMsgUpdateTrace & (1 << ctxt->spuNum)) != 0) || (arg3 != 0)) { - //vm::reservation_acquire(spu._ptr(0x80), ctxt->spurs.ptr(&CellSpurs::traceBuffer).addr(), 128); + //vm::reservation_acquire(ctxt->spurs.ptr(&CellSpurs::traceBuffer).addr()); auto spurs = spu._ptr(0x80 - offset32(&CellSpurs::traceBuffer)); if (ctxt->traceMsgCount != 0xffu || spurs->traceBuffer.addr() == 0u) diff --git a/rpcs3/Emu/Cell/Modules/cellSync.cpp b/rpcs3/Emu/Cell/Modules/cellSync.cpp index 61d8b672c3..5f281e3fed 100644 --- a/rpcs3/Emu/Cell/Modules/cellSync.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSync.cpp @@ -964,7 +964,7 @@ error_code _cellSyncLFQueueGetPushPointer(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) +error_code _cellSyncLFQueueGetPushPointer2(ppu_thread& /*ppu*/, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) { // arguments copied from _cellSyncLFQueueGetPushPointer cellSync.todo("_cellSyncLFQueueGetPushPointer2(queue=*0x%x, pointer=*0x%x, isBlocking=%d, useEventQueue=%d)", queue, pointer, isBlocking, useEventQueue); @@ -1105,7 +1105,7 @@ error_code _cellSyncLFQueueCompletePushPointer(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal) +error_code _cellSyncLFQueueCompletePushPointer2(ppu_thread&, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal) { // arguments copied from _cellSyncLFQueueCompletePushPointer cellSync.todo("_cellSyncLFQueueCompletePushPointer2(queue=*0x%x, pointer=%d, fpSendSignal=*0x%x)", queue, pointer, fpSendSignal); @@ -1263,7 +1263,7 @@ error_code _cellSyncLFQueueGetPopPointer(ppu_thread& ppu, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) +error_code _cellSyncLFQueueGetPopPointer2(ppu_thread&, vm::ptr queue, vm::ptr pointer, u32 isBlocking, u32 useEventQueue) { // arguments copied from _cellSyncLFQueueGetPopPointer cellSync.todo("_cellSyncLFQueueGetPopPointer2(queue=*0x%x, pointer=*0x%x, isBlocking=%d, useEventQueue=%d)", queue, pointer, isBlocking, useEventQueue); @@ -1405,7 +1405,7 @@ error_code _cellSyncLFQueueCompletePopPointer(ppu_thread& ppu, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal, u32 noQueueFull) +error_code _cellSyncLFQueueCompletePopPointer2(ppu_thread&, vm::ptr queue, s32 pointer, vm::ptr fpSendSignal, u32 noQueueFull) { // arguments copied from _cellSyncLFQueueCompletePopPointer cellSync.todo("_cellSyncLFQueueCompletePopPointer2(queue=*0x%x, pointer=%d, fpSendSignal=*0x%x, noQueueFull=%d)", queue, pointer, fpSendSignal, noQueueFull); diff --git a/rpcs3/Emu/Cell/Modules/cellSysCache.cpp b/rpcs3/Emu/Cell/Modules/cellSysCache.cpp index 8197bf6b39..3a2cad779c 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysCache.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysCache.cpp @@ -79,7 +79,7 @@ struct syscache_info // Poison opened files in /dev_hdd1 to return CELL_EIO on access if (remove_root) { - idm::select([](u32 id, lv2_file& file) + idm::select([](u32 /*id*/, lv2_file& file) { if (std::memcmp("/dev_hdd1", file.name.data(), 9) == 0) { diff --git a/rpcs3/Emu/Cell/Modules/cellVdec.cpp b/rpcs3/Emu/Cell/Modules/cellVdec.cpp index e10bf11c55..e8165b382d 100644 --- a/rpcs3/Emu/Cell/Modules/cellVdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVdec.cpp @@ -127,7 +127,7 @@ struct vdec_context final lf_queue> in_cmd; - vdec_context(s32 type, u32 profile, u32 addr, u32 size, vm::ptr func, u32 arg) + vdec_context(s32 type, u32 /*profile*/, u32 addr, u32 size, vm::ptr func, u32 arg) : type(type) , mem_addr(addr) , mem_size(size) diff --git a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp index 2a3fae3517..3ee43b7aa5 100644 --- a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp @@ -361,6 +361,11 @@ error_code cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutionId, return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT; } +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + error_code cellVideoOutGetConvertCursorColorInfo(vm::ptr rgbOutputRange) { cellSysutil.todo("cellVideoOutGetConvertCursorColorInfo()"); diff --git a/rpcs3/Emu/Cell/Modules/libsnd3.cpp b/rpcs3/Emu/Cell/Modules/libsnd3.cpp index a41737c289..0263f92ff6 100644 --- a/rpcs3/Emu/Cell/Modules/libsnd3.cpp +++ b/rpcs3/Emu/Cell/Modules/libsnd3.cpp @@ -34,6 +34,11 @@ void fmt_class_string::format(std::string& out, u64 arg) }); } +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + error_code cellSnd3Init(u32 maxVoice, u32 samples, vm::ptr queue) { UNIMPLEMENTED_FUNC(libsnd3); diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index 6f5a917b49..b4dea9b9bd 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -2571,7 +2571,7 @@ error_code sceNpManagerGetOnlineId(vm::ptr onlineId) return CELL_OK; } -error_code sceNpManagerGetNpId(ppu_thread& ppu, vm::ptr npId) +error_code sceNpManagerGetNpId(ppu_thread&, vm::ptr npId) { sceNp.warning("sceNpManagerGetNpId(npId=*0x%x)", npId); diff --git a/rpcs3/Emu/Cell/Modules/sceNp2.cpp b/rpcs3/Emu/Cell/Modules/sceNp2.cpp index 841a022328..b4caaacbdc 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp2.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp2.cpp @@ -285,7 +285,7 @@ error_code sceNp2Term(ppu_thread& ppu) return CELL_OK; } -error_code sceNpMatching2Term(ppu_thread& ppu) +error_code sceNpMatching2Term(ppu_thread&) { sceNp2.warning("sceNpMatching2Term()"); return sceNpMatching2Term2(); // > SDK 2.4.0 @@ -1529,7 +1529,7 @@ error_code sceNpAuthCreateOAuthRequest() error_code sceNpAuthDeleteOAuthRequest(SceNpAuthOAuthRequestId reqId) { - sceNp2.todo("sceNpAuthDeleteOAuthRequest(reqId=%d)"); + sceNp2.todo("sceNpAuthDeleteOAuthRequest(reqId=%d)", reqId); auto& nph = g_fxo->get>(); @@ -1543,7 +1543,7 @@ error_code sceNpAuthDeleteOAuthRequest(SceNpAuthOAuthRequestId reqId) error_code sceNpAuthAbortOAuthRequest(SceNpAuthOAuthRequestId reqId) { - sceNp2.todo("sceNpAuthAbortOAuthRequest(reqId=%d)"); + sceNp2.todo("sceNpAuthAbortOAuthRequest(reqId=%d)", reqId); auto& nph = g_fxo->get>(); diff --git a/rpcs3/Emu/Cell/Modules/sceNpMatchingInt.cpp b/rpcs3/Emu/Cell/Modules/sceNpMatchingInt.cpp index 22220c5360..099f7997d6 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpMatchingInt.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpMatchingInt.cpp @@ -1,6 +1,11 @@ #include "stdafx.h" #include "Emu/Cell/PPUModule.h" +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + LOG_CHANNEL(sceNpMatchingInt); error_code sceNpMatchingCancelRequest() diff --git a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp index a6177fc76d..1ed16791ab 100644 --- a/rpcs3/Emu/Cell/Modules/sys_libc_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_libc_.cpp @@ -16,7 +16,7 @@ struct ps3_fmt_src ppu_thread* ctx; u32 g_count; - bool test(usz index) const + bool test(usz) const { return true; } @@ -40,7 +40,7 @@ struct ps3_fmt_src return out.size() - start; } - usz type(usz extra) const + usz type(usz) const { return 0; } diff --git a/rpcs3/Emu/Cell/Modules/sys_lv2dbg.cpp b/rpcs3/Emu/Cell/Modules/sys_lv2dbg.cpp index a1b6c12541..2e13cf798b 100644 --- a/rpcs3/Emu/Cell/Modules/sys_lv2dbg.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_lv2dbg.cpp @@ -65,6 +65,11 @@ void fmt_class_string::format(std::string& out, u64 arg) }); } +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + error_code sys_dbg_read_ppu_thread_context(u64 id, vm::ptr ppu_context) { sys_lv2dbg.todo("sys_dbg_read_ppu_thread_context()"); diff --git a/rpcs3/Emu/Cell/Modules/sys_net_.cpp b/rpcs3/Emu/Cell/Modules/sys_net_.cpp index 835a5df71d..f566bd2070 100644 --- a/rpcs3/Emu/Cell/Modules/sys_net_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_net_.cpp @@ -6,6 +6,11 @@ LOG_CHANNEL(libnet); +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + s32 sys_net_accept(s32 s, vm::ptr addr, vm::ptr paddrlen) { libnet.todo("accept(s=%d, addr=*0x%x, paddrlen=*0x%x)", s, addr, paddrlen); diff --git a/rpcs3/Emu/Cell/Modules/sys_prx_.cpp b/rpcs3/Emu/Cell/Modules/sys_prx_.cpp index c0143023ad..c3cb6e8df2 100644 --- a/rpcs3/Emu/Cell/Modules/sys_prx_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_prx_.cpp @@ -251,12 +251,12 @@ error_code sys_prx_exitspawn_with_level() return CELL_OK; } -error_code sys_prx_get_my_module_id(ppu_thread& ppu, ppu_thread& _do, ppu_thread& _not, ppu_thread& _call) +error_code sys_prx_get_my_module_id(ppu_thread& ppu_do_not_call, ppu_thread&, ppu_thread&, ppu_thread&) // Do not call directly { sysPrxForUser.trace("sys_prx_get_my_module_id()"); // Call the syscall using the LR - return _sys_prx_get_module_id_by_address(ppu, static_cast(ppu.lr)); + return _sys_prx_get_module_id_by_address(ppu_do_not_call, static_cast(ppu_do_not_call.lr)); } void sysPrxForUser_sys_prx_init() diff --git a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp index c43b50f262..ce3249212e 100644 --- a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp @@ -398,7 +398,7 @@ error_code sys_raw_spu_load(s32 id, vm::cptr path, vm::ptr entry) return CELL_OK; } -error_code sys_raw_spu_image_load(ppu_thread& ppu, s32 id, vm::ptr img) +error_code sys_raw_spu_image_load(s32 id, vm::ptr img) { sysPrxForUser.warning("sys_raw_spu_image_load(id=%d, img=*0x%x)", id, img); diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index 87cbf14af3..e4c6e6f90f 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -1844,6 +1844,11 @@ void ppu_module::analyse(u32 lib_toc, u32 entry, const u32 sec_end, const std::b ppu_log.notice("Block analysis: %zu blocks (%zu enqueued)", funcs.size(), block_queue.size()); } +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + void ppu_acontext::UNK(ppu_opcode_t op) { std::fill_n(gpr, 32, spec_gpr{}); diff --git a/rpcs3/Emu/Cell/PPUCallback.h b/rpcs3/Emu/Cell/PPUCallback.h index 742d275f1d..9410a8c35f 100644 --- a/rpcs3/Emu/Cell/PPUCallback.h +++ b/rpcs3/Emu/Cell/PPUCallback.h @@ -77,13 +77,13 @@ namespace ppu_cb_detail { static_assert(std::is_same, ppu_thread>::value, "Invalid callback argument type for ARG_CONTEXT"); - FORCE_INLINE static void set_value(ppu_thread& CPU, const T& arg) + FORCE_INLINE static void set_value(ppu_thread&, const T&) { } }; template - FORCE_INLINE static bool _bind_func_args(ppu_thread& CPU) + FORCE_INLINE static bool _bind_func_args(ppu_thread&) { // terminator return false; diff --git a/rpcs3/Emu/Cell/PPUDisAsm.cpp b/rpcs3/Emu/Cell/PPUDisAsm.cpp index 0a8873fda2..21d5b0d0eb 100644 --- a/rpcs3/Emu/Cell/PPUDisAsm.cpp +++ b/rpcs3/Emu/Cell/PPUDisAsm.cpp @@ -1076,7 +1076,7 @@ void PPUDisAsm::CRANDC(ppu_opcode_t op) DisAsm_BI3("crandc", op.crbd, op.crba, op.crbb); } -void PPUDisAsm::ISYNC(ppu_opcode_t op) +void PPUDisAsm::ISYNC(ppu_opcode_t) { Write("isync"); } @@ -1938,7 +1938,7 @@ void PPUDisAsm::LVRXL(ppu_opcode_t op) DisAsm_V1_R2("lvrxl", op.vd, op.ra, op.rb); } -void PPUDisAsm::DSS(ppu_opcode_t op) +void PPUDisAsm::DSS(ppu_opcode_t) { Write("dss()"); } @@ -1953,7 +1953,7 @@ void PPUDisAsm::SRADI(ppu_opcode_t op) DisAsm_R2_INT1_RC("sradi", op.ra, op.rs, op.sh64, op.rc); } -void PPUDisAsm::EIEIO(ppu_opcode_t op) +void PPUDisAsm::EIEIO(ppu_opcode_t) { Write("eieio"); } @@ -2345,7 +2345,7 @@ void PPUDisAsm::FCFID(ppu_opcode_t op) extern std::vector g_ppu_function_names; -void PPUDisAsm::UNK(ppu_opcode_t op) +void PPUDisAsm::UNK(ppu_opcode_t) { if (ppu_function_manager::addr) { diff --git a/rpcs3/Emu/Cell/PPUFunction.h b/rpcs3/Emu/Cell/PPUFunction.h index ea4910ec3c..8c284f8423 100644 --- a/rpcs3/Emu/Cell/PPUFunction.h +++ b/rpcs3/Emu/Cell/PPUFunction.h @@ -102,9 +102,9 @@ namespace ppu_func_detail { static_assert(std::is_same, ppu_va_args_t>::value, "Invalid function argument type for ARG_VARIADIC"); - static FORCE_INLINE ppu_va_args_t get_arg(ppu_thread& ppu) + static FORCE_INLINE ppu_va_args_t get_arg(ppu_thread&) { - return{ g_count }; + return {g_count}; } }; diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index abbb97df3b..3cc2584df0 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -3156,7 +3156,7 @@ bool ppu_interpreter::CRANDC(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::ISYNC(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::ISYNC(ppu_thread&, ppu_opcode_t) { atomic_fence_acquire(); return true; @@ -3514,7 +3514,7 @@ bool ppu_interpreter::LDUX(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::DCBST(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::DCBST(ppu_thread&, ppu_opcode_t) { return true; } @@ -3587,7 +3587,7 @@ bool ppu_interpreter::LDARX(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::DCBF(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::DCBF(ppu_thread&, ppu_opcode_t) { return true; } @@ -3850,7 +3850,7 @@ bool ppu_interpreter::MULLW(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::DCBTST(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::DCBTST(ppu_thread&, ppu_opcode_t) { return true; } @@ -3873,7 +3873,7 @@ bool ppu_interpreter::ADD(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::DCBT(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::DCBT(ppu_thread&, ppu_opcode_t) { return true; } @@ -3892,7 +3892,7 @@ bool ppu_interpreter::EQV(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::ECIWX(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::ECIWX(ppu_thread&, ppu_opcode_t) { fmt::throw_exception("ECIWX"); } @@ -3938,7 +3938,7 @@ bool ppu_interpreter::LWAX(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::DST(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::DST(ppu_thread&, ppu_opcode_t) { return true; } @@ -3979,7 +3979,7 @@ bool ppu_interpreter::LWAUX(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::DSTST(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::DSTST(ppu_thread&, ppu_opcode_t) { return true; } @@ -4006,7 +4006,7 @@ bool ppu_interpreter::ORC(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::ECOWX(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::ECOWX(ppu_thread&, ppu_opcode_t) { fmt::throw_exception("ECOWX"); } @@ -4070,7 +4070,7 @@ bool ppu_interpreter::MTSPR(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::DCBI(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::DCBI(ppu_thread&, ppu_opcode_t) { return true; } @@ -4222,7 +4222,7 @@ bool ppu_interpreter::LFSUX(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::SYNC(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::SYNC(ppu_thread&, ppu_opcode_t) { atomic_fence_seq_cst(); return true; @@ -4406,7 +4406,7 @@ bool ppu_interpreter::LVRXL(ppu_thread& ppu, ppu_opcode_t op) return LVRX(ppu, op); } -bool ppu_interpreter::DSS(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::DSS(ppu_thread&, ppu_opcode_t) { return true; } @@ -4432,7 +4432,7 @@ bool ppu_interpreter::SRADI(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::EIEIO(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::EIEIO(ppu_thread&, ppu_opcode_t) { atomic_fence_seq_cst(); return true; @@ -4483,7 +4483,7 @@ bool ppu_interpreter::EXTSW(ppu_thread& ppu, ppu_opcode_t op) return true; } -bool ppu_interpreter::ICBI(ppu_thread& ppu, ppu_opcode_t op) +bool ppu_interpreter::ICBI(ppu_thread&, ppu_opcode_t) { return true; } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 0759c6d18d..ac332484e1 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -30,6 +30,7 @@ #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #include "llvm/Support/FormattedStream.h" #include "llvm/Support/MemoryBuffer.h" @@ -352,7 +353,7 @@ void ppu_reservation_fallback(ppu_thread& ppu) static std::unordered_map* s_ppu_toc; -static bool ppu_check_toc(ppu_thread& ppu, ppu_opcode_t op) +static bool ppu_check_toc(ppu_thread& ppu, ppu_opcode_t) { // Compare TOC with expected value const auto found = s_ppu_toc->find(ppu.cia); @@ -457,7 +458,7 @@ extern void ppu_register_function_at(u32 addr, u32 size, ppu_function_t ptr) } // Breakpoint entry point -static bool ppu_break(ppu_thread& ppu, ppu_opcode_t op) +static bool ppu_break(ppu_thread& ppu, ppu_opcode_t) { // Pause ppu.state.atomic_op([](bs_t& state) { if (!(state & cpu_flag::dbg_step)) state += cpu_flag::dbg_pause; }); @@ -1428,7 +1429,7 @@ static T ppu_load_acquire_reservation(ppu_thread& ppu, u32 addr) ppu_log.trace(u8"LARX after fail: addr=0x%x, faddr=0x%x, time=%u c", addr, ppu.last_faddr, (perf0.get() - ppu.last_ftsc)); } - if ((addr & addr_mask) == (ppu.last_faddr & addr_mask) && (perf0.get() - ppu.last_ftsc) < 600 && (vm::reservation_acquire(addr, sizeof(T)) & -128) == ppu.last_ftime) + if ((addr & addr_mask) == (ppu.last_faddr & addr_mask) && (perf0.get() - ppu.last_ftsc) < 600 && (vm::reservation_acquire(addr) & -128) == ppu.last_ftime) { be_t rdata; std::memcpy(&rdata, &ppu.rdata[addr & 0x78], 8); @@ -1450,7 +1451,7 @@ static T ppu_load_acquire_reservation(ppu_thread& ppu, u32 addr) ppu.last_faddr = 0; } - ppu.rtime = vm::reservation_acquire(addr, sizeof(T)) & -128; + ppu.rtime = vm::reservation_acquire(addr) & -128; be_t rdata; @@ -1834,7 +1835,7 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value) } auto& data = vm::_ref>(addr & -8); - auto& res = vm::reservation_acquire(addr, sizeof(T)); + auto& res = vm::reservation_acquire(addr); const u64 rtime = ppu.rtime; be_t old_data = 0; @@ -2143,7 +2144,7 @@ namespace return m_file.stat(); } - bool trunc(u64 length) override + bool trunc(u64) override { return false; } @@ -2159,7 +2160,7 @@ namespace return result; } - u64 write(const void* buffer, u64 size) override + u64 write(const void*, u64) override { return 0; } diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index 9faa4e0ffe..bd6e8b821e 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -2071,7 +2071,7 @@ void PPUTranslator::CRANDC(ppu_opcode_t op) SetCrb(op.crbd, m_ir->CreateAnd(GetCrb(op.crba), m_ir->CreateNot(GetCrb(op.crbb)))); } -void PPUTranslator::ISYNC(ppu_opcode_t op) +void PPUTranslator::ISYNC(ppu_opcode_t) { m_ir->CreateFence(AtomicOrdering::Acquire); } @@ -2081,7 +2081,7 @@ void PPUTranslator::CRXOR(ppu_opcode_t op) SetCrb(op.crbd, m_ir->CreateXor(GetCrb(op.crba), GetCrb(op.crbb))); } -void PPUTranslator::DCBI(ppu_opcode_t op) +void PPUTranslator::DCBI(ppu_opcode_t) { } @@ -2656,7 +2656,7 @@ void PPUTranslator::LDUX(ppu_opcode_t op) SetGpr(op.ra, addr); } -void PPUTranslator::DCBST(ppu_opcode_t op) +void PPUTranslator::DCBST(ppu_opcode_t) { } @@ -2723,7 +2723,7 @@ void PPUTranslator::LDARX(ppu_opcode_t op) SetGpr(op.rd, Call(GetType(), "__ldarx", m_thread, op.ra ? m_ir->CreateAdd(GetGpr(op.ra), GetGpr(op.rb)) : GetGpr(op.rb))); } -void PPUTranslator::DCBF(ppu_opcode_t op) +void PPUTranslator::DCBF(ppu_opcode_t) { } @@ -2978,7 +2978,7 @@ void PPUTranslator::MULLW(ppu_opcode_t op) if (op.oe) SetOverflow(Call(GetType(), m_pure_attr, "__mullw_get_ov", a, b)); } -void PPUTranslator::DCBTST(ppu_opcode_t op) +void PPUTranslator::DCBTST(ppu_opcode_t) { } @@ -3006,7 +3006,7 @@ void PPUTranslator::ADD(ppu_opcode_t op) if (op.rc) SetCrFieldSignedCmp(0, result, m_ir->getInt64(0)); } -void PPUTranslator::DCBT(ppu_opcode_t op) +void PPUTranslator::DCBT(ppu_opcode_t) { } @@ -3080,7 +3080,7 @@ void PPUTranslator::LWAX(ppu_opcode_t op) SetGpr(op.rd, SExt(ReadMemory(op.ra ? m_ir->CreateAdd(GetGpr(op.ra), GetGpr(op.rb)) : GetGpr(op.rb), GetType()))); } -void PPUTranslator::DST(ppu_opcode_t op) +void PPUTranslator::DST(ppu_opcode_t) { } @@ -3120,7 +3120,7 @@ void PPUTranslator::LWAUX(ppu_opcode_t op) SetGpr(op.ra, addr); } -void PPUTranslator::DSTST(ppu_opcode_t op) +void PPUTranslator::DSTST(ppu_opcode_t) { } @@ -3487,7 +3487,7 @@ void PPUTranslator::LVRXL(ppu_opcode_t op) return LVRX(op); } -void PPUTranslator::DSS(ppu_opcode_t op) +void PPUTranslator::DSS(ppu_opcode_t) { } @@ -3510,7 +3510,7 @@ void PPUTranslator::SRADI(ppu_opcode_t op) if (op.rc) SetCrFieldSignedCmp(0, result, m_ir->getInt64(0)); } -void PPUTranslator::EIEIO(ppu_opcode_t op) +void PPUTranslator::EIEIO(ppu_opcode_t) { // TODO m_ir->CreateFence(AtomicOrdering::SequentiallyConsistent); @@ -3557,7 +3557,7 @@ void PPUTranslator::EXTSW(ppu_opcode_t op) if (op.rc) SetCrFieldSignedCmp(0, result, m_ir->getInt64(0)); } -void PPUTranslator::ICBI(ppu_opcode_t op) +void PPUTranslator::ICBI(ppu_opcode_t) { } @@ -4734,7 +4734,7 @@ void PPUTranslator::SetFPCC(Value* lt, Value* gt, Value* eq, Value* un, bool set if (set_cr) SetCrField(1, lt, gt, eq, un); } -void PPUTranslator::SetFPRF(Value* value, bool set_cr) +void PPUTranslator::SetFPRF(Value* value, bool /*set_cr*/) { //const bool is32 = value->getType()->isFloatTy() ? true : @@ -4755,18 +4755,18 @@ void PPUTranslator::SetFPRF(Value* value, bool set_cr) //SetFPCC(lt, gt, eq, un, set_cr); } -void PPUTranslator::SetFPSCR_FR(Value* value) +void PPUTranslator::SetFPSCR_FR(Value* /*value*/) { //m_ir->CreateStore(value, m_fpscr_fr); } -void PPUTranslator::SetFPSCR_FI(Value* value) +void PPUTranslator::SetFPSCR_FI(Value* /*value*/) { //m_ir->CreateStore(value, m_fpscr_fi); //SetFPSCRException(m_fpscr_xx, value); } -void PPUTranslator::SetFPSCRException(Value* ptr, Value* value) +void PPUTranslator::SetFPSCRException(Value* /*ptr*/, Value* /*value*/) { //m_ir->CreateStore(m_ir->CreateOr(m_ir->CreateLoad(ptr), value), ptr); //m_ir->CreateStore(m_ir->CreateOr(m_ir->CreateLoad(m_fpscr_fx), value), m_fpscr_fx); @@ -4808,7 +4808,7 @@ Value* PPUTranslator::GetFPSCRBit(u32 n) return value; } -void PPUTranslator::SetFPSCRBit(u32 n, Value* value, bool update_fx) +void PPUTranslator::SetFPSCRBit(u32 n, Value* value, bool /*update_fx*/) { if (n < 16 || n > 19) { diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 372784c9c9..74459f8d44 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -1305,11 +1305,11 @@ void spu_recompiler::STOP(spu_opcode_t op) } } -void spu_recompiler::LNOP(spu_opcode_t op) +void spu_recompiler::LNOP(spu_opcode_t) { } -void spu_recompiler::SYNC(spu_opcode_t op) +void spu_recompiler::SYNC(spu_opcode_t) { // This instruction must be used following a store instruction that modifies the instruction stream. c->lock().or_(asmjit::x86::dword_ptr(asmjit::x86::rsp), 0); @@ -1324,7 +1324,7 @@ void spu_recompiler::SYNC(spu_opcode_t op) } } -void spu_recompiler::DSYNC(spu_opcode_t op) +void spu_recompiler::DSYNC(spu_opcode_t) { // This instruction forces all earlier load, store, and channel instructions to complete before proceeding. c->lock().or_(asmjit::x86::dword_ptr(asmjit::x86::rsp), 0); @@ -2259,7 +2259,7 @@ void spu_recompiler::AVGB(spu_opcode_t op) c->movdqa(SPU_OFF_128(gpr, op.rt), vb); } -void spu_recompiler::MTSPR(spu_opcode_t op) +void spu_recompiler::MTSPR(spu_opcode_t) { // Check SPUInterpreter for notes. } @@ -2581,7 +2581,7 @@ void spu_recompiler::BIHNZ(spu_opcode_t op) }); } -void spu_recompiler::STOPD(spu_opcode_t op) +void spu_recompiler::STOPD(spu_opcode_t) { STOP(spu_opcode_t{0x3fff}); } @@ -2678,7 +2678,7 @@ void spu_recompiler::BISLED(spu_opcode_t op) }); } -void spu_recompiler::HBR(spu_opcode_t op) +void spu_recompiler::HBR([[maybe_unused]] spu_opcode_t op) { } @@ -3186,7 +3186,7 @@ void spu_recompiler::SHLQBYI(spu_opcode_t op) c->movdqa(SPU_OFF_128(gpr, op.rt), va); } -void spu_recompiler::NOP(spu_opcode_t op) +void spu_recompiler::NOP(spu_opcode_t) { } @@ -3815,7 +3815,7 @@ void spu_recompiler::FRDS(spu_opcode_t op) c->movaps(SPU_OFF_128(gpr, op.rt), va); } -void spu_recompiler::FSCRWR(spu_opcode_t op) +void spu_recompiler::FSCRWR(spu_opcode_t /*op*/) { // nop (not implemented) } @@ -4579,11 +4579,11 @@ void spu_recompiler::HEQI(spu_opcode_t op) }); } -void spu_recompiler::HBRA(spu_opcode_t op) +void spu_recompiler::HBRA([[maybe_unused]] spu_opcode_t op) { } -void spu_recompiler::HBRR(spu_opcode_t op) +void spu_recompiler::HBRR([[maybe_unused]] spu_opcode_t op) { } diff --git a/rpcs3/Emu/Cell/SPUInterpreter.cpp b/rpcs3/Emu/Cell/SPUInterpreter.cpp index 8dd98ad028..8c13d4a2ea 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/SPUInterpreter.cpp @@ -93,7 +93,7 @@ namespace asmjit } } -bool spu_interpreter::UNK(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::UNK(spu_thread&, spu_opcode_t op) { fmt::throw_exception("Unknown/Illegal instruction (0x%08x)", op.opcode); } @@ -135,20 +135,20 @@ bool spu_interpreter::STOP(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::LNOP(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::LNOP(spu_thread&, spu_opcode_t) { return true; } // This instruction must be used following a store instruction that modifies the instruction stream. -bool spu_interpreter::SYNC(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::SYNC(spu_thread&, spu_opcode_t) { atomic_fence_seq_cst(); return true; } // This instruction forces all earlier load, store, and channel instructions to complete before proceeding. -bool spu_interpreter::DSYNC(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::DSYNC(spu_thread&, spu_opcode_t) { atomic_fence_seq_cst(); return true; @@ -416,7 +416,7 @@ bool spu_interpreter::AVGB(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::MTSPR(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::MTSPR(spu_thread&, spu_opcode_t) { // SPR writes are ignored. TODO: check it. return true; @@ -482,7 +482,7 @@ bool spu_interpreter::BIHNZ(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::STOPD(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::STOPD(spu_thread& spu, spu_opcode_t) { return spu.stop_and_signal(0x3fff); } @@ -531,7 +531,7 @@ bool spu_interpreter::BISLED(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::HBR(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::HBR(spu_thread&, spu_opcode_t) { return true; } @@ -834,7 +834,7 @@ bool spu_interpreter::SHLQBYI(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::NOP(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::NOP(spu_thread&, spu_opcode_t) { return true; } @@ -990,7 +990,7 @@ bool spu_interpreter_fast::FCGT(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::DFCGT(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::DFCGT(spu_thread&, spu_opcode_t) { fmt::throw_exception("Unexpected instruction"); return true; @@ -1077,7 +1077,7 @@ bool spu_interpreter_fast::FCMGT(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::DFCMGT(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::DFCMGT(spu_thread&, spu_opcode_t) { fmt::throw_exception("Unexpected Instruction"); return true; @@ -1220,12 +1220,12 @@ bool spu_interpreter_fast::FRDS(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter_fast::FSCRWR(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter_fast::FSCRWR(spu_thread&, spu_opcode_t) { return true; } -bool spu_interpreter::DFTSV(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::DFTSV(spu_thread&, spu_opcode_t) { fmt::throw_exception("Unexpected instruction"); return true; @@ -1237,7 +1237,7 @@ bool spu_interpreter_fast::FCEQ(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::DFCEQ(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::DFCEQ(spu_thread&, spu_opcode_t) { fmt::throw_exception("Unexpected instruction"); return true; @@ -1281,7 +1281,7 @@ bool spu_interpreter_fast::FCMEQ(spu_thread& spu, spu_opcode_t op) return true; } -bool spu_interpreter::DFCMEQ(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::DFCMEQ(spu_thread&, spu_opcode_t) { fmt::throw_exception("Unexpected instruction"); return true; @@ -1667,12 +1667,12 @@ bool spu_interpreter::HEQI(spu_thread& spu, spu_opcode_t op) } -bool spu_interpreter::HBRA(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::HBRA(spu_thread&, spu_opcode_t) { return true; } -bool spu_interpreter::HBRR(spu_thread& spu, spu_opcode_t op) +bool spu_interpreter::HBRR(spu_thread&, spu_opcode_t) { return true; } @@ -1713,7 +1713,7 @@ bool spu_interpreter::SHUFB(spu_thread& spu, spu_opcode_t op) return true; } -const spu_inter_func_t optimized_shufb = build_function_asm([](asmjit::X86Assembler& c, auto& args) +const spu_inter_func_t optimized_shufb = build_function_asm([](asmjit::X86Assembler& c, auto& /*args*/) { using namespace asmjit; diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index caee8f01e9..6ea743e0a3 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -1182,7 +1182,7 @@ void spu_recompiler_base::branch(spu_thread& spu, void*, u8* rip) spu_runtime::g_tail_escape(&spu, func, rip); } -void spu_recompiler_base::old_interpreter(spu_thread& spu, void* ls, u8* rip) +void spu_recompiler_base::old_interpreter(spu_thread& spu, void* ls, u8* /*rip*/) { if (g_cfg.core.spu_decoder > spu_decoder_type::fast) { @@ -3220,6 +3220,7 @@ void spu_recompiler_base::dump(const spu_program& result, std::string& out) #pragma GCC diagnostic ignored "-Wall" #pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wold-style-cast" +#pragma GCC diagnostic ignored "-Wunused-parameter" #endif #include "llvm/ADT/Triple.h" #include "llvm/IR/LegacyPassManager.h" @@ -3765,7 +3766,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator // Get pointer to the vector register (interpreter only) template - llvm::Value* init_vr(const bf_t& index) + llvm::Value* init_vr(const bf_t&) { if (!m_interp_magn) { @@ -5311,7 +5312,7 @@ public: call(name, &exec_fall, m_thread, m_ir->getInt32(op.opcode)); } - static void exec_unk(spu_thread* _spu, u32 op) + static void exec_unk(spu_thread*, u32 op) { fmt::throw_exception("Unknown/Illegal instruction (0x%08x)", op); } @@ -5364,7 +5365,7 @@ public: } } - void STOPD(spu_opcode_t op) // + void STOPD(spu_opcode_t) // { if (m_interp_magn) { @@ -6165,15 +6166,15 @@ public: call("spu_write_channel", &exec_wrch, m_thread, m_ir->getInt32(op.ra), val.value); } - void LNOP(spu_opcode_t op) // + void LNOP(spu_opcode_t) // { } - void NOP(spu_opcode_t op) // + void NOP(spu_opcode_t) // { } - void SYNC(spu_opcode_t op) // + void SYNC(spu_opcode_t) // { // This instruction must be used following a store instruction that modifies the instruction stream. m_ir->CreateFence(llvm::AtomicOrdering::SequentiallyConsistent); @@ -6186,7 +6187,7 @@ public: } } - void DSYNC(spu_opcode_t op) // + void DSYNC(spu_opcode_t) // { // This instruction forces all earlier load, store, and channel instructions to complete before proceeding. m_ir->CreateFence(llvm::AtomicOrdering::SequentiallyConsistent); @@ -6198,7 +6199,7 @@ public: set_vr(op.rt, splat(0)); } - void MTSPR(spu_opcode_t op) // + void MTSPR(spu_opcode_t) // { // Check SPUInterpreter for notes. } @@ -6400,7 +6401,7 @@ public: void AND(spu_opcode_t op) { - if (match_vr(op.ra, [&](auto a, auto MP1) + if (match_vr(op.ra, [&](auto a, auto /*MP1*/) { if (auto b = match_vr_as(a, op.rb)) { @@ -6408,7 +6409,7 @@ public: return true; } - return match_vr(op.rb, [&](auto b, auto MP2) + return match_vr(op.rb, [&](auto /*b*/, auto /*MP2*/) { set_vr(op.rt, a & get_vr_as(a, op.rb)); return true; @@ -7441,7 +7442,7 @@ public: set_vr(op.rt, splat(0)); } - void FSCRWR(spu_opcode_t op) // + void FSCRWR(spu_opcode_t /*op*/) // { // Hack } @@ -8341,17 +8342,17 @@ public: make_halt(cond); } - void HBR(spu_opcode_t op) // + void HBR([[maybe_unused]] spu_opcode_t op) // { // TODO: use the hint. } - void HBRA(spu_opcode_t op) // + void HBRA([[maybe_unused]] spu_opcode_t op) // { // TODO: use the hint. } - void HBRR(spu_opcode_t op) // + void HBRR([[maybe_unused]] spu_opcode_t op) // { // TODO: use the hint. } @@ -9026,7 +9027,7 @@ struct spu_llvm } // Collect profiling samples - idm::select>([&](u32 id, spu_thread& spu) + idm::select>([&](u32 /*id*/, spu_thread& spu) { const u64 name = atomic_storage::load(spu.block_hash); diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index d1b35c8f75..911e02378e 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -2038,7 +2038,7 @@ void spu_thread::do_dma_transfer(spu_thread* _this, const spu_mfc_cmd& args, u8* } }()) { - const u64 time0 = vm::reservation_acquire(eal, size0); + const u64 time0 = vm::reservation_acquire(eal); if (time0 & 127) { @@ -2103,7 +2103,7 @@ void spu_thread::do_dma_transfer(spu_thread* _this, const spu_mfc_cmd& args, u8* } } - if (time0 != vm::reservation_acquire(eal, size0) || (size0 == 128 && !cmp_rdata(*reinterpret_cast(dst0), *reinterpret_cast(src)))) + if (time0 != vm::reservation_acquire(eal) || (size0 == 128 && !cmp_rdata(*reinterpret_cast(dst0), *reinterpret_cast(src)))) { continue; } @@ -2158,7 +2158,7 @@ void spu_thread::do_dma_transfer(spu_thread* _this, const spu_mfc_cmd& args, u8* } // Lock each cache line - auto& res = vm::reservation_acquire(eal, size0); + auto& res = vm::reservation_acquire(eal); // Lock each bit corresponding to a byte being written, using some free space in reservation memory auto* bits = reinterpret_cast*>(vm::g_reservations + (eal & 0xff80) / 2 + 16); @@ -2712,7 +2712,7 @@ bool spu_thread::do_putllc(const spu_mfc_cmd& args) } const auto& to_write = _ref(args.lsa & 0x3ff80); - auto& res = vm::reservation_acquire(addr, 128); + auto& res = vm::reservation_acquire(addr); // TODO: Limit scope!! rsx::reservation_lock rsx_lock(addr, 128); @@ -2849,7 +2849,7 @@ bool spu_thread::do_putllc(const spu_mfc_cmd& args) return success; }()) { - vm::reservation_notifier(addr, 128).notify_all(-128); + vm::reservation_notifier(addr).notify_all(-128); raddr = 0; perf0.reset(); return true; @@ -2894,7 +2894,7 @@ void do_cell_atomic_128_store(u32 addr, const void* to_write) if (result == 0) { auto& sdata = *vm::get_super_ptr(addr); - auto& res = vm::reservation_acquire(addr, 128); + auto& res = vm::reservation_acquire(addr); cpu_thread::suspend_all<+2>(cpu, {&res}, [&] { @@ -2954,10 +2954,10 @@ void spu_thread::do_putlluc(const spu_mfc_cmd& args) } do_cell_atomic_128_store(addr, _ptr(args.lsa & 0x3ff80)); - vm::reservation_notifier(addr, 128).notify_all(-128); + vm::reservation_notifier(addr).notify_all(-128); } -void spu_thread::do_mfc(bool wait) +void spu_thread::do_mfc(bool /*wait*/) { u32 removed = 0; u32 barrier = 0; @@ -3149,7 +3149,7 @@ bool spu_thread::process_mfc_cmd() spu_log.trace(u8"GETLLAR after fail: addr=0x%x, time=%u c", last_faddr, (perf0.get() - last_ftsc)); } - if (addr == last_faddr && perf0.get() - last_ftsc < 1000 && (vm::reservation_acquire(addr, 128) & -128) == last_ftime) + if (addr == last_faddr && perf0.get() - last_ftsc < 1000 && (vm::reservation_acquire(addr) & -128) == last_ftime) { rtime = last_ftime; raddr = last_faddr; @@ -3165,7 +3165,7 @@ bool spu_thread::process_mfc_cmd() last_faddr = 0; } - if (addr == raddr && !g_use_rtm && g_cfg.core.spu_getllar_polling_detection && rtime == vm::reservation_acquire(addr, 128) && cmp_rdata(rdata, data)) + if (addr == raddr && !g_use_rtm && g_cfg.core.spu_getllar_polling_detection && rtime == vm::reservation_acquire(addr) && cmp_rdata(rdata, data)) { // Spinning, might as well yield cpu resources std::this_thread::yield(); @@ -3193,7 +3193,7 @@ bool spu_thread::process_mfc_cmd() const bool ok = cpu_thread::if_suspended<0>(this, {&ntime}, [&] { // Guaranteed success - ntime = vm::reservation_acquire(addr, 128); + ntime = vm::reservation_acquire(addr); mov_rdata_nt(rdata, sdata); }); @@ -3218,7 +3218,7 @@ bool spu_thread::process_mfc_cmd() } }()) { - ntime = vm::reservation_acquire(addr, 128); + ntime = vm::reservation_acquire(addr); if (ntime & vm::rsrv_unique_lock) { @@ -3247,7 +3247,7 @@ bool spu_thread::process_mfc_cmd() mov_rdata(rdata, data); } - if (u64 time0 = vm::reservation_acquire(addr, 128); (ntime & test_mask) != (time0 & test_mask)) + if (u64 time0 = vm::reservation_acquire(addr); (ntime & test_mask) != (time0 & test_mask)) { // Reservation data has been modified recently if (time0 & vm::rsrv_unique_lock) i += 12; @@ -3429,7 +3429,7 @@ bool spu_thread::process_mfc_cmd() //if (g_cfg.core.mfc_debug) //{ - // TODO: This needs a disambiguator with list elements dumping + // TODO: This needs a disambiguator with list elements dumping // auto& dump = reinterpret_cast(vm::g_stat_addr + vm_offset())[mfc_dump_idx++ % spu_thread::max_mfc_dump_idx]; // dump.cmd = ch_mfc_cmd; // dump.cmd.eah = pc; @@ -3497,7 +3497,7 @@ bool spu_thread::reservation_check(u32 addr, const decltype(rdata)& data) return false; } - if ((vm::reservation_acquire(addr, 128) & -128) != rtime) + if ((vm::reservation_acquire(addr) & -128) != rtime) { return true; } @@ -3883,7 +3883,7 @@ s64 spu_thread::get_ch_value(u32 ch) continue; } - vm::reservation_notifier(raddr, 128).wait(rtime, -128, atomic_wait_timeout{100'000}); + vm::reservation_notifier(raddr).wait(rtime, -128, atomic_wait_timeout{100'000}); } check_state(); diff --git a/rpcs3/Emu/Cell/lv2/sys_config.cpp b/rpcs3/Emu/Cell/lv2/sys_config.cpp index 407e061d4a..e630ea01cb 100644 --- a/rpcs3/Emu/Cell/lv2/sys_config.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_config.cpp @@ -161,7 +161,8 @@ void lv2_config_service_listener::notify_all() std::vector> services; // Grab all events - idm::select([&](u32 id, lv2_config_service& service) -> void { + idm::select([&](u32 /*id*/, lv2_config_service& service) + { if (check_service(service)) { services.push_back(service.get_shared_ptr()); @@ -169,7 +170,8 @@ void lv2_config_service_listener::notify_all() }, 0); // Sort services by timestamp - sort(services.begin(), services.end(), [](const std::shared_ptr& s1, const std::shared_ptr& s2) -> bool { + sort(services.begin(), services.end(), [](const std::shared_ptr& s1, const std::shared_ptr& s2) + { return s1->timestamp < s2->timestamp; }); @@ -200,7 +202,8 @@ void lv2_config_service::notify() const auto sptr = wkptr.lock(); - idm::select([&](u32 id, lv2_config_service_listener& listener) -> void { + idm::select([&](u32 /*id*/, lv2_config_service_listener& listener) + { if (listener.check_service(*sptr)) listeners.push_back(listener.get_shared_ptr()); }); diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 959cced2f6..4cfc046074 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -197,7 +197,7 @@ struct lv2_file::file_view : fs::file_base return m_file->file.stat(); } - bool trunc(u64 length) override + bool trunc(u64) override { return false; } @@ -213,7 +213,7 @@ struct lv2_file::file_view : fs::file_base return result; } - u64 write(const void* buffer, u64 size) override + u64 write(const void*, u64) override { return 0; } @@ -248,7 +248,7 @@ fs::file lv2_file::make_view(const std::shared_ptr& _file, u64 offset) return result; } -error_code sys_fs_test(ppu_thread& ppu, u32 arg1, u32 arg2, vm::ptr arg3, u32 arg4, vm::ptr buf, u32 buf_size) +error_code sys_fs_test(ppu_thread&, u32 arg1, u32 arg2, vm::ptr arg3, u32 arg4, vm::ptr buf, u32 buf_size) { sys_fs.trace("sys_fs_test(arg1=0x%x, arg2=0x%x, arg3=*0x%x, arg4=0x%x, buf=*0x%x, buf_size=0x%x)", arg1, arg2, arg3, arg4, buf, buf_size); @@ -281,7 +281,7 @@ error_code sys_fs_test(ppu_thread& ppu, u32 arg1, u32 arg2, vm::ptr arg3, u return CELL_OK; } -lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s32 flags, s32 mode, lv2_file_type type, const lv2_fs_mount_point* mp) +lv2_file::open_raw_result_t lv2_file::open_raw(const std::string& local_path, s32 flags, s32 /*mode*/, lv2_file_type type, const lv2_fs_mount_point* mp) { // TODO: other checks for path @@ -1005,7 +1005,7 @@ error_code sys_fs_fstat(ppu_thread& ppu, u32 fd, vm::ptr sb) return CELL_OK; } -error_code sys_fs_link(ppu_thread& ppu, vm::cptr from, vm::cptr to) +error_code sys_fs_link(ppu_thread&, vm::cptr from, vm::cptr to) { sys_fs.todo("sys_fs_link(from=%s, to=%s)", from, to); @@ -1225,7 +1225,7 @@ error_code sys_fs_unlink(ppu_thread& ppu, vm::cptr path) return CELL_OK; } -error_code sys_fs_access(ppu_thread& ppu, vm::cptr path, s32 mode) +error_code sys_fs_access(ppu_thread&, vm::cptr path, s32 mode) { sys_fs.todo("sys_fs_access(path=%s, mode=%#o)", path, mode); @@ -1732,6 +1732,8 @@ error_code sys_fs_fsync(ppu_thread& ppu, u32 fd) error_code sys_fs_fget_block_size(ppu_thread& ppu, u32 fd, vm::ptr sector_size, vm::ptr block_size, vm::ptr arg4, vm::ptr out_flags) { + ppu.state += cpu_flag::wait; + sys_fs.warning("sys_fs_fget_block_size(fd=%d, sector_size=*0x%x, block_size=*0x%x, arg4=*0x%x, out_flags=*0x%x)", fd, sector_size, block_size, arg4, out_flags); const auto file = idm::get(fd); @@ -1741,6 +1743,11 @@ error_code sys_fs_fget_block_size(ppu_thread& ppu, u32 fd, vm::ptr sector_s return CELL_EBADF; } + if (ppu.is_stopped()) + { + return {}; + } + // TODO *sector_size = file->mp->sector_size; *block_size = file->mp->block_size; @@ -1752,6 +1759,8 @@ error_code sys_fs_fget_block_size(ppu_thread& ppu, u32 fd, vm::ptr sector_s error_code sys_fs_get_block_size(ppu_thread& ppu, vm::cptr path, vm::ptr sector_size, vm::ptr block_size, vm::ptr arg4) { + ppu.state += cpu_flag::wait; + sys_fs.warning("sys_fs_get_block_size(path=%s, sector_size=*0x%x, block_size=*0x%x, arg4=*0x%x)", path, sector_size, block_size, arg4); if (!path) @@ -1788,6 +1797,11 @@ error_code sys_fs_get_block_size(ppu_thread& ppu, vm::cptr path, vm::ptrsector_size; *block_size = mp->block_size; @@ -1890,21 +1904,21 @@ error_code sys_fs_ftruncate(ppu_thread& ppu, u32 fd, u64 size) return CELL_OK; } -error_code sys_fs_symbolic_link(ppu_thread& ppu, vm::cptr target, vm::cptr linkpath) +error_code sys_fs_symbolic_link(ppu_thread&, vm::cptr target, vm::cptr linkpath) { sys_fs.todo("sys_fs_symbolic_link(target=%s, linkpath=%s)", target, linkpath); return CELL_OK; } -error_code sys_fs_chmod(ppu_thread& ppu, vm::cptr path, s32 mode) +error_code sys_fs_chmod(ppu_thread&, vm::cptr path, s32 mode) { sys_fs.todo("sys_fs_chmod(path=%s, mode=%#o)", path, mode); return CELL_OK; } -error_code sys_fs_chown(ppu_thread& ppu, vm::cptr path, s32 uid, s32 gid) +error_code sys_fs_chown(ppu_thread&, vm::cptr path, s32 uid, s32 gid) { sys_fs.todo("sys_fs_chown(path=%s, uid=%d, gid=%d)", path, uid, gid); @@ -2033,21 +2047,21 @@ error_code sys_fs_utime(ppu_thread& ppu, vm::cptr path, vm::cptr path, vm::ptr ptr) +error_code sys_fs_acl_read(ppu_thread&, vm::cptr path, vm::ptr ptr) { sys_fs.todo("sys_fs_acl_read(path=%s, ptr=*0x%x)", path, ptr); return CELL_OK; } -error_code sys_fs_acl_write(ppu_thread& ppu, vm::cptr path, vm::ptr ptr) +error_code sys_fs_acl_write(ppu_thread&, vm::cptr path, vm::ptr ptr) { sys_fs.todo("sys_fs_acl_write(path=%s, ptr=*0x%x)", path, ptr); return CELL_OK; } -error_code sys_fs_lsn_get_cda_size(ppu_thread& ppu, u32 fd, vm::ptr ptr) +error_code sys_fs_lsn_get_cda_size(ppu_thread&, u32 fd, vm::ptr ptr) { sys_fs.warning("sys_fs_lsn_get_cda_size(fd=%d, ptr=*0x%x)", fd, ptr); @@ -2063,14 +2077,14 @@ error_code sys_fs_lsn_get_cda_size(ppu_thread& ppu, u32 fd, vm::ptr ptr) return CELL_OK; } -error_code sys_fs_lsn_get_cda(ppu_thread& ppu, u32 fd, vm::ptr arg2, u64 arg3, vm::ptr arg4) +error_code sys_fs_lsn_get_cda(ppu_thread&, u32 fd, vm::ptr arg2, u64 arg3, vm::ptr arg4) { sys_fs.todo("sys_fs_lsn_get_cda(fd=%d, arg2=*0x%x, arg3=0x%x, arg4=*0x%x)", fd, arg2, arg3, arg4); return CELL_OK; } -error_code sys_fs_lsn_lock(ppu_thread& ppu, u32 fd) +error_code sys_fs_lsn_lock(ppu_thread&, u32 fd) { sys_fs.trace("sys_fs_lsn_lock(fd=%d)", fd); @@ -2091,7 +2105,7 @@ error_code sys_fs_lsn_lock(ppu_thread& ppu, u32 fd) return CELL_OK; } -error_code sys_fs_lsn_unlock(ppu_thread& ppu, u32 fd) +error_code sys_fs_lsn_unlock(ppu_thread&, u32 fd) { sys_fs.trace("sys_fs_lsn_unlock(fd=%d)", fd); @@ -2107,56 +2121,56 @@ error_code sys_fs_lsn_unlock(ppu_thread& ppu, u32 fd) return CELL_OK; } -error_code sys_fs_lsn_read(ppu_thread& ppu, u32 fd, vm::cptr ptr, u64 size) +error_code sys_fs_lsn_read(ppu_thread&, u32 fd, vm::cptr ptr, u64 size) { sys_fs.todo("sys_fs_lsn_read(fd=%d, ptr=*0x%x, size=0x%x)", fd, ptr, size); return CELL_OK; } -error_code sys_fs_lsn_write(ppu_thread& ppu, u32 fd, vm::cptr ptr, u64 size) +error_code sys_fs_lsn_write(ppu_thread&, u32 fd, vm::cptr ptr, u64 size) { sys_fs.todo("sys_fs_lsn_write(fd=%d, ptr=*0x%x, size=0x%x)", fd, ptr, size); return CELL_OK; } -error_code sys_fs_mapped_allocate(ppu_thread& ppu, u32 fd, u64 size, vm::pptr out_ptr) +error_code sys_fs_mapped_allocate(ppu_thread&, u32 fd, u64 size, vm::pptr out_ptr) { sys_fs.todo("sys_fs_mapped_allocate(fd=%d, arg2=0x%x, out_ptr=**0x%x)", fd, size, out_ptr); return CELL_OK; } -error_code sys_fs_mapped_free(ppu_thread& ppu, u32 fd, vm::ptr ptr) +error_code sys_fs_mapped_free(ppu_thread&, u32 fd, vm::ptr ptr) { sys_fs.todo("sys_fs_mapped_free(fd=%d, ptr=0x%#x)", fd, ptr); return CELL_OK; } -error_code sys_fs_truncate2(ppu_thread& ppu, u32 fd, u64 size) +error_code sys_fs_truncate2(ppu_thread&, u32 fd, u64 size) { sys_fs.todo("sys_fs_truncate2(fd=%d, size=0x%x)", fd, size); return CELL_OK; } -error_code sys_fs_get_mount_info_size(ppu_thread& ppu, vm::ptr len) +error_code sys_fs_get_mount_info_size(ppu_thread&, vm::ptr len) { sys_fs.todo("sys_fs_get_mount_info_size(len=*0x%x)", len); return CELL_OK; } -error_code sys_fs_get_mount_info(ppu_thread& ppu, vm::ptr info, u32 len, vm::ptr out_len) +error_code sys_fs_get_mount_info(ppu_thread&, vm::ptr info, u32 len, vm::ptr out_len) { sys_fs.todo("sys_fs_get_mount_info(info=*0x%x, len=0x%x, out_len=*0x%x)", info, len, out_len); 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&, vm::cptr dev_name, vm::cptr file_system, vm::cptr path, s32 unk1, s32 prot, s32 unk3, vm::cptr str1, u32 str_len) { sys_fs.todo("sys_fs_mount(dev_name=%s, file_system=%s, path=%s, unk1=0x%x, prot=0x%x, unk3=0x%x, str1=%s, str_len=%d)", dev_name, file_system, path, unk1, prot, unk3, str1, str_len); diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index 83233e66b1..13109d0cd0 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -699,7 +699,7 @@ struct nt_p2p_port return true; } - bool handle_listening(s32 sock_id, lv2_socket::p2ps_i::encapsulated_tcp* tcp_header, u8* data, ::sockaddr_storage* op_addr) + bool handle_listening(s32 sock_id, lv2_socket::p2ps_i::encapsulated_tcp* tcp_header, u8* /*data*/, ::sockaddr_storage* op_addr) { auto sock = idm::get(sock_id); if (!sock) @@ -3656,7 +3656,7 @@ error_code _sys_net_write_dump(ppu_thread& ppu, s32 id, vm::cptr buf, s32 { ppu.state += cpu_flag::wait; - sys_net.todo(__func__); + sys_net.todo("_sys_net_write_dump(id=0x%x, buf=*0x%x, len=%d, unk=0x%x)", id, buf, len, unknown); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_overlay.cpp b/rpcs3/Emu/Cell/lv2/sys_overlay.cpp index 70745b1446..590385ed9d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_overlay.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_overlay.cpp @@ -19,7 +19,7 @@ extern void ppu_finalize(const ppu_module&); LOG_CHANNEL(sys_overlay); -static error_code overlay_load_module(vm::ptr ovlmid, const std::string& vpath, u64 flags, vm::ptr entry, fs::file src = {}) +static error_code overlay_load_module(vm::ptr ovlmid, const std::string& vpath, u64 /*flags*/, vm::ptr entry, fs::file src = {}) { if (!src) { diff --git a/rpcs3/Emu/Cell/lv2/sys_process.cpp b/rpcs3/Emu/Cell/lv2/sys_process.cpp index d744521d1a..152ed7e8de 100644 --- a/rpcs3/Emu/Cell/lv2/sys_process.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_process.cpp @@ -272,7 +272,7 @@ error_code _sys_process_get_paramsfo(vm::ptr buffer) return CELL_OK; } -s32 process_get_sdk_version(u32 pid, s32& ver) +s32 process_get_sdk_version(u32 /*pid*/, s32& ver) { // get correct SDK version for selected pid ver = g_ps3_process_info.sdk_ver; diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp index 20550c5bf0..cab860cdae 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp @@ -169,7 +169,7 @@ extern const std::map g_prx_list { "libwmadec.sprx", 0 }, }; -static error_code prx_load_module(const std::string& vpath, u64 flags, vm::ptr pOpt, fs::file src = {}) +static error_code prx_load_module(const std::string& vpath, u64 flags, vm::ptr /*pOpt*/, fs::file src = {}) { if (flags != 0) { @@ -323,7 +323,7 @@ error_code _sys_prx_load_module_on_memcontainer_by_fd(ppu_thread& ppu, s32 fd, u return _sys_prx_load_module_by_fd(ppu, fd, offset, flags, pOpt); } -static error_code prx_load_module_list(ppu_thread& ppu, s32 count, vm::cpptr path_list, u32 mem_ct, u64 flags, vm::ptr pOpt, vm::ptr id_list) +static error_code prx_load_module_list(ppu_thread& ppu, s32 count, vm::cpptr path_list, u32 /*mem_ct*/, u64 flags, vm::ptr pOpt, vm::ptr id_list) { if (flags != 0) { diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 4beac51415..7e705d4911 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -2026,7 +2026,7 @@ error_code sys_isolated_spu_destroy(ppu_thread& ppu, u32 id) } template -error_code raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 hwthread, vm::ptr intrtag) +error_code raw_spu_create_interrupt_tag(u32 id, u32 class_id, u32 /*hwthread*/, vm::ptr intrtag) { if (class_id != 0 && class_id != 2) { diff --git a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp index 476b56b426..c63c45b62c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp @@ -625,7 +625,7 @@ error_code sys_usbd_register_ldd(ppu_thread& ppu, u32 handle, vm::ptr s_pr return CELL_OK; } -error_code sys_usbd_unregister_ldd(ppu_thread& ppu) +error_code sys_usbd_unregister_ldd(ppu_thread&) { sys_usbd.todo("sys_usbd_unregister_ldd()"); return CELL_OK; diff --git a/rpcs3/Emu/GDB.cpp b/rpcs3/Emu/GDB.cpp index 295b3030d4..7f172dd9ed 100644 --- a/rpcs3/Emu/GDB.cpp +++ b/rpcs3/Emu/GDB.cpp @@ -480,7 +480,7 @@ bool gdb_thread::set_reg(ppu_thread* thread, u32 rid, std::string value) } } -u32 gdb_thread::get_reg_size(ppu_thread* thread, u32 rid) +u32 gdb_thread::get_reg_size(ppu_thread*, u32 rid) { switch (rid) { case 66: @@ -523,22 +523,22 @@ void gdb_thread::wait_with_interrupts() } } -bool gdb_thread::cmd_extended_mode(gdb_cmd& cmd) +bool gdb_thread::cmd_extended_mode(gdb_cmd&) { return send_cmd_ack("OK"); } -bool gdb_thread::cmd_reason(gdb_cmd& cmd) +bool gdb_thread::cmd_reason(gdb_cmd&) { return send_reason(); } -bool gdb_thread::cmd_supported(gdb_cmd& cmd) +bool gdb_thread::cmd_supported(gdb_cmd&) { return send_cmd_ack("PacketSize=1200"); } -bool gdb_thread::cmd_thread_info(gdb_cmd& cmd) +bool gdb_thread::cmd_thread_info(gdb_cmd&) { std::string result; const auto on_select = [&](u32, cpu_thread& cpu) @@ -557,7 +557,7 @@ bool gdb_thread::cmd_thread_info(gdb_cmd& cmd) return send_cmd_ack(result);; } -bool gdb_thread::cmd_current_thread(gdb_cmd& cmd) +bool gdb_thread::cmd_current_thread(gdb_cmd&) { return send_cmd_ack(selected_thread.expired() ? "" : ("QC" + u64_to_padded_hex(selected_thread.lock()->id))); } @@ -657,7 +657,7 @@ bool gdb_thread::cmd_write_memory(gdb_cmd& cmd) return send_cmd_ack("OK"); } -bool gdb_thread::cmd_read_all_registers(gdb_cmd& cmd) +bool gdb_thread::cmd_read_all_registers(gdb_cmd&) { std::string result; select_thread(general_ops_thread_id); @@ -711,19 +711,19 @@ bool gdb_thread::cmd_set_thread_ops(gdb_cmd& cmd) return send_cmd_ack("E01"); } -bool gdb_thread::cmd_attached_to_what(gdb_cmd& cmd) +bool gdb_thread::cmd_attached_to_what(gdb_cmd&) { //creating processes from client is not available yet return send_cmd_ack("1"); } -bool gdb_thread::cmd_kill(gdb_cmd& cmd) +bool gdb_thread::cmd_kill(gdb_cmd&) { Emu.Stop(); return true; } -bool gdb_thread::cmd_continue_support(gdb_cmd& cmd) +bool gdb_thread::cmd_continue_support(gdb_cmd&) { return send_cmd_ack("vCont;c;s;C;S"); } diff --git a/rpcs3/Emu/Io/Buzz.cpp b/rpcs3/Emu/Io/Buzz.cpp index 5ff8076167..499f9191e5 100644 --- a/rpcs3/Emu/Io/Buzz.cpp +++ b/rpcs3/Emu/Io/Buzz.cpp @@ -42,7 +42,7 @@ void usb_device_buzz::control_transfer(u8 bmRequestType, u8 bRequest, u16 wValue } } -void usb_device_buzz::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, UsbTransfer* transfer) +void usb_device_buzz::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endpoint*/, UsbTransfer* transfer) { transfer->fake = true; transfer->expected_count = 5; diff --git a/rpcs3/Emu/Io/GHLtar.cpp b/rpcs3/Emu/Io/GHLtar.cpp index 9e583c0e67..e6d80e8134 100644 --- a/rpcs3/Emu/Io/GHLtar.cpp +++ b/rpcs3/Emu/Io/GHLtar.cpp @@ -45,7 +45,7 @@ void usb_device_ghltar::control_transfer(u8 bmRequestType, u8 bRequest, u16 wVal } } -void usb_device_ghltar::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, UsbTransfer* transfer) +void usb_device_ghltar::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endpoint*/, UsbTransfer* transfer) { transfer->fake = true; transfer->expected_count = buf_size; diff --git a/rpcs3/Emu/Io/Skylander.cpp b/rpcs3/Emu/Io/Skylander.cpp index bd4cfc0efa..c2767546ac 100644 --- a/rpcs3/Emu/Io/Skylander.cpp +++ b/rpcs3/Emu/Io/Skylander.cpp @@ -307,7 +307,7 @@ void usb_device_skylander::control_transfer(u8 bmRequestType, u8 bRequest, u16 w } } -void usb_device_skylander::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, UsbTransfer* transfer) +void usb_device_skylander::interrupt_transfer(u32 buf_size, u8* buf, u32 /*endpoint*/, UsbTransfer* transfer) { ensure(buf_size == 0x20); diff --git a/rpcs3/Emu/Io/usb_device.cpp b/rpcs3/Emu/Io/usb_device.cpp index 9a8594f967..4383c5f8c2 100644 --- a/rpcs3/Emu/Io/usb_device.cpp +++ b/rpcs3/Emu/Io/usb_device.cpp @@ -102,7 +102,7 @@ bool usb_device_passthrough::set_interface(u8 int_num) return (libusb_claim_interface(lusb_handle, int_num) == LIBUSB_SUCCESS); } -void usb_device_passthrough::control_transfer(u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, u32 buf_size, u8* buf, UsbTransfer* transfer) +void usb_device_passthrough::control_transfer(u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 /*wLength*/, u32 buf_size, u8* buf, UsbTransfer* transfer) { if (transfer->setup_buf.size() < buf_size + 8) transfer->setup_buf.resize(buf_size + 8); @@ -150,7 +150,7 @@ bool usb_device_emulated::open_device() return true; } -s32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* ptr, u32 max_size) +s32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* ptr, u32 /*max_size*/) { if (type == USB_DESCRIPTOR_STRING) { @@ -175,7 +175,7 @@ s32 usb_device_emulated::get_descriptor(u8 type, u8 index, u8* ptr, u32 max_size return -1; } -void usb_device_emulated::control_transfer(u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, u32 buf_size, u8* buf, UsbTransfer* transfer) +void usb_device_emulated::control_transfer(u8 bmRequestType, u8 bRequest, u16 wValue, u16 /*wIndex*/, u16 /*wLength*/, u32 buf_size, u8* /*buf*/, UsbTransfer* transfer) { transfer->fake = true; transfer->expected_count = buf_size; @@ -195,6 +195,11 @@ void usb_device_emulated::control_transfer(u8 bmRequestType, u8 bRequest, u16 wV } } +// Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + void usb_device_emulated::interrupt_transfer(u32 buf_size, u8* buf, u32 endpoint, UsbTransfer* transfer) { } diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index bfc8153efe..481801006c 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -85,7 +85,7 @@ namespace vm std::pair try_reservation_update(u32 addr) { // Update reservation info with new timestamp - auto& res = reservation_acquire(addr, 1); + auto& res = reservation_acquire(addr); const u64 rtime = res; return {!(rtime & vm::rsrv_unique_lock) && res.compare_and_swap_test(rtime, rtime + 128), rtime}; @@ -609,7 +609,7 @@ namespace vm void reservation_op_internal(u32 addr, std::function func) { - auto& res = vm::reservation_acquire(addr, 1); + auto& res = vm::reservation_acquire(addr); auto* ptr = vm::get_super_ptr(addr & -128); cpu_thread::suspend_all<+1>(get_current_cpu_thread(), {ptr, ptr + 64, &res}, [&] diff --git a/rpcs3/Emu/Memory/vm_reservation.h b/rpcs3/Emu/Memory/vm_reservation.h index a40e42e941..dcf4f606ff 100644 --- a/rpcs3/Emu/Memory/vm_reservation.h +++ b/rpcs3/Emu/Memory/vm_reservation.h @@ -36,7 +36,7 @@ namespace vm }; // Get reservation status for further atomic update: last update timestamp - inline atomic_t& reservation_acquire(u32 addr, u32 size) + inline atomic_t& reservation_acquire(u32 addr) { // Access reservation info: stamp and the lock bit return *reinterpret_cast*>(g_reservations + (addr & 0xff80) / 2); @@ -46,7 +46,7 @@ namespace vm void reservation_update(u32 addr); // Get reservation sync variable - inline atomic_t& reservation_notifier(u32 addr, u32 size) + inline atomic_t& reservation_notifier(u32 addr) { return *reinterpret_cast*>(g_reservations + (addr & 0xff80) / 2); } @@ -67,7 +67,7 @@ namespace vm inline std::pair&, u64> reservation_lock(u32 addr) { - auto res = &vm::reservation_acquire(addr, 1); + auto res = &vm::reservation_acquire(addr); auto rtime = res->load(); if (rtime & 127 || !reservation_try_lock(*res, rtime)) [[unlikely]] @@ -105,7 +105,7 @@ namespace vm // Use 128-byte aligned addr const u32 addr = static_cast(ptr.addr()) & -128; - auto& res = vm::reservation_acquire(addr, 128); + auto& res = vm::reservation_acquire(addr); //_m_prefetchw(&res); if (g_use_rtm) @@ -346,7 +346,7 @@ namespace vm } } - const u64 rtime = vm::reservation_acquire(addr, 128); + const u64 rtime = vm::reservation_acquire(addr); if (rtime & 127) { @@ -358,7 +358,7 @@ namespace vm { std::invoke(op, *ptr); - if (rtime == vm::reservation_acquire(addr, 128)) + if (rtime == vm::reservation_acquire(addr)) { return; } @@ -367,7 +367,7 @@ namespace vm { auto res = std::invoke(op, *ptr); - if (rtime == vm::reservation_acquire(addr, 128)) + if (rtime == vm::reservation_acquire(addr)) { return res; } @@ -385,7 +385,7 @@ namespace vm const auto sptr = vm::get_super_ptr(addr); // "Lock" reservation - auto& res = vm::reservation_acquire(addr, 128); + auto& res = vm::reservation_acquire(addr); auto [_old, _ok] = res.fetch_op([&](u64& r) { diff --git a/rpcs3/Emu/Memory/vm_var.h b/rpcs3/Emu/Memory/vm_var.h index 97ccbbc4e9..8d8202fcc2 100644 --- a/rpcs3/Emu/Memory/vm_var.h +++ b/rpcs3/Emu/Memory/vm_var.h @@ -14,7 +14,7 @@ namespace vm return vm::cast(vm::alloc(size, Location, std::max(align, 0x10000))); } - static inline void dealloc(u32 addr, u32 size = 0) noexcept + static inline void dealloc(u32 addr, u32 /*size*/ = 0) noexcept { ensure(vm::dealloc(addr, Location)); } diff --git a/rpcs3/Emu/NP/np_handler.cpp b/rpcs3/Emu/NP/np_handler.cpp index b39b8bece5..14bab182e2 100644 --- a/rpcs3/Emu/NP/np_handler.cpp +++ b/rpcs3/Emu/NP/np_handler.cpp @@ -471,7 +471,7 @@ u32 np_handler::get_server_status(SceNpMatching2ContextId ctx_id, vm::cptr optParam, u16 server_id) +u32 np_handler::create_server_context(SceNpMatching2ContextId ctx_id, vm::cptr optParam, u16 /*server_id*/) { u32 req_id = generate_callback_info(ctx_id, optParam); u32 event_key = get_event_key(); @@ -636,7 +636,7 @@ void np_handler::req_sign_infos(const std::string& npid, u32 conn_id) return; } -void np_handler::req_ticket(u32 version, const SceNpId *npid, const char *service_id, const u8 *cookie, u32 cookie_size, const char *entitlement_id, u32 consumed_count) +void np_handler::req_ticket(u32 /*version*/, const SceNpId* /*npid*/, const char* service_id, const u8* /*cookie*/, u32 /*cookie_size*/, const char* /*entitlement_id*/, u32 /*consumed_count*/) { u32 req_id = get_req_id(0x3333); @@ -910,7 +910,7 @@ bool np_handler::reply_search_room(u32 req_id, std::vector& reply_data) return true; } -bool np_handler::reply_set_roomdata_external(u32 req_id, std::vector& reply_data) +bool np_handler::reply_set_roomdata_external(u32 req_id, std::vector& /*reply_data*/) { if (pending_requests.count(req_id) == 0) return error_and_disconnect("Unexpected reply ID to SetRoomDataExternal"); @@ -963,7 +963,7 @@ bool np_handler::reply_get_roomdata_internal(u32 req_id, std::vector& reply_ return true; } -bool np_handler::reply_set_roomdata_internal(u32 req_id, std::vector& reply_data) +bool np_handler::reply_set_roomdata_internal(u32 req_id, std::vector& /*reply_data*/) { if (pending_requests.count(req_id) == 0) return error_and_disconnect("Unexpected reply ID to SetRoomDataInternal"); @@ -1012,7 +1012,7 @@ bool np_handler::reply_get_ping_info(u32 req_id, std::vector& reply_data) return true; } -bool np_handler::reply_send_room_message(u32 req_id, std::vector& reply_data) +bool np_handler::reply_send_room_message(u32 req_id, std::vector& /*reply_data*/) { if (pending_requests.count(req_id) == 0) return error_and_disconnect("Unexpected reply ID to PingRoomOwner"); @@ -1050,7 +1050,7 @@ bool np_handler::reply_req_sign_infos(u32 req_id, std::vector& reply_data) return true; } -bool np_handler::reply_req_ticket(u32 req_id, std::vector& reply_data) +bool np_handler::reply_req_ticket(u32 /*req_id*/, std::vector& reply_data) { vec_stream reply(reply_data, 1); auto ticket_raw = reply.get_rawdata(); @@ -1372,7 +1372,7 @@ u8* np_handler::allocate_req_result(u32 event_key, usz size) return match2_req_results[event_key].data(); } -u32 np_handler::add_players_to_history(vm::cptr npids, u32 count) +u32 np_handler::add_players_to_history(vm::cptr /*npids*/, u32 /*count*/) { const u32 req_id = get_req_id(0); diff --git a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp index d0a8c59246..db04b407fa 100644 --- a/rpcs3/Emu/RSX/Capture/rsx_replay.cpp +++ b/rpcs3/Emu/RSX/Capture/rsx_replay.cpp @@ -54,7 +54,7 @@ namespace rsx return contextInfo->context_id; } - std::vector rsx_replay_thread::alloc_write_fifo(be_t context_id) + std::vector rsx_replay_thread::alloc_write_fifo(be_t /*context_id*/) { // copy commands into fifo buffer // todo: could change rsx_command to just be values to avoid this loop, diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 83371433f8..b79ceb9143 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -140,7 +140,7 @@ struct copy_unmodified_block_swizzled struct copy_unmodified_block_vtc { template - static void copy_mipmap_level(gsl::span dst, gsl::span src, u16 width_in_block, u16 row_count, u16 depth, u32 dst_pitch_in_block, u32 src_pitch_in_block) + static void copy_mipmap_level(gsl::span dst, gsl::span src, u16 width_in_block, u16 row_count, u16 depth, u32 /*dst_pitch_in_block*/, u32 /*src_pitch_in_block*/) { static_assert(sizeof(T) == sizeof(U), "Type size doesn't match."); u32 row_element_count = width_in_block * row_count; diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 6d108a8694..63c5467ab5 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -1226,7 +1226,7 @@ namespace rsx } template - void discard_framebuffer_memory_region(commandbuffer_type& cmd, const address_range& rsx_range, Args&&... extras) + void discard_framebuffer_memory_region(commandbuffer_type& /*cmd*/, const address_range& rsx_range, Args&&... /*extras*/) { if (g_cfg.video.write_color_buffers || g_cfg.video.write_depth_buffer) { @@ -1565,7 +1565,7 @@ namespace rsx } } - template + template sampled_image_descriptor fast_texture_search( commandbuffer_type& cmd, const image_section_attributes_t& attr, @@ -1575,7 +1575,7 @@ namespace rsx const texture_cache_search_options& options, const utils::address_range& memory_range, rsx::texture_dimension_extended extended_dimension, - surface_store_type& m_rtts, Args&& ... extras) + SurfaceStoreType& m_rtts, Args&&... /*extras*/) { if (options.is_compressed_format) [[likely]] { @@ -1609,7 +1609,7 @@ namespace rsx } } - std::vector overlapping_fbos; + std::vector overlapping_fbos; std::vector overlapping_locals; auto fast_fbo_check = [&]() -> sampled_image_descriptor diff --git a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h index 86a5bc9734..a97b0fcbda 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h @@ -238,7 +238,7 @@ namespace rsx const surface_store_list_type& fbos, const std::vector& local, const image_section_attributes_t& attr, - u16 count, bool is_depth) + u16 count, bool /*is_depth*/) { // Need to preserve sorting order struct sort_helper @@ -589,7 +589,7 @@ namespace rsx const image_section_attributes_t& attr, const size2f& scale, texture_dimension_extended extended_dimension, - u32 encoded_remap, const texture_channel_remap_t& decoded_remap, + u32 /*encoded_remap*/, const texture_channel_remap_t& decoded_remap, int select_hint = -1) { ensure((select_hint & 0x1) == select_hint); diff --git a/rpcs3/Emu/RSX/GL/GLHelpers.cpp b/rpcs3/Emu/RSX/GL/GLHelpers.cpp index d20dfebcb2..f64a4424fb 100644 --- a/rpcs3/Emu/RSX/GL/GLHelpers.cpp +++ b/rpcs3/Emu/RSX/GL/GLHelpers.cpp @@ -61,8 +61,8 @@ namespace gl // https://www.khronos.org/opengl/wiki/Debug_Output void APIENTRY log_debug(GLenum source, GLenum type, GLuint id, - GLenum severity, GLsizei length, const GLchar* message, - const void* user_param) + GLenum severity, GLsizei /*length*/, const GLchar* message, + const void* /*user_param*/) { // Message source std::string str_source; @@ -631,7 +631,7 @@ namespace gl glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, GL_NONE, 0); } - void blitter::fast_clear_image(gl::command_context& cmd, const texture* dst, float depth, u8 stencil) + void blitter::fast_clear_image(gl::command_context& cmd, const texture* dst, float /*depth*/, u8 /*stencil*/) { GLenum attachment; GLbitfield clear_mask; diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index f606ef61c3..e57470b7bf 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -99,7 +99,7 @@ u8 rsx::internals::get_pixel_size(rsx::surface_depth_format format) fmt::throw_exception("Unknown depth format"); } -void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool skip_reading) +void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool /*skip_reading*/) { const bool clipped_scissor = (context == rsx::framebuffer_creation_context::context_draw); if (m_current_framebuffer_context == context && !m_rtts_dirty && m_draw_fbo) diff --git a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp index b692b78c6e..7d01e4c534 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexBuffers.cpp @@ -66,7 +66,7 @@ namespace , m_vertex_layout(vertex_layout) {} - vertex_input_state operator()(const rsx::draw_array_command& command) + vertex_input_state operator()(const rsx::draw_array_command& /*command*/) { const u32 vertex_count = rsx::method_registers.current_draw_clause.get_elements_count(); const u32 min_index = rsx::method_registers.current_draw_clause.min_index(); @@ -127,7 +127,7 @@ namespace return{ true, min_index, max_index, index_count, index_offset, std::make_tuple(get_index_type(type), offset_in_index_buffer) }; } - vertex_input_state operator()(const rsx::draw_inlined_array& command) + vertex_input_state operator()(const rsx::draw_inlined_array& /*command*/) { const auto stream_length = rsx::method_registers.current_draw_clause.inline_vertex_array.size(); const u32 vertex_count = u32(stream_length * sizeof(u32)) / m_vertex_layout.interleaved_blocks[0].attribute_stride; diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp index eb951c398a..33aca9f605 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp @@ -13,7 +13,7 @@ std::string GLVertexDecompilerThread::getFloatTypeName(usz elementCount) return glsl::getFloatTypeNameImpl(elementCount); } -std::string GLVertexDecompilerThread::getIntTypeName(usz elementCount) +std::string GLVertexDecompilerThread::getIntTypeName(usz /*elementCount*/) { return "ivec4"; } @@ -50,13 +50,13 @@ void GLVertexDecompilerThread::insertHeader(std::stringstream &OS) OS << "};\n\n"; } -void GLVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::vector& inputs) +void GLVertexDecompilerThread::insertInputs(std::stringstream& OS, const std::vector& /*inputs*/) { OS << "layout(location=0) uniform usamplerBuffer persistent_input_stream;\n"; //Data stream with persistent vertex data (cacheable) OS << "layout(location=1) uniform usamplerBuffer volatile_input_stream;\n"; //Data stream with per-draw data (registers and immediate draw data) } -void GLVertexDecompilerThread::insertConstants(std::stringstream & OS, const std::vector & constants) +void GLVertexDecompilerThread::insertConstants(std::stringstream& OS, const std::vector& constants) { OS << "layout(std140, binding = 2) uniform VertexConstantsBuffer\n"; OS << "{\n"; @@ -105,7 +105,7 @@ static const vertex_reg_info reg_table[] = { "tc9", true, "dst_reg6", "", false, "", "", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_TEX9 } // In this line, dst_reg6 is correct since dst_reg goes from 0 to 15. }; -void GLVertexDecompilerThread::insertOutputs(std::stringstream & OS, const std::vector & outputs) +void GLVertexDecompilerThread::insertOutputs(std::stringstream& OS, const std::vector& /*outputs*/) { for (auto &i : reg_table) { diff --git a/rpcs3/Emu/RSX/GSRender.cpp b/rpcs3/Emu/RSX/GSRender.cpp index d3d33a5ec5..43e3122f62 100644 --- a/rpcs3/Emu/RSX/GSRender.cpp +++ b/rpcs3/Emu/RSX/GSRender.cpp @@ -44,7 +44,7 @@ void GSRender::on_exit() rsx::thread::on_exit(); } -void GSRender::flip(const rsx::display_flip_info_t& info) +void GSRender::flip(const rsx::display_flip_info_t&) { if (m_frame) { diff --git a/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog.cpp b/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog.cpp index 12a2a90d96..ff9e35369a 100644 --- a/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog.cpp @@ -16,7 +16,7 @@ namespace rsx dlg->type.bg_invisible = true; dlg->type.progress_bar_count = 2; dlg->ProgressBarSetTaskbarIndex(-1); // -1 to combine all progressbars in the taskbar progress - dlg->on_close = [](s32 status) { Emu.CallAfter([]() { Emu.Stop(); }); }; + dlg->on_close = [](s32 /*status*/) { Emu.CallAfter([]() { Emu.Stop(); }); }; ref_cnt++; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp index 2571b707e2..f123e40775 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_osk.cpp @@ -786,7 +786,7 @@ namespace rsx static constexpr auto thread_name = "OSK Thread"sv; }; - void osk_dialog::Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel) + void osk_dialog::Create(const std::string& /*title*/, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel) { state = OskDialogState::Open; flags = prohibit_flags; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 26c39a96c3..c0341e6244 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -761,12 +761,12 @@ namespace rsx * Fill buffer with vertex program constants. * Buffer must be at least 512 float4 wide. */ - void thread::fill_vertex_program_constants_data(void *buffer) + void thread::fill_vertex_program_constants_data(void* buffer) { memcpy(buffer, rsx::method_registers.transform_constants.data(), 468 * 4 * sizeof(float)); } - void thread::fill_fragment_state_buffer(void *buffer, const RSXFragmentProgram &fragment_program) + void thread::fill_fragment_state_buffer(void* buffer, const RSXFragmentProgram& /*fragment_program*/) { u32 rop_control = 0u; @@ -842,7 +842,7 @@ namespace rsx stream_vector(dst + 4, 0u, fog_mode, std::bit_cast(wpos_scale), std::bit_cast(wpos_bias)); } - void thread::fill_fragment_texture_parameters(void *buffer, const RSXFragmentProgram &fragment_program) + void thread::fill_fragment_texture_parameters(void* buffer, const RSXFragmentProgram& fragment_program) { // Copy only the relevant section if (current_fp_metadata.referenced_textures_mask) diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index c22908ea26..05341032ba 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -900,18 +900,18 @@ namespace rsx * Fill buffer with vertex program constants. * Buffer must be at least 512 float4 wide. */ - void fill_vertex_program_constants_data(void *buffer); + void fill_vertex_program_constants_data(void* buffer); /** * Fill buffer with fragment rasterization state. * Fills current fog values, alpha test parameters and texture scaling parameters */ - void fill_fragment_state_buffer(void *buffer, const RSXFragmentProgram &fragment_program); + void fill_fragment_state_buffer(void* buffer, const RSXFragmentProgram& fragment_program); /** * Fill buffer with fragment texture parameter constants (texture matrix) */ - void fill_fragment_texture_parameters(void *buffer, const RSXFragmentProgram &fragment_program); + void fill_fragment_texture_parameters(void* buffer, const RSXFragmentProgram& fragment_program); /** * Notify that a section of memory has been mapped diff --git a/rpcs3/Emu/RSX/VK/VKDMA.cpp b/rpcs3/Emu/RSX/VK/VKDMA.cpp index bccf1e5566..39f05f0ef1 100644 --- a/rpcs3/Emu/RSX/VK/VKDMA.cpp +++ b/rpcs3/Emu/RSX/VK/VKDMA.cpp @@ -227,17 +227,17 @@ namespace vk // NOP } - void dma_block_EXT::flush(const utils::address_range& range) + void dma_block_EXT::flush(const utils::address_range&) { // NOP } - void dma_block_EXT::load(const utils::address_range& range) + void dma_block_EXT::load(const utils::address_range&) { // NOP } - bool test_host_pointer(u32 base_address, usz length) + bool test_host_pointer([[maybe_unused]] u32 base_address, [[maybe_unused]] usz length) { #ifdef _WIN32 MEMORY_BASIC_INFORMATION mem_info; diff --git a/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp b/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp index 4b5386430f..f48ee138c6 100644 --- a/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp +++ b/rpcs3/Emu/RSX/VK/VKMemAlloc.cpp @@ -44,6 +44,7 @@ private: #pragma GCC diagnostic ignored "-Wold-style-cast" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wsuggest-override" +#pragma GCC diagnostic ignored "-Wunused-parameter" #ifdef __clang__ #pragma clang diagnostic ignored "-Winconsistent-missing-override" #endif diff --git a/rpcs3/Emu/RSX/VK/VKTexture.cpp b/rpcs3/Emu/RSX/VK/VKTexture.cpp index 50a5043254..34c26fcd9b 100644 --- a/rpcs3/Emu/RSX/VK/VKTexture.cpp +++ b/rpcs3/Emu/RSX/VK/VKTexture.cpp @@ -514,7 +514,7 @@ namespace vk ensure(!dst_rect.is_flipped()); auto stretch_image_typeless_unsafe = [&cmd, filter](vk::image* src, vk::image* dst, vk::image* typeless, - const areai& src_rect, const areai& dst_rect, VkImageAspectFlags aspect, VkImageAspectFlags transfer_flags = 0xFF) + const areai& src_rect, const areai& dst_rect, VkImageAspectFlags /*aspect*/, VkImageAspectFlags transfer_flags = 0xFF) { const auto src_w = src_rect.width(); const auto src_h = src_rect.height(); @@ -834,7 +834,7 @@ namespace vk } void upload_image(const vk::command_buffer& cmd, vk::image* dst_image, - const std::vector& subresource_layout, int format, bool is_swizzled, u16 mipmap_count, + const std::vector& subresource_layout, int format, bool is_swizzled, u16 /*mipmap_count*/, VkImageAspectFlags flags, vk::data_heap &upload_heap, u32 heap_align, rsx::flags32_t image_setup_flags) { const bool requires_depth_processing = (dst_image->aspect() & VK_IMAGE_ASPECT_STENCIL_BIT) || (format == CELL_GCM_TEXTURE_DEPTH16_FLOAT); diff --git a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp index 48c7cb3581..3b2fe975f8 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexBuffers.cpp @@ -95,7 +95,7 @@ namespace { } - vertex_input_state operator()(const rsx::draw_array_command& command) + vertex_input_state operator()(const rsx::draw_array_command& /*command*/) { bool primitives_emulated = false; VkPrimitiveTopology prims = vk::get_appropriate_topology( @@ -195,7 +195,7 @@ namespace return {prims, true, min_index, max_index, index_count, index_offset, index_info}; } - vertex_input_state operator()(const rsx::draw_inlined_array& command) + vertex_input_state operator()(const rsx::draw_inlined_array& /*command*/) { bool primitives_emulated = false; auto &draw_clause = rsx::method_registers.current_draw_clause; diff --git a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp index b7b9076c6f..081a1e50ad 100644 --- a/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp +++ b/rpcs3/Emu/RSX/VK/VKVertexProgram.cpp @@ -12,7 +12,7 @@ std::string VKVertexDecompilerThread::getFloatTypeName(usz elementCount) return glsl::getFloatTypeNameImpl(elementCount); } -std::string VKVertexDecompilerThread::getIntTypeName(usz elementCount) +std::string VKVertexDecompilerThread::getIntTypeName(usz /*elementCount*/) { return "ivec4"; } @@ -73,7 +73,7 @@ void VKVertexDecompilerThread::insertHeader(std::stringstream &OS) inputs.push_back(in); } -void VKVertexDecompilerThread::insertInputs(std::stringstream & OS, const std::vector& inputs) +void VKVertexDecompilerThread::insertInputs(std::stringstream& OS, const std::vector& /*inputs*/) { OS << "layout(set=0, binding=5) uniform usamplerBuffer persistent_input_stream;\n"; // Data stream with persistent vertex data (cacheable) OS << "layout(set=0, binding=6) uniform usamplerBuffer volatile_input_stream;\n"; // Data stream with per-draw data (registers and immediate draw data) @@ -169,7 +169,7 @@ static const vertex_reg_info reg_table[] = { "tc9", true, "dst_reg6", "", false, "", "", "", true, CELL_GCM_ATTRIB_OUTPUT_MASK_TEX9 } // In this line, dst_reg6 is correct since dst_reg goes from 0 to 15. }; -void VKVertexDecompilerThread::insertOutputs(std::stringstream & OS, const std::vector & outputs) +void VKVertexDecompilerThread::insertOutputs(std::stringstream& OS, const std::vector& /*outputs*/) { for (auto &i : reg_table) { diff --git a/rpcs3/Emu/RSX/VK/vkutils/memory.cpp b/rpcs3/Emu/RSX/VK/vkutils/memory.cpp index 4781344e63..78f2a6f67b 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/memory.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/memory.cpp @@ -239,7 +239,7 @@ namespace vk return 0ull; } - void* memory_block_host::map(u64 offset, u64 size) + void* memory_block_host::map(u64 offset, u64 /*size*/) { return reinterpret_cast(m_host_pointer) + offset; } diff --git a/rpcs3/Emu/RSX/VK/vkutils/shared.cpp b/rpcs3/Emu/RSX/VK/vkutils/shared.cpp index 756a99df52..e9580bd23f 100644 --- a/rpcs3/Emu/RSX/VK/vkutils/shared.cpp +++ b/rpcs3/Emu/RSX/VK/vkutils/shared.cpp @@ -1,6 +1,10 @@ #include "shared.h" #include "util/logs.hpp" +#ifndef _WIN32 +#include +#endif + namespace vk { void die_with_error(VkResult error_code, std::string message, @@ -109,9 +113,9 @@ namespace vk } } - VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, - u64 srcObject, usz location, s32 msgCode, - const char* pLayerPrefix, const char* pMsg, void* pUserData) + VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT /*objType*/, + u64 /*srcObject*/, usz /*location*/, s32 msgCode, + const char* pLayerPrefix, const char* pMsg, void* /*pUserData*/) { if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { @@ -133,12 +137,19 @@ namespace vk return false; } + // Temporarily +#ifndef _MSC_VER +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + VkBool32 BreakCallback(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, u64 srcObject, usz location, s32 msgCode, const char* pLayerPrefix, const char* pMsg, void* pUserData) { #ifdef _WIN32 DebugBreak(); +#else + raise(SIGTRAP); #endif return false; diff --git a/rpcs3/Emu/RSX/gcm_printing.cpp b/rpcs3/Emu/RSX/gcm_printing.cpp index 16ce949b85..b0df9a18cb 100644 --- a/rpcs3/Emu/RSX/gcm_printing.cpp +++ b/rpcs3/Emu/RSX/gcm_printing.cpp @@ -990,7 +990,7 @@ namespace } template - std::array create_printing_table(std::integer_sequence seq) + std::array create_printing_table(std::integer_sequence) { std::array result{}; diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index 4ccd0bb5ea..1cb2d41353 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -15,20 +15,20 @@ namespace rsx std::array methods{}; - void invalid_method(thread* rsx, u32 _reg, u32 arg) + void invalid_method(thread* rsx, u32 reg, u32 arg) { //Don't throw, gather information and ignore broken/garbage commands //TODO: Investigate why these commands are executed at all. (Heap corruption? Alignment padding?) const u32 cmd = rsx->get_fifo_cmd(); - rsx_log.error("Invalid RSX method 0x%x (arg=0x%x, start=0x%x, count=0x%x, non-inc=%s)", _reg << 2, arg, + rsx_log.error("Invalid RSX method 0x%x (arg=0x%x, start=0x%x, count=0x%x, non-inc=%s)", reg << 2, arg, cmd & 0xfffc, (cmd >> 18) & 0x7ff, !!(cmd & RSX_METHOD_NON_INCREMENT_CMD)); rsx->recover_fifo(); } - static void trace_method(thread* rsx, u32 _reg, u32 arg) + static void trace_method(thread* /*rsx*/, u32 reg, u32 arg) { // For unknown yet valid methods - rsx_log.trace("RSX method 0x%x (arg=0x%x)", _reg << 2, arg); + rsx_log.trace("RSX method 0x%x (arg=0x%x)", reg << 2, arg); } template struct vertex_data_type_from_element_type; @@ -40,7 +40,7 @@ namespace rsx namespace nv406e { - void set_reference(thread* rsx, u32 _reg, u32 arg) + void set_reference(thread* rsx, u32 /*reg*/, u32 arg) { rsx->sync(); @@ -48,7 +48,7 @@ namespace rsx vm::_ref>(rsx->dma_address + ::offset32(&RsxDmaControl::get)).store(u64{rsx->fifo_ctrl->get_pos()} << 32 | arg); } - void semaphore_acquire(thread* rsx, u32 /*_reg*/, u32 arg) + void semaphore_acquire(thread* rsx, u32 /*reg*/, u32 arg) { rsx->sync_point_request.release(true); const u32 addr = get_address(method_registers.semaphore_offset_406e(), method_registers.semaphore_context_dma_406e()); @@ -114,7 +114,7 @@ namespace rsx rsx->performance_counters.idle_time += (get_system_time() - start); } - void semaphore_release(thread* rsx, u32 /*_reg*/, u32 arg) + void semaphore_release(thread* rsx, u32 /*reg*/, u32 arg) { rsx->sync(); @@ -150,7 +150,7 @@ namespace rsx namespace nv4097 { - void clear(thread* rsx, u32 _reg, u32 arg) + void clear(thread* rsx, u32 /*reg*/, u32 arg) { rsx->clear_surface(arg); @@ -160,7 +160,7 @@ namespace rsx } } - void clear_zcull(thread* rsx, u32 _reg, u32 arg) + void clear_zcull(thread* rsx, u32 /*reg*/, u32 /*arg*/) { if (rsx->capture_current_frame) { @@ -168,9 +168,9 @@ namespace rsx } } - void set_cull_face(thread* rsx, u32 reg, u32 arg) + void set_cull_face(thread* /*rsx*/, u32 reg, u32 arg) { - switch(arg) + switch (arg) { case CELL_GCM_FRONT_AND_BACK: case CELL_GCM_FRONT: @@ -182,7 +182,7 @@ namespace rsx } } - void set_notify(thread* rsx, u32 _reg, u32 arg) + void set_notify(thread* rsx, u32 /*reg*/, u32 /*arg*/) { const u32 location = method_registers.context_dma_notify(); const u32 index = (location & 0x7) ^ 0x7; @@ -204,7 +204,7 @@ namespace rsx }); } - void texture_read_semaphore_release(thread* rsx, u32 _reg, u32 arg) + void texture_read_semaphore_release(thread* rsx, u32 /*reg*/, u32 arg) { // Pipeline barrier seems to be equivalent to a SHADER_READ stage barrier g_fxo->get().sync(); @@ -227,7 +227,7 @@ namespace rsx vm::_ref(get_address(offset, method_registers.semaphore_context_dma_4097())).val = arg; } - void back_end_write_semaphore_release(thread* rsx, u32 _reg, u32 arg) + void back_end_write_semaphore_release(thread* rsx, u32 /*reg*/, u32 arg) { // Full pipeline barrier g_fxo->get().sync(); @@ -295,7 +295,7 @@ namespace rsx template struct set_vertex_data4ub_m { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 arg) { set_vertex_data_impl(rsx, arg); } @@ -304,7 +304,7 @@ namespace rsx template struct set_vertex_data1f_m { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 arg) { set_vertex_data_impl(rsx, arg); } @@ -313,7 +313,7 @@ namespace rsx template struct set_vertex_data2f_m { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 arg) { set_vertex_data_impl(rsx, arg); } @@ -322,7 +322,7 @@ namespace rsx template struct set_vertex_data3f_m { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 arg) { //Register alignment is only 1, 2, or 4 (Rachet & Clank 2) set_vertex_data_impl(rsx, arg); @@ -332,7 +332,7 @@ namespace rsx template struct set_vertex_data4f_m { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 arg) { set_vertex_data_impl(rsx, arg); } @@ -341,7 +341,7 @@ namespace rsx template struct set_vertex_data2s_m { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 arg) { set_vertex_data_impl(rsx, arg); } @@ -350,7 +350,7 @@ namespace rsx template struct set_vertex_data4s_m { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 arg) { set_vertex_data_impl(rsx, arg); } @@ -359,7 +359,7 @@ namespace rsx template struct set_vertex_data_scaled4s_m { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 arg) { set_vertex_data_impl(rsx, arg); } @@ -380,7 +380,7 @@ namespace rsx rsx->append_array_element(arg); } - void draw_arrays(thread* rsx, u32 _reg, u32 arg) + void draw_arrays(thread* /*rsx*/, u32 /*reg*/, u32 arg) { rsx::method_registers.current_draw_clause.command = rsx::draw_command::array; rsx::registers_decoder::decoded_type v(arg); @@ -388,7 +388,7 @@ namespace rsx rsx::method_registers.current_draw_clause.append(v.start(), v.count()); } - void draw_index_array(thread* rsx, u32 _reg, u32 arg) + void draw_index_array(thread* /*rsx*/, u32 /*reg*/, u32 arg) { rsx::method_registers.current_draw_clause.command = rsx::draw_command::indexed; rsx::registers_decoder::decoded_type v(arg); @@ -396,7 +396,7 @@ namespace rsx rsx::method_registers.current_draw_clause.append(v.start(), v.count()); } - void draw_inline_array(thread* rsx, u32 _reg, u32 arg) + void draw_inline_array(thread* /*rsx*/, u32 /*reg*/, u32 arg) { rsx::method_registers.current_draw_clause.command = rsx::draw_command::inlined_array; rsx::method_registers.current_draw_clause.inline_vertex_array.push_back(arg); @@ -405,7 +405,7 @@ namespace rsx template struct set_transform_constant { - static void impl(thread* rsx, u32 /*_reg*/, u32 /*arg*/) + static void impl(thread* rsx, u32 /*reg*/, u32 /*arg*/) { static constexpr u32 reg = index / 4; static constexpr u8 subreg = index % 4; @@ -451,7 +451,7 @@ namespace rsx template struct set_transform_program { - static void impl(thread* rsx, u32 /*_reg*/, u32 /*arg*/) + static void impl(thread* rsx, u32 /*reg*/, u32 /*arg*/) { // Get real args count const u32 count = std::min({rsx->fifo_ctrl->get_remaining_args_count() + 1, @@ -496,7 +496,7 @@ namespace rsx } } - void set_begin_end(thread* rsxthr, u32 _reg, u32 arg) + void set_begin_end(thread* rsxthr, u32 /*reg*/, u32 arg) { // Ignore upper bits if (const u8 prim = static_cast(arg)) @@ -575,7 +575,7 @@ namespace rsx return vm::cast(get_address(offset, location)); } - void get_report(thread* rsx, u32 _reg, u32 arg) + void get_report(thread* rsx, u32 /*reg*/, u32 arg) { u8 type = arg >> 24; u32 offset = arg & 0xffffff; @@ -608,7 +608,7 @@ namespace rsx } } - void clear_report_value(thread* rsx, u32 _reg, u32 arg) + void clear_report_value(thread* rsx, u32 /*reg*/, u32 arg) { switch (arg) { @@ -790,7 +790,7 @@ namespace rsx } } - void set_blend_equation(thread* rsx, u32 reg, u32 arg) + void set_blend_equation(thread* /*rsx*/, u32 reg, u32 arg) { for (u32 i = 0; i < 32u; i += 16) { @@ -816,7 +816,7 @@ namespace rsx } } - void set_blend_factor(thread* rsx, u32 reg, u32 arg) + void set_blend_factor(thread* /*rsx*/, u32 reg, u32 arg) { for (u32 i = 0; i < 32u; i += 16) { @@ -850,7 +850,7 @@ namespace rsx template struct set_texture_dirty_bit { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 /*arg*/) { rsx->m_textures_dirty[index] = true; @@ -864,7 +864,7 @@ namespace rsx template struct set_vertex_texture_dirty_bit { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* rsx, u32 /*reg*/, u32 /*arg*/) { rsx->m_vertex_textures_dirty[index] = true; @@ -881,7 +881,7 @@ namespace rsx template struct color { - static void impl(thread* rsx, u32 /*_reg*/, u32 /*arg*/) + static void impl(thread* rsx, u32 /*reg*/, u32 /*arg*/) { const u32 out_x_max = method_registers.nv308a_size_out_x(); @@ -1002,7 +1002,7 @@ namespace rsx namespace nv3089 { - void image_in(thread *rsx, u32 _reg, u32 arg) + void image_in(thread* rsx, u32 /*reg*/, u32 /*arg*/) { const rsx::blit_engine::transfer_operation operation = method_registers.blit_engine_operation(); @@ -1471,7 +1471,7 @@ namespace rsx namespace nv0039 { - void buffer_notify(thread *rsx, u32, u32 arg) + void buffer_notify(thread* rsx, u32, u32 arg) { s32 in_pitch = method_registers.nv0039_input_pitch(); s32 out_pitch = method_registers.nv0039_output_pitch(); @@ -1618,7 +1618,7 @@ namespace rsx template struct driver_flip { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* /*rsx*/, u32 /*reg*/, u32 arg) { sys_rsx_context_attribute(0x55555555, 0x102, index, arg, 0, 0); } @@ -1627,7 +1627,7 @@ namespace rsx template struct queue_flip { - static void impl(thread* rsx, u32 _reg, u32 arg) + static void impl(thread* /*rsx*/, u32 /*reg*/, u32 arg) { sys_rsx_context_attribute(0x55555555, 0x103, index, arg, 0, 0); } diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index b2da648fef..865474e174 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -230,8 +230,8 @@ namespace rsx { CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_REMAP, CELL_GCM_TEXTURE_REMAP_REMAP } }; - template - void pad_texture(void* input_pixels, void* output_pixels, u16 input_width, u16 input_height, u16 output_width, u16 output_height) + template + void pad_texture(void* input_pixels, void* output_pixels, u16 input_width, u16 input_height, u16 output_width, u16 /*output_height*/) { T *src = static_cast(input_pixels); T *dst = static_cast(output_pixels); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index f090962b13..4d4765f962 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -363,7 +363,7 @@ namespace dlg->type.se_normal = true; dlg->type.bg_invisible = true; dlg->type.progress_bar_count = 1; - dlg->on_close = [](s32 status) + dlg->on_close = [](s32 /*status*/) { Emu.CallAfter([]() { @@ -1924,7 +1924,7 @@ void Emulator::Stop(bool restart) aw_colc = 0; aw_used = 0; - atomic_wait::parse_hashtable([](u64 id, u32 refs, u64 ptr, u32 maxc) -> bool + atomic_wait::parse_hashtable([](u64 /*id*/, u32 refs, u64 ptr, u32 maxc) -> bool { aw_refs += refs != 0; aw_used += ptr != 0; diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index 8bfd2d5c7c..482873c215 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -744,7 +744,7 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2 return path.starts_with(from) && (path.size() == from.size() || path[from.size()] == fs::delim[0] || path[from.size()] == fs::delim[1]); }; - idm::select([&](u32 id, lv2_file& file) + idm::select([&](u32 /*id*/, lv2_file& file) { if (check_path(fs::escape_path(file.real_path))) { @@ -773,7 +773,7 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2 const auto fs_error = fs::g_tls_error; - idm::select([&](u32 id, lv2_file& file) + idm::select([&](u32 /*id*/, lv2_file& file) { const auto escaped_real = fs::escape_path(file.real_path); @@ -797,7 +797,7 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2 return res; } -bool vfs::host::unlink(const std::string& path, const std::string& dev_root) +bool vfs::host::unlink(const std::string& path, [[maybe_unused]] const std::string& dev_root) { #ifdef _WIN32 if (auto device = fs::get_virtual_device(path)) @@ -831,7 +831,7 @@ bool vfs::host::unlink(const std::string& path, const std::string& dev_root) #endif } -bool vfs::host::remove_all(const std::string& path, const std::string& dev_root, const lv2_fs_mount_point* mp, bool remove_root) +bool vfs::host::remove_all(const std::string& path, [[maybe_unused]] const std::string& dev_root, [[maybe_unused]] const lv2_fs_mount_point* mp, bool remove_root) { #ifdef _WIN32 if (remove_root) diff --git a/rpcs3/Input/keyboard_pad_handler.cpp b/rpcs3/Input/keyboard_pad_handler.cpp index 692ee55f6a..56ffff1230 100644 --- a/rpcs3/Input/keyboard_pad_handler.cpp +++ b/rpcs3/Input/keyboard_pad_handler.cpp @@ -613,7 +613,7 @@ u32 keyboard_pad_handler::GetKeyCode(const QString& keyName) return key_code; } -int keyboard_pad_handler::native_scan_code_from_string(const std::string& key) +int keyboard_pad_handler::native_scan_code_from_string([[maybe_unused]] const std::string& key) { // NOTE: Qt throws a Ctrl key at us when using Alt Gr, so there is no point in distinguishing left and right Alt at the moment #ifdef _WIN32 diff --git a/rpcs3/Loader/TRP.cpp b/rpcs3/Loader/TRP.cpp index 36f80553ba..655eaf651a 100644 --- a/rpcs3/Loader/TRP.cpp +++ b/rpcs3/Loader/TRP.cpp @@ -11,7 +11,7 @@ TRPLoader::TRPLoader(const fs::file& f) { } -bool TRPLoader::Install(const std::string& dest, bool show) +bool TRPLoader::Install(const std::string& dest, bool /*show*/) { if (!trp_f) { diff --git a/rpcs3/cmake_modules/ConfigureCompiler.cmake b/rpcs3/cmake_modules/ConfigureCompiler.cmake index 2e03d92109..bc10dfa600 100644 --- a/rpcs3/cmake_modules/ConfigureCompiler.cmake +++ b/rpcs3/cmake_modules/ConfigureCompiler.cmake @@ -32,6 +32,7 @@ else() add_compile_options(-Werror=reorder) add_compile_options(-Werror=return-type) add_compile_options(-Werror=overloaded-virtual) + add_compile_options(-Wunused-parameter) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Werror=inconsistent-missing-override) diff --git a/rpcs3/rpcs3qt/save_manager_dialog.cpp b/rpcs3/rpcs3qt/save_manager_dialog.cpp index 40a0bd8859..1e9f974217 100644 --- a/rpcs3/rpcs3qt/save_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/save_manager_dialog.cpp @@ -111,7 +111,7 @@ save_manager_dialog::save_manager_dialog(std::shared_ptr gui_setti /* * Future proofing. Makes it easier in future if I add ability to change directories */ -void save_manager_dialog::Init(std::string dir) +void save_manager_dialog::Init(std::string /*dir*/) { // Table m_list = new QTableWidget(this); diff --git a/rpcs3/util/atomic.cpp b/rpcs3/util/atomic.cpp index 8bc7c44b6b..79fd107ba2 100644 --- a/rpcs3/util/atomic.cpp +++ b/rpcs3/util/atomic.cpp @@ -1296,7 +1296,7 @@ SAFE_BUFFERS(void) atomic_wait_engine::wait(const void* data, u32 size, u128 old } template -static u32 alert_sema(u32 cond_id, const void* data, u64 tid, u32 size, u128 mask, u128 phantom) +static u32 alert_sema(u32 cond_id, u64 tid, u32 size, u128 mask, u128 phantom) { ensure(cond_id); @@ -1483,7 +1483,7 @@ bool atomic_wait_engine::raw_notify(const void* data, u64 thread_id) root_info::slot_search(iptr, 0, thread_id, u128(-1), [&](u32 cond_id) { // Forced notification - if (alert_sema(cond_id, data, thread_id, 0, 0, 0)) + if (alert_sema(cond_id, thread_id, 0, 0, 0)) { if (s_tls_notify_cb) s_tls_notify_cb(data, ++progress); @@ -1517,7 +1517,7 @@ void atomic_wait_engine::notify_one(const void* data, u32 size, u128 mask, u128 root_info::slot_search(iptr, size, 0, mask, [&](u32 cond_id) { - if (alert_sema(cond_id, data, -1, size, mask, new_value)) + if (alert_sema(cond_id, -1, size, mask, new_value)) { if (s_tls_notify_cb) s_tls_notify_cb(data, ++progress); @@ -1548,7 +1548,7 @@ SAFE_BUFFERS(void) atomic_wait_engine::notify_all(const void* data, u32 size, u1 root_info::slot_search(iptr, size, 0, mask, [&](u32 cond_id) { - u32 res = alert_sema(cond_id, data, -1, size, mask, 0); + u32 res = alert_sema(cond_id, -1, size, mask, 0); if (res && ~res <= UINT16_MAX) { diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index 9ada74dac3..72e83b5761 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -106,7 +106,7 @@ namespace logs ~root_listener() override = default; // Encode level, current thread name, channel name and write log message - void log(u64 stamp, const message& msg, const std::string& prefix, const std::string& text) override + void log(u64, const message&, const std::string&, const std::string&) override { // Do nothing } diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 802a2d3908..cdb77fdd15 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -725,7 +725,7 @@ struct narrow_impl static_assert(std::is_void::value, "narrow_impl<> specialization not found"); // Returns true if value cannot be represented in type To - static constexpr bool test(const From& value) + static constexpr bool test(const From&) { // Unspecialized cases (including cast to void) always considered narrowing return true;