diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/logging/backend.cpp | 1 | ||||
| -rw-r--r-- | src/common/logging/log.h | 1 | ||||
| -rw-r--r-- | src/core/hle/service/frd/frd.cpp | 91 | ||||
| -rw-r--r-- | src/core/hle/service/frd/frd.h | 88 | ||||
| -rw-r--r-- | src/core/hle/service/frd/frd_u.cpp | 107 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 3 |
6 files changed, 236 insertions, 55 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 4c86151ab..757e0cf47 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -34,6 +34,7 @@ namespace Log { | |||
| 34 | SUB(Kernel, SVC) \ | 34 | SUB(Kernel, SVC) \ |
| 35 | CLS(Service) \ | 35 | CLS(Service) \ |
| 36 | SUB(Service, SRV) \ | 36 | SUB(Service, SRV) \ |
| 37 | SUB(Service, FRD) \ | ||
| 37 | SUB(Service, FS) \ | 38 | SUB(Service, FS) \ |
| 38 | SUB(Service, ERR) \ | 39 | SUB(Service, ERR) \ |
| 39 | SUB(Service, APT) \ | 40 | SUB(Service, APT) \ |
diff --git a/src/common/logging/log.h b/src/common/logging/log.h index e4c39c308..4da4831c3 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h | |||
| @@ -49,6 +49,7 @@ enum class Class : ClassType { | |||
| 49 | Service, ///< HLE implementation of system services. Each major service | 49 | Service, ///< HLE implementation of system services. Each major service |
| 50 | /// should have its own subclass. | 50 | /// should have its own subclass. |
| 51 | Service_SRV, ///< The SRV (Service Directory) implementation | 51 | Service_SRV, ///< The SRV (Service Directory) implementation |
| 52 | Service_FRD, ///< The FRD (Friends) service | ||
| 52 | Service_FS, ///< The FS (Filesystem) service implementation | 53 | Service_FS, ///< The FS (Filesystem) service implementation |
| 53 | Service_ERR, ///< The ERR (Error) port implementation | 54 | Service_ERR, ///< The ERR (Error) port implementation |
| 54 | Service_APT, ///< The APT (Applets) service | 55 | Service_APT, ///< The APT (Applets) service |
diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index c13ffd9d2..15d604bb6 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/string_util.h" | ||
| 6 | |||
| 5 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 6 | #include "core/hle/service/frd/frd.h" | 8 | #include "core/hle/service/frd/frd.h" |
| 7 | #include "core/hle/service/frd/frd_a.h" | 9 | #include "core/hle/service/frd/frd_a.h" |
| @@ -10,6 +12,95 @@ | |||
| 10 | namespace Service { | 12 | namespace Service { |
| 11 | namespace FRD { | 13 | namespace FRD { |
| 12 | 14 | ||
| 15 | static FriendKey my_friend_key = {0, 0, 0ull}; | ||
| 16 | static MyPresence my_presence = {}; | ||
| 17 | |||
| 18 | void GetMyPresence(Service::Interface* self) { | ||
| 19 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 20 | |||
| 21 | u32 shifted_out_size = cmd_buff[64]; | ||
| 22 | u32 my_presence_addr = cmd_buff[65]; | ||
| 23 | |||
| 24 | ASSERT(shifted_out_size == ((sizeof(MyPresence) << 14) | 2)); | ||
| 25 | |||
| 26 | Memory::WriteBlock(my_presence_addr, reinterpret_cast<const u8*>(&my_presence), sizeof(MyPresence)); | ||
| 27 | |||
| 28 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 29 | |||
| 30 | LOG_WARNING(Service_FRD, "(STUBBED) called"); | ||
| 31 | } | ||
| 32 | |||
| 33 | void GetFriendKeyList(Service::Interface* self) { | ||
| 34 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 35 | |||
| 36 | u32 unknown = cmd_buff[1]; | ||
| 37 | u32 frd_count = cmd_buff[2]; | ||
| 38 | u32 frd_key_addr = cmd_buff[65]; | ||
| 39 | |||
| 40 | FriendKey zero_key = {}; | ||
| 41 | for (u32 i = 0; i < frd_count; ++i) { | ||
| 42 | Memory::WriteBlock(frd_key_addr + i * sizeof(FriendKey), | ||
| 43 | reinterpret_cast<const u8*>(&zero_key), sizeof(FriendKey)); | ||
| 44 | } | ||
| 45 | |||
| 46 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 47 | cmd_buff[2] = 0; // 0 friends | ||
| 48 | LOG_WARNING(Service_FRD, "(STUBBED) called, unknown=%d, frd_count=%d, frd_key_addr=0x%08X", | ||
| 49 | unknown, frd_count, frd_key_addr); | ||
| 50 | } | ||
| 51 | |||
| 52 | void GetFriendProfile(Service::Interface* self) { | ||
| 53 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 54 | |||
| 55 | u32 count = cmd_buff[1]; | ||
| 56 | u32 frd_key_addr = cmd_buff[3]; | ||
| 57 | u32 profiles_addr = cmd_buff[65]; | ||
| 58 | |||
| 59 | Profile zero_profile = {}; | ||
| 60 | for (u32 i = 0; i < count; ++i) { | ||
| 61 | Memory::WriteBlock(profiles_addr + i * sizeof(Profile), | ||
| 62 | reinterpret_cast<const u8*>(&zero_profile), sizeof(Profile)); | ||
| 63 | } | ||
| 64 | |||
| 65 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 66 | LOG_WARNING(Service_FRD, "(STUBBED) called, count=%d, frd_key_addr=0x%08X, profiles_addr=0x%08X", | ||
| 67 | count, frd_key_addr, profiles_addr); | ||
| 68 | } | ||
| 69 | |||
| 70 | void GetFriendAttributeFlags(Service::Interface* self) { | ||
| 71 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 72 | |||
| 73 | u32 count = cmd_buff[1]; | ||
| 74 | u32 frd_key_addr = cmd_buff[3]; | ||
| 75 | u32 attr_flags_addr = cmd_buff[65]; | ||
| 76 | |||
| 77 | for (u32 i = 0; i < count; ++i) { | ||
| 78 | //TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte | ||
| 79 | Memory::Write8(attr_flags_addr + i, 0); | ||
| 80 | } | ||
| 81 | |||
| 82 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 83 | LOG_WARNING(Service_FRD, "(STUBBED) called, count=%d, frd_key_addr=0x%08X, attr_flags_addr=0x%08X", | ||
| 84 | count, frd_key_addr, attr_flags_addr); | ||
| 85 | } | ||
| 86 | |||
| 87 | void GetMyFriendKey(Service::Interface* self) { | ||
| 88 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 89 | |||
| 90 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 91 | Memory::WriteBlock(cmd_buff[2], reinterpret_cast<const u8*>(&my_friend_key), sizeof(FriendKey)); | ||
| 92 | LOG_WARNING(Service_FRD, "(STUBBED) called"); | ||
| 93 | } | ||
| 94 | |||
| 95 | void GetMyScreenName(Service::Interface* self) { | ||
| 96 | u32* cmd_buff = Kernel::GetCommandBuffer(); | ||
| 97 | |||
| 98 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | ||
| 99 | // TODO: (mailwl) get the name from config | ||
| 100 | Common::UTF8ToUTF16("Citra").copy(reinterpret_cast<char16_t*>(&cmd_buff[2]), 11); | ||
| 101 | LOG_WARNING(Service_FRD, "(STUBBED) called"); | ||
| 102 | } | ||
| 103 | |||
| 13 | void Init() { | 104 | void Init() { |
| 14 | using namespace Kernel; | 105 | using namespace Kernel; |
| 15 | 106 | ||
diff --git a/src/core/hle/service/frd/frd.h b/src/core/hle/service/frd/frd.h index f9f88b444..c8283a7f3 100644 --- a/src/core/hle/service/frd/frd.h +++ b/src/core/hle/service/frd/frd.h | |||
| @@ -4,9 +4,97 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 7 | namespace Service { | 9 | namespace Service { |
| 10 | |||
| 11 | class Interface; | ||
| 12 | |||
| 8 | namespace FRD { | 13 | namespace FRD { |
| 9 | 14 | ||
| 15 | struct FriendKey { | ||
| 16 | u32 friend_id; | ||
| 17 | u32 unknown; | ||
| 18 | u64 friend_code; | ||
| 19 | }; | ||
| 20 | |||
| 21 | struct MyPresence { | ||
| 22 | u8 unknown[0x12C]; | ||
| 23 | }; | ||
| 24 | |||
| 25 | struct Profile { | ||
| 26 | u8 region; | ||
| 27 | u8 country; | ||
| 28 | u8 area; | ||
| 29 | u8 language; | ||
| 30 | u32 unknown; | ||
| 31 | }; | ||
| 32 | |||
| 33 | /** | ||
| 34 | * FRD::GetMyPresence service function | ||
| 35 | * Inputs: | ||
| 36 | * 64 : sizeof (MyPresence) << 14 | 2 | ||
| 37 | * 65 : Address of MyPresence structure | ||
| 38 | * Outputs: | ||
| 39 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 40 | */ | ||
| 41 | void GetMyPresence(Service::Interface* self); | ||
| 42 | |||
| 43 | /** | ||
| 44 | * FRD::GetFriendKeyList service function | ||
| 45 | * Inputs: | ||
| 46 | * 1 : Unknown | ||
| 47 | * 2 : Max friends count | ||
| 48 | * 65 : Address of FriendKey List | ||
| 49 | * Outputs: | ||
| 50 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 51 | * 2 : FriendKey count filled | ||
| 52 | */ | ||
| 53 | void GetFriendKeyList(Service::Interface* self); | ||
| 54 | |||
| 55 | /** | ||
| 56 | * FRD::GetFriendProfile service function | ||
| 57 | * Inputs: | ||
| 58 | * 1 : Friends count | ||
| 59 | * 2 : Friends count << 18 | 2 | ||
| 60 | * 3 : Address of FriendKey List | ||
| 61 | * 64 : (count * sizeof (Profile)) << 10 | 2 | ||
| 62 | * 65 : Address of Profiles List | ||
| 63 | * Outputs: | ||
| 64 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 65 | */ | ||
| 66 | void GetFriendProfile(Service::Interface* self); | ||
| 67 | |||
| 68 | /** | ||
| 69 | * FRD::GetFriendAttributeFlags service function | ||
| 70 | * Inputs: | ||
| 71 | * 1 : Friends count | ||
| 72 | * 2 : Friends count << 18 | 2 | ||
| 73 | * 3 : Address of FriendKey List | ||
| 74 | * 65 : Address of AttributeFlags | ||
| 75 | * Outputs: | ||
| 76 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 77 | */ | ||
| 78 | void GetFriendAttributeFlags(Service::Interface* self); | ||
| 79 | |||
| 80 | /** | ||
| 81 | * FRD::GetMyFriendKey service function | ||
| 82 | * Inputs: | ||
| 83 | * none | ||
| 84 | * Outputs: | ||
| 85 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 86 | * 2-5 : FriendKey | ||
| 87 | */ | ||
| 88 | void GetMyFriendKey(Service::Interface* self); | ||
| 89 | |||
| 90 | /** | ||
| 91 | * FRD::GetMyScreenName service function | ||
| 92 | * Outputs: | ||
| 93 | * 1 : Result of function, 0 on success, otherwise error code | ||
| 94 | * 2 : UTF16 encoded name (max 11 symbols) | ||
| 95 | */ | ||
| 96 | void GetMyScreenName(Service::Interface* self); | ||
| 97 | |||
| 10 | /// Initialize FRD service(s) | 98 | /// Initialize FRD service(s) |
| 11 | void Init(); | 99 | void Init(); |
| 12 | 100 | ||
diff --git a/src/core/hle/service/frd/frd_u.cpp b/src/core/hle/service/frd/frd_u.cpp index 2c6885377..db8666416 100644 --- a/src/core/hle/service/frd/frd_u.cpp +++ b/src/core/hle/service/frd/frd_u.cpp | |||
| @@ -2,65 +2,66 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "core/hle/service/frd/frd.h" | ||
| 5 | #include "core/hle/service/frd/frd_u.h" | 6 | #include "core/hle/service/frd/frd_u.h" |
| 6 | 7 | ||
| 7 | namespace Service { | 8 | namespace Service { |
| 8 | namespace FRD { | 9 | namespace FRD { |
| 9 | 10 | ||
| 10 | const Interface::FunctionInfo FunctionTable[] = { | 11 | const Interface::FunctionInfo FunctionTable[] = { |
| 11 | {0x00010000, nullptr, "HasLoggedIn"}, | 12 | {0x00010000, nullptr, "HasLoggedIn"}, |
| 12 | {0x00020000, nullptr, "IsOnline"}, | 13 | {0x00020000, nullptr, "IsOnline"}, |
| 13 | {0x00030000, nullptr, "Login"}, | 14 | {0x00030000, nullptr, "Login"}, |
| 14 | {0x00040000, nullptr, "Logout"}, | 15 | {0x00040000, nullptr, "Logout"}, |
| 15 | {0x00050000, nullptr, "GetMyFriendKey"}, | 16 | {0x00050000, GetMyFriendKey, "GetMyFriendKey"}, |
| 16 | {0x00060000, nullptr, "GetMyPreference"}, | 17 | {0x00060000, nullptr, "GetMyPreference"}, |
| 17 | {0x00070000, nullptr, "GetMyProfile"}, | 18 | {0x00070000, nullptr, "GetMyProfile"}, |
| 18 | {0x00080000, nullptr, "GetMyPresence"}, | 19 | {0x00080000, GetMyPresence, "GetMyPresence"}, |
| 19 | {0x00090000, nullptr, "GetMyScreenName"}, | 20 | {0x00090000, GetMyScreenName, "GetMyScreenName"}, |
| 20 | {0x000A0000, nullptr, "GetMyMii"}, | 21 | {0x000A0000, nullptr, "GetMyMii"}, |
| 21 | {0x000B0000, nullptr, "GetMyLocalAccountId"}, | 22 | {0x000B0000, nullptr, "GetMyLocalAccountId"}, |
| 22 | {0x000C0000, nullptr, "GetMyPlayingGame"}, | 23 | {0x000C0000, nullptr, "GetMyPlayingGame"}, |
| 23 | {0x000D0000, nullptr, "GetMyFavoriteGame"}, | 24 | {0x000D0000, nullptr, "GetMyFavoriteGame"}, |
| 24 | {0x000E0000, nullptr, "GetMyNcPrincipalId"}, | 25 | {0x000E0000, nullptr, "GetMyNcPrincipalId"}, |
| 25 | {0x000F0000, nullptr, "GetMyComment"}, | 26 | {0x000F0000, nullptr, "GetMyComment"}, |
| 26 | {0x00100040, nullptr, "GetMyPassword"}, | 27 | {0x00100040, nullptr, "GetMyPassword"}, |
| 27 | {0x00110080, nullptr, "GetFriendKeyList"}, | 28 | {0x00110080, GetFriendKeyList, "GetFriendKeyList"}, |
| 28 | {0x00120042, nullptr, "GetFriendPresence"}, | 29 | {0x00120042, nullptr, "GetFriendPresence"}, |
| 29 | {0x00130142, nullptr, "GetFriendScreenName"}, | 30 | {0x00130142, nullptr, "GetFriendScreenName"}, |
| 30 | {0x00140044, nullptr, "GetFriendMii"}, | 31 | {0x00140044, nullptr, "GetFriendMii"}, |
| 31 | {0x00150042, nullptr, "GetFriendProfile"}, | 32 | {0x00150042, GetFriendProfile, "GetFriendProfile"}, |
| 32 | {0x00160042, nullptr, "GetFriendRelationship"}, | 33 | {0x00160042, nullptr, "GetFriendRelationship"}, |
| 33 | {0x00170042, nullptr, "GetFriendAttributeFlags"}, | 34 | {0x00170042, GetFriendAttributeFlags, "GetFriendAttributeFlags"}, |
| 34 | {0x00180044, nullptr, "GetFriendPlayingGame"}, | 35 | {0x00180044, nullptr, "GetFriendPlayingGame"}, |
| 35 | {0x00190042, nullptr, "GetFriendFavoriteGame"}, | 36 | {0x00190042, nullptr, "GetFriendFavoriteGame"}, |
| 36 | {0x001A00C4, nullptr, "GetFriendInfo"}, | 37 | {0x001A00C4, nullptr, "GetFriendInfo"}, |
| 37 | {0x001B0080, nullptr, "IsIncludedInFriendList"}, | 38 | {0x001B0080, nullptr, "IsIncludedInFriendList"}, |
| 38 | {0x001C0042, nullptr, "UnscrambleLocalFriendCode"}, | 39 | {0x001C0042, nullptr, "UnscrambleLocalFriendCode"}, |
| 39 | {0x001D0002, nullptr, "UpdateGameModeDescription"}, | 40 | {0x001D0002, nullptr, "UpdateGameModeDescription"}, |
| 40 | {0x001E02C2, nullptr, "UpdateGameMode"}, | 41 | {0x001E02C2, nullptr, "UpdateGameMode"}, |
| 41 | {0x001F0042, nullptr, "SendInvitation"}, | 42 | {0x001F0042, nullptr, "SendInvitation"}, |
| 42 | {0x00200002, nullptr, "AttachToEventNotification"}, | 43 | {0x00200002, nullptr, "AttachToEventNotification"}, |
| 43 | {0x00210040, nullptr, "SetNotificationMask"}, | 44 | {0x00210040, nullptr, "SetNotificationMask"}, |
| 44 | {0x00220040, nullptr, "GetEventNotification"}, | 45 | {0x00220040, nullptr, "GetEventNotification"}, |
| 45 | {0x00230000, nullptr, "GetLastResponseResult"}, | 46 | {0x00230000, nullptr, "GetLastResponseResult"}, |
| 46 | {0x00240040, nullptr, "PrincipalIdToFriendCode"}, | 47 | {0x00240040, nullptr, "PrincipalIdToFriendCode"}, |
| 47 | {0x00250080, nullptr, "FriendCodeToPrincipalId"}, | 48 | {0x00250080, nullptr, "FriendCodeToPrincipalId"}, |
| 48 | {0x00260080, nullptr, "IsValidFriendCode"}, | 49 | {0x00260080, nullptr, "IsValidFriendCode"}, |
| 49 | {0x00270040, nullptr, "ResultToErrorCode"}, | 50 | {0x00270040, nullptr, "ResultToErrorCode"}, |
| 50 | {0x00280244, nullptr, "RequestGameAuthentication"}, | 51 | {0x00280244, nullptr, "RequestGameAuthentication"}, |
| 51 | {0x00290000, nullptr, "GetGameAuthenticationData"}, | 52 | {0x00290000, nullptr, "GetGameAuthenticationData"}, |
| 52 | {0x002A0204, nullptr, "RequestServiceLocator"}, | 53 | {0x002A0204, nullptr, "RequestServiceLocator"}, |
| 53 | {0x002B0000, nullptr, "GetServiceLocatorData"}, | 54 | {0x002B0000, nullptr, "GetServiceLocatorData"}, |
| 54 | {0x002C0002, nullptr, "DetectNatProperties"}, | 55 | {0x002C0002, nullptr, "DetectNatProperties"}, |
| 55 | {0x002D0000, nullptr, "GetNatProperties"}, | 56 | {0x002D0000, nullptr, "GetNatProperties"}, |
| 56 | {0x002E0000, nullptr, "GetServerTimeInterval"}, | 57 | {0x002E0000, nullptr, "GetServerTimeInterval"}, |
| 57 | {0x002F0040, nullptr, "AllowHalfAwake"}, | 58 | {0x002F0040, nullptr, "AllowHalfAwake"}, |
| 58 | {0x00300000, nullptr, "GetServerTypes"}, | 59 | {0x00300000, nullptr, "GetServerTypes"}, |
| 59 | {0x00310082, nullptr, "GetFriendComment"}, | 60 | {0x00310082, nullptr, "GetFriendComment"}, |
| 60 | {0x00320042, nullptr, "SetClientSdkVersion"}, | 61 | {0x00320042, nullptr, "SetClientSdkVersion"}, |
| 61 | {0x00330000, nullptr, "GetMyApproachContext"}, | 62 | {0x00330000, nullptr, "GetMyApproachContext"}, |
| 62 | {0x00340046, nullptr, "AddFriendWithApproach"}, | 63 | {0x00340046, nullptr, "AddFriendWithApproach"}, |
| 63 | {0x00350082, nullptr, "DecryptApproachContext"}, | 64 | {0x00350082, nullptr, "DecryptApproachContext"}, |
| 64 | }; | 65 | }; |
| 65 | 66 | ||
| 66 | FRD_U_Interface::FRD_U_Interface() { | 67 | FRD_U_Interface::FRD_U_Interface() { |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 35b648409..833a68f05 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -70,9 +70,8 @@ ResultVal<bool> Interface::SyncRequest() { | |||
| 70 | // TODO(bunnei): Hack - ignore error | 70 | // TODO(bunnei): Hack - ignore error |
| 71 | cmd_buff[1] = 0; | 71 | cmd_buff[1] = 0; |
| 72 | return MakeResult<bool>(false); | 72 | return MakeResult<bool>(false); |
| 73 | } else { | ||
| 74 | LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName().c_str(), cmd_buff).c_str()); | ||
| 75 | } | 73 | } |
| 74 | LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName().c_str(), cmd_buff).c_str()); | ||
| 76 | 75 | ||
| 77 | itr->second.func(this); | 76 | itr->second.func(this); |
| 78 | 77 | ||