summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar mailwl2016-05-28 20:55:34 +0300
committerGravatar mailwl2016-05-31 10:06:00 +0300
commitdc338ccecf0e5a31242b48ca4f9941039bdf9ca6 (patch)
treee3eb5095f55bc136e4f6ba1fd1070280e6f0bbd4 /src/core
parentMerge pull request #1751 from linkmauve/no-recursive-readdir (diff)
downloadyuzu-dc338ccecf0e5a31242b48ca4f9941039bdf9ca6.tar.gz
yuzu-dc338ccecf0e5a31242b48ca4f9941039bdf9ca6.tar.xz
yuzu-dc338ccecf0e5a31242b48ca4f9941039bdf9ca6.zip
srv: Update according 3dbrew
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/srv.cpp152
1 files changed, 137 insertions, 15 deletions
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index aae955bf8..9aebb67b2 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -1,4 +1,4 @@
1// Copyright 2014 Citra Emulator Project 1// Copyright 2016 Citra Emulator Project
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
@@ -15,23 +15,86 @@ namespace SRV {
15 15
16static Kernel::SharedPtr<Kernel::Event> event_handle; 16static Kernel::SharedPtr<Kernel::Event> event_handle;
17 17
18static void Initialize(Service::Interface* self) { 18static const char* NotifDesc(u32 notif_id) {
19 switch (notif_id) {
20 case 0x100: return "This indicates that all processes must terminate : power - off, reboot, or FIRM - launch.";
21 case 0x104: return "This indicates that the system is entering sleep mode. (PTM : NotifySleepPreparationComplete needed for this and the following ? )";
22 case 0x105: return "This indicates that the system has exited sleep mode.";
23 case 0x107: return "Unknown.Subscribed to by CECD module.";
24 case 0x108: return "error at boot ?";
25 case 0x109: return "?(Subscribed to by GSP)";
26 case 0x10C: return "Unknown.";
27 //case 0x110 - 0x11F Unknown.See PM launch flags.
28 case 0x179: return "Unknown";
29 case 0x202: return "POWER button pressed";
30 case 0x203: return "POWER button held long";
31 case 0x204: return "HOME button pressed";
32 case 0x205: return "HOME button released";
33 case 0x206: return "This is signaled by NWMEXT : ControlWirelessEnabled and when the physical Wi - Fi slider is enabled";
34 case 0x207: return "SD card inserted";
35 case 0x208: return "Game cartridge inserted";
36 case 0x209: return "SD card removed";
37 case 0x20A: return "Game cartridge removed";
38 case 0x20B: return "Game cartridge inserted or removed";
39 case 0x20D: return "? (Subscribed to by GSP)";
40 case 0x20E: return "? (Subscribed to by GSP)";
41 case 0x213: return "? (Subscribed to by GSP)";
42 case 0x214: return "? (Subscribed to by GSP)";
43 case 0x302: return "Unknown.Signaled by nwm module.";
44 case 0x303: return "Unknown.Subscribed to by CECD module.";
45 case 0x304: return "Unknown.Subscribed to by CECD module";
46 }
47 return "Unknown notification";
48}
49
50/**
51 * SRV::RegisterClient service function
52 * Inputs:
53 * 0: 0x00010002
54 * 1: ProcessId Header (must be 0x20)
55 * Outputs:
56 * 1: ResultCode
57 */
58static void RegisterClient(Service::Interface* self) {
19 u32* cmd_buff = Kernel::GetCommandBuffer(); 59 u32* cmd_buff = Kernel::GetCommandBuffer();
20 60
21 cmd_buff[1] = 0; // No error 61 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
62 LOG_WARNING(Service_SRV, "(STUBBED) called");
22} 63}
23 64
24static void GetProcSemaphore(Service::Interface* self) { 65/**
66 * SRV::EnableNotification service function
67 * Inputs:
68 * 0: 0x00020000
69 * Outputs:
70 * 1: ResultCode
71 * 2: Translation descriptor: 0x20
72 * 3: Handle to semaphore signaled on process notification
73 */
74static void EnableNotification(Service::Interface* self) {
25 u32* cmd_buff = Kernel::GetCommandBuffer(); 75 u32* cmd_buff = Kernel::GetCommandBuffer();
26 76
27 // TODO(bunnei): Change to a semaphore once these have been implemented 77 // TODO(bunnei): Change to a semaphore once these have been implemented
28 event_handle = Kernel::Event::Create(Kernel::ResetType::OneShot, "SRV:Event"); 78 event_handle = Kernel::Event::Create(Kernel::ResetType::OneShot, "SRV:Event");
29 event_handle->Clear(); 79 event_handle->Clear();
30 80
31 cmd_buff[1] = 0; // No error 81 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
82 cmd_buff[2] = 0x20;
32 cmd_buff[3] = Kernel::g_handle_table.Create(event_handle).MoveFrom(); 83 cmd_buff[3] = Kernel::g_handle_table.Create(event_handle).MoveFrom();
84 LOG_WARNING(Service_SRV, "(STUBBED) called");
33} 85}
34 86
87/**
88 * SRV::EnableNotification service function
89 * Inputs:
90 * 0: 0x00050100
91 * 1-2: 8-byte UTF-8 service name
92 * 3: Name length
93 * 4: Flags (bit0: if not set, return port-handle if session-handle unavailable)
94 * Outputs:
95 * 1: ResultCode
96 * 3: Service handle
97 */
35static void GetServiceHandle(Service::Interface* self) { 98static void GetServiceHandle(Service::Interface* self) {
36 ResultCode res = RESULT_SUCCESS; 99 ResultCode res = RESULT_SUCCESS;
37 u32* cmd_buff = Kernel::GetCommandBuffer(); 100 u32* cmd_buff = Kernel::GetCommandBuffer();
@@ -49,16 +112,74 @@ static void GetServiceHandle(Service::Interface* self) {
49 cmd_buff[1] = res.raw; 112 cmd_buff[1] = res.raw;
50} 113}
51 114
115/**
116 * SRV::Subscribe service function
117 * Inputs:
118 * 0: 0x00090040
119 * 1: Notification ID
120 * Outputs:
121 * 1: ResultCode
122 */
123static void Subscribe(Service::Interface* self) {
124 u32* cmd_buff = Kernel::GetCommandBuffer();
125
126 u32 notif_id = cmd_buff[1];
127
128 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
129 LOG_WARNING(Service_SRV, "(STUBBED) called, notif_id=0x%X, desc: %s", notif_id, NotifDesc(notif_id));
130}
131
132/**
133 * SRV::Unsubscribe service function
134 * Inputs:
135 * 0: 0x000A0040
136 * 1: Notification ID
137 * Outputs:
138 * 1: ResultCode
139 */
140static void Unsubscribe(Service::Interface* self) {
141 u32* cmd_buff = Kernel::GetCommandBuffer();
142
143 u32 notif_id = cmd_buff[1];
144
145 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
146 LOG_WARNING(Service_SRV, "(STUBBED) called, notif_id=0x%X, desc: %s", notif_id, NotifDesc(notif_id));
147}
148
149/**
150 * SRV::PublishToSubscriber service function
151 * Inputs:
152 * 0: 0x000C0080
153 * 1: Notification ID
154 * 2: Flags (bit0: only fire if not fired, bit1: report errors)
155 * Outputs:
156 * 1: ResultCode
157 */
158static void PublishToSubscriber(Service::Interface* self) {
159 u32* cmd_buff = Kernel::GetCommandBuffer();
160
161 u32 notif_id = cmd_buff[1];
162 u8 flags = cmd_buff[2] & 0xFF;
163
164 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
165 LOG_WARNING(Service_SRV, "(STUBBED) called, notif_id=0x%X, flags=%u, desc: %s", notif_id, flags, NotifDesc(notif_id));
166}
167
52const Interface::FunctionInfo FunctionTable[] = { 168const Interface::FunctionInfo FunctionTable[] = {
53 {0x00010002, Initialize, "Initialize"}, 169 {0x00010002, RegisterClient, "RegisterClient"},
54 {0x00020000, GetProcSemaphore, "GetProcSemaphore"}, 170 {0x00020000, EnableNotification, "EnableNotification"},
55 {0x00030100, nullptr, "RegisterService"}, 171 {0x00030100, nullptr, "RegisterService"},
56 {0x000400C0, nullptr, "UnregisterService"}, 172 {0x000400C0, nullptr, "UnregisterService"},
57 {0x00050100, GetServiceHandle, "GetServiceHandle"}, 173 {0x00050100, GetServiceHandle, "GetServiceHandle"},
58 {0x000600C2, nullptr, "RegisterHandle"}, 174 {0x000600C2, nullptr, "RegisterPort"},
59 {0x00090040, nullptr, "Subscribe"}, 175 {0x000700C0, nullptr, "UnregisterPort"},
60 {0x000B0000, nullptr, "ReceiveNotification"}, 176 {0x00080100, nullptr, "GetPort"},
61 {0x000C0080, nullptr, "PublishToSubscriber"}, 177 {0x00090040, Subscribe, "Subscribe"},
178 {0x000A0040, Unsubscribe, "Unsubscribe"},
179 {0x000B0000, nullptr, "ReceiveNotification"},
180 {0x000C0080, PublishToSubscriber, "PublishToSubscriber"},
181 {0x000D0040, nullptr, "PublishAndGetSubscriber"},
182 {0x000E00C0, nullptr, "IsServiceRegistered"},
62}; 183};
63 184
64//////////////////////////////////////////////////////////////////////////////////////////////////// 185////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -66,10 +187,11 @@ const Interface::FunctionInfo FunctionTable[] = {
66 187
67Interface::Interface() { 188Interface::Interface() {
68 Register(FunctionTable); 189 Register(FunctionTable);
190 event_handle = nullptr;
69} 191}
70 192
71Interface::~Interface() { 193Interface::~Interface() {
72 event_handle = nullptr; 194 event_handle = nullptr;
73} 195}
74 196
75} // namespace 197} // namespace SRV