mm_u.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "common/logging/log.h"
  5. #include "core/hle/ipc_helpers.h"
  6. #include "core/hle/kernel/client_session.h"
  7. #include "core/hle/service/mm/mm_u.h"
  8. namespace Service::MM {
  9. class MM_U final : public ServiceFramework<MM_U> {
  10. public:
  11. explicit MM_U() : ServiceFramework{"mm:u"} {
  12. // clang-format off
  13. static const FunctionInfo functions[] = {
  14. {0, &MM_U::Initialize, "Initialize"},
  15. {1, &MM_U::Finalize, "Finalize"},
  16. {2, &MM_U::SetAndWait, "SetAndWait"},
  17. {3, &MM_U::Get, "Get"},
  18. {4, &MM_U::InitializeWithId, "InitializeWithId"},
  19. {5, &MM_U::FinalizeWithId, "FinalizeWithId"},
  20. {6, &MM_U::SetAndWaitWithId, "SetAndWaitWithId"},
  21. {7, &MM_U::GetWithId, "GetWithId"},
  22. };
  23. // clang-format on
  24. RegisterHandlers(functions);
  25. }
  26. private:
  27. void Initialize(Kernel::HLERequestContext& ctx) {
  28. LOG_WARNING(Service_MM, "(STUBBED) called");
  29. IPC::ResponseBuilder rb{ctx, 2};
  30. rb.Push(RESULT_SUCCESS);
  31. }
  32. void Finalize(Kernel::HLERequestContext& ctx) {
  33. LOG_WARNING(Service_MM, "(STUBBED) called");
  34. IPC::ResponseBuilder rb{ctx, 2};
  35. rb.Push(RESULT_SUCCESS);
  36. }
  37. void SetAndWait(Kernel::HLERequestContext& ctx) {
  38. IPC::RequestParser rp{ctx};
  39. min = rp.Pop<u32>();
  40. max = rp.Pop<u32>();
  41. LOG_WARNING(Service_MM, "(STUBBED) called, min=0x{:X}, max=0x{:X}", min, max);
  42. current = min;
  43. IPC::ResponseBuilder rb{ctx, 2};
  44. rb.Push(RESULT_SUCCESS);
  45. }
  46. void Get(Kernel::HLERequestContext& ctx) {
  47. LOG_WARNING(Service_MM, "(STUBBED) called");
  48. IPC::ResponseBuilder rb{ctx, 3};
  49. rb.Push(RESULT_SUCCESS);
  50. rb.Push(current);
  51. }
  52. void InitializeWithId(Kernel::HLERequestContext& ctx) {
  53. LOG_WARNING(Service_MM, "(STUBBED) called");
  54. IPC::ResponseBuilder rb{ctx, 3};
  55. rb.Push(RESULT_SUCCESS);
  56. rb.Push<u32>(id); // Any non zero value
  57. }
  58. void FinalizeWithId(Kernel::HLERequestContext& ctx) {
  59. LOG_WARNING(Service_MM, "(STUBBED) called");
  60. IPC::ResponseBuilder rb{ctx, 2};
  61. rb.Push(RESULT_SUCCESS);
  62. }
  63. void SetAndWaitWithId(Kernel::HLERequestContext& ctx) {
  64. IPC::RequestParser rp{ctx};
  65. u32 input_id = rp.Pop<u32>();
  66. min = rp.Pop<u32>();
  67. max = rp.Pop<u32>();
  68. LOG_WARNING(Service_MM, "(STUBBED) called, input_id=0x{:X}, min=0x{:X}, max=0x{:X}",
  69. input_id, min, max);
  70. current = min;
  71. IPC::ResponseBuilder rb{ctx, 2};
  72. rb.Push(RESULT_SUCCESS);
  73. }
  74. void GetWithId(Kernel::HLERequestContext& ctx) {
  75. LOG_WARNING(Service_MM, "(STUBBED) called");
  76. IPC::ResponseBuilder rb{ctx, 3};
  77. rb.Push(RESULT_SUCCESS);
  78. rb.Push(current);
  79. }
  80. u32 min{0};
  81. u32 max{0};
  82. u32 current{0};
  83. u32 id{1};
  84. };
  85. void InstallInterfaces(SM::ServiceManager& service_manager) {
  86. std::make_shared<MM_U>()->InstallAsService(service_manager);
  87. }
  88. } // namespace Service::MM