Service/NFC: convert to ServiceFramework

This commit is contained in:
wwylele
2018-03-05 10:48:09 +02:00
parent 42d68d6ea4
commit e40d693057
7 changed files with 272 additions and 260 deletions

View File

@@ -4,12 +4,16 @@
#pragma once
#include <memory>
#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 {
class Interface;
namespace NFC {
namespace ErrCodes {
@@ -32,128 +36,146 @@ enum class CommunicationStatus : u8 {
NfcInitialized = 2,
};
/**
* NFC::Initialize service function
* Inputs:
* 0 : Header code [0x00010040]
* 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 Module final {
public:
Module();
~Module();
/**
* NFC::Shutdown service function
* Inputs:
* 0 : Header code [0x00020040]
* 1 : (u8) unknown parameter
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Shutdown(Interface* self);
class Interface : public ServiceFramework<Interface> {
public:
Interface(std::shared_ptr<Module> nfc, const char* name, u32 max_session);
~Interface();
/**
* NFC::StartCommunication service function
* Inputs:
* 0 : Header code [0x00030000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StartCommunication(Interface* self);
protected:
/**
* NFC::Initialize service function
* Inputs:
* 0 : Header code [0x00010040]
* 1 : (u8) unknown parameter. Can be either value 0x1 or 0x2
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Initialize(Kernel::HLERequestContext& ctx);
/**
* NFC::StopCommunication service function
* Inputs:
* 0 : Header code [0x00040000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StopCommunication(Interface* self);
/**
* NFC::Shutdown service function
* Inputs:
* 0 : Header code [0x00020040]
* 1 : (u8) unknown parameter
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Shutdown(Kernel::HLERequestContext& ctx);
/**
* NFC::StartTagScanning service function
* Inputs:
* 0 : Header code [0x00050040]
* 1 : (u16) unknown. This is normally 0x0
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StartTagScanning(Interface* self);
/**
* NFC::StartCommunication service function
* Inputs:
* 0 : Header code [0x00030000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StartCommunication(Kernel::HLERequestContext& ctx);
/**
* NFC::StopTagScanning service function
* Inputs:
* 0 : Header code [0x00060000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StopTagScanning(Interface* self);
/**
* NFC::StopCommunication service function
* Inputs:
* 0 : Header code [0x00040000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StopCommunication(Kernel::HLERequestContext& ctx);
/**
* NFC::LoadAmiiboData service function
* Inputs:
* 0 : Header code [0x00070000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void LoadAmiiboData(Interface* self);
/**
* NFC::StartTagScanning service function
* Inputs:
* 0 : Header code [0x00050040]
* 1 : (u16) unknown. This is normally 0x0
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StartTagScanning(Kernel::HLERequestContext& ctx);
/**
* NFC::ResetTagScanState service function
* Inputs:
* 0 : Header code [0x00080000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void ResetTagScanState(Interface* self);
/**
* NFC::StopTagScanning service function
* Inputs:
* 0 : Header code [0x00060000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StopTagScanning(Kernel::HLERequestContext& ctx);
/**
* NFC::GetTagInRangeEvent service function
* Inputs:
* 0 : Header code [0x000B0000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Copy handle descriptor
* 3 : Event Handle
*/
void GetTagInRangeEvent(Interface* self);
/**
* NFC::LoadAmiiboData service function
* Inputs:
* 0 : Header code [0x00070000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void LoadAmiiboData(Kernel::HLERequestContext& ctx);
/**
* NFC::GetTagOutOfRangeEvent service function
* Inputs:
* 0 : Header code [0x000C0000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Copy handle descriptor
* 3 : Event Handle
*/
void GetTagOutOfRangeEvent(Interface* self);
/**
* NFC::ResetTagScanState service function
* Inputs:
* 0 : Header code [0x00080000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void ResetTagScanState(Kernel::HLERequestContext& ctx);
/**
* 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(Interface* self);
/**
* NFC::GetTagInRangeEvent service function
* Inputs:
* 0 : Header code [0x000B0000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Copy handle descriptor
* 3 : Event Handle
*/
void GetTagInRangeEvent(Kernel::HLERequestContext& ctx);
/**
* 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(Interface* self);
/**
* NFC::GetTagOutOfRangeEvent service function
* Inputs:
* 0 : Header code [0x000C0000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Copy handle descriptor
* 3 : Event Handle
*/
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 Service