summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2014-04-15 22:40:19 -0400
committerGravatar bunnei2014-04-15 22:40:19 -0400
commit7ec5950bc4c8e4a786df1f4c3392d7b5332d1613 (patch)
tree7d7046dcced5ce635921ebdadabf1a1aa8b0647f /src
parentadded helper functions for upper/lowercase strings (diff)
downloadyuzu-7ec5950bc4c8e4a786df1f4c3392d7b5332d1613.tar.gz
yuzu-7ec5950bc4c8e4a786df1f4c3392d7b5332d1613.tar.xz
yuzu-7ec5950bc4c8e4a786df1f4c3392d7b5332d1613.zip
- extracted srv: calls from service.cpp and put in its own module
- added function tables for service calls - lots of refactoring
Diffstat (limited to 'src')
-rw-r--r--src/core/core.vcxproj2
-rw-r--r--src/core/core.vcxproj.filters6
-rw-r--r--src/core/hle/service/apt.cpp91
-rw-r--r--src/core/hle/service/apt.h17
-rw-r--r--src/core/hle/service/service.cpp84
-rw-r--r--src/core/hle/service/service.h19
6 files changed, 113 insertions, 106 deletions
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index be750b24f..da3cc7a26 100644
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -155,6 +155,7 @@
155 <ClCompile Include="hle\hle.cpp" /> 155 <ClCompile Include="hle\hle.cpp" />
156 <ClCompile Include="hle\service\apt.cpp" /> 156 <ClCompile Include="hle\service\apt.cpp" />
157 <ClCompile Include="hle\service\service.cpp" /> 157 <ClCompile Include="hle\service\service.cpp" />
158 <ClCompile Include="hle\service\srv.cpp" />
158 <ClCompile Include="hle\syscall.cpp" /> 159 <ClCompile Include="hle\syscall.cpp" />
159 <ClCompile Include="hw\hw.cpp" /> 160 <ClCompile Include="hw\hw.cpp" />
160 <ClCompile Include="hw\hw_lcd.cpp" /> 161 <ClCompile Include="hw\hw_lcd.cpp" />
@@ -190,6 +191,7 @@
190 <ClInclude Include="hle\hle.h" /> 191 <ClInclude Include="hle\hle.h" />
191 <ClInclude Include="hle\service\apt.h" /> 192 <ClInclude Include="hle\service\apt.h" />
192 <ClInclude Include="hle\service\service.h" /> 193 <ClInclude Include="hle\service\service.h" />
194 <ClInclude Include="hle\service\srv.h" />
193 <ClInclude Include="hle\syscall.h" /> 195 <ClInclude Include="hle\syscall.h" />
194 <ClInclude Include="hw\hw.h" /> 196 <ClInclude Include="hw\hw.h" />
195 <ClInclude Include="hw\hw_lcd.h" /> 197 <ClInclude Include="hw\hw_lcd.h" />
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters
index 29d680935..fa20ab686 100644
--- a/src/core/core.vcxproj.filters
+++ b/src/core/core.vcxproj.filters
@@ -93,6 +93,9 @@
93 <ClCompile Include="hle\service\apt.cpp"> 93 <ClCompile Include="hle\service\apt.cpp">
94 <Filter>hle\service</Filter> 94 <Filter>hle\service</Filter>
95 </ClCompile> 95 </ClCompile>
96 <ClCompile Include="hle\service\srv.cpp">
97 <Filter>hle\service</Filter>
98 </ClCompile>
96 </ItemGroup> 99 </ItemGroup>
97 <ItemGroup> 100 <ItemGroup>
98 <ClInclude Include="arm\disassembler\arm_disasm.h"> 101 <ClInclude Include="arm\disassembler\arm_disasm.h">
@@ -181,6 +184,9 @@
181 <ClInclude Include="hle\service\apt.h"> 184 <ClInclude Include="hle\service\apt.h">
182 <Filter>hle\service</Filter> 185 <Filter>hle\service</Filter>
183 </ClInclude> 186 </ClInclude>
187 <ClInclude Include="hle\service\srv.h">
188 <Filter>hle\service</Filter>
189 </ClInclude>
184 </ItemGroup> 190 </ItemGroup>
185 <ItemGroup> 191 <ItemGroup>
186 <Text Include="CMakeLists.txt" /> 192 <Text Include="CMakeLists.txt" />
diff --git a/src/core/hle/service/apt.cpp b/src/core/hle/service/apt.cpp
index 5e37b838a..b1e49db97 100644
--- a/src/core/hle/service/apt.cpp
+++ b/src/core/hle/service/apt.cpp
@@ -10,8 +10,89 @@
10 10
11namespace Service { 11namespace Service {
12 12
13const HLE::FunctionDef APT_U_Table[] = {
14 {0x00010040, NULL, "GetLockHandle"},
15 {0x00020080, NULL, "Initialize"},
16 {0x00030040, NULL, "Enable"},
17 {0x00040040, NULL, "Finalize"},
18 {0x00050040, NULL, "GetAppletManInfo"},
19 {0x00060040, NULL, "GetAppletInfo"},
20 {0x00070000, NULL, "GetLastSignaledAppletId"},
21 {0x00080000, NULL, "CountRegisteredApplet"},
22 {0x00090040, NULL, "IsRegistered"},
23 {0x000A0040, NULL, "GetAttribute"},
24 {0x000B0040, NULL, "InquireNotification"},
25 {0x000C0104, NULL, "SendParameter"},
26 {0x000D0080, NULL, "ReceiveParameter"},
27 {0x000E0080, NULL, "GlanceParameter"},
28 {0x000F0100, NULL, "CancelParameter"},
29 {0x001000C2, NULL, "DebugFunc"},
30 {0x001100C0, NULL, "MapProgramIdForDebug"},
31 {0x00120040, NULL, "SetHomeMenuAppletIdForDebug"},
32 {0x00130000, NULL, "GetPreparationState"},
33 {0x00140040, NULL, "SetPreparationState"},
34 {0x00150140, NULL, "PrepareToStartApplication"},
35 {0x00160040, NULL, "PreloadLibraryApplet"},
36 {0x00170040, NULL, "FinishPreloadingLibraryApplet"},
37 {0x00180040, NULL, "PrepareToStartLibraryApplet"},
38 {0x00190040, NULL, "PrepareToStartSystemApplet"},
39 {0x001A0000, NULL, "PrepareToStartNewestHomeMenu"},
40 {0x001B00C4, NULL, "StartApplication"},
41 {0x001C0000, NULL, "WakeupApplication"},
42 {0x001D0000, NULL, "CancelApplication"},
43 {0x001E0084, NULL, "StartLibraryApplet"},
44 {0x001F0084, NULL, "StartSystemApplet"},
45 {0x00200044, NULL, "StartNewestHomeMenu"},
46 {0x00210000, NULL, "OrderToCloseApplication"},
47 {0x00220040, NULL, "PrepareToCloseApplication"},
48 {0x00230040, NULL, "PrepareToJumpToApplication"},
49 {0x00240044, NULL, "JumpToApplication"},
50 {0x002500C0, NULL, "PrepareToCloseLibraryApplet"},
51 {0x00260000, NULL, "PrepareToCloseSystemApplet"},
52 {0x00270044, NULL, "CloseApplication"},
53 {0x00280044, NULL, "CloseLibraryApplet"},
54 {0x00290044, NULL, "CloseSystemApplet"},
55 {0x002A0000, NULL, "OrderToCloseSystemApplet"},
56 {0x002B0000, NULL, "PrepareToJumpToHomeMenu"},
57 {0x002C0044, NULL, "JumpToHomeMenu"},
58 {0x002D0000, NULL, "PrepareToLeaveHomeMenu"},
59 {0x002E0044, NULL, "LeaveHomeMenu"},
60 {0x002F0040, NULL, "PrepareToLeaveResidentApplet"},
61 {0x00300044, NULL, "LeaveResidentApplet"},
62 {0x00310100, NULL, "PrepareToDoApplicationJump"},
63 {0x00320084, NULL, "DoApplicationJump"},
64 {0x00330000, NULL, "GetProgramIdOnApplicationJump"},
65 {0x00340084, NULL, "SendDeliverArg"},
66 {0x00350080, NULL, "ReceiveDeliverArg"},
67 {0x00360040, NULL, "LoadSysMenuArg"},
68 {0x00370042, NULL, "StoreSysMenuArg"},
69 {0x00380040, NULL, "PreloadResidentApplet"},
70 {0x00390040, NULL, "PrepareToStartResidentApplet"},
71 {0x003A0044, NULL, "StartResidentApplet"},
72 {0x003B0040, NULL, "CancelLibraryApplet"},
73 {0x003C0042, NULL, "SendDspSleep"},
74 {0x003D0042, NULL, "SendDspWakeUp"},
75 {0x003E0080, NULL, "ReplySleepQuery"},
76 {0x003F0040, NULL, "ReplySleepNotificationComplete"},
77 {0x00400042, NULL, "SendCaptureBufferInfo"},
78 {0x00410040, NULL, "ReceiveCaptureBufferInfo"},
79 {0x00420080, NULL, "SleepSystem"},
80 {0x00430040, NULL, "NotifyToWait"},
81 {0x00440000, NULL, "GetSharedFont"},
82 {0x00450040, NULL, "GetWirelessRebootInfo"},
83 {0x00460104, NULL, "Wrap"},
84 {0x00470104, NULL, "Unwrap"},
85 {0x00480100, NULL, "GetProgramInfo"},
86 {0x00490180, NULL, "Reboot"},
87 {0x004A0040, NULL, "GetCaptureInfo"},
88 {0x004B00C2, NULL, "AppletUtility"},
89 {0x004C0000, NULL, "SetFatalErrDispMode"},
90 {0x004D0080, NULL, "GetAppletProgramInfo"},
91 {0x004E0000, NULL, "HardwareResetAsync"},
92};
93
13// Returns handle to APT Mutex. Not imlemented. 94// Returns handle to APT Mutex. Not imlemented.
14Syscall::Result APT::GetLockHandle() { 95Syscall::Result APT_U::GetLockHandle() {
15 return 0x00000000; 96 return 0x00000000;
16} 97}
17 98
@@ -19,22 +100,22 @@ Syscall::Result APT::GetLockHandle() {
19 * Called when svcSendSyncRequest is called, loads command buffer and executes comand 100 * Called when svcSendSyncRequest is called, loads command buffer and executes comand
20 * @return Return result of svcSendSyncRequest passed back to user app 101 * @return Return result of svcSendSyncRequest passed back to user app
21 */ 102 */
22Syscall::Result APT::Sync() { 103Syscall::Result APT_U::Sync() {
23 Syscall::Result res = 0; 104 Syscall::Result res = 0;
24 u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + CMD_OFFSET); 105 u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + CMD_OFFSET);
25 106
26 switch(cmd_buff[0]) { 107 switch(cmd_buff[0]) {
27 case CMD_HEADER_INIT: 108 case CMD_HEADER_INIT:
28 NOTICE_LOG(OSHLE, "APT::Sync - Initialize"); 109 NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize");
29 break; 110 break;
30 111
31 case CMD_HEADER_GET_LOCK_HANDLE: 112 case CMD_HEADER_GET_LOCK_HANDLE:
32 NOTICE_LOG(OSHLE, "APT::Sync - GetLockHandle"); 113 NOTICE_LOG(OSHLE, "APT_U::Sync - GetLockHandle");
33 cmd_buff[5] = GetLockHandle(); 114 cmd_buff[5] = GetLockHandle();
34 break; 115 break;
35 116
36 default: 117 default:
37 ERROR_LOG(OSHLE, "APT::Sync - Unknown command 0x%08X", cmd_buff[0]); 118 ERROR_LOG(OSHLE, "APT_U::Sync - Unknown command 0x%08X", cmd_buff[0]);
38 res = -1; 119 res = -1;
39 break; 120 break;
40 } 121 }
diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h
index 3730bc30e..0e1f205c7 100644
--- a/src/core/hle/service/apt.h
+++ b/src/core/hle/service/apt.h
@@ -17,13 +17,13 @@ namespace Service {
17// exactly the same, however certain commands are only accessible with APT:S(NS module will call 17// exactly the same, however certain commands are only accessible with APT:S(NS module will call
18// svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services. 18// svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services.
19 19
20class APT : public Interface { 20class APT_U : public Interface {
21public: 21public:
22 22
23 APT() { 23 APT_U() {
24 } 24 }
25 25
26 ~APT() { 26 ~APT_U() {
27 } 27 }
28 28
29 enum { 29 enum {
@@ -45,14 +45,6 @@ public:
45 }; 45 };
46 46
47 /** 47 /**
48 * Gets the string name used by CTROS for the APT service
49 * @return String name of service
50 */
51 std::string GetName() const {
52 return "APT";
53 }
54
55 /**
56 * Gets the string port name used by CTROS for the APT service 48 * Gets the string port name used by CTROS for the APT service
57 * @return Port name of service 49 * @return Port name of service
58 */ 50 */
@@ -68,10 +60,9 @@ public:
68 60
69private: 61private:
70 62
71
72 Syscall::Result GetLockHandle(); 63 Syscall::Result GetLockHandle();
73 64
74 65 DISALLOW_COPY_AND_ASSIGN(APT_U);
75}; 66};
76 67
77} // namespace 68} // namespace
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 44c7c8627..799dbe90e 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -4,10 +4,12 @@
4 4
5#include "common/common.h" 5#include "common/common.h"
6#include "common/log.h" 6#include "common/log.h"
7#include "common/string_util.h"
7 8
8#include "core/hle/hle.h" 9#include "core/hle/hle.h"
9#include "core/hle/service/service.h" 10#include "core/hle/service/service.h"
10#include "core/hle/service/apt.h" 11#include "core/hle/service/apt.h"
12#include "core/hle/service/srv.h"
11 13
12namespace Service { 14namespace Service {
13 15
@@ -64,84 +66,6 @@ Interface* Manager::FetchFromPortName(std::string port_name) {
64 return FetchFromUID(itr->second); 66 return FetchFromUID(itr->second);
65} 67}
66 68
67////////////////////////////////////////////////////////////////////////////////////////////////////
68// Interface to "SRV" service
69
70class SRV : public Interface {
71
72public:
73
74 SRV() {
75 }
76
77 ~SRV() {
78 }
79
80 enum {
81 CMD_OFFSET = 0x80,
82 CMD_HEADER_INIT = 0x10002, ///< Command header to initialize SRV service
83 CMD_HEADER_GET_HANDLE = 0x50100, ///< Command header to get handle of other services
84 };
85
86 /**
87 * Gets the string name used by CTROS for a service
88 * @return String name of service
89 */
90 std::string GetName() const {
91 return "ServiceManager";
92 }
93
94 /**
95 * Gets the string name used by CTROS for a service
96 * @return Port name of service
97 */
98 std::string GetPortName() const {
99 return "srv:";
100 }
101
102 /**
103 * Called when svcSendSyncRequest is called, loads command buffer and executes comand
104 * @return Return result of svcSendSyncRequest passed back to user app
105 */
106 Syscall::Result Sync() {
107 Syscall::Result res = 0;
108 u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + CMD_OFFSET);
109
110 switch (cmd_buff[0]) {
111
112 case CMD_HEADER_INIT:
113 NOTICE_LOG(OSHLE, "SRV::Sync - Initialize");
114 break;
115
116 case CMD_HEADER_GET_HANDLE:
117 {
118 const char* port_name = (const char*)&cmd_buff[1];
119 Interface* service = g_manager->FetchFromPortName(port_name);
120
121 NOTICE_LOG(OSHLE, "SRV::Sync - GetHandle - port: %s, handle: 0x%08X", port_name,
122 service->GetUID());
123
124 if (NULL != service) {
125 cmd_buff[3] = service->GetUID();
126 } else {
127 ERROR_LOG(OSHLE, "Service %s does not exist", port_name);
128 res = -1;
129 }
130 break;
131 }
132
133 default:
134 ERROR_LOG(OSHLE, "SRV::Sync - Unknown command 0x%08X", cmd_buff[0]);
135 res = -1;
136 break;
137 }
138
139 cmd_buff[1] = res;
140
141 return res;
142 }
143
144};
145 69
146//////////////////////////////////////////////////////////////////////////////////////////////////// 70////////////////////////////////////////////////////////////////////////////////////////////////////
147// Module interface 71// Module interface
@@ -149,8 +73,8 @@ public:
149/// Initialize ServiceManager 73/// Initialize ServiceManager
150void Init() { 74void Init() {
151 g_manager = new Manager; 75 g_manager = new Manager;
152 g_manager->AddService(new SRV); 76 g_manager->AddService(new SRV::Interface);
153 g_manager->AddService(new APT); 77 g_manager->AddService(new APT_U);
154 NOTICE_LOG(HLE, "Services initialized OK"); 78 NOTICE_LOG(HLE, "Services initialized OK");
155} 79}
156 80
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 365583ed2..9368a9f0f 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -39,14 +39,6 @@ public:
39 39
40 /** 40 /**
41 * Gets the string name used by CTROS for a service 41 * Gets the string name used by CTROS for a service
42 * @return String name of service
43 */
44 virtual std::string GetName() const {
45 return "[UNKNOWN SERVICE NAME]";
46 }
47
48 /**
49 * Gets the string name used by CTROS for a service
50 * @return Port name of service 42 * @return Port name of service
51 */ 43 */
52 virtual std::string GetPortName() const { 44 virtual std::string GetPortName() const {
@@ -59,8 +51,19 @@ public:
59 */ 51 */
60 virtual Syscall::Result Sync() = 0; 52 virtual Syscall::Result Sync() = 0;
61 53
54protected:
55 /**
56 * Registers the functions in the service
57 */
58 void Register(const HLE::FunctionDef* functions, int len) {
59 for (int i = 0; i < len; i++) {
60 m_functions[functions[i].id] = functions[i];
61 }
62 }
63
62private: 64private:
63 u32 m_uid; 65 u32 m_uid;
66 std::map<u32, HLE::FunctionDef> m_functions;
64}; 67};
65 68
66/// Simple class to manage accessing services from ports and UID handles 69/// Simple class to manage accessing services from ports and UID handles