mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Service/NFC: convert to ServiceFramework
This commit is contained in:
		
							parent
							
								
									42d68d6ea4
								
							
						
					
					
						commit
						e40d693057
					
				
					 7 changed files with 272 additions and 260 deletions
				
			
		|  | @ -2,10 +2,8 @@ | ||||||
| // Licensed under GPLv2 or any later version
 | // Licensed under GPLv2 or any later version
 | ||||||
| // Refer to the license.txt file included.
 | // Refer to the license.txt file included.
 | ||||||
| 
 | 
 | ||||||
| #include "core/hle/ipc.h" |  | ||||||
| #include "core/hle/ipc_helpers.h" | #include "core/hle/ipc_helpers.h" | ||||||
| #include "core/hle/kernel/event.h" | #include "core/hle/kernel/event.h" | ||||||
| #include "core/hle/kernel/handle_table.h" |  | ||||||
| #include "core/hle/service/nfc/nfc.h" | #include "core/hle/service/nfc/nfc.h" | ||||||
| #include "core/hle/service/nfc/nfc_m.h" | #include "core/hle/service/nfc/nfc_m.h" | ||||||
| #include "core/hle/service/nfc/nfc_u.h" | #include "core/hle/service/nfc/nfc_u.h" | ||||||
|  | @ -13,48 +11,46 @@ | ||||||
| namespace Service { | namespace Service { | ||||||
| namespace NFC { | namespace NFC { | ||||||
| 
 | 
 | ||||||
| static Kernel::SharedPtr<Kernel::Event> tag_in_range_event; | void Module::Interface::Initialize(Kernel::HLERequestContext& ctx) { | ||||||
| static Kernel::SharedPtr<Kernel::Event> tag_out_of_range_event; |     IPC::RequestParser rp(ctx, 0x01, 1, 0); | ||||||
| static TagState nfc_tag_state = TagState::NotInitialized; |     u8 param = rp.Pop<u8>(); | ||||||
| static CommunicationStatus nfc_status = CommunicationStatus::NfcInitialized; |  | ||||||
| 
 | 
 | ||||||
| void Initialize(Interface* self) { |     nfc->nfc_tag_state = TagState::NotScanning; | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |  | ||||||
| 
 | 
 | ||||||
|     u8 param = static_cast<u8>(cmd_buff[1] & 0xFF); |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | ||||||
| 
 |     rb.Push(RESULT_SUCCESS); | ||||||
|     nfc_tag_state = TagState::NotScanning; |  | ||||||
| 
 |  | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |  | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called, param=%u", param); |     LOG_WARNING(Service_NFC, "(STUBBED) called, param=%u", param); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Shutdown(Interface* self) { | void Module::Interface::Shutdown(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x02, 1, 0); | ||||||
|  |     u8 param = rp.Pop<u8>(); | ||||||
| 
 | 
 | ||||||
|     u8 param = static_cast<u8>(cmd_buff[1] & 0xFF); |     nfc->nfc_tag_state = TagState::NotInitialized; | ||||||
|     nfc_tag_state = TagState::NotInitialized; |  | ||||||
| 
 | 
 | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | ||||||
|  |     rb.Push(RESULT_SUCCESS); | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called, param=%u", param); |     LOG_WARNING(Service_NFC, "(STUBBED) called, param=%u", param); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void StartCommunication(Interface* self) { | void Module::Interface::StartCommunication(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x03, 0, 0); | ||||||
| 
 | 
 | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | ||||||
|  |     rb.Push(RESULT_SUCCESS); | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called"); |     LOG_WARNING(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void StopCommunication(Interface* self) { | void Module::Interface::StopCommunication(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x04, 0, 0); | ||||||
| 
 | 
 | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | ||||||
|  |     rb.Push(RESULT_SUCCESS); | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called"); |     LOG_WARNING(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void StartTagScanning(Interface* self) { | void Module::Interface::StartTagScanning(Kernel::HLERequestContext& ctx) { | ||||||
|     IPC::RequestParser rp(Kernel::GetCommandBuffer(), 5, 1, 0); // 0x00050040
 |     IPC::RequestParser rp(ctx, 0x05, 1, 0); // 0x00050040
 | ||||||
|     u16 in_val = rp.Pop<u16>(); |     u16 in_val = rp.Pop<u16>(); | ||||||
| 
 | 
 | ||||||
|     ResultCode result = RESULT_SUCCESS; |     ResultCode result = RESULT_SUCCESS; | ||||||
|  | @ -64,8 +60,8 @@ void StartTagScanning(Interface* self) { | ||||||
|                         ErrorSummary::InvalidState, ErrorLevel::Status); |                         ErrorSummary::InvalidState, ErrorLevel::Status); | ||||||
| 
 | 
 | ||||||
|     if (result == RESULT_SUCCESS) { |     if (result == RESULT_SUCCESS) { | ||||||
|         nfc_tag_state = TagState::TagInRange; |         nfc->nfc_tag_state = TagState::TagInRange; | ||||||
|         tag_in_range_event->Signal(); |         nfc->tag_in_range_event->Signal(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | ||||||
|  | @ -73,83 +69,90 @@ void StartTagScanning(Interface* self) { | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called, in_val=%04x", in_val); |     LOG_WARNING(Service_NFC, "(STUBBED) called, in_val=%04x", in_val); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void StopTagScanning(Interface* self) { | void Module::Interface::StopTagScanning(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x06, 0, 0); | ||||||
| 
 | 
 | ||||||
|     nfc_tag_state = TagState::NotScanning; |     nfc->nfc_tag_state = TagState::NotScanning; | ||||||
| 
 | 
 | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | ||||||
|  |     rb.Push(RESULT_SUCCESS); | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called"); |     LOG_WARNING(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void LoadAmiiboData(Interface* self) { | void Module::Interface::LoadAmiiboData(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x07, 0, 0); | ||||||
| 
 | 
 | ||||||
|     nfc_tag_state = TagState::TagDataLoaded; |     nfc->nfc_tag_state = TagState::TagDataLoaded; | ||||||
| 
 | 
 | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | ||||||
|  |     rb.Push(RESULT_SUCCESS); | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called"); |     LOG_WARNING(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ResetTagScanState(Interface* self) { | void Module::Interface::ResetTagScanState(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x08, 0, 0); | ||||||
| 
 | 
 | ||||||
|     nfc_tag_state = TagState::NotScanning; |     nfc->nfc_tag_state = TagState::NotScanning; | ||||||
| 
 | 
 | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); | ||||||
|  |     rb.Push(RESULT_SUCCESS); | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called"); |     LOG_WARNING(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GetTagInRangeEvent(Interface* self) { | void Module::Interface::GetTagInRangeEvent(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x0B, 0, 0); | ||||||
| 
 | 
 | ||||||
|     cmd_buff[0] = IPC::MakeHeader(0xB, 1, 2); |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; |     rb.Push(RESULT_SUCCESS); | ||||||
|     cmd_buff[2] = IPC::CopyHandleDesc(); |     rb.PushCopyObjects(nfc->tag_in_range_event); | ||||||
|     cmd_buff[3] = Kernel::g_handle_table.Create(tag_in_range_event).Unwrap(); |  | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called"); |     LOG_WARNING(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GetTagOutOfRangeEvent(Interface* self) { | void Module::Interface::GetTagOutOfRangeEvent(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x0C, 0, 0); | ||||||
| 
 | 
 | ||||||
|     cmd_buff[0] = IPC::MakeHeader(0xC, 1, 2); |     IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; |     rb.Push(RESULT_SUCCESS); | ||||||
|     cmd_buff[2] = IPC::CopyHandleDesc(); |     rb.PushCopyObjects(nfc->tag_out_of_range_event); | ||||||
|     cmd_buff[3] = Kernel::g_handle_table.Create(tag_out_of_range_event).Unwrap(); |  | ||||||
|     LOG_WARNING(Service_NFC, "(STUBBED) called"); |     LOG_WARNING(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void GetTagState(Interface* self) { | void Module::Interface::GetTagState(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x0D, 0, 0); | ||||||
| 
 | 
 | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |     IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); | ||||||
|     cmd_buff[2] = static_cast<u8>(nfc_tag_state); |     rb.Push(RESULT_SUCCESS); | ||||||
|  |     rb.PushEnum(nfc->nfc_tag_state); | ||||||
|     LOG_DEBUG(Service_NFC, "(STUBBED) called"); |     LOG_DEBUG(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CommunicationGetStatus(Interface* self) { | void Module::Interface::CommunicationGetStatus(Kernel::HLERequestContext& ctx) { | ||||||
|     u32* cmd_buff = Kernel::GetCommandBuffer(); |     IPC::RequestParser rp(ctx, 0x0F, 0, 0); | ||||||
| 
 | 
 | ||||||
|     cmd_buff[1] = RESULT_SUCCESS.raw; // No error
 |     IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); | ||||||
|     cmd_buff[2] = static_cast<u8>(nfc_status); |     rb.Push(RESULT_SUCCESS); | ||||||
|  |     rb.PushEnum(nfc->nfc_status); | ||||||
|     LOG_DEBUG(Service_NFC, "(STUBBED) called"); |     LOG_DEBUG(Service_NFC, "(STUBBED) called"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Init() { | Module::Interface::Interface(std::shared_ptr<Module> nfc, const char* name, u32 max_session) | ||||||
|     AddService(new NFC_M()); |     : ServiceFramework(name, max_session), nfc(std::move(nfc)) {} | ||||||
|     AddService(new NFC_U()); |  | ||||||
| 
 | 
 | ||||||
|  | Module::Interface::~Interface() = default; | ||||||
|  | 
 | ||||||
|  | Module::Module() { | ||||||
|     tag_in_range_event = |     tag_in_range_event = | ||||||
|         Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_in_range_event"); |         Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_in_range_event"); | ||||||
|     tag_out_of_range_event = |     tag_out_of_range_event = | ||||||
|         Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_out_range_event"); |         Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_out_range_event"); | ||||||
|     nfc_tag_state = TagState::NotInitialized; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Shutdown() { | Module::~Module() = default; | ||||||
|     tag_in_range_event = nullptr; | 
 | ||||||
|     tag_out_of_range_event = nullptr; | void InstallInterfaces(SM::ServiceManager& service_manager) { | ||||||
|  |     auto nfc = std::make_shared<Module>(); | ||||||
|  |     std::make_shared<NFC_M>(nfc)->InstallAsService(service_manager); | ||||||
|  |     std::make_shared<NFC_U>(nfc)->InstallAsService(service_manager); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace NFC
 | } // namespace NFC
 | ||||||
|  |  | ||||||
|  | @ -4,12 +4,16 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include <memory> | ||||||
| #include "common/common_types.h" | #include "common/common_types.h" | ||||||
|  | #include "core/hle/kernel/kernel.h" | ||||||
|  | #include "core/hle/service/service.h" | ||||||
|  | 
 | ||||||
|  | namespace Kernel { | ||||||
|  | class Event; | ||||||
|  | } // namespace Kernel
 | ||||||
| 
 | 
 | ||||||
| namespace Service { | namespace Service { | ||||||
| 
 |  | ||||||
| class Interface; |  | ||||||
| 
 |  | ||||||
| namespace NFC { | namespace NFC { | ||||||
| 
 | 
 | ||||||
| namespace ErrCodes { | namespace ErrCodes { | ||||||
|  | @ -32,128 +36,146 @@ enum class CommunicationStatus : u8 { | ||||||
|     NfcInitialized = 2, |     NfcInitialized = 2, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| /**
 | class Module final { | ||||||
|  * NFC::Initialize service function | public: | ||||||
|  *  Inputs: |     Module(); | ||||||
|  *      0 : Header code [0x00010040] |     ~Module(); | ||||||
|  *      1 : (u8) unknown parameter. Can be either value 0x1 or 0x2 |  | ||||||
|  *  Outputs: |  | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |  | ||||||
|  */ |  | ||||||
| void Initialize(Interface* self); |  | ||||||
| 
 | 
 | ||||||
| /**
 |     class Interface : public ServiceFramework<Interface> { | ||||||
|  * NFC::Shutdown service function |     public: | ||||||
|  *  Inputs: |         Interface(std::shared_ptr<Module> nfc, const char* name, u32 max_session); | ||||||
|  *      0 : Header code [0x00020040] |         ~Interface(); | ||||||
|  *      1 : (u8) unknown parameter |  | ||||||
|  *  Outputs: |  | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |  | ||||||
|  */ |  | ||||||
| void Shutdown(Interface* self); |  | ||||||
| 
 | 
 | ||||||
| /**
 |     protected: | ||||||
|  * NFC::StartCommunication service function |         /**
 | ||||||
|  *  Inputs: |          * NFC::Initialize service function | ||||||
|  *      0 : Header code [0x00030000] |          *  Inputs: | ||||||
|  *  Outputs: |          *      0 : Header code [0x00010040] | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *      1 : (u8) unknown parameter. Can be either value 0x1 or 0x2 | ||||||
|  */ |          *  Outputs: | ||||||
| void StartCommunication(Interface* self); |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  |          */ | ||||||
|  |         void Initialize(Kernel::HLERequestContext& ctx); | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::StopCommunication service function |          * NFC::Shutdown service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x00040000] |          *      0 : Header code [0x00020040] | ||||||
|  *  Outputs: |          *      1 : (u8) unknown parameter | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *  Outputs: | ||||||
|  */ |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
| void StopCommunication(Interface* self); |          */ | ||||||
|  |         void Shutdown(Kernel::HLERequestContext& ctx); | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::StartTagScanning service function |          * NFC::StartCommunication service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x00050040] |          *      0 : Header code [0x00030000] | ||||||
|  *      1 : (u16) unknown. This is normally 0x0 |          *  Outputs: | ||||||
|  *  Outputs: |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          */ | ||||||
|  */ |         void StartCommunication(Kernel::HLERequestContext& ctx); | ||||||
| void StartTagScanning(Interface* self); |  | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::StopTagScanning service function |          * NFC::StopCommunication service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x00060000] |          *      0 : Header code [0x00040000] | ||||||
|  *  Outputs: |          *  Outputs: | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  */ |          */ | ||||||
| void StopTagScanning(Interface* self); |         void StopCommunication(Kernel::HLERequestContext& ctx); | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::LoadAmiiboData service function |          * NFC::StartTagScanning service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x00070000] |          *      0 : Header code [0x00050040] | ||||||
|  *  Outputs: |          *      1 : (u16) unknown. This is normally 0x0 | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *  Outputs: | ||||||
|  */ |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
| void LoadAmiiboData(Interface* self); |          */ | ||||||
|  |         void StartTagScanning(Kernel::HLERequestContext& ctx); | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::ResetTagScanState service function |          * NFC::StopTagScanning service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x00080000] |          *      0 : Header code [0x00060000] | ||||||
|  *  Outputs: |          *  Outputs: | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  */ |          */ | ||||||
| void ResetTagScanState(Interface* self); |         void StopTagScanning(Kernel::HLERequestContext& ctx); | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::GetTagInRangeEvent service function |          * NFC::LoadAmiiboData service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x000B0000] |          *      0 : Header code [0x00070000] | ||||||
|  *  Outputs: |          *  Outputs: | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  *      2 : Copy handle descriptor |          */ | ||||||
|  *      3 : Event Handle |         void LoadAmiiboData(Kernel::HLERequestContext& ctx); | ||||||
|  */ |  | ||||||
| void GetTagInRangeEvent(Interface* self); |  | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::GetTagOutOfRangeEvent service function |          * NFC::ResetTagScanState service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x000C0000] |          *      0 : Header code [0x00080000] | ||||||
|  *  Outputs: |          *  Outputs: | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  *      2 : Copy handle descriptor |          */ | ||||||
|  *      3 : Event Handle |         void ResetTagScanState(Kernel::HLERequestContext& ctx); | ||||||
|  */ |  | ||||||
| void GetTagOutOfRangeEvent(Interface* self); |  | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::GetTagState service function |          * NFC::GetTagInRangeEvent service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x000D0000] |          *      0 : Header code [0x000B0000] | ||||||
|  *  Outputs: |          *  Outputs: | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  *      2 : (u8) Tag state |          *      2 : Copy handle descriptor | ||||||
|  */ |          *      3 : Event Handle | ||||||
| void GetTagState(Interface* self); |          */ | ||||||
|  |         void GetTagInRangeEvent(Kernel::HLERequestContext& ctx); | ||||||
| 
 | 
 | ||||||
| /**
 |         /**
 | ||||||
|  * NFC::CommunicationGetStatus service function |          * NFC::GetTagOutOfRangeEvent service function | ||||||
|  *  Inputs: |          *  Inputs: | ||||||
|  *      0 : Header code [0x000F0000] |          *      0 : Header code [0x000C0000] | ||||||
|  *  Outputs: |          *  Outputs: | ||||||
|  *      1 : Result of function, 0 on success, otherwise error code |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  *      2 : (u8) Communication state |          *      2 : Copy handle descriptor | ||||||
|  */ |          *      3 : Event Handle | ||||||
| void CommunicationGetStatus(Interface* self); |          */ | ||||||
|  |         void GetTagOutOfRangeEvent(Kernel::HLERequestContext& ctx); | ||||||
| 
 | 
 | ||||||
| /// Initialize all NFC services.
 |         /**
 | ||||||
| void Init(); |          * NFC::GetTagState service function | ||||||
|  |          *  Inputs: | ||||||
|  |          *      0 : Header code [0x000D0000] | ||||||
|  |          *  Outputs: | ||||||
|  |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  |          *      2 : (u8) Tag state | ||||||
|  |          */ | ||||||
|  |         void GetTagState(Kernel::HLERequestContext& ctx); | ||||||
| 
 | 
 | ||||||
| /// Shutdown all NFC services.
 |         /**
 | ||||||
| void Shutdown(); |          * NFC::CommunicationGetStatus service function | ||||||
|  |          *  Inputs: | ||||||
|  |          *      0 : Header code [0x000F0000] | ||||||
|  |          *  Outputs: | ||||||
|  |          *      1 : Result of function, 0 on success, otherwise error code | ||||||
|  |          *      2 : (u8) Communication state | ||||||
|  |          */ | ||||||
|  |         void CommunicationGetStatus(Kernel::HLERequestContext& ctx); | ||||||
|  | 
 | ||||||
|  |     private: | ||||||
|  |         std::shared_ptr<Module> nfc; | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |     Kernel::SharedPtr<Kernel::Event> tag_in_range_event; | ||||||
|  |     Kernel::SharedPtr<Kernel::Event> tag_out_of_range_event; | ||||||
|  |     TagState nfc_tag_state = TagState::NotInitialized; | ||||||
|  |     CommunicationStatus nfc_status = CommunicationStatus::NfcInitialized; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | void InstallInterfaces(SM::ServiceManager& service_manager); | ||||||
| 
 | 
 | ||||||
| } // namespace NFC
 | } // namespace NFC
 | ||||||
| } // namespace Service
 | } // namespace Service
 | ||||||
|  |  | ||||||
|  | @ -2,45 +2,43 @@ | ||||||
| // Licensed under GPLv2 or any later version
 | // Licensed under GPLv2 or any later version
 | ||||||
| // Refer to the license.txt file included.
 | // Refer to the license.txt file included.
 | ||||||
| 
 | 
 | ||||||
| #include "core/hle/service/nfc/nfc.h" |  | ||||||
| #include "core/hle/service/nfc/nfc_m.h" | #include "core/hle/service/nfc/nfc_m.h" | ||||||
| 
 | 
 | ||||||
| namespace Service { | namespace Service { | ||||||
| namespace NFC { | namespace NFC { | ||||||
| 
 | 
 | ||||||
| const Interface::FunctionInfo FunctionTable[] = { | NFC_M::NFC_M(std::shared_ptr<Module> nfc) : Module::Interface(std::move(nfc), "nfc:m", 1) { | ||||||
|     // clang-format off
 |     static const FunctionInfo functions[] = { | ||||||
|     // nfc:u shared commands
 |         // clang-format off
 | ||||||
|     {0x00010040, Initialize, "Initialize"}, |         // nfc:u shared commands
 | ||||||
|     {0x00020040, Shutdown, "Shutdown"}, |         {0x00010040, &NFC_M::Initialize, "Initialize"}, | ||||||
|     {0x00030000, StartCommunication, "StartCommunication"}, |         {0x00020040, &NFC_M::Shutdown, "Shutdown"}, | ||||||
|     {0x00040000, StopCommunication, "StopCommunication"}, |         {0x00030000, &NFC_M::StartCommunication, "StartCommunication"}, | ||||||
|     {0x00050040, StartTagScanning, "StartTagScanning"}, |         {0x00040000, &NFC_M::StopCommunication, "StopCommunication"}, | ||||||
|     {0x00060000, StopTagScanning, "StopTagScanning"}, |         {0x00050040, &NFC_M::StartTagScanning, "StartTagScanning"}, | ||||||
|     {0x00070000, LoadAmiiboData, "LoadAmiiboData"}, |         {0x00060000, &NFC_M::StopTagScanning, "StopTagScanning"}, | ||||||
|     {0x00080000, ResetTagScanState, "ResetTagScanState"}, |         {0x00070000, &NFC_M::LoadAmiiboData, "LoadAmiiboData"}, | ||||||
|     {0x00090002, nullptr, "UpdateStoredAmiiboData"}, |         {0x00080000, &NFC_M::ResetTagScanState, "ResetTagScanState"}, | ||||||
|     {0x000B0000, GetTagInRangeEvent, "GetTagInRangeEvent"}, |         {0x00090002, nullptr, "UpdateStoredAmiiboData"}, | ||||||
|     {0x000C0000, GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"}, |         {0x000B0000, &NFC_M::GetTagInRangeEvent, "GetTagInRangeEvent"}, | ||||||
|     {0x000D0000, GetTagState, "GetTagState"}, |         {0x000C0000, &NFC_M::GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"}, | ||||||
|     {0x000F0000, CommunicationGetStatus, "CommunicationGetStatus"}, |         {0x000D0000, &NFC_M::GetTagState, "GetTagState"}, | ||||||
|     {0x00100000, nullptr, "GetTagInfo2"}, |         {0x000F0000, &NFC_M::CommunicationGetStatus, "CommunicationGetStatus"}, | ||||||
|     {0x00110000, nullptr, "GetTagInfo"}, |         {0x00100000, nullptr, "GetTagInfo2"}, | ||||||
|     {0x00120000, nullptr, "CommunicationGetResult"}, |         {0x00110000, nullptr, "GetTagInfo"}, | ||||||
|     {0x00130040, nullptr, "OpenAppData"}, |         {0x00120000, nullptr, "CommunicationGetResult"}, | ||||||
|     {0x00140384, nullptr, "InitializeWriteAppData"}, |         {0x00130040, nullptr, "OpenAppData"}, | ||||||
|     {0x00150040, nullptr, "ReadAppData"}, |         {0x00140384, nullptr, "InitializeWriteAppData"}, | ||||||
|     {0x00160242, nullptr, "WriteAppData"}, |         {0x00150040, nullptr, "ReadAppData"}, | ||||||
|     {0x00170000, nullptr, "GetAmiiboSettings"}, |         {0x00160242, nullptr, "WriteAppData"}, | ||||||
|     {0x00180000, nullptr, "GetAmiiboConfig"}, |         {0x00170000, nullptr, "GetAmiiboSettings"}, | ||||||
|     {0x00190000, nullptr, "GetAppDataInitStruct"}, |         {0x00180000, nullptr, "GetAmiiboConfig"}, | ||||||
|     // nfc:m
 |         {0x00190000, nullptr, "GetAppDataInitStruct"}, | ||||||
|     {0x04040A40, nullptr, "SetAmiiboSettings"} |         // nfc:m
 | ||||||
|     // clang-format on
 |         {0x04040A40, nullptr, "SetAmiiboSettings"} | ||||||
| }; |         // clang-format on
 | ||||||
| 
 |     }; | ||||||
| NFC_M::NFC_M() { |     RegisterHandlers(functions); | ||||||
|     Register(FunctionTable); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace NFC
 | } // namespace NFC
 | ||||||
|  |  | ||||||
|  | @ -4,18 +4,14 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "core/hle/service/service.h" | #include "core/hle/service/nfc/nfc.h" | ||||||
| 
 | 
 | ||||||
| namespace Service { | namespace Service { | ||||||
| namespace NFC { | namespace NFC { | ||||||
| 
 | 
 | ||||||
| class NFC_M final : public Interface { | class NFC_M final : public Module::Interface { | ||||||
| public: | public: | ||||||
|     NFC_M(); |     explicit NFC_M(std::shared_ptr<Module> nfc); | ||||||
| 
 |  | ||||||
|     std::string GetPortName() const override { |  | ||||||
|         return "nfc:m"; |  | ||||||
|     } |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace NFC
 | } // namespace NFC
 | ||||||
|  |  | ||||||
|  | @ -2,42 +2,40 @@ | ||||||
| // Licensed under GPLv2 or any later version
 | // Licensed under GPLv2 or any later version
 | ||||||
| // Refer to the license.txt file included.
 | // Refer to the license.txt file included.
 | ||||||
| 
 | 
 | ||||||
| #include "core/hle/service/nfc/nfc.h" |  | ||||||
| #include "core/hle/service/nfc/nfc_u.h" | #include "core/hle/service/nfc/nfc_u.h" | ||||||
| 
 | 
 | ||||||
| namespace Service { | namespace Service { | ||||||
| namespace NFC { | namespace NFC { | ||||||
| 
 | 
 | ||||||
| const Interface::FunctionInfo FunctionTable[] = { | NFC_U::NFC_U(std::shared_ptr<Module> nfc) : Module::Interface(std::move(nfc), "nfc:u", 1) { | ||||||
|     // clang-format off
 |     static const FunctionInfo functions[] = { | ||||||
|     {0x00010040, Initialize, "Initialize"}, |         // clang-format off
 | ||||||
|     {0x00020040, Shutdown, "Shutdown"}, |         {0x00010040, &NFC_U::Initialize, "Initialize"}, | ||||||
|     {0x00030000, StartCommunication, "StartCommunication"}, |         {0x00020040, &NFC_U::Shutdown, "Shutdown"}, | ||||||
|     {0x00040000, StopCommunication, "StopCommunication"}, |         {0x00030000, &NFC_U::StartCommunication, "StartCommunication"}, | ||||||
|     {0x00050040, StartTagScanning, "StartTagScanning"}, |         {0x00040000, &NFC_U::StopCommunication, "StopCommunication"}, | ||||||
|     {0x00060000, StopTagScanning, "StopTagScanning"}, |         {0x00050040, &NFC_U::StartTagScanning, "StartTagScanning"}, | ||||||
|     {0x00070000, LoadAmiiboData, "LoadAmiiboData"}, |         {0x00060000, &NFC_U::StopTagScanning, "StopTagScanning"}, | ||||||
|     {0x00080000, ResetTagScanState, "ResetTagScanState"}, |         {0x00070000, &NFC_U::LoadAmiiboData, "LoadAmiiboData"}, | ||||||
|     {0x00090002, nullptr, "UpdateStoredAmiiboData"}, |         {0x00080000, &NFC_U::ResetTagScanState, "ResetTagScanState"}, | ||||||
|     {0x000B0000, GetTagInRangeEvent, "GetTagInRangeEvent"}, |         {0x00090002, nullptr, "UpdateStoredAmiiboData"}, | ||||||
|     {0x000C0000, GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"}, |         {0x000B0000, &NFC_U::GetTagInRangeEvent, "GetTagInRangeEvent"}, | ||||||
|     {0x000D0000, GetTagState, "GetTagState"}, |         {0x000C0000, &NFC_U::GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"}, | ||||||
|     {0x000F0000, CommunicationGetStatus, "CommunicationGetStatus"}, |         {0x000D0000, &NFC_U::GetTagState, "GetTagState"}, | ||||||
|     {0x00100000, nullptr, "GetTagInfo2"}, |         {0x000F0000, &NFC_U::CommunicationGetStatus, "CommunicationGetStatus"}, | ||||||
|     {0x00110000, nullptr, "GetTagInfo"}, |         {0x00100000, nullptr, "GetTagInfo2"}, | ||||||
|     {0x00120000, nullptr, "CommunicationGetResult"}, |         {0x00110000, nullptr, "GetTagInfo"}, | ||||||
|     {0x00130040, nullptr, "OpenAppData"}, |         {0x00120000, nullptr, "CommunicationGetResult"}, | ||||||
|     {0x00140384, nullptr, "InitializeWriteAppData"}, |         {0x00130040, nullptr, "OpenAppData"}, | ||||||
|     {0x00150040, nullptr, "ReadAppData"}, |         {0x00140384, nullptr, "InitializeWriteAppData"}, | ||||||
|     {0x00160242, nullptr, "WriteAppData"}, |         {0x00150040, nullptr, "ReadAppData"}, | ||||||
|     {0x00170000, nullptr, "GetAmiiboSettings"}, |         {0x00160242, nullptr, "WriteAppData"}, | ||||||
|     {0x00180000, nullptr, "GetAmiiboConfig"}, |         {0x00170000, nullptr, "GetAmiiboSettings"}, | ||||||
|     {0x00190000, nullptr, "GetAppDataInitStruct"}, |         {0x00180000, nullptr, "GetAmiiboConfig"}, | ||||||
|     // clang-format on
 |         {0x00190000, nullptr, "GetAppDataInitStruct"}, | ||||||
| }; |         // clang-format on
 | ||||||
| 
 |     }; | ||||||
| NFC_U::NFC_U() { |     RegisterHandlers(functions); | ||||||
|     Register(FunctionTable); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace NFC
 | } // namespace NFC
 | ||||||
|  |  | ||||||
|  | @ -4,18 +4,14 @@ | ||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "core/hle/service/service.h" | #include "core/hle/service/nfc/nfc.h" | ||||||
| 
 | 
 | ||||||
| namespace Service { | namespace Service { | ||||||
| namespace NFC { | namespace NFC { | ||||||
| 
 | 
 | ||||||
| class NFC_U final : public Interface { | class NFC_U final : public Module::Interface { | ||||||
| public: | public: | ||||||
|     NFC_U(); |     explicit NFC_U(std::shared_ptr<Module> nfc); | ||||||
| 
 |  | ||||||
|     std::string GetPortName() const override { |  | ||||||
|         return "nfc:u"; |  | ||||||
|     } |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } // namespace NFC
 | } // namespace NFC
 | ||||||
|  |  | ||||||
|  | @ -251,7 +251,7 @@ void Init() { | ||||||
|     MVD::Init(); |     MVD::Init(); | ||||||
|     NDM::Init(); |     NDM::Init(); | ||||||
|     NEWS::InstallInterfaces(*SM::g_service_manager); |     NEWS::InstallInterfaces(*SM::g_service_manager); | ||||||
|     NFC::Init(); |     NFC::InstallInterfaces(*SM::g_service_manager); | ||||||
|     NIM::InstallInterfaces(*SM::g_service_manager); |     NIM::InstallInterfaces(*SM::g_service_manager); | ||||||
|     NWM::Init(); |     NWM::Init(); | ||||||
|     PTM::InstallInterfaces(*SM::g_service_manager); |     PTM::InstallInterfaces(*SM::g_service_manager); | ||||||
|  | @ -271,7 +271,6 @@ void Init() { | ||||||
| 
 | 
 | ||||||
| /// Shutdown ServiceManager
 | /// Shutdown ServiceManager
 | ||||||
| void Shutdown() { | void Shutdown() { | ||||||
|     NFC::Shutdown(); |  | ||||||
|     NDM::Shutdown(); |     NDM::Shutdown(); | ||||||
|     DLP::Shutdown(); |     DLP::Shutdown(); | ||||||
|     CFG::Shutdown(); |     CFG::Shutdown(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue