summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-06-28 21:02:34 -0400
committerGravatar Zach Hilman2019-06-28 21:02:34 -0400
commitdb2fdd0352d023787fcac032101e1e36fb8aa03f (patch)
treefe785b7af5776cb9dc76de107ca5124d8d56a5ed /src
parentMerge pull request #2548 from DarkLordZach/applet-shopn (diff)
downloadyuzu-db2fdd0352d023787fcac032101e1e36fb8aa03f.tar.gz
yuzu-db2fdd0352d023787fcac032101e1e36fb8aa03f.tar.xz
yuzu-db2fdd0352d023787fcac032101e1e36fb8aa03f.zip
fsp-srv: Implement OutputAccessLogToSdCard
Allows games to log data to the SD.
Diffstat (limited to 'src')
-rw-r--r--src/core/core.cpp2
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp10
-rw-r--r--src/core/hle/service/filesystem/filesystem.h2
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp43
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.h24
-rw-r--r--src/core/hle/service/service.cpp5
-rw-r--r--src/core/hle/service/service.h3
7 files changed, 62 insertions, 27 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index df26eb109..678fa8cea 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -142,7 +142,7 @@ struct System::Impl {
142 telemetry_session = std::make_unique<Core::TelemetrySession>(); 142 telemetry_session = std::make_unique<Core::TelemetrySession>();
143 service_manager = std::make_shared<Service::SM::ServiceManager>(); 143 service_manager = std::make_shared<Service::SM::ServiceManager>();
144 144
145 Service::Init(service_manager, system, *virtual_filesystem); 145 Service::Init(service_manager, system);
146 GDBStub::Init(); 146 GDBStub::Init();
147 147
148 renderer = VideoCore::CreateRenderer(emu_window, system); 148 renderer = VideoCore::CreateRenderer(emu_window, system);
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index 1ebfeb4bf..8ce110dd1 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -472,12 +472,12 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) {
472 } 472 }
473} 473}
474 474
475void InstallInterfaces(SM::ServiceManager& service_manager, FileSys::VfsFilesystem& vfs) { 475void InstallInterfaces(Core::System& system) {
476 romfs_factory = nullptr; 476 romfs_factory = nullptr;
477 CreateFactories(vfs, false); 477 CreateFactories(*system.GetFilesystem(), false);
478 std::make_shared<FSP_LDR>()->InstallAsService(service_manager); 478 std::make_shared<FSP_LDR>()->InstallAsService(system.ServiceManager());
479 std::make_shared<FSP_PR>()->InstallAsService(service_manager); 479 std::make_shared<FSP_PR>()->InstallAsService(system.ServiceManager());
480 std::make_shared<FSP_SRV>()->InstallAsService(service_manager); 480 std::make_shared<FSP_SRV>(system.GetReporter())->InstallAsService(system.ServiceManager());
481} 481}
482 482
483} // namespace Service::FileSystem 483} // namespace Service::FileSystem
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h
index 6481f237c..3849dd89e 100644
--- a/src/core/hle/service/filesystem/filesystem.h
+++ b/src/core/hle/service/filesystem/filesystem.h
@@ -65,7 +65,7 @@ FileSys::VirtualDir GetModificationDumpRoot(u64 title_id);
65// above is called. 65// above is called.
66void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite = true); 66void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite = true);
67 67
68void InstallInterfaces(SM::ServiceManager& service_manager, FileSys::VfsFilesystem& vfs); 68void InstallInterfaces(Core::System& system);
69 69
70// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of 70// A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of
71// pointers and booleans. This makes using a VfsDirectory with switch services much easier and 71// pointers and booleans. This makes using a VfsDirectory with switch services much easier and
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index e7df8fd98..bfe0c32b7 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -26,6 +26,7 @@
26#include "core/hle/kernel/process.h" 26#include "core/hle/kernel/process.h"
27#include "core/hle/service/filesystem/filesystem.h" 27#include "core/hle/service/filesystem/filesystem.h"
28#include "core/hle/service/filesystem/fsp_srv.h" 28#include "core/hle/service/filesystem/fsp_srv.h"
29#include "core/reporter.h"
29 30
30namespace Service::FileSystem { 31namespace Service::FileSystem {
31 32
@@ -613,7 +614,7 @@ private:
613 u64 next_entry_index = 0; 614 u64 next_entry_index = 0;
614}; 615};
615 616
616FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { 617FSP_SRV::FSP_SRV(const Core::Reporter& reporter) : ServiceFramework("fsp-srv"), reporter(reporter) {
617 // clang-format off 618 // clang-format off
618 static const FunctionInfo functions[] = { 619 static const FunctionInfo functions[] = {
619 {0, nullptr, "OpenFileSystem"}, 620 {0, nullptr, "OpenFileSystem"},
@@ -710,9 +711,9 @@ FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") {
710 {1001, nullptr, "SetSaveDataSize"}, 711 {1001, nullptr, "SetSaveDataSize"},
711 {1002, nullptr, "SetSaveDataRootPath"}, 712 {1002, nullptr, "SetSaveDataRootPath"},
712 {1003, nullptr, "DisableAutoSaveDataCreation"}, 713 {1003, nullptr, "DisableAutoSaveDataCreation"},
713 {1004, nullptr, "SetGlobalAccessLogMode"}, 714 {1004, &FSP_SRV::SetGlobalAccessLogMode, "SetGlobalAccessLogMode"},
714 {1005, &FSP_SRV::GetGlobalAccessLogMode, "GetGlobalAccessLogMode"}, 715 {1005, &FSP_SRV::GetGlobalAccessLogMode, "GetGlobalAccessLogMode"},
715 {1006, nullptr, "OutputAccessLogToSdCard"}, 716 {1006, &FSP_SRV::OutputAccessLogToSdCard, "OutputAccessLogToSdCard"},
716 {1007, nullptr, "RegisterUpdatePartition"}, 717 {1007, nullptr, "RegisterUpdatePartition"},
717 {1008, nullptr, "OpenRegisteredUpdatePartition"}, 718 {1008, nullptr, "OpenRegisteredUpdatePartition"},
718 {1009, nullptr, "GetAndClearMemoryReportInfo"}, 719 {1009, nullptr, "GetAndClearMemoryReportInfo"},
@@ -814,21 +815,22 @@ void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext&
814 rb.PushIpcInterface<ISaveDataInfoReader>(std::make_shared<ISaveDataInfoReader>(space)); 815 rb.PushIpcInterface<ISaveDataInfoReader>(std::make_shared<ISaveDataInfoReader>(space));
815} 816}
816 817
817void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { 818void FSP_SRV::SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
818 LOG_WARNING(Service_FS, "(STUBBED) called"); 819 IPC::RequestParser rp{ctx};
820 log_mode = rp.PopEnum<LogMode>();
819 821
820 enum class LogMode : u32 { 822 LOG_DEBUG(Service_FS, "called, log_mode={:08X}", static_cast<u32>(log_mode));
821 Off, 823
822 Log, 824 IPC::ResponseBuilder rb{ctx, 2};
823 RedirectToSdCard, 825 rb.Push(RESULT_SUCCESS);
824 LogToSdCard = Log | RedirectToSdCard, 826}
825 }; 827
828void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) {
829 LOG_WARNING(Service_FS, "called");
826 830
827 // Given we always want to receive logging information,
828 // we always specify logging as enabled.
829 IPC::ResponseBuilder rb{ctx, 3}; 831 IPC::ResponseBuilder rb{ctx, 3};
830 rb.Push(RESULT_SUCCESS); 832 rb.Push(RESULT_SUCCESS);
831 rb.PushEnum(LogMode::Log); 833 rb.PushEnum(log_mode);
832} 834}
833 835
834void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) { 836void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
@@ -902,4 +904,17 @@ void FSP_SRV::OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ct
902 rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND); 904 rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND);
903} 905}
904 906
907void FSP_SRV::OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx) {
908 const auto raw = ctx.ReadBuffer();
909 auto log = Common::StringFromFixedZeroTerminatedBuffer(
910 reinterpret_cast<const char*>(raw.data()), raw.size());
911
912 LOG_DEBUG(Service_FS, "called, log='{}'", log);
913
914 reporter.SaveFilesystemAccessReport(log_mode, std::move(log));
915
916 IPC::ResponseBuilder rb{ctx, 2};
917 rb.Push(RESULT_SUCCESS);
918}
919
905} // namespace Service::FileSystem 920} // namespace Service::FileSystem
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h
index d7572ba7a..bfaeaad5d 100644
--- a/src/core/hle/service/filesystem/fsp_srv.h
+++ b/src/core/hle/service/filesystem/fsp_srv.h
@@ -7,15 +7,32 @@
7#include <memory> 7#include <memory>
8#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
9 9
10namespace Core {
11class Reporter;
12}
13
10namespace FileSys { 14namespace FileSys {
11class FileSystemBackend; 15class FileSystemBackend;
12} 16}
13 17
14namespace Service::FileSystem { 18namespace Service::FileSystem {
15 19
20enum class AccessLogVersion : u32 {
21 V7_0_0 = 2,
22
23 Latest = V7_0_0,
24};
25
26enum class LogMode : u32 {
27 Off,
28 Log,
29 RedirectToSdCard,
30 LogToSdCard = Log | RedirectToSdCard,
31};
32
16class FSP_SRV final : public ServiceFramework<FSP_SRV> { 33class FSP_SRV final : public ServiceFramework<FSP_SRV> {
17public: 34public:
18 explicit FSP_SRV(); 35 explicit FSP_SRV(const Core::Reporter& reporter);
19 ~FSP_SRV() override; 36 ~FSP_SRV() override;
20 37
21private: 38private:
@@ -26,13 +43,18 @@ private:
26 void OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx); 43 void OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx);
27 void OpenReadOnlySaveDataFileSystem(Kernel::HLERequestContext& ctx); 44 void OpenReadOnlySaveDataFileSystem(Kernel::HLERequestContext& ctx);
28 void OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext& ctx); 45 void OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext& ctx);
46 void SetGlobalAccessLogMode(Kernel::HLERequestContext& ctx);
29 void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); 47 void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx);
30 void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); 48 void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx);
31 void OpenDataStorageByDataId(Kernel::HLERequestContext& ctx); 49 void OpenDataStorageByDataId(Kernel::HLERequestContext& ctx);
32 void OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); 50 void OpenPatchDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx);
51 void OutputAccessLogToSdCard(Kernel::HLERequestContext& ctx);
33 52
34 FileSys::VirtualFile romfs; 53 FileSys::VirtualFile romfs;
35 u64 current_process_id = 0; 54 u64 current_process_id = 0;
55 LogMode log_mode;
56
57 const Core::Reporter& reporter;
36}; 58};
37 59
38} // namespace Service::FileSystem 60} // namespace Service::FileSystem
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index ec9d755b7..60155f2d0 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -195,8 +195,7 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co
195// Module interface 195// Module interface
196 196
197/// Initialize ServiceManager 197/// Initialize ServiceManager
198void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system, 198void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) {
199 FileSys::VfsFilesystem& vfs) {
200 // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it 199 // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it
201 // here and pass it into the respective InstallInterfaces functions. 200 // here and pass it into the respective InstallInterfaces functions.
202 auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(system.CoreTiming()); 201 auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(system.CoreTiming());
@@ -218,7 +217,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system,
218 EUPLD::InstallInterfaces(*sm); 217 EUPLD::InstallInterfaces(*sm);
219 Fatal::InstallInterfaces(*sm); 218 Fatal::InstallInterfaces(*sm);
220 FGM::InstallInterfaces(*sm); 219 FGM::InstallInterfaces(*sm);
221 FileSystem::InstallInterfaces(*sm, vfs); 220 FileSystem::InstallInterfaces(system);
222 Friend::InstallInterfaces(*sm); 221 Friend::InstallInterfaces(*sm);
223 Glue::InstallInterfaces(system); 222 Glue::InstallInterfaces(system);
224 GRC::InstallInterfaces(*sm); 223 GRC::InstallInterfaces(*sm);
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index abbfe5524..c6c4bdae5 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -182,8 +182,7 @@ private:
182}; 182};
183 183
184/// Initialize ServiceManager 184/// Initialize ServiceManager
185void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system, 185void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system);
186 FileSys::VfsFilesystem& vfs);
187 186
188/// Shutdown ServiceManager 187/// Shutdown ServiceManager
189void Shutdown(); 188void Shutdown();