summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-03-10 16:51:42 -0400
committerGravatar Zach Hilman2019-03-10 16:51:42 -0400
commited82bb968a2ec785485345aa202143df57c0f8fe (patch)
tree3db6e12366aadee572fadd80920c9dcf3568d445
parentMerge pull request #2217 from ReinUsesLisp/rasterizer-logger (diff)
downloadyuzu-ed82bb968a2ec785485345aa202143df57c0f8fe.tar.gz
yuzu-ed82bb968a2ec785485345aa202143df57c0f8fe.tar.xz
yuzu-ed82bb968a2ec785485345aa202143df57c0f8fe.zip
set_sys: Implement GetFirmwareVersion(2) for libnx hosversion
Uses the synthesized system archive 9 (SystemVersion) and reports v5.1.0-0.0
Diffstat (limited to '')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/file_sys/system_archive/system_archive.cpp3
-rw-r--r--src/core/file_sys/system_archive/system_version.cpp48
-rw-r--r--src/core/file_sys/system_archive/system_version.h13
-rw-r--r--src/core/hle/service/set/set_sys.cpp63
-rw-r--r--src/core/hle/service/set/set_sys.h2
6 files changed, 128 insertions, 3 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 8ccb2d5f0..3f855dcb7 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -68,6 +68,8 @@ add_library(core STATIC
68 file_sys/system_archive/ng_word.h 68 file_sys/system_archive/ng_word.h
69 file_sys/system_archive/system_archive.cpp 69 file_sys/system_archive/system_archive.cpp
70 file_sys/system_archive/system_archive.h 70 file_sys/system_archive/system_archive.h
71 file_sys/system_archive/system_version.cpp
72 file_sys/system_archive/system_version.h
71 file_sys/vfs.cpp 73 file_sys/vfs.cpp
72 file_sys/vfs.h 74 file_sys/vfs.h
73 file_sys/vfs_concat.cpp 75 file_sys/vfs_concat.cpp
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 @@
6#include "core/file_sys/romfs.h" 6#include "core/file_sys/romfs.h"
7#include "core/file_sys/system_archive/ng_word.h" 7#include "core/file_sys/system_archive/ng_word.h"
8#include "core/file_sys/system_archive/system_archive.h" 8#include "core/file_sys/system_archive/system_archive.h"
9#include "core/file_sys/system_archive/system_version.h"
9 10
10namespace FileSys::SystemArchive { 11namespace FileSys::SystemArchive {
11 12
@@ -30,7 +31,7 @@ constexpr std::array<SystemArchiveDescriptor, SYSTEM_ARCHIVE_COUNT> SYSTEM_ARCHI
30 {0x0100000000000806, "NgWord", &NgWord1}, 31 {0x0100000000000806, "NgWord", &NgWord1},
31 {0x0100000000000807, "SsidList", nullptr}, 32 {0x0100000000000807, "SsidList", nullptr},
32 {0x0100000000000808, "Dictionary", nullptr}, 33 {0x0100000000000808, "Dictionary", nullptr},
33 {0x0100000000000809, "SystemVersion", nullptr}, 34 {0x0100000000000809, "SystemVersion", &SystemVersion},
34 {0x010000000000080A, "AvatarImage", nullptr}, 35 {0x010000000000080A, "AvatarImage", nullptr},
35 {0x010000000000080B, "LocalNews", nullptr}, 36 {0x010000000000080B, "LocalNews", nullptr},
36 {0x010000000000080C, "Eula", nullptr}, 37 {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 @@
1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "core/file_sys/system_archive/system_version.h"
6#include "core/file_sys/vfs_vector.h"
7
8namespace FileSys::SystemArchive {
9
10namespace SystemVersionData {
11
12// This section should reflect the best system version to describe yuzu's HLE api.
13// TODO(DarkLordZach): Update when HLE gets better.
14
15constexpr u8 VERSION_MAJOR = 5;
16constexpr u8 VERSION_MINOR = 1;
17constexpr u8 VERSION_MICRO = 0;
18
19constexpr u8 REVISION_MAJOR = 0;
20constexpr u8 REVISION_MINOR = 0;
21
22constexpr char PLATFORM_STRING[] = "YUZU";
23constexpr char VERSION_HASH[] = "";
24constexpr char DISPLAY_VERSION[] = "5.1.0";
25constexpr char DISPLAY_TITLE[] = "YuzuEmulated Firmware for NX 5.1.0-0.0";
26
27} // namespace SystemVersionData
28
29VirtualDir SystemVersion() {
30 VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file");
31 file->WriteObject(SystemVersionData::VERSION_MAJOR, 0);
32 file->WriteObject(SystemVersionData::VERSION_MINOR, 1);
33 file->WriteObject(SystemVersionData::VERSION_MICRO, 2);
34 file->WriteObject(SystemVersionData::REVISION_MAJOR, 4);
35 file->WriteObject(SystemVersionData::REVISION_MINOR, 5);
36 file->WriteArray(SystemVersionData::PLATFORM_STRING,
37 std::min(sizeof(SystemVersionData::PLATFORM_STRING), 0x20ull), 0x8);
38 file->WriteArray(SystemVersionData::VERSION_HASH,
39 std::min(sizeof(SystemVersionData::VERSION_HASH), 0x40ull), 0x28);
40 file->WriteArray(SystemVersionData::DISPLAY_VERSION,
41 std::min(sizeof(SystemVersionData::DISPLAY_VERSION), 0x18ull), 0x68);
42 file->WriteArray(SystemVersionData::DISPLAY_TITLE,
43 std::min(sizeof(SystemVersionData::DISPLAY_TITLE), 0x80ull), 0x80);
44 return std::make_shared<VectorVfsDirectory>(std::vector<VirtualFile>{file},
45 std::vector<VirtualDir>{}, "data");
46}
47
48} // 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 @@
1// Copyright 2019 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "core/file_sys/vfs_types.h"
8
9namespace FileSys::SystemArchive {
10
11VirtualDir SystemVersion();
12
13} // namespace FileSys::SystemArchive
diff --git a/src/core/hle/service/set/set_sys.cpp b/src/core/hle/service/set/set_sys.cpp
index c9b4da5b0..ddab0e36f 100644
--- a/src/core/hle/service/set/set_sys.cpp
+++ b/src/core/hle/service/set/set_sys.cpp
@@ -3,12 +3,71 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/file_sys/system_archive/system_version.h"
6#include "core/hle/ipc_helpers.h" 7#include "core/hle/ipc_helpers.h"
7#include "core/hle/kernel/client_port.h" 8#include "core/hle/kernel/client_port.h"
9#include "core/hle/service/filesystem/filesystem.h"
8#include "core/hle/service/set/set_sys.h" 10#include "core/hle/service/set/set_sys.h"
9 11
10namespace Service::Set { 12namespace Service::Set {
11 13
14void SET_SYS::GetFirmwareVersion(Kernel::HLERequestContext& ctx) {
15 LOG_DEBUG(Service_SET, "called");
16
17 ASSERT(ctx.GetWriteBufferSize() == 0x100,
18 "FirmwareVersion output buffer must be 0x100 bytes in size!");
19
20 // Instead of using the normal procedure of checking for the real system archive and if it
21 // doesn't exist, synthesizing one, I feel that that would lead to strange bugs because a used
22 // is using a really old or really new SystemVersion title. The synthesized one ensures
23 // consistence (currently reports as 5.1.0-0.0)
24 const auto archive = FileSys::SystemArchive::SystemVersion();
25
26 const auto early_exit_failure = [&ctx](const std::string& desc) {
27 LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).",
28 desc.c_str());
29 IPC::ResponseBuilder rb{ctx, 2};
30 rb.Push(ResultCode(-1));
31 };
32
33 if (archive == nullptr) {
34 early_exit_failure("The system version archive couldn't be synthesized.");
35 return;
36 }
37
38 const auto ver_file = archive->GetFile("file");
39 if (ver_file == nullptr) {
40 early_exit_failure("The system version archive didn't contain the file 'file'.");
41 return;
42 }
43
44 auto data = ver_file->ReadAllBytes();
45 if (data.size() != 0x100) {
46 early_exit_failure("The system version file 'file' was not the correct size.");
47 return;
48 }
49
50 // If the command is GetFirmwareVersion (as opposed to GetFirmwareVersion2), hardware will zero
51 // out the REVISION_MAJOR and REVISION_MICRO fields, which are u8s at offsets 0x4 and 0x5,
52 // respectively. This if statement will only execute when the true intended command is
53 // GetFirmwareVersion, and allows removing duplicate code for the implementation of
54 // GetFirmwareVersion2.
55 if (ctx.GetCommand() == 3) {
56 data[0x4] = 0x0;
57 data[0x5] = 0x0;
58 }
59
60 ctx.WriteBuffer(data);
61
62 IPC::ResponseBuilder rb{ctx, 2};
63 rb.Push(RESULT_SUCCESS);
64}
65
66void SET_SYS::GetFirmwareVersion2(Kernel::HLERequestContext& ctx) {
67 LOG_WARNING(Service_SET, "called - delegating to GetFirmwareVersion");
68 GetFirmwareVersion(ctx);
69}
70
12void SET_SYS::GetColorSetId(Kernel::HLERequestContext& ctx) { 71void SET_SYS::GetColorSetId(Kernel::HLERequestContext& ctx) {
13 LOG_DEBUG(Service_SET, "called"); 72 LOG_DEBUG(Service_SET, "called");
14 73
@@ -33,8 +92,8 @@ SET_SYS::SET_SYS() : ServiceFramework("set:sys") {
33 {0, nullptr, "SetLanguageCode"}, 92 {0, nullptr, "SetLanguageCode"},
34 {1, nullptr, "SetNetworkSettings"}, 93 {1, nullptr, "SetNetworkSettings"},
35 {2, nullptr, "GetNetworkSettings"}, 94 {2, nullptr, "GetNetworkSettings"},
36 {3, nullptr, "GetFirmwareVersion"}, 95 {3, &SET_SYS::GetFirmwareVersion, "GetFirmwareVersion"},
37 {4, nullptr, "GetFirmwareVersion2"}, 96 {4, &SET_SYS::GetFirmwareVersion2, "GetFirmwareVersion2"},
38 {5, nullptr, "GetFirmwareVersionDigest"}, 97 {5, nullptr, "GetFirmwareVersionDigest"},
39 {7, nullptr, "GetLockScreenFlag"}, 98 {7, nullptr, "GetLockScreenFlag"},
40 {8, nullptr, "SetLockScreenFlag"}, 99 {8, nullptr, "SetLockScreenFlag"},
diff --git a/src/core/hle/service/set/set_sys.h b/src/core/hle/service/set/set_sys.h
index f602f3c77..13ee2cf46 100644
--- a/src/core/hle/service/set/set_sys.h
+++ b/src/core/hle/service/set/set_sys.h
@@ -20,6 +20,8 @@ private:
20 BasicBlack = 1, 20 BasicBlack = 1,
21 }; 21 };
22 22
23 void GetFirmwareVersion(Kernel::HLERequestContext& ctx);
24 void GetFirmwareVersion2(Kernel::HLERequestContext& ctx);
23 void GetColorSetId(Kernel::HLERequestContext& ctx); 25 void GetColorSetId(Kernel::HLERequestContext& ctx);
24 void SetColorSetId(Kernel::HLERequestContext& ctx); 26 void SetColorSetId(Kernel::HLERequestContext& ctx);
25 27