From dd43d725c619980bb07d3cae0410b15c51dbdfd7 Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Thu, 23 Apr 2020 13:05:50 +0100 Subject: [PATCH 1/5] Dump RomFS command to include Updates Patch the RomFS with the selected updates before dumping. Previously the resulting RomFS only contained data from the original title. To dump the RomFS without updates the user can disable the update under Properties before choosing Dump RomFS. --- src/yuzu/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 05baec7e13..506f753072 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1304,7 +1304,9 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa FileSys::VirtualFile romfs; if (*romfs_title_id == program_id) { - romfs = file; + u64 ivfc_offset = loader->ReadRomFSIVFCOffset(); + FileSys::PatchManager pm{program_id}; + romfs = pm.PatchRomFS(file, ivfc_offset, FileSys::ContentRecordType::Program); } else { romfs = installed.GetEntry(*romfs_title_id, FileSys::ContentRecordType::Data)->GetRomFS(); } From bcd0444bb93e600c7d36c992802152de18c8c3aa Mon Sep 17 00:00:00 2001 From: Ben Russell Date: Thu, 23 Apr 2020 13:10:06 +0100 Subject: [PATCH 2/5] Update src/yuzu/main.cpp with missing const Co-Authored-By: Mat M. --- src/yuzu/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 506f753072..b44b4276ca 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1304,7 +1304,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa FileSys::VirtualFile romfs; if (*romfs_title_id == program_id) { - u64 ivfc_offset = loader->ReadRomFSIVFCOffset(); + const u64 ivfc_offset = loader->ReadRomFSIVFCOffset(); FileSys::PatchManager pm{program_id}; romfs = pm.PatchRomFS(file, ivfc_offset, FileSys::ContentRecordType::Program); } else { From cc84b48ce5b981bbdc737931c1030f8d3ff3f32b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 24 Apr 2020 00:07:38 -0400 Subject: [PATCH 3/5] physical_core: Make use of std::make_unique instead of std::make_shared in ctor We can also allow unicorn to be constructed in 32-bit mode or 64-bit mode to satisfy the need for both interpreter instances. Allows this code to compile successfully of non x86-64 architectures. --- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 7 +++---- src/core/arm/unicorn/arm_unicorn.cpp | 5 +++-- src/core/arm/unicorn/arm_unicorn.h | 7 ++++++- src/core/hle/kernel/physical_core.cpp | 4 +++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 65cbfe5e60..337b97be94 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -185,10 +185,9 @@ void ARM_Dynarmic_64::Step() { ARM_Dynarmic_64::ARM_Dynarmic_64(System& system, ExclusiveMonitor& exclusive_monitor, std::size_t core_index) - : ARM_Interface{system}, - cb(std::make_unique(*this)), inner_unicorn{system}, - core_index{core_index}, exclusive_monitor{ - dynamic_cast(exclusive_monitor)} {} + : ARM_Interface{system}, cb(std::make_unique(*this)), + inner_unicorn{system, ARM_Unicorn::Arch::AArch64}, core_index{core_index}, + exclusive_monitor{dynamic_cast(exclusive_monitor)} {} ARM_Dynarmic_64::~ARM_Dynarmic_64() = default; diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp index b965831232..e40e9626a3 100644 --- a/src/core/arm/unicorn/arm_unicorn.cpp +++ b/src/core/arm/unicorn/arm_unicorn.cpp @@ -62,8 +62,9 @@ static bool UnmappedMemoryHook(uc_engine* uc, uc_mem_type type, u64 addr, int si return false; } -ARM_Unicorn::ARM_Unicorn(System& system) : ARM_Interface{system} { - CHECKED(uc_open(UC_ARCH_ARM64, UC_MODE_ARM, &uc)); +ARM_Unicorn::ARM_Unicorn(System& system, Arch architecture) : ARM_Interface{system} { + const auto arch = architecture == Arch::AArch32 ? UC_ARCH_ARM : UC_ARCH_ARM64; + CHECKED(uc_open(arch, UC_MODE_ARM, &uc)); auto fpv = 3 << 20; CHECKED(uc_reg_write(uc, UC_ARM64_REG_CPACR_EL1, &fpv)); diff --git a/src/core/arm/unicorn/arm_unicorn.h b/src/core/arm/unicorn/arm_unicorn.h index f30d13cb69..725c650851 100644 --- a/src/core/arm/unicorn/arm_unicorn.h +++ b/src/core/arm/unicorn/arm_unicorn.h @@ -15,7 +15,12 @@ class System; class ARM_Unicorn final : public ARM_Interface { public: - explicit ARM_Unicorn(System& system); + enum class Arch { + AArch32, // 32-bit ARM + AArch64, // 64-bit ARM + }; + + explicit ARM_Unicorn(System& system, Arch architecture); ~ARM_Unicorn() override; void SetPC(u64 pc) override; diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index aa2787467e..a150110767 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -27,7 +27,9 @@ PhysicalCore::PhysicalCore(Core::System& system, std::size_t id, std::make_unique(system, exclusive_monitor, core_index); #else - arm_interface = std::make_shared(system); + using Core::ARM_Unicorn; + arm_interface_32 = std::make_unique(system, ARM_Unicorn::Arch::AArch32); + arm_interface_64 = std::make_unique(system, ARM_Unicorn::Arch::AArch64); LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available"); #endif From b4dbf1b9c7a69ee7ba9682fe0d6c8377f0512a34 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Wed, 29 Apr 2020 11:15:21 +1000 Subject: [PATCH 4/5] Don't fail silently for vi, sm, set and ns services --- src/core/hle/service/ns/ns.cpp | 8 ++++++++ src/core/hle/service/set/set.cpp | 1 + src/core/hle/service/sm/sm.cpp | 12 +++++++++--- src/core/hle/service/vi/vi.cpp | 9 +++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 8fb88990ee..7e5ceccdb4 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp @@ -371,10 +371,15 @@ ResultVal IApplicationManagerInterface::GetApplicationDesiredLanguage( // Convert to application language, get priority list const auto application_language = ConvertToApplicationLanguage(language_code); if (application_language == std::nullopt) { + LOG_ERROR(Service_NS, "Could not convert application language! language_code={}", + language_code); return ERR_APPLICATION_LANGUAGE_NOT_FOUND; } const auto priority_list = GetApplicationLanguagePriorityList(*application_language); if (!priority_list) { + LOG_ERROR(Service_NS, + "Could not find application language priorities! application_language={}", + *application_language); return ERR_APPLICATION_LANGUAGE_NOT_FOUND; } @@ -386,6 +391,8 @@ ResultVal IApplicationManagerInterface::GetApplicationDesiredLanguage( } } + LOG_ERROR(Service_NS, "Could not find a valid language! supported_languages={:08X}", + supported_languages); return ERR_APPLICATION_LANGUAGE_NOT_FOUND; } @@ -410,6 +417,7 @@ ResultVal IApplicationManagerInterface::ConvertApplicationLanguageToLanguag const auto language_code = ConvertToLanguageCode(static_cast(application_language)); if (language_code == std::nullopt) { + LOG_ERROR(Service_NS, "Language not found! application_language={}", application_language); return ERR_APPLICATION_LANGUAGE_NOT_FOUND; } diff --git a/src/core/hle/service/set/set.cpp b/src/core/hle/service/set/set.cpp index 9e12c76fc0..f3b4b286cd 100644 --- a/src/core/hle/service/set/set.cpp +++ b/src/core/hle/service/set/set.cpp @@ -67,6 +67,7 @@ void SET::MakeLanguageCode(Kernel::HLERequestContext& ctx) { const auto index = rp.Pop(); if (index >= available_language_codes.size()) { + LOG_ERROR(Service_SET, "Invalid language code index! index={}", index); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_INVALID_LANGUAGE); return; diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 88909504da..6ada13be44 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -28,9 +28,11 @@ void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { static ResultCode ValidateServiceName(const std::string& name) { if (name.size() <= 0 || name.size() > 8) { + LOG_ERROR(Service_SM, "Invalid service name! service={}", name); return ERR_INVALID_NAME; } if (name.find('\0') != std::string::npos) { + LOG_ERROR(Service_SM, "A non null terminated service was passed"); return ERR_INVALID_NAME; } return RESULT_SUCCESS; @@ -51,8 +53,10 @@ ResultVal> ServiceManager::RegisterService( CASCADE_CODE(ValidateServiceName(name)); - if (registered_services.find(name) != registered_services.end()) + if (registered_services.find(name) != registered_services.end()) { + LOG_ERROR(Service_SM, "Service is already registered! service={}", name); return ERR_ALREADY_REGISTERED; + } auto& kernel = Core::System::GetInstance().Kernel(); auto [server_port, client_port] = @@ -66,9 +70,10 @@ ResultCode ServiceManager::UnregisterService(const std::string& name) { CASCADE_CODE(ValidateServiceName(name)); const auto iter = registered_services.find(name); - if (iter == registered_services.end()) + if (iter == registered_services.end()) { + LOG_ERROR(Service_SM, "Server is not registered! service={}", name); return ERR_SERVICE_NOT_REGISTERED; - + } registered_services.erase(iter); return RESULT_SUCCESS; } @@ -79,6 +84,7 @@ ResultVal> ServiceManager::GetServicePort( CASCADE_CODE(ValidateServiceName(name)); auto it = registered_services.find(name); if (it == registered_services.end()) { + LOG_ERROR(Service_SM, "Server is not registered! service={}", name); return ERR_SERVICE_NOT_REGISTERED; } diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 9390ca83d4..46e14c2a3f 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -867,6 +867,7 @@ private: const auto layer_id = nv_flinger->CreateLayer(display); if (!layer_id) { + LOG_ERROR(Service_VI, "Layer not found! display=0x{:016X}", display); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_NOT_FOUND); return; @@ -983,6 +984,7 @@ private: const auto display_id = nv_flinger->OpenDisplay(name); if (!display_id) { + LOG_ERROR(Service_VI, "Display not found! display_name={}", name); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_NOT_FOUND); return; @@ -1082,6 +1084,7 @@ private: const auto display_id = nv_flinger->OpenDisplay(display_name); if (!display_id) { + LOG_ERROR(Service_VI, "Layer not found! layer_id={}", layer_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_NOT_FOUND); return; @@ -1089,6 +1092,7 @@ private: const auto buffer_queue_id = nv_flinger->FindBufferQueueId(*display_id, layer_id); if (!buffer_queue_id) { + LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", *display_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_NOT_FOUND); return; @@ -1124,6 +1128,7 @@ private: const auto layer_id = nv_flinger->CreateLayer(display_id); if (!layer_id) { + LOG_ERROR(Service_VI, "Layer not found! layer_id={}", *layer_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_NOT_FOUND); return; @@ -1131,6 +1136,7 @@ private: const auto buffer_queue_id = nv_flinger->FindBufferQueueId(display_id, *layer_id); if (!buffer_queue_id) { + LOG_ERROR(Service_VI, "Buffer queue id not found! display_id={}", display_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_NOT_FOUND); return; @@ -1161,6 +1167,7 @@ private: const auto vsync_event = nv_flinger->FindVsyncEvent(display_id); if (!vsync_event) { + LOG_ERROR(Service_VI, "Vsync event was not found for display_id={}", display_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_NOT_FOUND); return; @@ -1201,6 +1208,7 @@ private: case NintendoScaleMode::PreserveAspectRatio: return MakeResult(ConvertedScaleMode::PreserveAspectRatio); default: + LOG_ERROR(Service_VI, "Invalid scaling mode specified, mode={}", mode); return ERR_OPERATION_FAILED; } } @@ -1257,6 +1265,7 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, const auto policy = rp.PopEnum(); if (!IsValidServiceAccess(permission, policy)) { + LOG_ERROR(Service_VI, "Permission denied for policy {}", static_cast(policy)); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ERR_PERMISSION_DENIED); return; From b7a69501cd4b6187bfcac4ee59e5b663420f908d Mon Sep 17 00:00:00 2001 From: MerryMage Date: Wed, 29 Apr 2020 14:25:53 +0100 Subject: [PATCH 5/5] externals: Update dynarmic to e7166e8b --- externals/dynarmic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/dynarmic b/externals/dynarmic index a3cd05577c..e7166e8ba7 160000 --- a/externals/dynarmic +++ b/externals/dynarmic @@ -1 +1 @@ -Subproject commit a3cd05577c9b6c51f0f345d0e915b6feab68fe12 +Subproject commit e7166e8ba74d7b9c85e87afc0aaf667e7e84cfe0