From ed82bb968a2ec785485345aa202143df57c0f8fe Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sun, 10 Mar 2019 16:51:42 -0400 Subject: set_sys: Implement GetFirmwareVersion(2) for libnx hosversion Uses the synthesized system archive 9 (SystemVersion) and reports v5.1.0-0.0 --- .../file_sys/system_archive/system_archive.cpp | 3 +- .../file_sys/system_archive/system_version.cpp | 48 ++++++++++++++++++++++ src/core/file_sys/system_archive/system_version.h | 13 ++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/core/file_sys/system_archive/system_version.cpp create mode 100644 src/core/file_sys/system_archive/system_version.h (limited to 'src/core/file_sys') diff --git a/src/core/file_sys/system_archive/system_archive.cpp b/src/core/file_sys/system_archive/system_archive.cpp index e3e79f40a..c9722ed77 100644 --- a/src/core/file_sys/system_archive/system_archive.cpp +++ b/src/core/file_sys/system_archive/system_archive.cpp @@ -6,6 +6,7 @@ #include "core/file_sys/romfs.h" #include "core/file_sys/system_archive/ng_word.h" #include "core/file_sys/system_archive/system_archive.h" +#include "core/file_sys/system_archive/system_version.h" namespace FileSys::SystemArchive { @@ -30,7 +31,7 @@ constexpr std::array SYSTEM_ARCHI {0x0100000000000806, "NgWord", &NgWord1}, {0x0100000000000807, "SsidList", nullptr}, {0x0100000000000808, "Dictionary", nullptr}, - {0x0100000000000809, "SystemVersion", nullptr}, + {0x0100000000000809, "SystemVersion", &SystemVersion}, {0x010000000000080A, "AvatarImage", nullptr}, {0x010000000000080B, "LocalNews", nullptr}, {0x010000000000080C, "Eula", nullptr}, diff --git a/src/core/file_sys/system_archive/system_version.cpp b/src/core/file_sys/system_archive/system_version.cpp new file mode 100644 index 000000000..3fc5f9586 --- /dev/null +++ b/src/core/file_sys/system_archive/system_version.cpp @@ -0,0 +1,48 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/file_sys/system_archive/system_version.h" +#include "core/file_sys/vfs_vector.h" + +namespace FileSys::SystemArchive { + +namespace SystemVersionData { + +// This section should reflect the best system version to describe yuzu's HLE api. +// TODO(DarkLordZach): Update when HLE gets better. + +constexpr u8 VERSION_MAJOR = 5; +constexpr u8 VERSION_MINOR = 1; +constexpr u8 VERSION_MICRO = 0; + +constexpr u8 REVISION_MAJOR = 0; +constexpr u8 REVISION_MINOR = 0; + +constexpr char PLATFORM_STRING[] = "YUZU"; +constexpr char VERSION_HASH[] = ""; +constexpr char DISPLAY_VERSION[] = "5.1.0"; +constexpr char DISPLAY_TITLE[] = "YuzuEmulated Firmware for NX 5.1.0-0.0"; + +} // namespace SystemVersionData + +VirtualDir SystemVersion() { + VirtualFile file = std::make_shared(std::vector(0x100), "file"); + file->WriteObject(SystemVersionData::VERSION_MAJOR, 0); + file->WriteObject(SystemVersionData::VERSION_MINOR, 1); + file->WriteObject(SystemVersionData::VERSION_MICRO, 2); + file->WriteObject(SystemVersionData::REVISION_MAJOR, 4); + file->WriteObject(SystemVersionData::REVISION_MINOR, 5); + file->WriteArray(SystemVersionData::PLATFORM_STRING, + std::min(sizeof(SystemVersionData::PLATFORM_STRING), 0x20ull), 0x8); + file->WriteArray(SystemVersionData::VERSION_HASH, + std::min(sizeof(SystemVersionData::VERSION_HASH), 0x40ull), 0x28); + file->WriteArray(SystemVersionData::DISPLAY_VERSION, + std::min(sizeof(SystemVersionData::DISPLAY_VERSION), 0x18ull), 0x68); + file->WriteArray(SystemVersionData::DISPLAY_TITLE, + std::min(sizeof(SystemVersionData::DISPLAY_TITLE), 0x80ull), 0x80); + return std::make_shared(std::vector{file}, + std::vector{}, "data"); +} + +} // namespace FileSys::SystemArchive diff --git a/src/core/file_sys/system_archive/system_version.h b/src/core/file_sys/system_archive/system_version.h new file mode 100644 index 000000000..9fb794b36 --- /dev/null +++ b/src/core/file_sys/system_archive/system_version.h @@ -0,0 +1,13 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/file_sys/vfs_types.h" + +namespace FileSys::SystemArchive { + +VirtualDir SystemVersion(); + +} // namespace FileSys::SystemArchive -- cgit v1.2.3