summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/pm/pm.cpp32
-rw-r--r--src/core/hle/service/pm/pm.h6
-rw-r--r--src/core/hle/service/service.cpp2
3 files changed, 33 insertions, 7 deletions
diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp
index d03187410..fe6b5f798 100644
--- a/src/core/hle/service/pm/pm.cpp
+++ b/src/core/hle/service/pm/pm.cpp
@@ -28,6 +28,17 @@ std::optional<Kernel::SharedPtr<Kernel::Process>> SearchProcessList(
28 return *iter; 28 return *iter;
29} 29}
30 30
31void GetApplicationPidGeneric(Kernel::HLERequestContext& ctx,
32 const std::vector<Kernel::SharedPtr<Kernel::Process>>& process_list) {
33 const auto process = SearchProcessList(process_list, [](const auto& process) {
34 return process->GetProcessID() == Kernel::Process::ProcessIDMin;
35 });
36
37 IPC::ResponseBuilder rb{ctx, 4};
38 rb.Push(RESULT_SUCCESS);
39 rb.Push(process.has_value() ? (*process)->GetProcessID() : NO_PROCESS_FOUND_PID);
40}
41
31} // Anonymous namespace 42} // Anonymous namespace
32 43
33class BootMode final : public ServiceFramework<BootMode> { 44class BootMode final : public ServiceFramework<BootMode> {
@@ -71,7 +82,7 @@ public:
71 {1, nullptr, "StartDebugProcess"}, 82 {1, nullptr, "StartDebugProcess"},
72 {2, &DebugMonitor::GetTitlePid, "GetTitlePid"}, 83 {2, &DebugMonitor::GetTitlePid, "GetTitlePid"},
73 {3, nullptr, "EnableDebugForTitleId"}, 84 {3, nullptr, "EnableDebugForTitleId"},
74 {4, nullptr, "GetApplicationPid"}, 85 {4, &DebugMonitor::GetApplicationPid, "GetApplicationPid"},
75 {5, nullptr, "EnableDebugForApplication"}, 86 {5, nullptr, "EnableDebugForApplication"},
76 {6, nullptr, "DisableDebug"}, 87 {6, nullptr, "DisableDebug"},
77 }; 88 };
@@ -103,6 +114,11 @@ private:
103 rb.Push((*process)->GetProcessID()); 114 rb.Push((*process)->GetProcessID());
104 } 115 }
105 116
117 void GetApplicationPid(Kernel::HLERequestContext& ctx) {
118 LOG_DEBUG(Service_PM, "called");
119 GetApplicationPidGeneric(ctx, kernel.GetProcessList());
120 }
121
106 const Kernel::KernelCore& kernel; 122 const Kernel::KernelCore& kernel;
107}; 123};
108 124
@@ -143,7 +159,8 @@ private:
143 159
144class Shell final : public ServiceFramework<Shell> { 160class Shell final : public ServiceFramework<Shell> {
145public: 161public:
146 explicit Shell() : ServiceFramework{"pm:shell"} { 162 explicit Shell(const Kernel::KernelCore& kernel)
163 : ServiceFramework{"pm:shell"}, kernel(kernel) {
147 // clang-format off 164 // clang-format off
148 static const FunctionInfo functions[] = { 165 static const FunctionInfo functions[] = {
149 {0, nullptr, "LaunchProcess"}, 166 {0, nullptr, "LaunchProcess"},
@@ -152,14 +169,23 @@ public:
152 {3, nullptr, "GetProcessEventWaiter"}, 169 {3, nullptr, "GetProcessEventWaiter"},
153 {4, nullptr, "GetProcessEventType"}, 170 {4, nullptr, "GetProcessEventType"},
154 {5, nullptr, "NotifyBootFinished"}, 171 {5, nullptr, "NotifyBootFinished"},
155 {6, nullptr, "GetApplicationPid"}, 172 {6, &Shell::GetApplicationPid, "GetApplicationPid"},
156 {7, nullptr, "BoostSystemMemoryResourceLimit"}, 173 {7, nullptr, "BoostSystemMemoryResourceLimit"},
157 {8, nullptr, "EnableAdditionalSystemThreads"}, 174 {8, nullptr, "EnableAdditionalSystemThreads"},
175 {9, nullptr, "GetUnimplementedEventHandle"},
158 }; 176 };
159 // clang-format on 177 // clang-format on
160 178
161 RegisterHandlers(functions); 179 RegisterHandlers(functions);
162 } 180 }
181
182private:
183 void GetApplicationPid(Kernel::HLERequestContext& ctx) {
184 LOG_DEBUG(Service_PM, "called");
185 GetApplicationPidGeneric(ctx, kernel.GetProcessList());
186 }
187
188 const Kernel::KernelCore& kernel;
163}; 189};
164 190
165void InstallInterfaces(Core::System& system) { 191void InstallInterfaces(Core::System& system) {
diff --git a/src/core/hle/service/pm/pm.h b/src/core/hle/service/pm/pm.h
index cc8d3f215..852e7050c 100644
--- a/src/core/hle/service/pm/pm.h
+++ b/src/core/hle/service/pm/pm.h
@@ -4,8 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7namespace Service::SM { 7namespace Core {
8class ServiceManager; 8class System;
9} 9}
10 10
11namespace Service::PM { 11namespace Service::PM {
@@ -16,6 +16,6 @@ enum class SystemBootMode {
16}; 16};
17 17
18/// Registers all PM services with the specified service manager. 18/// Registers all PM services with the specified service manager.
19void InstallInterfaces(SM::ServiceManager& service_manager); 19void InstallInterfaces(Core::System& system);
20 20
21} // namespace Service::PM 21} // namespace Service::PM
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index ec9d755b7..0c1af124b 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -242,7 +242,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system,
242 PCTL::InstallInterfaces(*sm); 242 PCTL::InstallInterfaces(*sm);
243 PCV::InstallInterfaces(*sm); 243 PCV::InstallInterfaces(*sm);
244 PlayReport::InstallInterfaces(*sm); 244 PlayReport::InstallInterfaces(*sm);
245 PM::InstallInterfaces(*sm); 245 PM::InstallInterfaces(system);
246 PSC::InstallInterfaces(*sm); 246 PSC::InstallInterfaces(*sm);
247 PSM::InstallInterfaces(*sm); 247 PSM::InstallInterfaces(*sm);
248 Set::InstallInterfaces(*sm); 248 Set::InstallInterfaces(*sm);