1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
// Copyright 2016 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <boost/serialization/binary_object.hpp>
#include "common/common_types.h"
#include "core/hle/service/nfc/nfc_device.h"
#include "core/hle/service/service.h"
namespace Core {
class System;
}
namespace Kernel {
class Event;
} // namespace Kernel
namespace Service::NFC {
enum class CommunicationMode : u8 {
NotInitialized = 0,
Ntag = 1,
Amiibo = 2,
TrainTag = 3,
};
class Module final {
public:
explicit Module(Core::System& system);
~Module();
class Interface : public ServiceFramework<Interface> {
public:
Interface(std::shared_ptr<Module> nfc, const char* name, u32 max_session);
~Interface();
std::shared_ptr<Module> GetModule() const;
bool IsSearchingForAmiibos();
bool IsTagActive();
bool LoadAmiibo(const std::string& fullpath);
void RemoveAmiibo();
protected:
/**
* NFC::Initialize service function
* Inputs:
* 0 : Header code [0x00010040]
* 1 : (u8) CommunicationMode. Can be either value 0x1, 0x2 or 0x3
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Initialize(Kernel::HLERequestContext& ctx);
/**
* NFC::Finalize service function
* Inputs:
* 0 : Header code [0x00020040]
* 1 : (u8) CommunicationMode.
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Finalize(Kernel::HLERequestContext& ctx);
/**
* NFC::Connect service function
* Inputs:
* 0 : Header code [0x00030000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Connect(Kernel::HLERequestContext& ctx);
/**
* NFC::Disconnect service function
* Inputs:
* 0 : Header code [0x00040000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Disconnect(Kernel::HLERequestContext& ctx);
/**
* NFC::StartDetection 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 StartDetection(Kernel::HLERequestContext& ctx);
/**
* NFC::StopDetection service function
* Inputs:
* 0 : Header code [0x00060000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void StopDetection(Kernel::HLERequestContext& ctx);
/**
* NFC::Mount service function
* Inputs:
* 0 : Header code [0x00070000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Mount(Kernel::HLERequestContext& ctx);
/**
* NFC::Unmount service function
* Inputs:
* 0 : Header code [0x00080000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Unmount(Kernel::HLERequestContext& ctx);
/**
* NFC::Flush service function
* Inputs:
* 0 : Header code [0x00090002]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Flush(Kernel::HLERequestContext& ctx);
/**
* NFC::GetActivateEvent 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 GetActivateEvent(Kernel::HLERequestContext& ctx);
/**
* NFC::GetDeactivateEvent 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 GetDeactivateEvent(Kernel::HLERequestContext& ctx);
/**
* NFC::GetStatus service function
* Inputs:
* 0 : Header code [0x000D0000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : (u8) Tag state
*/
void GetStatus(Kernel::HLERequestContext& ctx);
/**
* NFC::GetTargetConnectionStatus service function
* Inputs:
* 0 : Header code [0x000F0000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : (u8) Communication state
*/
void GetTargetConnectionStatus(Kernel::HLERequestContext& ctx);
/**
* NFC::GetTagInfo2 service function
* Inputs:
* 0 : Header code [0x00100000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2-26 : 0x60-byte struct
*/
void GetTagInfo2(Kernel::HLERequestContext& ctx);
/**
* NFC::GetTagInfo service function
* Inputs:
* 0 : Header code [0x00110000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2-12 : 0x2C-byte struct
*/
void GetTagInfo(Kernel::HLERequestContext& ctx);
/**
* NFC::GetConnectResult service function
* Inputs:
* 0 : Header code [0x00120000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Output NFC-adapter result-code
*/
void GetConnectResult(Kernel::HLERequestContext& ctx);
/**
* NFC::OpenApplicationArea service function
* Inputs:
* 0 : Header code [0x00130040]
* 1 : (u32) App ID
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void OpenApplicationArea(Kernel::HLERequestContext& ctx);
/**
* NFC::CreateApplicationArea service function
* Inputs:
* 0 : Header code [0x00140384]
* 1 : (u32) App ID
* 2 : Size
* 3-14 : 0x30-byte zeroed-out struct
* 15 : 0x20, PID translate-header for kernel
* 16 : PID written by kernel
* 17 : (Size << 14) | 2
* 18 : Pointer to input buffer
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void CreateApplicationArea(Kernel::HLERequestContext& ctx);
/**
* NFC::ReadApplicationArea service function
* Inputs:
* 0 : Header code [0x00150040]
* 1 : Size (unused? Hard-coded to be 0xD8)
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void ReadApplicationArea(Kernel::HLERequestContext& ctx);
/**
* NFC::WriteApplicationArea service function
* Inputs:
* 0 : Header code [0x00160242]
* 1 : Size
* 2-9 : AmiiboWriteRequest struct (see above)
* 10 : (Size << 14) | 2
* 11 : Pointer to input appdata buffer
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void WriteApplicationArea(Kernel::HLERequestContext& ctx);
/**
* NFC::GetNfpRegisterInfo service function
* Inputs:
* 0 : Header code [0x00170000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2-43 : AmiiboSettings struct (see above)
*/
void GetNfpRegisterInfo(Kernel::HLERequestContext& ctx);
/**
* NFC::GetNfpCommonInfo service function
* Inputs:
* 0 : Header code [0x00180000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2-17 : 0x40-byte config struct
*/
void GetNfpCommonInfo(Kernel::HLERequestContext& ctx);
/**
* NFC::InitializeCreateInfo service function
* Inputs:
* 0 : Header code [0x00180000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2-16 : 0x3C-byte config struct
*/
void InitializeCreateInfo(Kernel::HLERequestContext& ctx);
/**
* NFC::LoadAmiiboPartially service function
* Inputs:
* 0 : Header code [0x001A0000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void MountRom(Kernel::HLERequestContext& ctx);
/**
* NFC::GetIdentificationBlock service function
* Inputs:
* 0 : Header code [0x001B0000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2-31 : 0x36-byte struct
*/
void GetIdentificationBlock(Kernel::HLERequestContext& ctx);
/**
* NFC::Format service function
* Inputs:
* 0 : Header code [0x040100C2]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void Format(Kernel::HLERequestContext& ctx);
/**
* NFC::GetAdminInfo service function
* Inputs:
* 0 : Header code [0x04020000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void GetAdminInfo(Kernel::HLERequestContext& ctx);
/**
* NFC::GetEmptyRegisterInfo service function
* Inputs:
* 0 : Header code [0x04030000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void GetEmptyRegisterInfo(Kernel::HLERequestContext& ctx);
/**
* NFC::SetRegisterInfo service function
* Inputs:
* 0 : Header code [0x04040A40]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void SetRegisterInfo(Kernel::HLERequestContext& ctx);
/**
* NFC::DeleteRegisterInfo service function
* Inputs:
* 0 : Header code [0x04050000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void DeleteRegisterInfo(Kernel::HLERequestContext& ctx);
/**
* NFC::DeleteApplicationArea service function
* Inputs:
* 0 : Header code [0x04060000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void DeleteApplicationArea(Kernel::HLERequestContext& ctx);
/**
* NFC::ExistsApplicationArea service function
* Inputs:
* 0 : Header code [0x04070000]
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void ExistsApplicationArea(Kernel::HLERequestContext& ctx);
protected:
std::shared_ptr<Module> nfc;
};
private:
CommunicationMode nfc_mode = CommunicationMode::NotInitialized;
std::shared_ptr<NfcDevice> device = nullptr;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);
} // namespace Service::NFC
SERVICE_CONSTRUCT(Service::NFC::Module)
BOOST_CLASS_EXPORT_KEY(Service::NFC::Module)
|