Merge pull request #3476 from wwylele/nfc-new-framework
Service/NFC: convert to ServiceFramework
This commit is contained in:
commit
ebb8a9b8f0
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,7 +36,18 @@ enum class CommunicationStatus : u8 {
|
||||||
NfcInitialized = 2,
|
NfcInitialized = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
class Module final {
|
||||||
|
public:
|
||||||
|
Module();
|
||||||
|
~Module();
|
||||||
|
|
||||||
|
class Interface : public ServiceFramework<Interface> {
|
||||||
|
public:
|
||||||
|
Interface(std::shared_ptr<Module> nfc, const char* name, u32 max_session);
|
||||||
|
~Interface();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
* NFC::Initialize service function
|
* NFC::Initialize service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x00010040]
|
* 0 : Header code [0x00010040]
|
||||||
|
@ -40,9 +55,9 @@ enum class CommunicationStatus : u8 {
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
*/
|
*/
|
||||||
void Initialize(Interface* self);
|
void Initialize(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::Shutdown service function
|
* NFC::Shutdown service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x00020040]
|
* 0 : Header code [0x00020040]
|
||||||
|
@ -50,27 +65,27 @@ void Initialize(Interface* self);
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
*/
|
*/
|
||||||
void Shutdown(Interface* self);
|
void Shutdown(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::StartCommunication service function
|
* NFC::StartCommunication service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x00030000]
|
* 0 : Header code [0x00030000]
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
*/
|
*/
|
||||||
void StartCommunication(Interface* self);
|
void StartCommunication(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::StopCommunication service function
|
* NFC::StopCommunication service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x00040000]
|
* 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 StopCommunication(Interface* self);
|
void StopCommunication(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::StartTagScanning service function
|
* NFC::StartTagScanning service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x00050040]
|
* 0 : Header code [0x00050040]
|
||||||
|
@ -78,36 +93,36 @@ void StopCommunication(Interface* self);
|
||||||
* Outputs:
|
* Outputs:
|
||||||
* 1 : Result of function, 0 on success, otherwise error code
|
* 1 : Result of function, 0 on success, otherwise error code
|
||||||
*/
|
*/
|
||||||
void StartTagScanning(Interface* self);
|
void StartTagScanning(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::StopTagScanning service function
|
* NFC::StopTagScanning service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x00060000]
|
* 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 StopTagScanning(Interface* self);
|
void StopTagScanning(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::LoadAmiiboData service function
|
* NFC::LoadAmiiboData service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x00070000]
|
* 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
|
||||||
*/
|
*/
|
||||||
void LoadAmiiboData(Interface* self);
|
void LoadAmiiboData(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::ResetTagScanState service function
|
* NFC::ResetTagScanState service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x00080000]
|
* 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
|
||||||
*/
|
*/
|
||||||
void ResetTagScanState(Interface* self);
|
void ResetTagScanState(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::GetTagInRangeEvent service function
|
* NFC::GetTagInRangeEvent service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x000B0000]
|
* 0 : Header code [0x000B0000]
|
||||||
|
@ -116,9 +131,9 @@ void ResetTagScanState(Interface* self);
|
||||||
* 2 : Copy handle descriptor
|
* 2 : Copy handle descriptor
|
||||||
* 3 : Event Handle
|
* 3 : Event Handle
|
||||||
*/
|
*/
|
||||||
void GetTagInRangeEvent(Interface* self);
|
void GetTagInRangeEvent(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::GetTagOutOfRangeEvent service function
|
* NFC::GetTagOutOfRangeEvent service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x000C0000]
|
* 0 : Header code [0x000C0000]
|
||||||
|
@ -127,9 +142,9 @@ void GetTagInRangeEvent(Interface* self);
|
||||||
* 2 : Copy handle descriptor
|
* 2 : Copy handle descriptor
|
||||||
* 3 : Event Handle
|
* 3 : Event Handle
|
||||||
*/
|
*/
|
||||||
void GetTagOutOfRangeEvent(Interface* self);
|
void GetTagOutOfRangeEvent(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::GetTagState service function
|
* NFC::GetTagState service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x000D0000]
|
* 0 : Header code [0x000D0000]
|
||||||
|
@ -137,9 +152,9 @@ void GetTagOutOfRangeEvent(Interface* self);
|
||||||
* 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 : (u8) Tag state
|
||||||
*/
|
*/
|
||||||
void GetTagState(Interface* self);
|
void GetTagState(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NFC::CommunicationGetStatus service function
|
* NFC::CommunicationGetStatus service function
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* 0 : Header code [0x000F0000]
|
* 0 : Header code [0x000F0000]
|
||||||
|
@ -147,13 +162,20 @@ void GetTagState(Interface* self);
|
||||||
* 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 : (u8) Communication state
|
||||||
*/
|
*/
|
||||||
void CommunicationGetStatus(Interface* self);
|
void CommunicationGetStatus(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
/// Initialize all NFC services.
|
private:
|
||||||
void Init();
|
std::shared_ptr<Module> nfc;
|
||||||
|
};
|
||||||
|
|
||||||
/// Shutdown all NFC services.
|
private:
|
||||||
void Shutdown();
|
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,28 +2,28 @@
|
||||||
// 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) {
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// nfc:u shared commands
|
// nfc:u shared commands
|
||||||
{0x00010040, Initialize, "Initialize"},
|
{0x00010040, &NFC_M::Initialize, "Initialize"},
|
||||||
{0x00020040, Shutdown, "Shutdown"},
|
{0x00020040, &NFC_M::Shutdown, "Shutdown"},
|
||||||
{0x00030000, StartCommunication, "StartCommunication"},
|
{0x00030000, &NFC_M::StartCommunication, "StartCommunication"},
|
||||||
{0x00040000, StopCommunication, "StopCommunication"},
|
{0x00040000, &NFC_M::StopCommunication, "StopCommunication"},
|
||||||
{0x00050040, StartTagScanning, "StartTagScanning"},
|
{0x00050040, &NFC_M::StartTagScanning, "StartTagScanning"},
|
||||||
{0x00060000, StopTagScanning, "StopTagScanning"},
|
{0x00060000, &NFC_M::StopTagScanning, "StopTagScanning"},
|
||||||
{0x00070000, LoadAmiiboData, "LoadAmiiboData"},
|
{0x00070000, &NFC_M::LoadAmiiboData, "LoadAmiiboData"},
|
||||||
{0x00080000, ResetTagScanState, "ResetTagScanState"},
|
{0x00080000, &NFC_M::ResetTagScanState, "ResetTagScanState"},
|
||||||
{0x00090002, nullptr, "UpdateStoredAmiiboData"},
|
{0x00090002, nullptr, "UpdateStoredAmiiboData"},
|
||||||
{0x000B0000, GetTagInRangeEvent, "GetTagInRangeEvent"},
|
{0x000B0000, &NFC_M::GetTagInRangeEvent, "GetTagInRangeEvent"},
|
||||||
{0x000C0000, GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"},
|
{0x000C0000, &NFC_M::GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"},
|
||||||
{0x000D0000, GetTagState, "GetTagState"},
|
{0x000D0000, &NFC_M::GetTagState, "GetTagState"},
|
||||||
{0x000F0000, CommunicationGetStatus, "CommunicationGetStatus"},
|
{0x000F0000, &NFC_M::CommunicationGetStatus, "CommunicationGetStatus"},
|
||||||
{0x00100000, nullptr, "GetTagInfo2"},
|
{0x00100000, nullptr, "GetTagInfo2"},
|
||||||
{0x00110000, nullptr, "GetTagInfo"},
|
{0x00110000, nullptr, "GetTagInfo"},
|
||||||
{0x00120000, nullptr, "CommunicationGetResult"},
|
{0x00120000, nullptr, "CommunicationGetResult"},
|
||||||
|
@ -37,10 +37,8 @@ const Interface::FunctionInfo FunctionTable[] = {
|
||||||
// nfc:m
|
// nfc:m
|
||||||
{0x04040A40, nullptr, "SetAmiiboSettings"}
|
{0x04040A40, nullptr, "SetAmiiboSettings"}
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
NFC_M::NFC_M() {
|
|
||||||
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,27 +2,27 @@
|
||||||
// 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) {
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
{0x00010040, Initialize, "Initialize"},
|
{0x00010040, &NFC_U::Initialize, "Initialize"},
|
||||||
{0x00020040, Shutdown, "Shutdown"},
|
{0x00020040, &NFC_U::Shutdown, "Shutdown"},
|
||||||
{0x00030000, StartCommunication, "StartCommunication"},
|
{0x00030000, &NFC_U::StartCommunication, "StartCommunication"},
|
||||||
{0x00040000, StopCommunication, "StopCommunication"},
|
{0x00040000, &NFC_U::StopCommunication, "StopCommunication"},
|
||||||
{0x00050040, StartTagScanning, "StartTagScanning"},
|
{0x00050040, &NFC_U::StartTagScanning, "StartTagScanning"},
|
||||||
{0x00060000, StopTagScanning, "StopTagScanning"},
|
{0x00060000, &NFC_U::StopTagScanning, "StopTagScanning"},
|
||||||
{0x00070000, LoadAmiiboData, "LoadAmiiboData"},
|
{0x00070000, &NFC_U::LoadAmiiboData, "LoadAmiiboData"},
|
||||||
{0x00080000, ResetTagScanState, "ResetTagScanState"},
|
{0x00080000, &NFC_U::ResetTagScanState, "ResetTagScanState"},
|
||||||
{0x00090002, nullptr, "UpdateStoredAmiiboData"},
|
{0x00090002, nullptr, "UpdateStoredAmiiboData"},
|
||||||
{0x000B0000, GetTagInRangeEvent, "GetTagInRangeEvent"},
|
{0x000B0000, &NFC_U::GetTagInRangeEvent, "GetTagInRangeEvent"},
|
||||||
{0x000C0000, GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"},
|
{0x000C0000, &NFC_U::GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"},
|
||||||
{0x000D0000, GetTagState, "GetTagState"},
|
{0x000D0000, &NFC_U::GetTagState, "GetTagState"},
|
||||||
{0x000F0000, CommunicationGetStatus, "CommunicationGetStatus"},
|
{0x000F0000, &NFC_U::CommunicationGetStatus, "CommunicationGetStatus"},
|
||||||
{0x00100000, nullptr, "GetTagInfo2"},
|
{0x00100000, nullptr, "GetTagInfo2"},
|
||||||
{0x00110000, nullptr, "GetTagInfo"},
|
{0x00110000, nullptr, "GetTagInfo"},
|
||||||
{0x00120000, nullptr, "CommunicationGetResult"},
|
{0x00120000, nullptr, "CommunicationGetResult"},
|
||||||
|
@ -34,10 +34,8 @@ const Interface::FunctionInfo FunctionTable[] = {
|
||||||
{0x00180000, nullptr, "GetAmiiboConfig"},
|
{0x00180000, nullptr, "GetAmiiboConfig"},
|
||||||
{0x00190000, nullptr, "GetAppDataInitStruct"},
|
{0x00190000, nullptr, "GetAppDataInitStruct"},
|
||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
NFC_U::NFC_U() {
|
|
||||||
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…
Reference in a new issue