diff options
| author | 2019-09-09 16:44:41 +1000 | |
|---|---|---|
| committer | 2019-09-09 16:44:41 +1000 | |
| commit | 1487153e06e47744a7238a012735e44916d3169a (patch) | |
| tree | 3be2575dc8eab73d83310f5d05d91fec8fa5c843 /src | |
| parent | Merge pull request #2763 from lioncash/map-phys (diff) | |
| parent | service/am: Remove usages of global system accessors (diff) | |
| download | yuzu-1487153e06e47744a7238a012735e44916d3169a.tar.gz yuzu-1487153e06e47744a7238a012735e44916d3169a.tar.xz yuzu-1487153e06e47744a7238a012735e44916d3169a.zip | |
Merge pull request #2716 from lioncash/hle-global
service/am: Remove usages of global system accessors
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 50 | ||||
| -rw-r--r-- | src/core/hle/service/am/am.h | 28 | ||||
| -rw-r--r-- | src/core/hle/service/am/applet_ae.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/service/am/applet_oe.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applets.cpp | 25 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applets.h | 17 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/error.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/error.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/general_backend.cpp | 13 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/general_backend.h | 12 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/profile_select.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/profile_select.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/software_keyboard.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/web_browser.cpp | 19 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/web_browser.h | 12 |
17 files changed, 143 insertions, 97 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 20d64f3b0..3d0978cbf 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -104,7 +104,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 104 | return vfs->OpenFile(path, FileSys::Mode::Read); | 104 | return vfs->OpenFile(path, FileSys::Mode::Read); |
| 105 | } | 105 | } |
| 106 | struct System::Impl { | 106 | struct System::Impl { |
| 107 | explicit Impl(System& system) : kernel{system}, cpu_core_manager{system}, reporter{system} {} | 107 | explicit Impl(System& system) |
| 108 | : kernel{system}, cpu_core_manager{system}, applet_manager{system}, reporter{system} {} | ||
| 108 | 109 | ||
| 109 | Cpu& CurrentCpuCore() { | 110 | Cpu& CurrentCpuCore() { |
| 110 | return cpu_core_manager.GetCurrentCore(); | 111 | return cpu_core_manager.GetCurrentCore(); |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 111633ba3..aa2c83937 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -56,7 +56,8 @@ struct LaunchParameters { | |||
| 56 | }; | 56 | }; |
| 57 | static_assert(sizeof(LaunchParameters) == 0x88); | 57 | static_assert(sizeof(LaunchParameters) == 0x88); |
| 58 | 58 | ||
| 59 | IWindowController::IWindowController() : ServiceFramework("IWindowController") { | 59 | IWindowController::IWindowController(Core::System& system_) |
| 60 | : ServiceFramework("IWindowController"), system{system_} { | ||
| 60 | // clang-format off | 61 | // clang-format off |
| 61 | static const FunctionInfo functions[] = { | 62 | static const FunctionInfo functions[] = { |
| 62 | {0, nullptr, "CreateWindow"}, | 63 | {0, nullptr, "CreateWindow"}, |
| @@ -75,7 +76,7 @@ IWindowController::IWindowController() : ServiceFramework("IWindowController") { | |||
| 75 | IWindowController::~IWindowController() = default; | 76 | IWindowController::~IWindowController() = default; |
| 76 | 77 | ||
| 77 | void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) { | 78 | void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) { |
| 78 | const u64 process_id = Core::System::GetInstance().Kernel().CurrentProcess()->GetProcessID(); | 79 | const u64 process_id = system.CurrentProcess()->GetProcessID(); |
| 79 | 80 | ||
| 80 | LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id); | 81 | LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id); |
| 81 | 82 | ||
| @@ -231,8 +232,9 @@ IDebugFunctions::IDebugFunctions() : ServiceFramework{"IDebugFunctions"} { | |||
| 231 | 232 | ||
| 232 | IDebugFunctions::~IDebugFunctions() = default; | 233 | IDebugFunctions::~IDebugFunctions() = default; |
| 233 | 234 | ||
| 234 | ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger) | 235 | ISelfController::ISelfController(Core::System& system_, |
| 235 | : ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger)) { | 236 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger_) |
| 237 | : ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger_)) { | ||
| 236 | // clang-format off | 238 | // clang-format off |
| 237 | static const FunctionInfo functions[] = { | 239 | static const FunctionInfo functions[] = { |
| 238 | {0, nullptr, "Exit"}, | 240 | {0, nullptr, "Exit"}, |
| @@ -280,7 +282,7 @@ ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger | |||
| 280 | 282 | ||
| 281 | RegisterHandlers(functions); | 283 | RegisterHandlers(functions); |
| 282 | 284 | ||
| 283 | auto& kernel = Core::System::GetInstance().Kernel(); | 285 | auto& kernel = system_.Kernel(); |
| 284 | launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, | 286 | launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, |
| 285 | "ISelfController:LaunchableEvent"); | 287 | "ISelfController:LaunchableEvent"); |
| 286 | 288 | ||
| @@ -501,8 +503,7 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest | |||
| 501 | rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable); | 503 | rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable); |
| 502 | } | 504 | } |
| 503 | 505 | ||
| 504 | AppletMessageQueue::AppletMessageQueue() { | 506 | AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) { |
| 505 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 506 | on_new_message = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, | 507 | on_new_message = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual, |
| 507 | "AMMessageQueue:OnMessageRecieved"); | 508 | "AMMessageQueue:OnMessageRecieved"); |
| 508 | on_operation_mode_changed = Kernel::WritableEvent::CreateEventPair( | 509 | on_operation_mode_changed = Kernel::WritableEvent::CreateEventPair( |
| @@ -937,9 +938,8 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) { | |||
| 937 | rb.Push(RESULT_SUCCESS); | 938 | rb.Push(RESULT_SUCCESS); |
| 938 | } | 939 | } |
| 939 | 940 | ||
| 940 | ILibraryAppletCreator::ILibraryAppletCreator(u64 current_process_title_id) | 941 | ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_) |
| 941 | : ServiceFramework("ILibraryAppletCreator"), | 942 | : ServiceFramework("ILibraryAppletCreator"), system{system_} { |
| 942 | current_process_title_id(current_process_title_id) { | ||
| 943 | static const FunctionInfo functions[] = { | 943 | static const FunctionInfo functions[] = { |
| 944 | {0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"}, | 944 | {0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"}, |
| 945 | {1, nullptr, "TerminateAllLibraryApplets"}, | 945 | {1, nullptr, "TerminateAllLibraryApplets"}, |
| @@ -961,8 +961,8 @@ void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) | |||
| 961 | LOG_DEBUG(Service_AM, "called with applet_id={:08X}, applet_mode={:08X}", | 961 | LOG_DEBUG(Service_AM, "called with applet_id={:08X}, applet_mode={:08X}", |
| 962 | static_cast<u32>(applet_id), applet_mode); | 962 | static_cast<u32>(applet_id), applet_mode); |
| 963 | 963 | ||
| 964 | const auto& applet_manager{Core::System::GetInstance().GetAppletManager()}; | 964 | const auto& applet_manager{system.GetAppletManager()}; |
| 965 | const auto applet = applet_manager.GetApplet(applet_id, current_process_title_id); | 965 | const auto applet = applet_manager.GetApplet(applet_id); |
| 966 | 966 | ||
| 967 | if (applet == nullptr) { | 967 | if (applet == nullptr) { |
| 968 | LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", static_cast<u32>(applet_id)); | 968 | LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", static_cast<u32>(applet_id)); |
| @@ -999,8 +999,7 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex | |||
| 999 | const auto handle{rp.Pop<Kernel::Handle>()}; | 999 | const auto handle{rp.Pop<Kernel::Handle>()}; |
| 1000 | 1000 | ||
| 1001 | const auto transfer_mem = | 1001 | const auto transfer_mem = |
| 1002 | Core::System::GetInstance().CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>( | 1002 | system.CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(handle); |
| 1003 | handle); | ||
| 1004 | 1003 | ||
| 1005 | if (transfer_mem == nullptr) { | 1004 | if (transfer_mem == nullptr) { |
| 1006 | LOG_ERROR(Service_AM, "shared_mem is a nullpr for handle={:08X}", handle); | 1005 | LOG_ERROR(Service_AM, "shared_mem is a nullpr for handle={:08X}", handle); |
| @@ -1018,7 +1017,8 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex | |||
| 1018 | rb.PushIpcInterface(std::make_shared<IStorage>(std::move(memory))); | 1017 | rb.PushIpcInterface(std::make_shared<IStorage>(std::move(memory))); |
| 1019 | } | 1018 | } |
| 1020 | 1019 | ||
| 1021 | IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationFunctions") { | 1020 | IApplicationFunctions::IApplicationFunctions(Core::System& system_) |
| 1021 | : ServiceFramework("IApplicationFunctions"), system{system_} { | ||
| 1022 | // clang-format off | 1022 | // clang-format off |
| 1023 | static const FunctionInfo functions[] = { | 1023 | static const FunctionInfo functions[] = { |
| 1024 | {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"}, | 1024 | {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"}, |
| @@ -1180,7 +1180,7 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { | |||
| 1180 | // Get supported languages from NACP, if possible | 1180 | // Get supported languages from NACP, if possible |
| 1181 | // Default to 0 (all languages supported) | 1181 | // Default to 0 (all languages supported) |
| 1182 | u32 supported_languages = 0; | 1182 | u32 supported_languages = 0; |
| 1183 | FileSys::PatchManager pm{Core::System::GetInstance().CurrentProcess()->GetTitleID()}; | 1183 | FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()}; |
| 1184 | 1184 | ||
| 1185 | const auto res = pm.GetControlMetadata(); | 1185 | const auto res = pm.GetControlMetadata(); |
| 1186 | if (res.first != nullptr) { | 1186 | if (res.first != nullptr) { |
| @@ -1188,8 +1188,8 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { | |||
| 1188 | } | 1188 | } |
| 1189 | 1189 | ||
| 1190 | // Call IApplicationManagerInterface implementation. | 1190 | // Call IApplicationManagerInterface implementation. |
| 1191 | auto& service_manager = Core::System::GetInstance().ServiceManager(); | 1191 | auto& service_manager = system.ServiceManager(); |
| 1192 | auto ns_am2 = service_manager.GetService<Service::NS::NS>("ns:am2"); | 1192 | auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2"); |
| 1193 | auto app_man = ns_am2->GetApplicationManagerInterface(); | 1193 | auto app_man = ns_am2->GetApplicationManagerInterface(); |
| 1194 | 1194 | ||
| 1195 | // Get desired application language | 1195 | // Get desired application language |
| @@ -1261,8 +1261,8 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) { | |||
| 1261 | "new_journal={:016X}", | 1261 | "new_journal={:016X}", |
| 1262 | static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size); | 1262 | static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size); |
| 1263 | 1263 | ||
| 1264 | FileSystem::WriteSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id, | 1264 | const auto title_id = system.CurrentProcess()->GetTitleID(); |
| 1265 | {new_normal_size, new_journal_size}); | 1265 | FileSystem::WriteSaveDataSize(type, title_id, user_id, {new_normal_size, new_journal_size}); |
| 1266 | 1266 | ||
| 1267 | IPC::ResponseBuilder rb{ctx, 4}; | 1267 | IPC::ResponseBuilder rb{ctx, 4}; |
| 1268 | rb.Push(RESULT_SUCCESS); | 1268 | rb.Push(RESULT_SUCCESS); |
| @@ -1281,8 +1281,8 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) { | |||
| 1281 | LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type), | 1281 | LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type), |
| 1282 | user_id[1], user_id[0]); | 1282 | user_id[1], user_id[0]); |
| 1283 | 1283 | ||
| 1284 | const auto size = | 1284 | const auto title_id = system.CurrentProcess()->GetTitleID(); |
| 1285 | FileSystem::ReadSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id); | 1285 | const auto size = FileSystem::ReadSaveDataSize(type, title_id, user_id); |
| 1286 | 1286 | ||
| 1287 | IPC::ResponseBuilder rb{ctx, 6}; | 1287 | IPC::ResponseBuilder rb{ctx, 6}; |
| 1288 | rb.Push(RESULT_SUCCESS); | 1288 | rb.Push(RESULT_SUCCESS); |
| @@ -1300,9 +1300,9 @@ void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestCon | |||
| 1300 | 1300 | ||
| 1301 | void InstallInterfaces(SM::ServiceManager& service_manager, | 1301 | void InstallInterfaces(SM::ServiceManager& service_manager, |
| 1302 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system) { | 1302 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system) { |
| 1303 | auto message_queue = std::make_shared<AppletMessageQueue>(); | 1303 | auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel()); |
| 1304 | message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); // Needed on | 1304 | // Needed on game boot |
| 1305 | // game boot | 1305 | message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); |
| 1306 | 1306 | ||
| 1307 | std::make_shared<AppletAE>(nvflinger, message_queue, system)->InstallAsService(service_manager); | 1307 | std::make_shared<AppletAE>(nvflinger, message_queue, system)->InstallAsService(service_manager); |
| 1308 | std::make_shared<AppletOE>(nvflinger, message_queue, system)->InstallAsService(service_manager); | 1308 | std::make_shared<AppletOE>(nvflinger, message_queue, system)->InstallAsService(service_manager); |
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index cbc9da7b6..28f870302 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -10,12 +10,15 @@ | |||
| 10 | #include "core/hle/kernel/writable_event.h" | 10 | #include "core/hle/kernel/writable_event.h" |
| 11 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 12 | 12 | ||
| 13 | namespace Service { | 13 | namespace Kernel { |
| 14 | namespace NVFlinger { | 14 | class KernelCore; |
| 15 | } | ||
| 16 | |||
| 17 | namespace Service::NVFlinger { | ||
| 15 | class NVFlinger; | 18 | class NVFlinger; |
| 16 | } | 19 | } |
| 17 | 20 | ||
| 18 | namespace AM { | 21 | namespace Service::AM { |
| 19 | 22 | ||
| 20 | enum SystemLanguage { | 23 | enum SystemLanguage { |
| 21 | Japanese = 0, | 24 | Japanese = 0, |
| @@ -47,7 +50,7 @@ public: | |||
| 47 | PerformanceModeChanged = 31, | 50 | PerformanceModeChanged = 31, |
| 48 | }; | 51 | }; |
| 49 | 52 | ||
| 50 | AppletMessageQueue(); | 53 | explicit AppletMessageQueue(Kernel::KernelCore& kernel); |
| 51 | ~AppletMessageQueue(); | 54 | ~AppletMessageQueue(); |
| 52 | 55 | ||
| 53 | const Kernel::SharedPtr<Kernel::ReadableEvent>& GetMesssageRecieveEvent() const; | 56 | const Kernel::SharedPtr<Kernel::ReadableEvent>& GetMesssageRecieveEvent() const; |
| @@ -65,12 +68,14 @@ private: | |||
| 65 | 68 | ||
| 66 | class IWindowController final : public ServiceFramework<IWindowController> { | 69 | class IWindowController final : public ServiceFramework<IWindowController> { |
| 67 | public: | 70 | public: |
| 68 | IWindowController(); | 71 | explicit IWindowController(Core::System& system_); |
| 69 | ~IWindowController() override; | 72 | ~IWindowController() override; |
| 70 | 73 | ||
| 71 | private: | 74 | private: |
| 72 | void GetAppletResourceUserId(Kernel::HLERequestContext& ctx); | 75 | void GetAppletResourceUserId(Kernel::HLERequestContext& ctx); |
| 73 | void AcquireForegroundRights(Kernel::HLERequestContext& ctx); | 76 | void AcquireForegroundRights(Kernel::HLERequestContext& ctx); |
| 77 | |||
| 78 | Core::System& system; | ||
| 74 | }; | 79 | }; |
| 75 | 80 | ||
| 76 | class IAudioController final : public ServiceFramework<IAudioController> { | 81 | class IAudioController final : public ServiceFramework<IAudioController> { |
| @@ -113,7 +118,8 @@ public: | |||
| 113 | 118 | ||
| 114 | class ISelfController final : public ServiceFramework<ISelfController> { | 119 | class ISelfController final : public ServiceFramework<ISelfController> { |
| 115 | public: | 120 | public: |
| 116 | explicit ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger); | 121 | explicit ISelfController(Core::System& system_, |
| 122 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger_); | ||
| 117 | ~ISelfController() override; | 123 | ~ISelfController() override; |
| 118 | 124 | ||
| 119 | private: | 125 | private: |
| @@ -208,7 +214,7 @@ private: | |||
| 208 | 214 | ||
| 209 | class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> { | 215 | class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> { |
| 210 | public: | 216 | public: |
| 211 | ILibraryAppletCreator(u64 current_process_title_id); | 217 | explicit ILibraryAppletCreator(Core::System& system_); |
| 212 | ~ILibraryAppletCreator() override; | 218 | ~ILibraryAppletCreator() override; |
| 213 | 219 | ||
| 214 | private: | 220 | private: |
| @@ -216,12 +222,12 @@ private: | |||
| 216 | void CreateStorage(Kernel::HLERequestContext& ctx); | 222 | void CreateStorage(Kernel::HLERequestContext& ctx); |
| 217 | void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx); | 223 | void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx); |
| 218 | 224 | ||
| 219 | u64 current_process_title_id; | 225 | Core::System& system; |
| 220 | }; | 226 | }; |
| 221 | 227 | ||
| 222 | class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> { | 228 | class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> { |
| 223 | public: | 229 | public: |
| 224 | IApplicationFunctions(); | 230 | explicit IApplicationFunctions(Core::System& system_); |
| 225 | ~IApplicationFunctions() override; | 231 | ~IApplicationFunctions() override; |
| 226 | 232 | ||
| 227 | private: | 233 | private: |
| @@ -245,6 +251,7 @@ private: | |||
| 245 | void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx); | 251 | void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx); |
| 246 | 252 | ||
| 247 | Kernel::EventPair gpu_error_detected_event; | 253 | Kernel::EventPair gpu_error_detected_event; |
| 254 | Core::System& system; | ||
| 248 | }; | 255 | }; |
| 249 | 256 | ||
| 250 | class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { | 257 | class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> { |
| @@ -278,5 +285,4 @@ public: | |||
| 278 | void InstallInterfaces(SM::ServiceManager& service_manager, | 285 | void InstallInterfaces(SM::ServiceManager& service_manager, |
| 279 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system); | 286 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system); |
| 280 | 287 | ||
| 281 | } // namespace AM | 288 | } // namespace Service::AM |
| 282 | } // namespace Service | ||
diff --git a/src/core/hle/service/am/applet_ae.cpp b/src/core/hle/service/am/applet_ae.cpp index a34368c8b..e454b77d8 100644 --- a/src/core/hle/service/am/applet_ae.cpp +++ b/src/core/hle/service/am/applet_ae.cpp | |||
| @@ -50,7 +50,7 @@ private: | |||
| 50 | 50 | ||
| 51 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 51 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 52 | rb.Push(RESULT_SUCCESS); | 52 | rb.Push(RESULT_SUCCESS); |
| 53 | rb.PushIpcInterface<ISelfController>(nvflinger); | 53 | rb.PushIpcInterface<ISelfController>(system, nvflinger); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | void GetWindowController(Kernel::HLERequestContext& ctx) { | 56 | void GetWindowController(Kernel::HLERequestContext& ctx) { |
| @@ -58,7 +58,7 @@ private: | |||
| 58 | 58 | ||
| 59 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 59 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 60 | rb.Push(RESULT_SUCCESS); | 60 | rb.Push(RESULT_SUCCESS); |
| 61 | rb.PushIpcInterface<IWindowController>(); | 61 | rb.PushIpcInterface<IWindowController>(system); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | void GetAudioController(Kernel::HLERequestContext& ctx) { | 64 | void GetAudioController(Kernel::HLERequestContext& ctx) { |
| @@ -98,7 +98,7 @@ private: | |||
| 98 | 98 | ||
| 99 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 99 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 100 | rb.Push(RESULT_SUCCESS); | 100 | rb.Push(RESULT_SUCCESS); |
| 101 | rb.PushIpcInterface<ILibraryAppletCreator>(system.CurrentProcess()->GetTitleID()); | 101 | rb.PushIpcInterface<ILibraryAppletCreator>(system); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { | 104 | void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { |
| @@ -106,7 +106,7 @@ private: | |||
| 106 | 106 | ||
| 107 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 107 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 108 | rb.Push(RESULT_SUCCESS); | 108 | rb.Push(RESULT_SUCCESS); |
| 109 | rb.PushIpcInterface<IApplicationFunctions>(); | 109 | rb.PushIpcInterface<IApplicationFunctions>(system); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; | 112 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; |
| @@ -154,7 +154,7 @@ private: | |||
| 154 | 154 | ||
| 155 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 155 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 156 | rb.Push(RESULT_SUCCESS); | 156 | rb.Push(RESULT_SUCCESS); |
| 157 | rb.PushIpcInterface<ISelfController>(nvflinger); | 157 | rb.PushIpcInterface<ISelfController>(system, nvflinger); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | void GetWindowController(Kernel::HLERequestContext& ctx) { | 160 | void GetWindowController(Kernel::HLERequestContext& ctx) { |
| @@ -162,7 +162,7 @@ private: | |||
| 162 | 162 | ||
| 163 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 163 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 164 | rb.Push(RESULT_SUCCESS); | 164 | rb.Push(RESULT_SUCCESS); |
| 165 | rb.PushIpcInterface<IWindowController>(); | 165 | rb.PushIpcInterface<IWindowController>(system); |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | void GetAudioController(Kernel::HLERequestContext& ctx) { | 168 | void GetAudioController(Kernel::HLERequestContext& ctx) { |
| @@ -194,7 +194,7 @@ private: | |||
| 194 | 194 | ||
| 195 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 195 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 196 | rb.Push(RESULT_SUCCESS); | 196 | rb.Push(RESULT_SUCCESS); |
| 197 | rb.PushIpcInterface<ILibraryAppletCreator>(system.CurrentProcess()->GetTitleID()); | 197 | rb.PushIpcInterface<ILibraryAppletCreator>(system); |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | void GetHomeMenuFunctions(Kernel::HLERequestContext& ctx) { | 200 | void GetHomeMenuFunctions(Kernel::HLERequestContext& ctx) { |
diff --git a/src/core/hle/service/am/applet_oe.cpp b/src/core/hle/service/am/applet_oe.cpp index 5d53ef113..a2ffaa440 100644 --- a/src/core/hle/service/am/applet_oe.cpp +++ b/src/core/hle/service/am/applet_oe.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 6 | #include "core/hle/ipc_helpers.h" | 6 | #include "core/hle/ipc_helpers.h" |
| 7 | #include "core/hle/kernel/process.h" | ||
| 8 | #include "core/hle/service/am/am.h" | 7 | #include "core/hle/service/am/am.h" |
| 9 | #include "core/hle/service/am/applet_oe.h" | 8 | #include "core/hle/service/am/applet_oe.h" |
| 10 | #include "core/hle/service/nvflinger/nvflinger.h" | 9 | #include "core/hle/service/nvflinger/nvflinger.h" |
| @@ -64,7 +63,7 @@ private: | |||
| 64 | 63 | ||
| 65 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 64 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 66 | rb.Push(RESULT_SUCCESS); | 65 | rb.Push(RESULT_SUCCESS); |
| 67 | rb.PushIpcInterface<IWindowController>(); | 66 | rb.PushIpcInterface<IWindowController>(system); |
| 68 | } | 67 | } |
| 69 | 68 | ||
| 70 | void GetSelfController(Kernel::HLERequestContext& ctx) { | 69 | void GetSelfController(Kernel::HLERequestContext& ctx) { |
| @@ -72,7 +71,7 @@ private: | |||
| 72 | 71 | ||
| 73 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 72 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 74 | rb.Push(RESULT_SUCCESS); | 73 | rb.Push(RESULT_SUCCESS); |
| 75 | rb.PushIpcInterface<ISelfController>(nvflinger); | 74 | rb.PushIpcInterface<ISelfController>(system, nvflinger); |
| 76 | } | 75 | } |
| 77 | 76 | ||
| 78 | void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { | 77 | void GetCommonStateGetter(Kernel::HLERequestContext& ctx) { |
| @@ -88,7 +87,7 @@ private: | |||
| 88 | 87 | ||
| 89 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 88 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 90 | rb.Push(RESULT_SUCCESS); | 89 | rb.Push(RESULT_SUCCESS); |
| 91 | rb.PushIpcInterface<ILibraryAppletCreator>(system.CurrentProcess()->GetTitleID()); | 90 | rb.PushIpcInterface<ILibraryAppletCreator>(system); |
| 92 | } | 91 | } |
| 93 | 92 | ||
| 94 | void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { | 93 | void GetApplicationFunctions(Kernel::HLERequestContext& ctx) { |
| @@ -96,7 +95,7 @@ private: | |||
| 96 | 95 | ||
| 97 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 96 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 98 | rb.Push(RESULT_SUCCESS); | 97 | rb.Push(RESULT_SUCCESS); |
| 99 | rb.PushIpcInterface<IApplicationFunctions>(); | 98 | rb.PushIpcInterface<IApplicationFunctions>(system); |
| 100 | } | 99 | } |
| 101 | 100 | ||
| 102 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; | 101 | std::shared_ptr<NVFlinger::NVFlinger> nvflinger; |
diff --git a/src/core/hle/service/am/applets/applets.cpp b/src/core/hle/service/am/applets/applets.cpp index 6bdba2468..d2e35362f 100644 --- a/src/core/hle/service/am/applets/applets.cpp +++ b/src/core/hle/service/am/applets/applets.cpp | |||
| @@ -23,8 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | namespace Service::AM::Applets { | 24 | namespace Service::AM::Applets { |
| 25 | 25 | ||
| 26 | AppletDataBroker::AppletDataBroker() { | 26 | AppletDataBroker::AppletDataBroker(Kernel::KernelCore& kernel) { |
| 27 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 28 | state_changed_event = Kernel::WritableEvent::CreateEventPair( | 27 | state_changed_event = Kernel::WritableEvent::CreateEventPair( |
| 29 | kernel, Kernel::ResetType::Manual, "ILibraryAppletAccessor:StateChangedEvent"); | 28 | kernel, Kernel::ResetType::Manual, "ILibraryAppletAccessor:StateChangedEvent"); |
| 30 | pop_out_data_event = Kernel::WritableEvent::CreateEventPair( | 29 | pop_out_data_event = Kernel::WritableEvent::CreateEventPair( |
| @@ -121,7 +120,7 @@ Kernel::SharedPtr<Kernel::ReadableEvent> AppletDataBroker::GetStateChangedEvent( | |||
| 121 | return state_changed_event.readable; | 120 | return state_changed_event.readable; |
| 122 | } | 121 | } |
| 123 | 122 | ||
| 124 | Applet::Applet() = default; | 123 | Applet::Applet(Kernel::KernelCore& kernel_) : broker{kernel_} {} |
| 125 | 124 | ||
| 126 | Applet::~Applet() = default; | 125 | Applet::~Applet() = default; |
| 127 | 126 | ||
| @@ -154,7 +153,7 @@ AppletFrontendSet::AppletFrontendSet(AppletFrontendSet&&) noexcept = default; | |||
| 154 | 153 | ||
| 155 | AppletFrontendSet& AppletFrontendSet::operator=(AppletFrontendSet&&) noexcept = default; | 154 | AppletFrontendSet& AppletFrontendSet::operator=(AppletFrontendSet&&) noexcept = default; |
| 156 | 155 | ||
| 157 | AppletManager::AppletManager() = default; | 156 | AppletManager::AppletManager(Core::System& system_) : system{system_} {} |
| 158 | 157 | ||
| 159 | AppletManager::~AppletManager() = default; | 158 | AppletManager::~AppletManager() = default; |
| 160 | 159 | ||
| @@ -216,28 +215,28 @@ void AppletManager::ClearAll() { | |||
| 216 | frontend = {}; | 215 | frontend = {}; |
| 217 | } | 216 | } |
| 218 | 217 | ||
| 219 | std::shared_ptr<Applet> AppletManager::GetApplet(AppletId id, u64 current_process_title_id) const { | 218 | std::shared_ptr<Applet> AppletManager::GetApplet(AppletId id) const { |
| 220 | switch (id) { | 219 | switch (id) { |
| 221 | case AppletId::Auth: | 220 | case AppletId::Auth: |
| 222 | return std::make_shared<Auth>(*frontend.parental_controls); | 221 | return std::make_shared<Auth>(system, *frontend.parental_controls); |
| 223 | case AppletId::Error: | 222 | case AppletId::Error: |
| 224 | return std::make_shared<Error>(*frontend.error); | 223 | return std::make_shared<Error>(system, *frontend.error); |
| 225 | case AppletId::ProfileSelect: | 224 | case AppletId::ProfileSelect: |
| 226 | return std::make_shared<ProfileSelect>(*frontend.profile_select); | 225 | return std::make_shared<ProfileSelect>(system, *frontend.profile_select); |
| 227 | case AppletId::SoftwareKeyboard: | 226 | case AppletId::SoftwareKeyboard: |
| 228 | return std::make_shared<SoftwareKeyboard>(*frontend.software_keyboard); | 227 | return std::make_shared<SoftwareKeyboard>(system, *frontend.software_keyboard); |
| 229 | case AppletId::PhotoViewer: | 228 | case AppletId::PhotoViewer: |
| 230 | return std::make_shared<PhotoViewer>(*frontend.photo_viewer); | 229 | return std::make_shared<PhotoViewer>(system, *frontend.photo_viewer); |
| 231 | case AppletId::LibAppletShop: | 230 | case AppletId::LibAppletShop: |
| 232 | return std::make_shared<WebBrowser>(*frontend.web_browser, current_process_title_id, | 231 | return std::make_shared<WebBrowser>(system, *frontend.web_browser, |
| 233 | frontend.e_commerce.get()); | 232 | frontend.e_commerce.get()); |
| 234 | case AppletId::LibAppletOff: | 233 | case AppletId::LibAppletOff: |
| 235 | return std::make_shared<WebBrowser>(*frontend.web_browser, current_process_title_id); | 234 | return std::make_shared<WebBrowser>(system, *frontend.web_browser); |
| 236 | default: | 235 | default: |
| 237 | UNIMPLEMENTED_MSG( | 236 | UNIMPLEMENTED_MSG( |
| 238 | "No backend implementation exists for applet_id={:02X}! Falling back to stub applet.", | 237 | "No backend implementation exists for applet_id={:02X}! Falling back to stub applet.", |
| 239 | static_cast<u8>(id)); | 238 | static_cast<u8>(id)); |
| 240 | return std::make_shared<StubApplet>(id); | 239 | return std::make_shared<StubApplet>(system, id); |
| 241 | } | 240 | } |
| 242 | } | 241 | } |
| 243 | 242 | ||
diff --git a/src/core/hle/service/am/applets/applets.h b/src/core/hle/service/am/applets/applets.h index adc973dad..764c3418c 100644 --- a/src/core/hle/service/am/applets/applets.h +++ b/src/core/hle/service/am/applets/applets.h | |||
| @@ -12,6 +12,10 @@ | |||
| 12 | 12 | ||
| 13 | union ResultCode; | 13 | union ResultCode; |
| 14 | 14 | ||
| 15 | namespace Core { | ||
| 16 | class System; | ||
| 17 | } | ||
| 18 | |||
| 15 | namespace Core::Frontend { | 19 | namespace Core::Frontend { |
| 16 | class ECommerceApplet; | 20 | class ECommerceApplet; |
| 17 | class ErrorApplet; | 21 | class ErrorApplet; |
| @@ -22,6 +26,10 @@ class SoftwareKeyboardApplet; | |||
| 22 | class WebBrowserApplet; | 26 | class WebBrowserApplet; |
| 23 | } // namespace Core::Frontend | 27 | } // namespace Core::Frontend |
| 24 | 28 | ||
| 29 | namespace Kernel { | ||
| 30 | class KernelCore; | ||
| 31 | } | ||
| 32 | |||
| 25 | namespace Service::AM { | 33 | namespace Service::AM { |
| 26 | 34 | ||
| 27 | class IStorage; | 35 | class IStorage; |
| @@ -53,7 +61,7 @@ enum class AppletId : u32 { | |||
| 53 | 61 | ||
| 54 | class AppletDataBroker final { | 62 | class AppletDataBroker final { |
| 55 | public: | 63 | public: |
| 56 | AppletDataBroker(); | 64 | explicit AppletDataBroker(Kernel::KernelCore& kernel_); |
| 57 | ~AppletDataBroker(); | 65 | ~AppletDataBroker(); |
| 58 | 66 | ||
| 59 | struct RawChannelData { | 67 | struct RawChannelData { |
| @@ -108,7 +116,7 @@ private: | |||
| 108 | 116 | ||
| 109 | class Applet { | 117 | class Applet { |
| 110 | public: | 118 | public: |
| 111 | Applet(); | 119 | explicit Applet(Kernel::KernelCore& kernel_); |
| 112 | virtual ~Applet(); | 120 | virtual ~Applet(); |
| 113 | 121 | ||
| 114 | virtual void Initialize(); | 122 | virtual void Initialize(); |
| @@ -179,7 +187,7 @@ struct AppletFrontendSet { | |||
| 179 | 187 | ||
| 180 | class AppletManager { | 188 | class AppletManager { |
| 181 | public: | 189 | public: |
| 182 | AppletManager(); | 190 | explicit AppletManager(Core::System& system_); |
| 183 | ~AppletManager(); | 191 | ~AppletManager(); |
| 184 | 192 | ||
| 185 | void SetAppletFrontendSet(AppletFrontendSet set); | 193 | void SetAppletFrontendSet(AppletFrontendSet set); |
| @@ -187,10 +195,11 @@ public: | |||
| 187 | void SetDefaultAppletsIfMissing(); | 195 | void SetDefaultAppletsIfMissing(); |
| 188 | void ClearAll(); | 196 | void ClearAll(); |
| 189 | 197 | ||
| 190 | std::shared_ptr<Applet> GetApplet(AppletId id, u64 current_process_title_id) const; | 198 | std::shared_ptr<Applet> GetApplet(AppletId id) const; |
| 191 | 199 | ||
| 192 | private: | 200 | private: |
| 193 | AppletFrontendSet frontend; | 201 | AppletFrontendSet frontend; |
| 202 | Core::System& system; | ||
| 194 | }; | 203 | }; |
| 195 | 204 | ||
| 196 | } // namespace Applets | 205 | } // namespace Applets |
diff --git a/src/core/hle/service/am/applets/error.cpp b/src/core/hle/service/am/applets/error.cpp index af3a900f8..a7db26725 100644 --- a/src/core/hle/service/am/applets/error.cpp +++ b/src/core/hle/service/am/applets/error.cpp | |||
| @@ -85,7 +85,8 @@ ResultCode Decode64BitError(u64 error) { | |||
| 85 | 85 | ||
| 86 | } // Anonymous namespace | 86 | } // Anonymous namespace |
| 87 | 87 | ||
| 88 | Error::Error(const Core::Frontend::ErrorApplet& frontend) : frontend(frontend) {} | 88 | Error::Error(Core::System& system_, const Core::Frontend::ErrorApplet& frontend_) |
| 89 | : Applet{system_.Kernel()}, frontend(frontend_), system{system_} {} | ||
| 89 | 90 | ||
| 90 | Error::~Error() = default; | 91 | Error::~Error() = default; |
| 91 | 92 | ||
| @@ -145,8 +146,8 @@ void Error::Execute() { | |||
| 145 | } | 146 | } |
| 146 | 147 | ||
| 147 | const auto callback = [this] { DisplayCompleted(); }; | 148 | const auto callback = [this] { DisplayCompleted(); }; |
| 148 | const auto title_id = Core::CurrentProcess()->GetTitleID(); | 149 | const auto title_id = system.CurrentProcess()->GetTitleID(); |
| 149 | const auto& reporter{Core::System::GetInstance().GetReporter()}; | 150 | const auto& reporter{system.GetReporter()}; |
| 150 | 151 | ||
| 151 | switch (mode) { | 152 | switch (mode) { |
| 152 | case ErrorAppletMode::ShowError: | 153 | case ErrorAppletMode::ShowError: |
diff --git a/src/core/hle/service/am/applets/error.h b/src/core/hle/service/am/applets/error.h index a3590d181..a105cdb0c 100644 --- a/src/core/hle/service/am/applets/error.h +++ b/src/core/hle/service/am/applets/error.h | |||
| @@ -7,6 +7,10 @@ | |||
| 7 | #include "core/hle/result.h" | 7 | #include "core/hle/result.h" |
| 8 | #include "core/hle/service/am/applets/applets.h" | 8 | #include "core/hle/service/am/applets/applets.h" |
| 9 | 9 | ||
| 10 | namespace Core { | ||
| 11 | class System; | ||
| 12 | } | ||
| 13 | |||
| 10 | namespace Service::AM::Applets { | 14 | namespace Service::AM::Applets { |
| 11 | 15 | ||
| 12 | enum class ErrorAppletMode : u8 { | 16 | enum class ErrorAppletMode : u8 { |
| @@ -21,7 +25,7 @@ enum class ErrorAppletMode : u8 { | |||
| 21 | 25 | ||
| 22 | class Error final : public Applet { | 26 | class Error final : public Applet { |
| 23 | public: | 27 | public: |
| 24 | explicit Error(const Core::Frontend::ErrorApplet& frontend); | 28 | explicit Error(Core::System& system_, const Core::Frontend::ErrorApplet& frontend_); |
| 25 | ~Error() override; | 29 | ~Error() override; |
| 26 | 30 | ||
| 27 | void Initialize() override; | 31 | void Initialize() override; |
| @@ -42,6 +46,7 @@ private: | |||
| 42 | std::unique_ptr<ErrorArguments> args; | 46 | std::unique_ptr<ErrorArguments> args; |
| 43 | 47 | ||
| 44 | bool complete = false; | 48 | bool complete = false; |
| 49 | Core::System& system; | ||
| 45 | }; | 50 | }; |
| 46 | 51 | ||
| 47 | } // namespace Service::AM::Applets | 52 | } // namespace Service::AM::Applets |
diff --git a/src/core/hle/service/am/applets/general_backend.cpp b/src/core/hle/service/am/applets/general_backend.cpp index e0def8dff..328438a1d 100644 --- a/src/core/hle/service/am/applets/general_backend.cpp +++ b/src/core/hle/service/am/applets/general_backend.cpp | |||
| @@ -37,7 +37,8 @@ static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix) | |||
| 37 | } | 37 | } |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | Auth::Auth(Core::Frontend::ParentalControlsApplet& frontend) : frontend(frontend) {} | 40 | Auth::Auth(Core::System& system_, Core::Frontend::ParentalControlsApplet& frontend_) |
| 41 | : Applet{system_.Kernel()}, frontend(frontend_) {} | ||
| 41 | 42 | ||
| 42 | Auth::~Auth() = default; | 43 | Auth::~Auth() = default; |
| 43 | 44 | ||
| @@ -151,7 +152,8 @@ void Auth::AuthFinished(bool successful) { | |||
| 151 | broker.SignalStateChanged(); | 152 | broker.SignalStateChanged(); |
| 152 | } | 153 | } |
| 153 | 154 | ||
| 154 | PhotoViewer::PhotoViewer(const Core::Frontend::PhotoViewerApplet& frontend) : frontend(frontend) {} | 155 | PhotoViewer::PhotoViewer(Core::System& system_, const Core::Frontend::PhotoViewerApplet& frontend_) |
| 156 | : Applet{system_.Kernel()}, frontend(frontend_), system{system_} {} | ||
| 155 | 157 | ||
| 156 | PhotoViewer::~PhotoViewer() = default; | 158 | PhotoViewer::~PhotoViewer() = default; |
| 157 | 159 | ||
| @@ -185,7 +187,7 @@ void PhotoViewer::Execute() { | |||
| 185 | const auto callback = [this] { ViewFinished(); }; | 187 | const auto callback = [this] { ViewFinished(); }; |
| 186 | switch (mode) { | 188 | switch (mode) { |
| 187 | case PhotoViewerAppletMode::CurrentApp: | 189 | case PhotoViewerAppletMode::CurrentApp: |
| 188 | frontend.ShowPhotosForApplication(Core::CurrentProcess()->GetTitleID(), callback); | 190 | frontend.ShowPhotosForApplication(system.CurrentProcess()->GetTitleID(), callback); |
| 189 | break; | 191 | break; |
| 190 | case PhotoViewerAppletMode::AllApps: | 192 | case PhotoViewerAppletMode::AllApps: |
| 191 | frontend.ShowAllPhotos(callback); | 193 | frontend.ShowAllPhotos(callback); |
| @@ -200,7 +202,8 @@ void PhotoViewer::ViewFinished() { | |||
| 200 | broker.SignalStateChanged(); | 202 | broker.SignalStateChanged(); |
| 201 | } | 203 | } |
| 202 | 204 | ||
| 203 | StubApplet::StubApplet(AppletId id) : id(id) {} | 205 | StubApplet::StubApplet(Core::System& system_, AppletId id_) |
| 206 | : Applet{system_.Kernel()}, id(id_), system{system_} {} | ||
| 204 | 207 | ||
| 205 | StubApplet::~StubApplet() = default; | 208 | StubApplet::~StubApplet() = default; |
| 206 | 209 | ||
| @@ -209,7 +212,7 @@ void StubApplet::Initialize() { | |||
| 209 | Applet::Initialize(); | 212 | Applet::Initialize(); |
| 210 | 213 | ||
| 211 | const auto data = broker.PeekDataToAppletForDebug(); | 214 | const auto data = broker.PeekDataToAppletForDebug(); |
| 212 | Core::System::GetInstance().GetReporter().SaveUnimplementedAppletReport( | 215 | system.GetReporter().SaveUnimplementedAppletReport( |
| 213 | static_cast<u32>(id), common_args.arguments_version, common_args.library_version, | 216 | static_cast<u32>(id), common_args.arguments_version, common_args.library_version, |
| 214 | common_args.theme_color, common_args.play_startup_sound, common_args.system_tick, | 217 | common_args.theme_color, common_args.play_startup_sound, common_args.system_tick, |
| 215 | data.normal, data.interactive); | 218 | data.normal, data.interactive); |
diff --git a/src/core/hle/service/am/applets/general_backend.h b/src/core/hle/service/am/applets/general_backend.h index 0da252044..cfa2df369 100644 --- a/src/core/hle/service/am/applets/general_backend.h +++ b/src/core/hle/service/am/applets/general_backend.h | |||
| @@ -6,6 +6,10 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/service/am/applets/applets.h" | 7 | #include "core/hle/service/am/applets/applets.h" |
| 8 | 8 | ||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 9 | namespace Service::AM::Applets { | 13 | namespace Service::AM::Applets { |
| 10 | 14 | ||
| 11 | enum class AuthAppletType : u32 { | 15 | enum class AuthAppletType : u32 { |
| @@ -16,7 +20,7 @@ enum class AuthAppletType : u32 { | |||
| 16 | 20 | ||
| 17 | class Auth final : public Applet { | 21 | class Auth final : public Applet { |
| 18 | public: | 22 | public: |
| 19 | explicit Auth(Core::Frontend::ParentalControlsApplet& frontend); | 23 | explicit Auth(Core::System& system_, Core::Frontend::ParentalControlsApplet& frontend_); |
| 20 | ~Auth() override; | 24 | ~Auth() override; |
| 21 | 25 | ||
| 22 | void Initialize() override; | 26 | void Initialize() override; |
| @@ -45,7 +49,7 @@ enum class PhotoViewerAppletMode : u8 { | |||
| 45 | 49 | ||
| 46 | class PhotoViewer final : public Applet { | 50 | class PhotoViewer final : public Applet { |
| 47 | public: | 51 | public: |
| 48 | explicit PhotoViewer(const Core::Frontend::PhotoViewerApplet& frontend); | 52 | explicit PhotoViewer(Core::System& system_, const Core::Frontend::PhotoViewerApplet& frontend_); |
| 49 | ~PhotoViewer() override; | 53 | ~PhotoViewer() override; |
| 50 | 54 | ||
| 51 | void Initialize() override; | 55 | void Initialize() override; |
| @@ -60,11 +64,12 @@ private: | |||
| 60 | const Core::Frontend::PhotoViewerApplet& frontend; | 64 | const Core::Frontend::PhotoViewerApplet& frontend; |
| 61 | bool complete = false; | 65 | bool complete = false; |
| 62 | PhotoViewerAppletMode mode = PhotoViewerAppletMode::CurrentApp; | 66 | PhotoViewerAppletMode mode = PhotoViewerAppletMode::CurrentApp; |
| 67 | Core::System& system; | ||
| 63 | }; | 68 | }; |
| 64 | 69 | ||
| 65 | class StubApplet final : public Applet { | 70 | class StubApplet final : public Applet { |
| 66 | public: | 71 | public: |
| 67 | explicit StubApplet(AppletId id); | 72 | explicit StubApplet(Core::System& system_, AppletId id_); |
| 68 | ~StubApplet() override; | 73 | ~StubApplet() override; |
| 69 | 74 | ||
| 70 | void Initialize() override; | 75 | void Initialize() override; |
| @@ -76,6 +81,7 @@ public: | |||
| 76 | 81 | ||
| 77 | private: | 82 | private: |
| 78 | AppletId id; | 83 | AppletId id; |
| 84 | Core::System& system; | ||
| 79 | }; | 85 | }; |
| 80 | 86 | ||
| 81 | } // namespace Service::AM::Applets | 87 | } // namespace Service::AM::Applets |
diff --git a/src/core/hle/service/am/applets/profile_select.cpp b/src/core/hle/service/am/applets/profile_select.cpp index 57b5419e8..3eba696ca 100644 --- a/src/core/hle/service/am/applets/profile_select.cpp +++ b/src/core/hle/service/am/applets/profile_select.cpp | |||
| @@ -15,8 +15,9 @@ namespace Service::AM::Applets { | |||
| 15 | 15 | ||
| 16 | constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; | 16 | constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; |
| 17 | 17 | ||
| 18 | ProfileSelect::ProfileSelect(const Core::Frontend::ProfileSelectApplet& frontend) | 18 | ProfileSelect::ProfileSelect(Core::System& system_, |
| 19 | : frontend(frontend) {} | 19 | const Core::Frontend::ProfileSelectApplet& frontend_) |
| 20 | : Applet{system_.Kernel()}, frontend(frontend_) {} | ||
| 20 | 21 | ||
| 21 | ProfileSelect::~ProfileSelect() = default; | 22 | ProfileSelect::~ProfileSelect() = default; |
| 22 | 23 | ||
diff --git a/src/core/hle/service/am/applets/profile_select.h b/src/core/hle/service/am/applets/profile_select.h index 563cd744a..16364ead7 100644 --- a/src/core/hle/service/am/applets/profile_select.h +++ b/src/core/hle/service/am/applets/profile_select.h | |||
| @@ -11,6 +11,10 @@ | |||
| 11 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 12 | #include "core/hle/service/am/applets/applets.h" | 12 | #include "core/hle/service/am/applets/applets.h" |
| 13 | 13 | ||
| 14 | namespace Core { | ||
| 15 | class System; | ||
| 16 | } | ||
| 17 | |||
| 14 | namespace Service::AM::Applets { | 18 | namespace Service::AM::Applets { |
| 15 | 19 | ||
| 16 | struct UserSelectionConfig { | 20 | struct UserSelectionConfig { |
| @@ -29,7 +33,8 @@ static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has inco | |||
| 29 | 33 | ||
| 30 | class ProfileSelect final : public Applet { | 34 | class ProfileSelect final : public Applet { |
| 31 | public: | 35 | public: |
| 32 | explicit ProfileSelect(const Core::Frontend::ProfileSelectApplet& frontend); | 36 | explicit ProfileSelect(Core::System& system_, |
| 37 | const Core::Frontend::ProfileSelectApplet& frontend_); | ||
| 33 | ~ProfileSelect() override; | 38 | ~ProfileSelect() override; |
| 34 | 39 | ||
| 35 | void Initialize() override; | 40 | void Initialize() override; |
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index e197990f7..748559cd0 100644 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp | |||
| @@ -39,8 +39,9 @@ static Core::Frontend::SoftwareKeyboardParameters ConvertToFrontendParameters( | |||
| 39 | return params; | 39 | return params; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | SoftwareKeyboard::SoftwareKeyboard(const Core::Frontend::SoftwareKeyboardApplet& frontend) | 42 | SoftwareKeyboard::SoftwareKeyboard(Core::System& system_, |
| 43 | : frontend(frontend) {} | 43 | const Core::Frontend::SoftwareKeyboardApplet& frontend_) |
| 44 | : Applet{system_.Kernel()}, frontend(frontend_) {} | ||
| 44 | 45 | ||
| 45 | SoftwareKeyboard::~SoftwareKeyboard() = default; | 46 | SoftwareKeyboard::~SoftwareKeyboard() = default; |
| 46 | 47 | ||
diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h index 0fbc43e51..ef4801fc6 100644 --- a/src/core/hle/service/am/applets/software_keyboard.h +++ b/src/core/hle/service/am/applets/software_keyboard.h | |||
| @@ -16,6 +16,10 @@ | |||
| 16 | 16 | ||
| 17 | union ResultCode; | 17 | union ResultCode; |
| 18 | 18 | ||
| 19 | namespace Core { | ||
| 20 | class System; | ||
| 21 | } | ||
| 22 | |||
| 19 | namespace Service::AM::Applets { | 23 | namespace Service::AM::Applets { |
| 20 | 24 | ||
| 21 | enum class KeysetDisable : u32 { | 25 | enum class KeysetDisable : u32 { |
| @@ -55,7 +59,8 @@ static_assert(sizeof(KeyboardConfig) == 0x3E0, "KeyboardConfig has incorrect siz | |||
| 55 | 59 | ||
| 56 | class SoftwareKeyboard final : public Applet { | 60 | class SoftwareKeyboard final : public Applet { |
| 57 | public: | 61 | public: |
| 58 | explicit SoftwareKeyboard(const Core::Frontend::SoftwareKeyboardApplet& frontend); | 62 | explicit SoftwareKeyboard(Core::System& system_, |
| 63 | const Core::Frontend::SoftwareKeyboardApplet& frontend_); | ||
| 59 | ~SoftwareKeyboard() override; | 64 | ~SoftwareKeyboard() override; |
| 60 | 65 | ||
| 61 | void Initialize() override; | 66 | void Initialize() override; |
diff --git a/src/core/hle/service/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp index f3c9fef0e..32283e819 100644 --- a/src/core/hle/service/am/applets/web_browser.cpp +++ b/src/core/hle/service/am/applets/web_browser.cpp | |||
| @@ -190,8 +190,9 @@ std::map<WebArgTLVType, std::vector<u8>> GetWebArguments(const std::vector<u8>& | |||
| 190 | return out; | 190 | return out; |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | FileSys::VirtualFile GetApplicationRomFS(u64 title_id, FileSys::ContentRecordType type) { | 193 | FileSys::VirtualFile GetApplicationRomFS(const Core::System& system, u64 title_id, |
| 194 | const auto& installed{Core::System::GetInstance().GetContentProvider()}; | 194 | FileSys::ContentRecordType type) { |
| 195 | const auto& installed{system.GetContentProvider()}; | ||
| 195 | const auto res = installed.GetEntry(title_id, type); | 196 | const auto res = installed.GetEntry(title_id, type); |
| 196 | 197 | ||
| 197 | if (res != nullptr) { | 198 | if (res != nullptr) { |
| @@ -207,10 +208,10 @@ FileSys::VirtualFile GetApplicationRomFS(u64 title_id, FileSys::ContentRecordTyp | |||
| 207 | 208 | ||
| 208 | } // Anonymous namespace | 209 | } // Anonymous namespace |
| 209 | 210 | ||
| 210 | WebBrowser::WebBrowser(Core::Frontend::WebBrowserApplet& frontend, u64 current_process_title_id, | 211 | WebBrowser::WebBrowser(Core::System& system_, Core::Frontend::WebBrowserApplet& frontend_, |
| 211 | Core::Frontend::ECommerceApplet* frontend_e_commerce) | 212 | Core::Frontend::ECommerceApplet* frontend_e_commerce_) |
| 212 | : frontend(frontend), frontend_e_commerce(frontend_e_commerce), | 213 | : Applet{system_.Kernel()}, frontend(frontend_), |
| 213 | current_process_title_id(current_process_title_id) {} | 214 | frontend_e_commerce(frontend_e_commerce_), system{system_} {} |
| 214 | 215 | ||
| 215 | WebBrowser::~WebBrowser() = default; | 216 | WebBrowser::~WebBrowser() = default; |
| 216 | 217 | ||
| @@ -266,7 +267,7 @@ void WebBrowser::UnpackRomFS() { | |||
| 266 | ASSERT(offline_romfs != nullptr); | 267 | ASSERT(offline_romfs != nullptr); |
| 267 | const auto dir = | 268 | const auto dir = |
| 268 | FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard); | 269 | FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard); |
| 269 | const auto& vfs{Core::System::GetInstance().GetFilesystem()}; | 270 | const auto& vfs{system.GetFilesystem()}; |
| 270 | const auto temp_dir = vfs->CreateDirectory(temporary_dir, FileSys::Mode::ReadWrite); | 271 | const auto temp_dir = vfs->CreateDirectory(temporary_dir, FileSys::Mode::ReadWrite); |
| 271 | FileSys::VfsRawCopyD(dir, temp_dir); | 272 | FileSys::VfsRawCopyD(dir, temp_dir); |
| 272 | 273 | ||
| @@ -470,10 +471,10 @@ void WebBrowser::InitializeOffline() { | |||
| 470 | } | 471 | } |
| 471 | 472 | ||
| 472 | if (title_id == 0) { | 473 | if (title_id == 0) { |
| 473 | title_id = current_process_title_id; | 474 | title_id = system.CurrentProcess()->GetTitleID(); |
| 474 | } | 475 | } |
| 475 | 476 | ||
| 476 | offline_romfs = GetApplicationRomFS(title_id, type); | 477 | offline_romfs = GetApplicationRomFS(system, title_id, type); |
| 477 | if (offline_romfs == nullptr) { | 478 | if (offline_romfs == nullptr) { |
| 478 | status = ResultCode(-1); | 479 | status = ResultCode(-1); |
| 479 | LOG_ERROR(Service_AM, "Failed to find offline data for request!"); | 480 | LOG_ERROR(Service_AM, "Failed to find offline data for request!"); |
diff --git a/src/core/hle/service/am/applets/web_browser.h b/src/core/hle/service/am/applets/web_browser.h index 870f57b64..8d4027411 100644 --- a/src/core/hle/service/am/applets/web_browser.h +++ b/src/core/hle/service/am/applets/web_browser.h | |||
| @@ -9,6 +9,10 @@ | |||
| 9 | #include "core/hle/service/am/am.h" | 9 | #include "core/hle/service/am/am.h" |
| 10 | #include "core/hle/service/am/applets/applets.h" | 10 | #include "core/hle/service/am/applets/applets.h" |
| 11 | 11 | ||
| 12 | namespace Core { | ||
| 13 | class System; | ||
| 14 | } | ||
| 15 | |||
| 12 | namespace Service::AM::Applets { | 16 | namespace Service::AM::Applets { |
| 13 | 17 | ||
| 14 | enum class ShimKind : u32; | 18 | enum class ShimKind : u32; |
| @@ -17,8 +21,8 @@ enum class WebArgTLVType : u16; | |||
| 17 | 21 | ||
| 18 | class WebBrowser final : public Applet { | 22 | class WebBrowser final : public Applet { |
| 19 | public: | 23 | public: |
| 20 | WebBrowser(Core::Frontend::WebBrowserApplet& frontend, u64 current_process_title_id, | 24 | WebBrowser(Core::System& system_, Core::Frontend::WebBrowserApplet& frontend_, |
| 21 | Core::Frontend::ECommerceApplet* frontend_e_commerce = nullptr); | 25 | Core::Frontend::ECommerceApplet* frontend_e_commerce_ = nullptr); |
| 22 | 26 | ||
| 23 | ~WebBrowser() override; | 27 | ~WebBrowser() override; |
| 24 | 28 | ||
| @@ -59,8 +63,6 @@ private: | |||
| 59 | bool unpacked = false; | 63 | bool unpacked = false; |
| 60 | ResultCode status = RESULT_SUCCESS; | 64 | ResultCode status = RESULT_SUCCESS; |
| 61 | 65 | ||
| 62 | u64 current_process_title_id; | ||
| 63 | |||
| 64 | ShimKind kind; | 66 | ShimKind kind; |
| 65 | std::map<WebArgTLVType, std::vector<u8>> args; | 67 | std::map<WebArgTLVType, std::vector<u8>> args; |
| 66 | 68 | ||
| @@ -74,6 +76,8 @@ private: | |||
| 74 | std::optional<u128> user_id; | 76 | std::optional<u128> user_id; |
| 75 | std::optional<bool> shop_full_display; | 77 | std::optional<bool> shop_full_display; |
| 76 | std::string shop_extra_parameter; | 78 | std::string shop_extra_parameter; |
| 79 | |||
| 80 | Core::System& system; | ||
| 77 | }; | 81 | }; |
| 78 | 82 | ||
| 79 | } // namespace Service::AM::Applets | 83 | } // namespace Service::AM::Applets |