acc_u0.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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/service/acc/acc_u0.h"
  7. namespace Service {
  8. namespace Account {
  9. using Uid = std::array<u64, 2>;
  10. static constexpr Uid DEFAULT_USER_ID{0x10ull, 0x20ull};
  11. class IProfile final : public ServiceFramework<IProfile> {
  12. public:
  13. IProfile() : ServiceFramework("IProfile") {
  14. static const FunctionInfo functions[] = {
  15. {1, &IProfile::GetBase, "GetBase"},
  16. };
  17. RegisterHandlers(functions);
  18. }
  19. private:
  20. void GetBase(Kernel::HLERequestContext& ctx) {
  21. LOG_WARNING(Service_ACC, "(STUBBED) called");
  22. ProfileBase profile_base{};
  23. IPC::ResponseBuilder rb{ctx, 16};
  24. rb.Push(RESULT_SUCCESS);
  25. rb.PushRaw(profile_base);
  26. }
  27. };
  28. class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
  29. public:
  30. IManagerForApplication() : ServiceFramework("IManagerForApplication") {
  31. static const FunctionInfo functions[] = {
  32. {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"},
  33. {1, &IManagerForApplication::GetAccountId, "GetAccountId"},
  34. };
  35. RegisterHandlers(functions);
  36. }
  37. private:
  38. void CheckAvailability(Kernel::HLERequestContext& ctx) {
  39. LOG_WARNING(Service_ACC, "(STUBBED) called");
  40. IPC::ResponseBuilder rb{ctx, 3};
  41. rb.Push(RESULT_SUCCESS);
  42. rb.Push(true); // TODO: Check when this is supposed to return true and when not
  43. }
  44. void GetAccountId(Kernel::HLERequestContext& ctx) {
  45. LOG_WARNING(Service_ACC, "(STUBBED) called");
  46. IPC::ResponseBuilder rb{ctx, 4};
  47. rb.Push(RESULT_SUCCESS);
  48. rb.Push<u64>(0x12345678ABCDEF);
  49. }
  50. };
  51. void ACC_U0::GetUserExistence(Kernel::HLERequestContext& ctx) {
  52. LOG_WARNING(Service_ACC, "(STUBBED) called");
  53. IPC::ResponseBuilder rb{ctx, 3};
  54. rb.Push(RESULT_SUCCESS);
  55. rb.Push(true); // TODO: Check when this is supposed to return true and when not
  56. }
  57. void ACC_U0::ListAllUsers(Kernel::HLERequestContext& ctx) {
  58. constexpr std::array<u128, 10> user_ids{DEFAULT_USER_ID};
  59. const auto& output_buffer = ctx.BufferDescriptorC()[0];
  60. Memory::WriteBlock(output_buffer.Address(), user_ids.data(), user_ids.size());
  61. IPC::ResponseBuilder rb{ctx, 2};
  62. rb.Push(RESULT_SUCCESS);
  63. LOG_DEBUG(Service_ACC, "called");
  64. }
  65. void ACC_U0::GetProfile(Kernel::HLERequestContext& ctx) {
  66. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  67. rb.Push(RESULT_SUCCESS);
  68. rb.PushIpcInterface<IProfile>();
  69. LOG_DEBUG(Service_ACC, "called");
  70. }
  71. void ACC_U0::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) {
  72. LOG_WARNING(Service_ACC, "(STUBBED) called");
  73. IPC::ResponseBuilder rb{ctx, 2};
  74. rb.Push(RESULT_SUCCESS);
  75. }
  76. void ACC_U0::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) {
  77. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  78. rb.Push(RESULT_SUCCESS);
  79. rb.PushIpcInterface<IManagerForApplication>();
  80. LOG_DEBUG(Service_ACC, "called");
  81. }
  82. void ACC_U0::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
  83. LOG_WARNING(Service_ACC, "(STUBBED) called");
  84. IPC::ResponseBuilder rb{ctx, 6};
  85. rb.Push(RESULT_SUCCESS);
  86. rb.PushRaw(DEFAULT_USER_ID);
  87. }
  88. ACC_U0::ACC_U0() : ServiceFramework("acc:u0") {
  89. static const FunctionInfo functions[] = {
  90. {1, &ACC_U0::GetUserExistence, "GetUserExistence"},
  91. {2, &ACC_U0::ListAllUsers, "ListAllUsers"},
  92. {4, &ACC_U0::GetLastOpenedUser, "GetLastOpenedUser"},
  93. {5, &ACC_U0::GetProfile, "GetProfile"},
  94. {100, &ACC_U0::InitializeApplicationInfo, "InitializeApplicationInfo"},
  95. {101, &ACC_U0::GetBaasAccountManagerForApplication, "GetBaasAccountManagerForApplication"},
  96. };
  97. RegisterHandlers(functions);
  98. }
  99. } // namespace Account
  100. } // namespace Service