summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar mailwl2017-01-14 10:42:56 +0300
committerGravatar mailwl2017-01-14 16:15:16 +0300
commitefe7e245b2b1306c19373e05fb728b148a3ae29e (patch)
tree501bd6eaf9ebff1fbc85e0b27c5df73b922b65b5 /src
parentMerge pull request #2435 from mailwl/gsp-mask (diff)
downloadyuzu-efe7e245b2b1306c19373e05fb728b148a3ae29e.tar.gz
yuzu-efe7e245b2b1306c19373e05fb728b148a3ae29e.tar.xz
yuzu-efe7e245b2b1306c19373e05fb728b148a3ae29e.zip
Service/NFC: stub some functions
Tested on: Mini-Mario & Friends - amiibo Challenge
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nfc/nfc.cpp105
-rw-r--r--src/core/hle/service/nfc/nfc.h122
-rw-r--r--src/core/hle/service/nfc/nfc_m.cpp21
-rw-r--r--src/core/hle/service/nfc/nfc_u.cpp21
4 files changed, 249 insertions, 20 deletions
diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp
index e248285f9..fd3c7d9c2 100644
--- a/src/core/hle/service/nfc/nfc.cpp
+++ b/src/core/hle/service/nfc/nfc.cpp
@@ -11,6 +11,81 @@ namespace Service {
11namespace NFC { 11namespace NFC {
12 12
13static Kernel::SharedPtr<Kernel::Event> tag_in_range_event; 13static Kernel::SharedPtr<Kernel::Event> tag_in_range_event;
14static Kernel::SharedPtr<Kernel::Event> tag_out_of_range_event;
15static TagState nfc_tag_state = TagState::NotInitialized;
16static CommunicationStatus nfc_status = CommunicationStatus::NfcInitialized;
17
18void Initialize(Interface* self) {
19 u32* cmd_buff = Kernel::GetCommandBuffer();
20
21 u8 param = static_cast<u8>(cmd_buff[1] & 0xFF);
22
23 nfc_tag_state = TagState::NotScanning;
24
25 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
26 LOG_WARNING(Service_NFC, "(STUBBED) called, param=%u", param);
27}
28
29void Shutdown(Interface* self) {
30 u32* cmd_buff = Kernel::GetCommandBuffer();
31
32 u8 param = static_cast<u8>(cmd_buff[1] & 0xFF);
33 nfc_tag_state = TagState::NotInitialized;
34
35 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
36 LOG_WARNING(Service_NFC, "(STUBBED) called, param=%u", param);
37}
38
39void StartCommunication(Interface* self) {
40 u32* cmd_buff = Kernel::GetCommandBuffer();
41
42 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
43 LOG_WARNING(Service_NFC, "(STUBBED) called");
44}
45
46void StopCommunication(Interface* self) {
47 u32* cmd_buff = Kernel::GetCommandBuffer();
48
49 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
50 LOG_WARNING(Service_NFC, "(STUBBED) called");
51}
52
53void StartTagScanning(Interface* self) {
54 u32* cmd_buff = Kernel::GetCommandBuffer();
55
56 nfc_tag_state = TagState::TagInRange;
57 tag_in_range_event->Signal();
58
59 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
60 LOG_WARNING(Service_NFC, "(STUBBED) called");
61}
62
63void StopTagScanning(Interface* self) {
64 u32* cmd_buff = Kernel::GetCommandBuffer();
65
66 nfc_tag_state = TagState::NotScanning;
67
68 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
69 LOG_WARNING(Service_NFC, "(STUBBED) called");
70}
71
72void LoadAmiiboData(Interface* self) {
73 u32* cmd_buff = Kernel::GetCommandBuffer();
74
75 nfc_tag_state = TagState::TagDataLoaded;
76
77 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
78 LOG_WARNING(Service_NFC, "(STUBBED) called");
79}
80
81void ResetTagScanState(Interface* self) {
82 u32* cmd_buff = Kernel::GetCommandBuffer();
83
84 nfc_tag_state = TagState::NotScanning;
85
86 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
87 LOG_WARNING(Service_NFC, "(STUBBED) called");
88}
14 89
15void GetTagInRangeEvent(Interface* self) { 90void GetTagInRangeEvent(Interface* self) {
16 u32* cmd_buff = Kernel::GetCommandBuffer(); 91 u32* cmd_buff = Kernel::GetCommandBuffer();
@@ -22,16 +97,46 @@ void GetTagInRangeEvent(Interface* self) {
22 LOG_WARNING(Service_NFC, "(STUBBED) called"); 97 LOG_WARNING(Service_NFC, "(STUBBED) called");
23} 98}
24 99
100void GetTagOutOfRangeEvent(Interface* self) {
101 u32* cmd_buff = Kernel::GetCommandBuffer();
102
103 cmd_buff[0] = IPC::MakeHeader(0xC, 1, 2);
104 cmd_buff[1] = RESULT_SUCCESS.raw;
105 cmd_buff[2] = IPC::CopyHandleDesc();
106 cmd_buff[3] = Kernel::g_handle_table.Create(tag_out_of_range_event).MoveFrom();
107 LOG_WARNING(Service_NFC, "(STUBBED) called");
108}
109
110void GetTagState(Interface* self) {
111 u32* cmd_buff = Kernel::GetCommandBuffer();
112
113 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
114 cmd_buff[2] = static_cast<u8>(nfc_tag_state);
115 LOG_DEBUG(Service_NFC, "(STUBBED) called");
116}
117
118void CommunicationGetStatus(Interface* self) {
119 u32* cmd_buff = Kernel::GetCommandBuffer();
120
121 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
122 cmd_buff[2] = static_cast<u8>(nfc_status);
123 LOG_DEBUG(Service_NFC, "(STUBBED) called");
124}
125
25void Init() { 126void Init() {
26 AddService(new NFC_M()); 127 AddService(new NFC_M());
27 AddService(new NFC_U()); 128 AddService(new NFC_U());
28 129
29 tag_in_range_event = 130 tag_in_range_event =
30 Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_in_range_event"); 131 Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_in_range_event");
132 tag_out_of_range_event =
133 Kernel::Event::Create(Kernel::ResetType::OneShot, "NFC::tag_out_range_event");
134 nfc_tag_state = TagState::NotInitialized;
31} 135}
32 136
33void Shutdown() { 137void Shutdown() {
34 tag_in_range_event = nullptr; 138 tag_in_range_event = nullptr;
139 tag_out_of_range_event = nullptr;
35} 140}
36 141
37} // namespace NFC 142} // namespace NFC
diff --git a/src/core/hle/service/nfc/nfc.h b/src/core/hle/service/nfc/nfc.h
index b02354201..a013bdae7 100644
--- a/src/core/hle/service/nfc/nfc.h
+++ b/src/core/hle/service/nfc/nfc.h
@@ -4,12 +4,103 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h"
8
7namespace Service { 9namespace Service {
8 10
9class Interface; 11class Interface;
10 12
11namespace NFC { 13namespace NFC {
12 14
15enum class TagState : u8 {
16 NotInitialized = 0,
17 NotScanning = 1,
18 Scanning = 2,
19 TagInRange = 3,
20 TagOutOfRange = 4,
21 TagDataLoaded = 5,
22};
23
24enum class CommunicationStatus : u8 {
25 AttemptInitialize = 1,
26 NfcInitialized = 2,
27};
28
29/**
30 * NFC::Initialize service function
31 * Inputs:
32 * 0 : Header code [0x00010040]
33 * 1 : (u8) unknown parameter. Can be either value 0x1 or 0x2
34 * Outputs:
35 * 1 : Result of function, 0 on success, otherwise error code
36 */
37void Initialize(Interface* self);
38
39/**
40 * NFC::Shutdown service function
41 * Inputs:
42 * 0 : Header code [0x00020040]
43 * 1 : (u8) unknown parameter
44 * Outputs:
45 * 1 : Result of function, 0 on success, otherwise error code
46 */
47void Shutdown(Interface* self);
48
49/**
50 * NFC::StartCommunication service function
51 * Inputs:
52 * 0 : Header code [0x00030000]
53 * Outputs:
54 * 1 : Result of function, 0 on success, otherwise error code
55 */
56void StartCommunication(Interface* self);
57
58/**
59 * NFC::StopCommunication service function
60 * Inputs:
61 * 0 : Header code [0x00040000]
62 * Outputs:
63 * 1 : Result of function, 0 on success, otherwise error code
64 */
65void StopCommunication(Interface* self);
66
67/**
68 * NFC::StartTagScanning service function
69 * Inputs:
70 * 0 : Header code [0x00050040]
71 * 1 : (u16) unknown. This is normally 0x0
72 * Outputs:
73 * 1 : Result of function, 0 on success, otherwise error code
74 */
75void StartTagScanning(Interface* self);
76
77/**
78 * NFC::StopTagScanning service function
79 * Inputs:
80 * 0 : Header code [0x00060000]
81 * Outputs:
82 * 1 : Result of function, 0 on success, otherwise error code
83 */
84void StopTagScanning(Interface* self);
85
86/**
87 * NFC::LoadAmiiboData service function
88 * Inputs:
89 * 0 : Header code [0x00070000]
90 * Outputs:
91 * 1 : Result of function, 0 on success, otherwise error code
92 */
93void LoadAmiiboData(Interface* self);
94
95/**
96 * NFC::ResetTagScanState service function
97 * Inputs:
98 * 0 : Header code [0x00080000]
99 * Outputs:
100 * 1 : Result of function, 0 on success, otherwise error code
101 */
102void ResetTagScanState(Interface* self);
103
13/** 104/**
14 * NFC::GetTagInRangeEvent service function 105 * NFC::GetTagInRangeEvent service function
15 * Inputs: 106 * Inputs:
@@ -21,6 +112,37 @@ namespace NFC {
21 */ 112 */
22void GetTagInRangeEvent(Interface* self); 113void GetTagInRangeEvent(Interface* self);
23 114
115/**
116 * NFC::GetTagOutOfRangeEvent service function
117 * Inputs:
118 * 0 : Header code [0x000C0000]
119 * Outputs:
120 * 1 : Result of function, 0 on success, otherwise error code
121 * 2 : Copy handle descriptor
122 * 3 : Event Handle
123 */
124void GetTagOutOfRangeEvent(Interface* self);
125
126/**
127 * NFC::GetTagState service function
128 * Inputs:
129 * 0 : Header code [0x000D0000]
130 * Outputs:
131 * 1 : Result of function, 0 on success, otherwise error code
132 * 2 : (u8) Tag state
133 */
134void GetTagState(Interface* self);
135
136/**
137 * NFC::CommunicationGetStatus service function
138 * Inputs:
139 * 0 : Header code [0x000F0000]
140 * Outputs:
141 * 1 : Result of function, 0 on success, otherwise error code
142 * 2 : (u8) Communication state
143 */
144void CommunicationGetStatus(Interface* self);
145
24/// Initialize all NFC services. 146/// Initialize all NFC services.
25void Init(); 147void Init();
26 148
diff --git a/src/core/hle/service/nfc/nfc_m.cpp b/src/core/hle/service/nfc/nfc_m.cpp
index f43b4029a..ebe637650 100644
--- a/src/core/hle/service/nfc/nfc_m.cpp
+++ b/src/core/hle/service/nfc/nfc_m.cpp
@@ -11,18 +11,19 @@ namespace NFC {
11const Interface::FunctionInfo FunctionTable[] = { 11const Interface::FunctionInfo FunctionTable[] = {
12 // clang-format off 12 // clang-format off
13 // nfc:u shared commands 13 // nfc:u shared commands
14 {0x00010040, nullptr, "Initialize"}, 14 {0x00010040, Initialize, "Initialize"},
15 {0x00020040, nullptr, "Shutdown"}, 15 {0x00020040, Shutdown, "Shutdown"},
16 {0x00030000, nullptr, "StartCommunication"}, 16 {0x00030000, StartCommunication, "StartCommunication"},
17 {0x00040000, nullptr, "StopCommunication"}, 17 {0x00040000, StopCommunication, "StopCommunication"},
18 {0x00050040, nullptr, "StartTagScanning"}, 18 {0x00050040, StartTagScanning, "StartTagScanning"},
19 {0x00060000, nullptr, "StopTagScanning"}, 19 {0x00060000, StopTagScanning, "StopTagScanning"},
20 {0x00070000, nullptr, "LoadAmiiboData"}, 20 {0x00070000, LoadAmiiboData, "LoadAmiiboData"},
21 {0x00080000, nullptr, "ResetTagScanState"}, 21 {0x00080000, ResetTagScanState, "ResetTagScanState"},
22 {0x00090002, nullptr, "UpdateStoredAmiiboData"}, 22 {0x00090002, nullptr, "UpdateStoredAmiiboData"},
23 {0x000B0000, GetTagInRangeEvent, "GetTagInRangeEvent"}, 23 {0x000B0000, GetTagInRangeEvent, "GetTagInRangeEvent"},
24 {0x000D0000, nullptr, "GetTagState"}, 24 {0x000C0000, GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"},
25 {0x000F0000, nullptr, "CommunicationGetStatus"}, 25 {0x000D0000, GetTagState, "GetTagState"},
26 {0x000F0000, CommunicationGetStatus, "CommunicationGetStatus"},
26 {0x00100000, nullptr, "GetTagInfo2"}, 27 {0x00100000, nullptr, "GetTagInfo2"},
27 {0x00110000, nullptr, "GetTagInfo"}, 28 {0x00110000, nullptr, "GetTagInfo"},
28 {0x00120000, nullptr, "CommunicationGetResult"}, 29 {0x00120000, nullptr, "CommunicationGetResult"},
diff --git a/src/core/hle/service/nfc/nfc_u.cpp b/src/core/hle/service/nfc/nfc_u.cpp
index 4b5200ae8..5a40c7874 100644
--- a/src/core/hle/service/nfc/nfc_u.cpp
+++ b/src/core/hle/service/nfc/nfc_u.cpp
@@ -10,18 +10,19 @@ namespace NFC {
10 10
11const Interface::FunctionInfo FunctionTable[] = { 11const Interface::FunctionInfo FunctionTable[] = {
12 // clang-format off 12 // clang-format off
13 {0x00010040, nullptr, "Initialize"}, 13 {0x00010040, Initialize, "Initialize"},
14 {0x00020040, nullptr, "Shutdown"}, 14 {0x00020040, Shutdown, "Shutdown"},
15 {0x00030000, nullptr, "StartCommunication"}, 15 {0x00030000, StartCommunication, "StartCommunication"},
16 {0x00040000, nullptr, "StopCommunication"}, 16 {0x00040000, StopCommunication, "StopCommunication"},
17 {0x00050040, nullptr, "StartTagScanning"}, 17 {0x00050040, StartTagScanning, "StartTagScanning"},
18 {0x00060000, nullptr, "StopTagScanning"}, 18 {0x00060000, StopTagScanning, "StopTagScanning"},
19 {0x00070000, nullptr, "LoadAmiiboData"}, 19 {0x00070000, LoadAmiiboData, "LoadAmiiboData"},
20 {0x00080000, nullptr, "ResetTagScanState"}, 20 {0x00080000, ResetTagScanState, "ResetTagScanState"},
21 {0x00090002, nullptr, "UpdateStoredAmiiboData"}, 21 {0x00090002, nullptr, "UpdateStoredAmiiboData"},
22 {0x000B0000, GetTagInRangeEvent, "GetTagInRangeEvent"}, 22 {0x000B0000, GetTagInRangeEvent, "GetTagInRangeEvent"},
23 {0x000D0000, nullptr, "GetTagState"}, 23 {0x000C0000, GetTagOutOfRangeEvent, "GetTagOutOfRangeEvent"},
24 {0x000F0000, nullptr, "CommunicationGetStatus"}, 24 {0x000D0000, GetTagState, "GetTagState"},
25 {0x000F0000, CommunicationGetStatus, "CommunicationGetStatus"},
25 {0x00100000, nullptr, "GetTagInfo2"}, 26 {0x00100000, nullptr, "GetTagInfo2"},
26 {0x00110000, nullptr, "GetTagInfo"}, 27 {0x00110000, nullptr, "GetTagInfo"},
27 {0x00120000, nullptr, "CommunicationGetResult"}, 28 {0x00120000, nullptr, "CommunicationGetResult"},