diff options
| author | 2023-10-21 18:22:20 -0400 | |
|---|---|---|
| committer | 2023-10-21 18:22:20 -0400 | |
| commit | db37e583ffea39a4d25a8eb3eeea0cf825ec6661 (patch) | |
| tree | ff1954fea1d5b31f5af19cabdc9dd4c36d12dd30 | |
| parent | Merge pull request #11830 from liamwhite/ts-session (diff) | |
| parent | set: return version info from system archive (diff) | |
| download | yuzu-db37e583ffea39a4d25a8eb3eeea0cf825ec6661.tar.gz yuzu-db37e583ffea39a4d25a8eb3eeea0cf825ec6661.tar.xz yuzu-db37e583ffea39a4d25a8eb3eeea0cf825ec6661.zip | |
Merge pull request #11831 from liamwhite/hosversionbetween
set: return version info from system archive
| -rw-r--r-- | src/core/file_sys/system_archive/system_version.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/set/set_sys.cpp | 49 |
2 files changed, 34 insertions, 19 deletions
diff --git a/src/core/file_sys/system_archive/system_version.cpp b/src/core/file_sys/system_archive/system_version.cpp index bd493ecca..e4751c2b4 100644 --- a/src/core/file_sys/system_archive/system_version.cpp +++ b/src/core/file_sys/system_archive/system_version.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/logging/log.h" | ||
| 4 | #include "core/file_sys/system_archive/system_version.h" | 5 | #include "core/file_sys/system_archive/system_version.h" |
| 5 | #include "core/file_sys/vfs_vector.h" | 6 | #include "core/file_sys/vfs_vector.h" |
| 6 | #include "core/hle/api_version.h" | 7 | #include "core/hle/api_version.h" |
| @@ -12,6 +13,9 @@ std::string GetLongDisplayVersion() { | |||
| 12 | } | 13 | } |
| 13 | 14 | ||
| 14 | VirtualDir SystemVersion() { | 15 | VirtualDir SystemVersion() { |
| 16 | LOG_WARNING(Common_Filesystem, "called - Using hardcoded firmware version '{}'", | ||
| 17 | GetLongDisplayVersion()); | ||
| 18 | |||
| 15 | VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file"); | 19 | VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file"); |
| 16 | file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0); | 20 | file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0); |
| 17 | file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1); | 21 | file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1); |
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp index 165b97dad..ec3af80af 100644 --- a/src/core/hle/service/set/set_sys.cpp +++ b/src/core/hle/service/set/set_sys.cpp | |||
| @@ -5,8 +5,13 @@ | |||
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "common/settings.h" | 6 | #include "common/settings.h" |
| 7 | #include "common/string_util.h" | 7 | #include "common/string_util.h" |
| 8 | #include "core/core.h" | ||
| 9 | #include "core/file_sys/content_archive.h" | ||
| 8 | #include "core/file_sys/errors.h" | 10 | #include "core/file_sys/errors.h" |
| 9 | #include "core/file_sys/system_archive/system_version.h" | 11 | #include "core/file_sys/nca_metadata.h" |
| 12 | #include "core/file_sys/registered_cache.h" | ||
| 13 | #include "core/file_sys/romfs.h" | ||
| 14 | #include "core/file_sys/system_archive/system_archive.h" | ||
| 10 | #include "core/hle/service/filesystem/filesystem.h" | 15 | #include "core/hle/service/filesystem/filesystem.h" |
| 11 | #include "core/hle/service/ipc_helpers.h" | 16 | #include "core/hle/service/ipc_helpers.h" |
| 12 | #include "core/hle/service/set/set.h" | 17 | #include "core/hle/service/set/set.h" |
| @@ -22,18 +27,30 @@ enum class GetFirmwareVersionType { | |||
| 22 | Version2, | 27 | Version2, |
| 23 | }; | 28 | }; |
| 24 | 29 | ||
| 25 | void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type) { | 30 | void GetFirmwareVersionImpl(Core::System& system, HLERequestContext& ctx, |
| 26 | LOG_WARNING(Service_SET, "called - Using hardcoded firmware version '{}'", | 31 | GetFirmwareVersionType type) { |
| 27 | FileSys::SystemArchive::GetLongDisplayVersion()); | ||
| 28 | |||
| 29 | ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100, | 32 | ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100, |
| 30 | "FirmwareVersion output buffer must be 0x100 bytes in size!"); | 33 | "FirmwareVersion output buffer must be 0x100 bytes in size!"); |
| 31 | 34 | ||
| 32 | // Instead of using the normal procedure of checking for the real system archive and if it | 35 | constexpr u64 FirmwareVersionSystemDataId = 0x0100000000000809; |
| 33 | // doesn't exist, synthesizing one, I feel that that would lead to strange bugs because a | 36 | auto& fsc = system.GetFileSystemController(); |
| 34 | // used is using a really old or really new SystemVersion title. The synthesized one ensures | 37 | |
| 35 | // consistence (currently reports as 5.1.0-0.0) | 38 | // Attempt to load version data from disk |
| 36 | const auto archive = FileSys::SystemArchive::SystemVersion(); | 39 | const FileSys::RegisteredCache* bis_system{}; |
| 40 | std::unique_ptr<FileSys::NCA> nca{}; | ||
| 41 | FileSys::VirtualDir romfs{}; | ||
| 42 | |||
| 43 | bis_system = fsc.GetSystemNANDContents(); | ||
| 44 | if (bis_system) { | ||
| 45 | nca = bis_system->GetEntry(FirmwareVersionSystemDataId, FileSys::ContentRecordType::Data); | ||
| 46 | } | ||
| 47 | if (nca) { | ||
| 48 | romfs = FileSys::ExtractRomFS(nca->GetRomFS()); | ||
| 49 | } | ||
| 50 | if (!romfs) { | ||
| 51 | romfs = FileSys::ExtractRomFS( | ||
| 52 | FileSys::SystemArchive::SynthesizeSystemArchive(FirmwareVersionSystemDataId)); | ||
| 53 | } | ||
| 37 | 54 | ||
| 38 | const auto early_exit_failure = [&ctx](std::string_view desc, Result code) { | 55 | const auto early_exit_failure = [&ctx](std::string_view desc, Result code) { |
| 39 | LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).", | 56 | LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).", |
| @@ -42,13 +59,7 @@ void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type) | |||
| 42 | rb.Push(code); | 59 | rb.Push(code); |
| 43 | }; | 60 | }; |
| 44 | 61 | ||
| 45 | if (archive == nullptr) { | 62 | const auto ver_file = romfs->GetFile("file"); |
| 46 | early_exit_failure("The system version archive couldn't be synthesized.", | ||
| 47 | FileSys::ERROR_FAILED_MOUNT_ARCHIVE); | ||
| 48 | return; | ||
| 49 | } | ||
| 50 | |||
| 51 | const auto ver_file = archive->GetFile("file"); | ||
| 52 | if (ver_file == nullptr) { | 63 | if (ver_file == nullptr) { |
| 53 | early_exit_failure("The system version archive didn't contain the file 'file'.", | 64 | early_exit_failure("The system version archive didn't contain the file 'file'.", |
| 54 | FileSys::ERROR_INVALID_ARGUMENT); | 65 | FileSys::ERROR_INVALID_ARGUMENT); |
| @@ -87,12 +98,12 @@ void SET_SYS::SetLanguageCode(HLERequestContext& ctx) { | |||
| 87 | 98 | ||
| 88 | void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) { | 99 | void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) { |
| 89 | LOG_DEBUG(Service_SET, "called"); | 100 | LOG_DEBUG(Service_SET, "called"); |
| 90 | GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version1); | 101 | GetFirmwareVersionImpl(system, ctx, GetFirmwareVersionType::Version1); |
| 91 | } | 102 | } |
| 92 | 103 | ||
| 93 | void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) { | 104 | void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) { |
| 94 | LOG_DEBUG(Service_SET, "called"); | 105 | LOG_DEBUG(Service_SET, "called"); |
| 95 | GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version2); | 106 | GetFirmwareVersionImpl(system, ctx, GetFirmwareVersionType::Version2); |
| 96 | } | 107 | } |
| 97 | 108 | ||
| 98 | void SET_SYS::GetAccountSettings(HLERequestContext& ctx) { | 109 | void SET_SYS::GetAccountSettings(HLERequestContext& ctx) { |