pm.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/hle/ipc_helpers.h"
  5. #include "core/hle/service/pm/pm.h"
  6. #include "core/hle/service/service.h"
  7. namespace Service::PM {
  8. class BootMode final : public ServiceFramework<BootMode> {
  9. public:
  10. explicit BootMode() : ServiceFramework{"pm:bm"} {
  11. static const FunctionInfo functions[] = {
  12. {0, &BootMode::GetBootMode, "GetBootMode"},
  13. {1, &BootMode::SetMaintenanceBoot, "SetMaintenanceBoot"},
  14. };
  15. RegisterHandlers(functions);
  16. }
  17. private:
  18. void GetBootMode(Kernel::HLERequestContext& ctx) {
  19. LOG_DEBUG(Service_PM, "called");
  20. IPC::ResponseBuilder rb{ctx, 3};
  21. rb.Push(RESULT_SUCCESS);
  22. rb.PushEnum(boot_mode);
  23. }
  24. void SetMaintenanceBoot(Kernel::HLERequestContext& ctx) {
  25. LOG_DEBUG(Service_PM, "called");
  26. boot_mode = SystemBootMode::Maintenance;
  27. IPC::ResponseBuilder rb{ctx, 2};
  28. rb.Push(RESULT_SUCCESS);
  29. }
  30. SystemBootMode boot_mode = SystemBootMode::Normal;
  31. };
  32. class DebugMonitor final : public ServiceFramework<DebugMonitor> {
  33. public:
  34. explicit DebugMonitor() : ServiceFramework{"pm:dmnt"} {
  35. static const FunctionInfo functions[] = {
  36. {0, nullptr, "IsDebugMode"},
  37. {1, nullptr, "GetDebugProcesses"},
  38. {2, nullptr, "StartDebugProcess"},
  39. {3, nullptr, "GetTitlePid"},
  40. {4, nullptr, "EnableDebugForTitleId"},
  41. {5, nullptr, "GetApplicationPid"},
  42. {6, nullptr, "EnableDebugForApplication"},
  43. };
  44. RegisterHandlers(functions);
  45. }
  46. };
  47. class Info final : public ServiceFramework<Info> {
  48. public:
  49. explicit Info() : ServiceFramework{"pm:info"} {
  50. static const FunctionInfo functions[] = {
  51. {0, nullptr, "GetTitleId"},
  52. };
  53. RegisterHandlers(functions);
  54. }
  55. };
  56. class Shell final : public ServiceFramework<Shell> {
  57. public:
  58. explicit Shell() : ServiceFramework{"pm:shell"} {
  59. static const FunctionInfo functions[] = {
  60. {0, nullptr, "LaunchProcess"},
  61. {1, nullptr, "TerminateProcessByPid"},
  62. {2, nullptr, "TerminateProcessByTitleId"},
  63. {3, nullptr, "GetProcessEventWaiter"},
  64. {4, nullptr, "GetProcessEventType"},
  65. {5, nullptr, "NotifyBootFinished"},
  66. {6, nullptr, "GetApplicationPid"},
  67. {7, nullptr, "BoostSystemMemoryResourceLimit"},
  68. };
  69. RegisterHandlers(functions);
  70. }
  71. };
  72. void InstallInterfaces(SM::ServiceManager& sm) {
  73. std::make_shared<BootMode>()->InstallAsService(sm);
  74. std::make_shared<DebugMonitor>()->InstallAsService(sm);
  75. std::make_shared<Info>()->InstallAsService(sm);
  76. std::make_shared<Shell>()->InstallAsService(sm);
  77. }
  78. } // namespace Service::PM