2021-06-23 23:05:40 +00:00
|
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Nfc.NfcManager
|
|
|
|
|
{
|
|
|
|
|
class INfc : IpcService
|
|
|
|
|
{
|
|
|
|
|
private NfcPermissionLevel _permissionLevel;
|
2022-10-19 01:14:31 +00:00
|
|
|
|
private State _state;
|
2021-06-23 23:05:40 +00:00
|
|
|
|
|
|
|
|
|
public INfc(NfcPermissionLevel permissionLevel)
|
|
|
|
|
{
|
|
|
|
|
_permissionLevel = permissionLevel;
|
2022-10-19 01:14:31 +00:00
|
|
|
|
_state = State.NonInitialized;
|
2021-06-23 23:05:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
|
[CommandCmif(0)]
|
|
|
|
|
[CommandCmif(400)] // 4.0.0+
|
2022-10-19 01:14:31 +00:00
|
|
|
|
// Initialize(u64, u64, pid, buffer<unknown, 5>)
|
2021-06-23 23:05:40 +00:00
|
|
|
|
public ResultCode Initialize(ServiceCtx context)
|
|
|
|
|
{
|
2022-10-19 01:14:31 +00:00
|
|
|
|
_state = State.Initialized;
|
|
|
|
|
|
2021-06-23 23:05:40 +00:00
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel });
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
|
[CommandCmif(1)]
|
|
|
|
|
[CommandCmif(401)] // 4.0.0+
|
2022-10-19 01:14:31 +00:00
|
|
|
|
// Finalize()
|
|
|
|
|
public ResultCode Finalize(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
_state = State.NonInitialized;
|
|
|
|
|
|
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel });
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
|
[CommandCmif(2)]
|
|
|
|
|
[CommandCmif(402)] // 4.0.0+
|
2022-10-19 01:14:31 +00:00
|
|
|
|
// GetState() -> u32
|
|
|
|
|
public ResultCode GetState(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
context.ResponseData.Write((int)_state);
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
|
[CommandCmif(3)]
|
|
|
|
|
[CommandCmif(403)] // 4.0.0+
|
2021-06-23 23:05:40 +00:00
|
|
|
|
// IsNfcEnabled() -> b8
|
|
|
|
|
public ResultCode IsNfcEnabled(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
// NOTE: Write false value here could make nfp service not called.
|
|
|
|
|
context.ResponseData.Write(true);
|
|
|
|
|
|
|
|
|
|
Logger.Stub?.PrintStub(LogClass.ServiceNfc, new { _permissionLevel });
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|