acc.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.h"
  7. #include "core/hle/service/acc/acc_aa.h"
  8. #include "core/hle/service/acc/acc_su.h"
  9. #include "core/hle/service/acc/acc_u0.h"
  10. #include "core/hle/service/acc/acc_u1.h"
  11. namespace Service {
  12. namespace Account {
  13. // TODO: RE this structure
  14. struct UserData {
  15. INSERT_PADDING_WORDS(1);
  16. u32 icon_id;
  17. u8 bg_color_id;
  18. INSERT_PADDING_BYTES(0x7);
  19. INSERT_PADDING_BYTES(0x10);
  20. INSERT_PADDING_BYTES(0x60);
  21. };
  22. static_assert(sizeof(UserData) == 0x80, "UserData structure has incorrect size");
  23. struct ProfileBase {
  24. u8 user_id[0x10];
  25. u64 timestamp;
  26. u8 username[0x20];
  27. };
  28. static_assert(sizeof(ProfileBase) == 0x38, "ProfileBase structure has incorrect size");
  29. using Uid = std::array<u64, 2>;
  30. static constexpr Uid DEFAULT_USER_ID{0x10ull, 0x20ull};
  31. class IProfile final : public ServiceFramework<IProfile> {
  32. public:
  33. IProfile() : ServiceFramework("IProfile") {
  34. static const FunctionInfo functions[] = {
  35. {1, &IProfile::GetBase, "GetBase"},
  36. };
  37. RegisterHandlers(functions);
  38. }
  39. private:
  40. void GetBase(Kernel::HLERequestContext& ctx) {
  41. LOG_WARNING(Service_ACC, "(STUBBED) called");
  42. ProfileBase profile_base{};
  43. IPC::ResponseBuilder rb{ctx, 16};
  44. rb.Push(RESULT_SUCCESS);
  45. rb.PushRaw(profile_base);
  46. }
  47. };
  48. class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
  49. public:
  50. IManagerForApplication() : ServiceFramework("IManagerForApplication") {
  51. static const FunctionInfo functions[] = {
  52. {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"},
  53. {1, &IManagerForApplication::GetAccountId, "GetAccountId"},
  54. };
  55. RegisterHandlers(functions);
  56. }
  57. private:
  58. void CheckAvailability(Kernel::HLERequestContext& ctx) {
  59. LOG_WARNING(Service_ACC, "(STUBBED) called");
  60. IPC::ResponseBuilder rb{ctx, 3};
  61. rb.Push(RESULT_SUCCESS);
  62. rb.Push(true); // TODO: Check when this is supposed to return true and when not
  63. }
  64. void GetAccountId(Kernel::HLERequestContext& ctx) {
  65. LOG_WARNING(Service_ACC, "(STUBBED) called");
  66. IPC::ResponseBuilder rb{ctx, 4};
  67. rb.Push(RESULT_SUCCESS);
  68. rb.Push<u64>(0x12345678ABCDEF);
  69. }
  70. };
  71. void Module::Interface::GetUserExistence(Kernel::HLERequestContext& ctx) {
  72. LOG_WARNING(Service_ACC, "(STUBBED) called");
  73. IPC::ResponseBuilder rb{ctx, 3};
  74. rb.Push(RESULT_SUCCESS);
  75. rb.Push(true); // TODO: Check when this is supposed to return true and when not
  76. }
  77. void Module::Interface::ListAllUsers(Kernel::HLERequestContext& ctx) {
  78. LOG_WARNING(Service_ACC, "(STUBBED) called");
  79. constexpr std::array<u128, 10> user_ids{DEFAULT_USER_ID};
  80. ctx.WriteBuffer(user_ids.data(), user_ids.size());
  81. IPC::ResponseBuilder rb{ctx, 2};
  82. rb.Push(RESULT_SUCCESS);
  83. }
  84. void Module::Interface::ListOpenUsers(Kernel::HLERequestContext& ctx) {
  85. LOG_WARNING(Service_ACC, "(STUBBED) called");
  86. constexpr std::array<u128, 10> user_ids{DEFAULT_USER_ID};
  87. ctx.WriteBuffer(user_ids.data(), user_ids.size());
  88. IPC::ResponseBuilder rb{ctx, 2};
  89. rb.Push(RESULT_SUCCESS);
  90. }
  91. void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
  92. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  93. rb.Push(RESULT_SUCCESS);
  94. rb.PushIpcInterface<IProfile>();
  95. LOG_DEBUG(Service_ACC, "called");
  96. }
  97. void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) {
  98. LOG_WARNING(Service_ACC, "(STUBBED) called");
  99. IPC::ResponseBuilder rb{ctx, 2};
  100. rb.Push(RESULT_SUCCESS);
  101. }
  102. void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestContext& ctx) {
  103. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  104. rb.Push(RESULT_SUCCESS);
  105. rb.PushIpcInterface<IManagerForApplication>();
  106. LOG_DEBUG(Service_ACC, "called");
  107. }
  108. void Module::Interface::GetLastOpenedUser(Kernel::HLERequestContext& ctx) {
  109. LOG_WARNING(Service_ACC, "(STUBBED) called");
  110. IPC::ResponseBuilder rb{ctx, 6};
  111. rb.Push(RESULT_SUCCESS);
  112. rb.PushRaw(DEFAULT_USER_ID);
  113. }
  114. Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
  115. : ServiceFramework(name), module(std::move(module)) {}
  116. void InstallInterfaces(SM::ServiceManager& service_manager) {
  117. auto module = std::make_shared<Module>();
  118. std::make_shared<ACC_AA>(module)->InstallAsService(service_manager);
  119. std::make_shared<ACC_SU>(module)->InstallAsService(service_manager);
  120. std::make_shared<ACC_U0>(module)->InstallAsService(service_manager);
  121. std::make_shared<ACC_U1>(module)->InstallAsService(service_manager);
  122. }
  123. } // namespace Account
  124. } // namespace Service