diff options
| author | 2023-04-14 17:46:20 -0600 | |
|---|---|---|
| committer | 2023-04-23 23:28:09 -0600 | |
| commit | a3fa64fcc489d2cc1776807a37db3464dcc32686 (patch) | |
| tree | 2ec9e6abd4b588f6584ec41ea6edf816ad25c98c /src | |
| parent | Merge pull request #10074 from Kelebek1/fermi_blit (diff) | |
| download | yuzu-a3fa64fcc489d2cc1776807a37db3464dcc32686.tar.gz yuzu-a3fa64fcc489d2cc1776807a37db3464dcc32686.tar.xz yuzu-a3fa64fcc489d2cc1776807a37db3464dcc32686.zip | |
service: nfc: Create interface
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/service/nfc/nfc.cpp | 110 | ||||
| -rw-r--r-- | src/core/hle/service/nfc/nfc_device.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/service/nfc/nfc_interface.cpp (renamed from src/core/hle/service/nfc/nfc_user.cpp) | 66 | ||||
| -rw-r--r-- | src/core/hle/service/nfc/nfc_interface.h (renamed from src/core/hle/service/nfc/nfc_user.h) | 18 | ||||
| -rw-r--r-- | src/core/hle/service/nfp/nfp.cpp | 24 |
5 files changed, 104 insertions, 115 deletions
diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index 6595e34ed..7a8f59725 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp | |||
| @@ -8,12 +8,83 @@ | |||
| 8 | #include "core/hle/service/ipc_helpers.h" | 8 | #include "core/hle/service/ipc_helpers.h" |
| 9 | #include "core/hle/service/nfc/mifare_user.h" | 9 | #include "core/hle/service/nfc/mifare_user.h" |
| 10 | #include "core/hle/service/nfc/nfc.h" | 10 | #include "core/hle/service/nfc/nfc.h" |
| 11 | #include "core/hle/service/nfc/nfc_user.h" | 11 | #include "core/hle/service/nfc/nfc_interface.h" |
| 12 | #include "core/hle/service/server_manager.h" | 12 | #include "core/hle/service/server_manager.h" |
| 13 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| 14 | 14 | ||
| 15 | namespace Service::NFC { | 15 | namespace Service::NFC { |
| 16 | 16 | ||
| 17 | class IUser final : public Interface { | ||
| 18 | public: | ||
| 19 | explicit IUser(Core::System& system_) : Interface(system_, "IUser") { | ||
| 20 | // clang-format off | ||
| 21 | static const FunctionInfo functions[] = { | ||
| 22 | {0, &Interface::Initialize, "InitializeOld"}, | ||
| 23 | {1, &Interface::Finalize, "FinalizeOld"}, | ||
| 24 | {2, &Interface::GetState, "GetStateOld"}, | ||
| 25 | {3, &Interface::IsNfcEnabled, "IsNfcEnabledOld"}, | ||
| 26 | {400, &Interface::Initialize, "Initialize"}, | ||
| 27 | {401, &Interface::Finalize, "Finalize"}, | ||
| 28 | {402, &Interface::GetState, "GetState"}, | ||
| 29 | {403, &Interface::IsNfcEnabled, "IsNfcEnabled"}, | ||
| 30 | {404, &Interface::ListDevices, "ListDevices"}, | ||
| 31 | {405, &Interface::GetDeviceState, "GetDeviceState"}, | ||
| 32 | {406, &Interface::GetNpadId, "GetNpadId"}, | ||
| 33 | {407, &Interface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, | ||
| 34 | {408, &Interface::StartDetection, "StartDetection"}, | ||
| 35 | {409, &Interface::StopDetection, "StopDetection"}, | ||
| 36 | {410, &Interface::GetTagInfo, "GetTagInfo"}, | ||
| 37 | {411, &Interface::AttachActivateEvent, "AttachActivateEvent"}, | ||
| 38 | {412, &Interface::AttachDeactivateEvent, "AttachDeactivateEvent"}, | ||
| 39 | {1000, nullptr, "ReadMifare"}, | ||
| 40 | {1001, nullptr, "WriteMifare"}, | ||
| 41 | {1300, &Interface::SendCommandByPassThrough, "SendCommandByPassThrough"}, | ||
| 42 | {1301, nullptr, "KeepPassThroughSession"}, | ||
| 43 | {1302, nullptr, "ReleasePassThroughSession"}, | ||
| 44 | }; | ||
| 45 | // clang-format on | ||
| 46 | |||
| 47 | RegisterHandlers(functions); | ||
| 48 | } | ||
| 49 | }; | ||
| 50 | |||
| 51 | class ISystem final : public Interface { | ||
| 52 | public: | ||
| 53 | explicit ISystem(Core::System& system_) : Interface{system_, "ISystem"} { | ||
| 54 | // clang-format off | ||
| 55 | static const FunctionInfo functions[] = { | ||
| 56 | {0, &Interface::Initialize, "InitializeOld"}, | ||
| 57 | {1, &Interface::Finalize, "FinalizeOld"}, | ||
| 58 | {2, &Interface::GetState, "GetStateOld"}, | ||
| 59 | {3, &Interface::IsNfcEnabled, "IsNfcEnabledOld"}, | ||
| 60 | {100, nullptr, "SetNfcEnabledOld"}, | ||
| 61 | {400, &Interface::Initialize, "Initialize"}, | ||
| 62 | {401, &Interface::Finalize, "Finalize"}, | ||
| 63 | {402, &Interface::GetState, "GetState"}, | ||
| 64 | {403, &Interface::IsNfcEnabled, "IsNfcEnabled"}, | ||
| 65 | {404, &Interface::ListDevices, "ListDevices"}, | ||
| 66 | {405, &Interface::GetDeviceState, "GetDeviceState"}, | ||
| 67 | {406, &Interface::GetNpadId, "GetNpadId"}, | ||
| 68 | {407, &Interface::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, | ||
| 69 | {408, &Interface::StartDetection, "StartDetection"}, | ||
| 70 | {409, &Interface::StopDetection, "StopDetection"}, | ||
| 71 | {410, &Interface::GetTagInfo, "GetTagInfo"}, | ||
| 72 | {411, &Interface::AttachActivateEvent, "AttachActivateEvent"}, | ||
| 73 | {412, &Interface::AttachDeactivateEvent, "AttachDeactivateEvent"}, | ||
| 74 | {500, nullptr, "SetNfcEnabled"}, | ||
| 75 | {510, nullptr, "OutputTestWave"}, | ||
| 76 | {1000, nullptr, "ReadMifare"}, | ||
| 77 | {1001, nullptr, "WriteMifare"}, | ||
| 78 | {1300, &Interface::SendCommandByPassThrough, "SendCommandByPassThrough"}, | ||
| 79 | {1301, nullptr, "KeepPassThroughSession"}, | ||
| 80 | {1302, nullptr, "ReleasePassThroughSession"}, | ||
| 81 | }; | ||
| 82 | // clang-format on | ||
| 83 | |||
| 84 | RegisterHandlers(functions); | ||
| 85 | } | ||
| 86 | }; | ||
| 87 | |||
| 17 | class IAm final : public ServiceFramework<IAm> { | 88 | class IAm final : public ServiceFramework<IAm> { |
| 18 | public: | 89 | public: |
| 19 | explicit IAm(Core::System& system_) : ServiceFramework{system_, "NFC::IAm"} { | 90 | explicit IAm(Core::System& system_) : ServiceFramework{system_, "NFC::IAm"} { |
| @@ -95,43 +166,6 @@ private: | |||
| 95 | } | 166 | } |
| 96 | }; | 167 | }; |
| 97 | 168 | ||
| 98 | class ISystem final : public ServiceFramework<ISystem> { | ||
| 99 | public: | ||
| 100 | explicit ISystem(Core::System& system_) : ServiceFramework{system_, "ISystem"} { | ||
| 101 | // clang-format off | ||
| 102 | static const FunctionInfo functions[] = { | ||
| 103 | {0, nullptr, "Initialize"}, | ||
| 104 | {1, nullptr, "Finalize"}, | ||
| 105 | {2, nullptr, "GetStateOld"}, | ||
| 106 | {3, nullptr, "IsNfcEnabledOld"}, | ||
| 107 | {100, nullptr, "SetNfcEnabledOld"}, | ||
| 108 | {400, nullptr, "InitializeSystem"}, | ||
| 109 | {401, nullptr, "FinalizeSystem"}, | ||
| 110 | {402, nullptr, "GetState"}, | ||
| 111 | {403, nullptr, "IsNfcEnabled"}, | ||
| 112 | {404, nullptr, "ListDevices"}, | ||
| 113 | {405, nullptr, "GetDeviceState"}, | ||
| 114 | {406, nullptr, "GetNpadId"}, | ||
| 115 | {407, nullptr, "AttachAvailabilityChangeEvent"}, | ||
| 116 | {408, nullptr, "StartDetection"}, | ||
| 117 | {409, nullptr, "StopDetection"}, | ||
| 118 | {410, nullptr, "GetTagInfo"}, | ||
| 119 | {411, nullptr, "AttachActivateEvent"}, | ||
| 120 | {412, nullptr, "AttachDeactivateEvent"}, | ||
| 121 | {500, nullptr, "SetNfcEnabled"}, | ||
| 122 | {510, nullptr, "OutputTestWave"}, | ||
| 123 | {1000, nullptr, "ReadMifare"}, | ||
| 124 | {1001, nullptr, "WriteMifare"}, | ||
| 125 | {1300, nullptr, "SendCommandByPassThrough"}, | ||
| 126 | {1301, nullptr, "KeepPassThroughSession"}, | ||
| 127 | {1302, nullptr, "ReleasePassThroughSession"}, | ||
| 128 | }; | ||
| 129 | // clang-format on | ||
| 130 | |||
| 131 | RegisterHandlers(functions); | ||
| 132 | } | ||
| 133 | }; | ||
| 134 | |||
| 135 | class NFC_SYS final : public ServiceFramework<NFC_SYS> { | 169 | class NFC_SYS final : public ServiceFramework<NFC_SYS> { |
| 136 | public: | 170 | public: |
| 137 | explicit NFC_SYS(Core::System& system_) : ServiceFramework{system_, "nfc:sys"} { | 171 | explicit NFC_SYS(Core::System& system_) : ServiceFramework{system_, "nfc:sys"} { |
diff --git a/src/core/hle/service/nfc/nfc_device.cpp b/src/core/hle/service/nfc/nfc_device.cpp index c7db74d14..47bc1a05d 100644 --- a/src/core/hle/service/nfc/nfc_device.cpp +++ b/src/core/hle/service/nfc/nfc_device.cpp | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | #include "core/hle/service/ipc_helpers.h" | 11 | #include "core/hle/service/ipc_helpers.h" |
| 12 | #include "core/hle/service/nfc/nfc_device.h" | 12 | #include "core/hle/service/nfc/nfc_device.h" |
| 13 | #include "core/hle/service/nfc/nfc_result.h" | 13 | #include "core/hle/service/nfc/nfc_result.h" |
| 14 | #include "core/hle/service/nfc/nfc_user.h" | ||
| 15 | 14 | ||
| 16 | namespace Service::NFC { | 15 | namespace Service::NFC { |
| 17 | NfcDevice::NfcDevice(Core::HID::NpadIdType npad_id_, Core::System& system_, | 16 | NfcDevice::NfcDevice(Core::HID::NpadIdType npad_id_, Core::System& system_, |
diff --git a/src/core/hle/service/nfc/nfc_user.cpp b/src/core/hle/service/nfc/nfc_interface.cpp index 7c162a4f3..be96d0cbc 100644 --- a/src/core/hle/service/nfc/nfc_user.cpp +++ b/src/core/hle/service/nfc/nfc_interface.cpp | |||
| @@ -7,41 +7,15 @@ | |||
| 7 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/kernel/k_event.h" |
| 8 | #include "core/hle/service/ipc_helpers.h" | 8 | #include "core/hle/service/ipc_helpers.h" |
| 9 | #include "core/hle/service/nfc/nfc_device.h" | 9 | #include "core/hle/service/nfc/nfc_device.h" |
| 10 | #include "core/hle/service/nfc/nfc_interface.h" | ||
| 10 | #include "core/hle/service/nfc/nfc_result.h" | 11 | #include "core/hle/service/nfc/nfc_result.h" |
| 11 | #include "core/hle/service/nfc/nfc_user.h" | ||
| 12 | #include "core/hle/service/time/clock_types.h" | 12 | #include "core/hle/service/time/clock_types.h" |
| 13 | 13 | ||
| 14 | namespace Service::NFC { | 14 | namespace Service::NFC { |
| 15 | 15 | ||
| 16 | IUser::IUser(Core::System& system_) | 16 | Interface::Interface(Core::System& system_, const char* name) |
| 17 | : ServiceFramework{system_, "NFC::IUser"}, service_context{system_, service_name} { | 17 | : ServiceFramework{system_, name}, service_context{system_, service_name} { |
| 18 | static const FunctionInfo functions[] = { | 18 | availability_change_event = service_context.CreateEvent("Interface:AvailabilityChangeEvent"); |
| 19 | {0, &IUser::Initialize, "InitializeOld"}, | ||
| 20 | {1, &IUser::Finalize, "FinalizeOld"}, | ||
| 21 | {2, &IUser::GetState, "GetStateOld"}, | ||
| 22 | {3, &IUser::IsNfcEnabled, "IsNfcEnabledOld"}, | ||
| 23 | {400, &IUser::Initialize, "Initialize"}, | ||
| 24 | {401, &IUser::Finalize, "Finalize"}, | ||
| 25 | {402, &IUser::GetState, "GetState"}, | ||
| 26 | {403, &IUser::IsNfcEnabled, "IsNfcEnabled"}, | ||
| 27 | {404, &IUser::ListDevices, "ListDevices"}, | ||
| 28 | {405, &IUser::GetDeviceState, "GetDeviceState"}, | ||
| 29 | {406, &IUser::GetNpadId, "GetNpadId"}, | ||
| 30 | {407, &IUser::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, | ||
| 31 | {408, &IUser::StartDetection, "StartDetection"}, | ||
| 32 | {409, &IUser::StopDetection, "StopDetection"}, | ||
| 33 | {410, &IUser::GetTagInfo, "GetTagInfo"}, | ||
| 34 | {411, &IUser::AttachActivateEvent, "AttachActivateEvent"}, | ||
| 35 | {412, &IUser::AttachDeactivateEvent, "AttachDeactivateEvent"}, | ||
| 36 | {1000, nullptr, "ReadMifare"}, | ||
| 37 | {1001, nullptr, "WriteMifare"}, | ||
| 38 | {1300, &IUser::SendCommandByPassThrough, "SendCommandByPassThrough"}, | ||
| 39 | {1301, nullptr, "KeepPassThroughSession"}, | ||
| 40 | {1302, nullptr, "ReleasePassThroughSession"}, | ||
| 41 | }; | ||
| 42 | RegisterHandlers(functions); | ||
| 43 | |||
| 44 | availability_change_event = service_context.CreateEvent("IUser:AvailabilityChangeEvent"); | ||
| 45 | 19 | ||
| 46 | for (u32 device_index = 0; device_index < 10; device_index++) { | 20 | for (u32 device_index = 0; device_index < 10; device_index++) { |
| 47 | devices[device_index] = | 21 | devices[device_index] = |
| @@ -50,11 +24,11 @@ IUser::IUser(Core::System& system_) | |||
| 50 | } | 24 | } |
| 51 | } | 25 | } |
| 52 | 26 | ||
| 53 | IUser ::~IUser() { | 27 | Interface ::~Interface() { |
| 54 | availability_change_event->Close(); | 28 | availability_change_event->Close(); |
| 55 | } | 29 | } |
| 56 | 30 | ||
| 57 | void IUser::Initialize(HLERequestContext& ctx) { | 31 | void Interface::Initialize(HLERequestContext& ctx) { |
| 58 | LOG_INFO(Service_NFC, "called"); | 32 | LOG_INFO(Service_NFC, "called"); |
| 59 | 33 | ||
| 60 | state = State::Initialized; | 34 | state = State::Initialized; |
| @@ -67,7 +41,7 @@ void IUser::Initialize(HLERequestContext& ctx) { | |||
| 67 | rb.Push(ResultSuccess); | 41 | rb.Push(ResultSuccess); |
| 68 | } | 42 | } |
| 69 | 43 | ||
| 70 | void IUser::Finalize(HLERequestContext& ctx) { | 44 | void Interface::Finalize(HLERequestContext& ctx) { |
| 71 | LOG_INFO(Service_NFC, "called"); | 45 | LOG_INFO(Service_NFC, "called"); |
| 72 | 46 | ||
| 73 | state = State::NonInitialized; | 47 | state = State::NonInitialized; |
| @@ -80,7 +54,7 @@ void IUser::Finalize(HLERequestContext& ctx) { | |||
| 80 | rb.Push(ResultSuccess); | 54 | rb.Push(ResultSuccess); |
| 81 | } | 55 | } |
| 82 | 56 | ||
| 83 | void IUser::GetState(HLERequestContext& ctx) { | 57 | void Interface::GetState(HLERequestContext& ctx) { |
| 84 | LOG_DEBUG(Service_NFC, "called"); | 58 | LOG_DEBUG(Service_NFC, "called"); |
| 85 | 59 | ||
| 86 | IPC::ResponseBuilder rb{ctx, 3}; | 60 | IPC::ResponseBuilder rb{ctx, 3}; |
| @@ -88,7 +62,7 @@ void IUser::GetState(HLERequestContext& ctx) { | |||
| 88 | rb.PushEnum(state); | 62 | rb.PushEnum(state); |
| 89 | } | 63 | } |
| 90 | 64 | ||
| 91 | void IUser::IsNfcEnabled(HLERequestContext& ctx) { | 65 | void Interface::IsNfcEnabled(HLERequestContext& ctx) { |
| 92 | LOG_DEBUG(Service_NFC, "called"); | 66 | LOG_DEBUG(Service_NFC, "called"); |
| 93 | 67 | ||
| 94 | IPC::ResponseBuilder rb{ctx, 3}; | 68 | IPC::ResponseBuilder rb{ctx, 3}; |
| @@ -96,7 +70,7 @@ void IUser::IsNfcEnabled(HLERequestContext& ctx) { | |||
| 96 | rb.Push(state != State::NonInitialized); | 70 | rb.Push(state != State::NonInitialized); |
| 97 | } | 71 | } |
| 98 | 72 | ||
| 99 | void IUser::ListDevices(HLERequestContext& ctx) { | 73 | void Interface::ListDevices(HLERequestContext& ctx) { |
| 100 | LOG_DEBUG(Service_NFC, "called"); | 74 | LOG_DEBUG(Service_NFC, "called"); |
| 101 | 75 | ||
| 102 | if (state == State::NonInitialized) { | 76 | if (state == State::NonInitialized) { |
| @@ -142,7 +116,7 @@ void IUser::ListDevices(HLERequestContext& ctx) { | |||
| 142 | rb.Push(static_cast<s32>(nfp_devices.size())); | 116 | rb.Push(static_cast<s32>(nfp_devices.size())); |
| 143 | } | 117 | } |
| 144 | 118 | ||
| 145 | void IUser::GetDeviceState(HLERequestContext& ctx) { | 119 | void Interface::GetDeviceState(HLERequestContext& ctx) { |
| 146 | IPC::RequestParser rp{ctx}; | 120 | IPC::RequestParser rp{ctx}; |
| 147 | const auto device_handle{rp.Pop<u64>()}; | 121 | const auto device_handle{rp.Pop<u64>()}; |
| 148 | LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); | 122 | LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); |
| @@ -160,7 +134,7 @@ void IUser::GetDeviceState(HLERequestContext& ctx) { | |||
| 160 | rb.PushEnum(device.value()->GetCurrentState()); | 134 | rb.PushEnum(device.value()->GetCurrentState()); |
| 161 | } | 135 | } |
| 162 | 136 | ||
| 163 | void IUser::GetNpadId(HLERequestContext& ctx) { | 137 | void Interface::GetNpadId(HLERequestContext& ctx) { |
| 164 | IPC::RequestParser rp{ctx}; | 138 | IPC::RequestParser rp{ctx}; |
| 165 | const auto device_handle{rp.Pop<u64>()}; | 139 | const auto device_handle{rp.Pop<u64>()}; |
| 166 | LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); | 140 | LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); |
| @@ -184,7 +158,7 @@ void IUser::GetNpadId(HLERequestContext& ctx) { | |||
| 184 | rb.PushEnum(device.value()->GetNpadId()); | 158 | rb.PushEnum(device.value()->GetNpadId()); |
| 185 | } | 159 | } |
| 186 | 160 | ||
| 187 | void IUser::AttachAvailabilityChangeEvent(HLERequestContext& ctx) { | 161 | void Interface::AttachAvailabilityChangeEvent(HLERequestContext& ctx) { |
| 188 | LOG_INFO(Service_NFC, "called"); | 162 | LOG_INFO(Service_NFC, "called"); |
| 189 | 163 | ||
| 190 | if (state == State::NonInitialized) { | 164 | if (state == State::NonInitialized) { |
| @@ -198,7 +172,7 @@ void IUser::AttachAvailabilityChangeEvent(HLERequestContext& ctx) { | |||
| 198 | rb.PushCopyObjects(availability_change_event->GetReadableEvent()); | 172 | rb.PushCopyObjects(availability_change_event->GetReadableEvent()); |
| 199 | } | 173 | } |
| 200 | 174 | ||
| 201 | void IUser::StartDetection(HLERequestContext& ctx) { | 175 | void Interface::StartDetection(HLERequestContext& ctx) { |
| 202 | IPC::RequestParser rp{ctx}; | 176 | IPC::RequestParser rp{ctx}; |
| 203 | const auto device_handle{rp.Pop<u64>()}; | 177 | const auto device_handle{rp.Pop<u64>()}; |
| 204 | const auto nfp_protocol{rp.PopEnum<NFP::TagProtocol>()}; | 178 | const auto nfp_protocol{rp.PopEnum<NFP::TagProtocol>()}; |
| @@ -223,7 +197,7 @@ void IUser::StartDetection(HLERequestContext& ctx) { | |||
| 223 | rb.Push(result); | 197 | rb.Push(result); |
| 224 | } | 198 | } |
| 225 | 199 | ||
| 226 | void IUser::StopDetection(HLERequestContext& ctx) { | 200 | void Interface::StopDetection(HLERequestContext& ctx) { |
| 227 | IPC::RequestParser rp{ctx}; | 201 | IPC::RequestParser rp{ctx}; |
| 228 | const auto device_handle{rp.Pop<u64>()}; | 202 | const auto device_handle{rp.Pop<u64>()}; |
| 229 | LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); | 203 | LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); |
| @@ -247,7 +221,7 @@ void IUser::StopDetection(HLERequestContext& ctx) { | |||
| 247 | rb.Push(result); | 221 | rb.Push(result); |
| 248 | } | 222 | } |
| 249 | 223 | ||
| 250 | void IUser::GetTagInfo(HLERequestContext& ctx) { | 224 | void Interface::GetTagInfo(HLERequestContext& ctx) { |
| 251 | IPC::RequestParser rp{ctx}; | 225 | IPC::RequestParser rp{ctx}; |
| 252 | const auto device_handle{rp.Pop<u64>()}; | 226 | const auto device_handle{rp.Pop<u64>()}; |
| 253 | LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); | 227 | LOG_INFO(Service_NFC, "called, device_handle={}", device_handle); |
| @@ -273,7 +247,7 @@ void IUser::GetTagInfo(HLERequestContext& ctx) { | |||
| 273 | rb.Push(result); | 247 | rb.Push(result); |
| 274 | } | 248 | } |
| 275 | 249 | ||
| 276 | void IUser::AttachActivateEvent(HLERequestContext& ctx) { | 250 | void Interface::AttachActivateEvent(HLERequestContext& ctx) { |
| 277 | IPC::RequestParser rp{ctx}; | 251 | IPC::RequestParser rp{ctx}; |
| 278 | const auto device_handle{rp.Pop<u64>()}; | 252 | const auto device_handle{rp.Pop<u64>()}; |
| 279 | LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); | 253 | LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); |
| @@ -297,7 +271,7 @@ void IUser::AttachActivateEvent(HLERequestContext& ctx) { | |||
| 297 | rb.PushCopyObjects(device.value()->GetActivateEvent()); | 271 | rb.PushCopyObjects(device.value()->GetActivateEvent()); |
| 298 | } | 272 | } |
| 299 | 273 | ||
| 300 | void IUser::AttachDeactivateEvent(HLERequestContext& ctx) { | 274 | void Interface::AttachDeactivateEvent(HLERequestContext& ctx) { |
| 301 | IPC::RequestParser rp{ctx}; | 275 | IPC::RequestParser rp{ctx}; |
| 302 | const auto device_handle{rp.Pop<u64>()}; | 276 | const auto device_handle{rp.Pop<u64>()}; |
| 303 | LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); | 277 | LOG_DEBUG(Service_NFC, "called, device_handle={}", device_handle); |
| @@ -321,7 +295,7 @@ void IUser::AttachDeactivateEvent(HLERequestContext& ctx) { | |||
| 321 | rb.PushCopyObjects(device.value()->GetDeactivateEvent()); | 295 | rb.PushCopyObjects(device.value()->GetDeactivateEvent()); |
| 322 | } | 296 | } |
| 323 | 297 | ||
| 324 | void IUser::SendCommandByPassThrough(HLERequestContext& ctx) { | 298 | void Interface::SendCommandByPassThrough(HLERequestContext& ctx) { |
| 325 | IPC::RequestParser rp{ctx}; | 299 | IPC::RequestParser rp{ctx}; |
| 326 | const auto device_handle{rp.Pop<u64>()}; | 300 | const auto device_handle{rp.Pop<u64>()}; |
| 327 | const auto timeout{rp.PopRaw<Time::Clock::TimeSpanType>()}; | 301 | const auto timeout{rp.PopRaw<Time::Clock::TimeSpanType>()}; |
| @@ -353,7 +327,7 @@ void IUser::SendCommandByPassThrough(HLERequestContext& ctx) { | |||
| 353 | rb.Push(static_cast<u32>(out_data.size())); | 327 | rb.Push(static_cast<u32>(out_data.size())); |
| 354 | } | 328 | } |
| 355 | 329 | ||
| 356 | std::optional<std::shared_ptr<NfcDevice>> IUser::GetNfcDevice(u64 handle) { | 330 | std::optional<std::shared_ptr<NfcDevice>> Interface::GetNfcDevice(u64 handle) { |
| 357 | for (auto& device : devices) { | 331 | for (auto& device : devices) { |
| 358 | if (device->GetHandle() == handle) { | 332 | if (device->GetHandle() == handle) { |
| 359 | return device; | 333 | return device; |
diff --git a/src/core/hle/service/nfc/nfc_user.h b/src/core/hle/service/nfc/nfc_interface.h index aee046ae8..8c1bf5a59 100644 --- a/src/core/hle/service/nfc/nfc_user.h +++ b/src/core/hle/service/nfc/nfc_interface.h | |||
| @@ -13,16 +13,10 @@ | |||
| 13 | namespace Service::NFC { | 13 | namespace Service::NFC { |
| 14 | class NfcDevice; | 14 | class NfcDevice; |
| 15 | 15 | ||
| 16 | class IUser final : public ServiceFramework<IUser> { | 16 | class Interface : public ServiceFramework<Interface> { |
| 17 | public: | 17 | public: |
| 18 | explicit IUser(Core::System& system_); | 18 | explicit Interface(Core::System& system_, const char* name); |
| 19 | ~IUser(); | 19 | ~Interface(); |
| 20 | |||
| 21 | private: | ||
| 22 | enum class State : u32 { | ||
| 23 | NonInitialized, | ||
| 24 | Initialized, | ||
| 25 | }; | ||
| 26 | 20 | ||
| 27 | void Initialize(HLERequestContext& ctx); | 21 | void Initialize(HLERequestContext& ctx); |
| 28 | void Finalize(HLERequestContext& ctx); | 22 | void Finalize(HLERequestContext& ctx); |
| @@ -39,6 +33,12 @@ private: | |||
| 39 | void AttachDeactivateEvent(HLERequestContext& ctx); | 33 | void AttachDeactivateEvent(HLERequestContext& ctx); |
| 40 | void SendCommandByPassThrough(HLERequestContext& ctx); | 34 | void SendCommandByPassThrough(HLERequestContext& ctx); |
| 41 | 35 | ||
| 36 | private: | ||
| 37 | enum class State : u32 { | ||
| 38 | NonInitialized, | ||
| 39 | Initialized, | ||
| 40 | }; | ||
| 41 | |||
| 42 | std::optional<std::shared_ptr<NfcDevice>> GetNfcDevice(u64 handle); | 42 | std::optional<std::shared_ptr<NfcDevice>> GetNfcDevice(u64 handle); |
| 43 | 43 | ||
| 44 | KernelHelpers::ServiceContext service_context; | 44 | KernelHelpers::ServiceContext service_context; |
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 2714f4bea..2559fe598 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp | |||
| @@ -152,16 +152,10 @@ private: | |||
| 152 | void CreateUserInterface(HLERequestContext& ctx) { | 152 | void CreateUserInterface(HLERequestContext& ctx) { |
| 153 | LOG_DEBUG(Service_NFP, "called"); | 153 | LOG_DEBUG(Service_NFP, "called"); |
| 154 | 154 | ||
| 155 | if (user_interface == nullptr) { | ||
| 156 | user_interface = std::make_shared<IUser>(system); | ||
| 157 | } | ||
| 158 | |||
| 159 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 155 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 160 | rb.Push(ResultSuccess); | 156 | rb.Push(ResultSuccess); |
| 161 | rb.PushIpcInterface<IUser>(user_interface); | 157 | rb.PushIpcInterface<IUser>(system); |
| 162 | } | 158 | } |
| 163 | |||
| 164 | std::shared_ptr<IUser> user_interface; | ||
| 165 | }; | 159 | }; |
| 166 | 160 | ||
| 167 | class ISystemManager final : public ServiceFramework<ISystemManager> { | 161 | class ISystemManager final : public ServiceFramework<ISystemManager> { |
| @@ -180,16 +174,10 @@ private: | |||
| 180 | void CreateSystemInterface(HLERequestContext& ctx) { | 174 | void CreateSystemInterface(HLERequestContext& ctx) { |
| 181 | LOG_DEBUG(Service_NFP, "called"); | 175 | LOG_DEBUG(Service_NFP, "called"); |
| 182 | 176 | ||
| 183 | if (system_interface == nullptr) { | ||
| 184 | system_interface = std::make_shared<ISystem>(system); | ||
| 185 | } | ||
| 186 | |||
| 187 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 177 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 188 | rb.Push(ResultSuccess); | 178 | rb.Push(ResultSuccess); |
| 189 | rb.PushIpcInterface<ISystem>(system_interface); | 179 | rb.PushIpcInterface<ISystem>(system); |
| 190 | } | 180 | } |
| 191 | |||
| 192 | std::shared_ptr<ISystem> system_interface; | ||
| 193 | }; | 181 | }; |
| 194 | 182 | ||
| 195 | class IDebugManager final : public ServiceFramework<IDebugManager> { | 183 | class IDebugManager final : public ServiceFramework<IDebugManager> { |
| @@ -208,16 +196,10 @@ private: | |||
| 208 | void CreateDebugInterface(HLERequestContext& ctx) { | 196 | void CreateDebugInterface(HLERequestContext& ctx) { |
| 209 | LOG_DEBUG(Service_NFP, "called"); | 197 | LOG_DEBUG(Service_NFP, "called"); |
| 210 | 198 | ||
| 211 | if (system_interface == nullptr) { | ||
| 212 | system_interface = std::make_shared<IDebug>(system); | ||
| 213 | } | ||
| 214 | |||
| 215 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 199 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 216 | rb.Push(ResultSuccess); | 200 | rb.Push(ResultSuccess); |
| 217 | rb.PushIpcInterface<IDebug>(system_interface); | 201 | rb.PushIpcInterface<IDebug>(system); |
| 218 | } | 202 | } |
| 219 | |||
| 220 | std::shared_ptr<IDebug> system_interface; | ||
| 221 | }; | 203 | }; |
| 222 | 204 | ||
| 223 | void LoopProcess(Core::System& system) { | 205 | void LoopProcess(Core::System& system) { |