summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-10-20 19:28:52 +0200
committerLiam <byteslice@airmail.cc>2023-10-20 19:29:52 +0200
commit12ebc8d9d15e01f67614b4da909881b6a87bdc13 (patch)
tree85976f3894a2f5d4c9eb807df803b1de789396f0 /src/core/hle/service
parentMerge pull request #11748 from liamwhite/kern_1700 (diff)
downloadyuzu-12ebc8d9d15e01f67614b4da909881b6a87bdc13.tar
yuzu-12ebc8d9d15e01f67614b4da909881b6a87bdc13.tar.gz
yuzu-12ebc8d9d15e01f67614b4da909881b6a87bdc13.tar.bz2
yuzu-12ebc8d9d15e01f67614b4da909881b6a87bdc13.tar.lz
yuzu-12ebc8d9d15e01f67614b4da909881b6a87bdc13.tar.xz
yuzu-12ebc8d9d15e01f67614b4da909881b6a87bdc13.tar.zst
yuzu-12ebc8d9d15e01f67614b4da909881b6a87bdc13.zip
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/set/set_sys.cpp49
1 files changed, 30 insertions, 19 deletions
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 @@
#include "common/logging/log.h"
#include "common/settings.h"
#include "common/string_util.h"
+#include "core/core.h"
+#include "core/file_sys/content_archive.h"
#include "core/file_sys/errors.h"
-#include "core/file_sys/system_archive/system_version.h"
+#include "core/file_sys/nca_metadata.h"
+#include "core/file_sys/registered_cache.h"
+#include "core/file_sys/romfs.h"
+#include "core/file_sys/system_archive/system_archive.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/ipc_helpers.h"
#include "core/hle/service/set/set.h"
@@ -22,18 +27,30 @@ enum class GetFirmwareVersionType {
Version2,
};
-void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type) {
- LOG_WARNING(Service_SET, "called - Using hardcoded firmware version '{}'",
- FileSys::SystemArchive::GetLongDisplayVersion());
-
+void GetFirmwareVersionImpl(Core::System& system, HLERequestContext& ctx,
+ GetFirmwareVersionType type) {
ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100,
"FirmwareVersion output buffer must be 0x100 bytes in size!");
- // Instead of using the normal procedure of checking for the real system archive and if it
- // doesn't exist, synthesizing one, I feel that that would lead to strange bugs because a
- // used is using a really old or really new SystemVersion title. The synthesized one ensures
- // consistence (currently reports as 5.1.0-0.0)
- const auto archive = FileSys::SystemArchive::SystemVersion();
+ constexpr u64 FirmwareVersionSystemDataId = 0x0100000000000809;
+ auto& fsc = system.GetFileSystemController();
+
+ // Attempt to load version data from disk
+ const FileSys::RegisteredCache* bis_system{};
+ std::unique_ptr<FileSys::NCA> nca{};
+ FileSys::VirtualDir romfs{};
+
+ bis_system = fsc.GetSystemNANDContents();
+ if (bis_system) {
+ nca = bis_system->GetEntry(FirmwareVersionSystemDataId, FileSys::ContentRecordType::Data);
+ }
+ if (nca) {
+ romfs = FileSys::ExtractRomFS(nca->GetRomFS());
+ }
+ if (!romfs) {
+ romfs = FileSys::ExtractRomFS(
+ FileSys::SystemArchive::SynthesizeSystemArchive(FirmwareVersionSystemDataId));
+ }
const auto early_exit_failure = [&ctx](std::string_view desc, Result code) {
LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).",
@@ -42,13 +59,7 @@ void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type)
rb.Push(code);
};
- if (archive == nullptr) {
- early_exit_failure("The system version archive couldn't be synthesized.",
- FileSys::ERROR_FAILED_MOUNT_ARCHIVE);
- return;
- }
-
- const auto ver_file = archive->GetFile("file");
+ const auto ver_file = romfs->GetFile("file");
if (ver_file == nullptr) {
early_exit_failure("The system version archive didn't contain the file 'file'.",
FileSys::ERROR_INVALID_ARGUMENT);
@@ -87,12 +98,12 @@ void SET_SYS::SetLanguageCode(HLERequestContext& ctx) {
void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) {
LOG_DEBUG(Service_SET, "called");
- GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version1);
+ GetFirmwareVersionImpl(system, ctx, GetFirmwareVersionType::Version1);
}
void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) {
LOG_DEBUG(Service_SET, "called");
- GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version2);
+ GetFirmwareVersionImpl(system, ctx, GetFirmwareVersionType::Version2);
}
void SET_SYS::GetAccountSettings(HLERequestContext& ctx) {