summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2014-04-24 22:16:54 -0400
committerGravatar bunnei2014-04-24 22:16:54 -0400
commitcd0664eb77e14a801fe1f15be50c3a90b98ee5ef (patch)
treecddeb131b3ff7e43cc638ff0b8817b746b284491 /src
parentremoved "COVERAGE_" from "GCC_COVERAGE_COMPILE_FLAGS" (diff)
downloadyuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.tar.gz
yuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.tar.xz
yuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.zip
- refactored how service functions are called
- added option to create/delete service handles
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/apt.cpp6
-rw-r--r--src/core/hle/service/apt.h4
-rw-r--r--src/core/hle/service/hid.cpp2
-rw-r--r--src/core/hle/service/service.h40
-rw-r--r--src/core/hle/service/srv.cpp6
5 files changed, 39 insertions, 19 deletions
diff --git a/src/core/hle/service/apt.cpp b/src/core/hle/service/apt.cpp
index 4f8d7248d..4a1e8c992 100644
--- a/src/core/hle/service/apt.cpp
+++ b/src/core/hle/service/apt.cpp
@@ -13,16 +13,16 @@
13 13
14namespace APT_U { 14namespace APT_U {
15 15
16void Initialize() { 16void Initialize(Service::Interface* self) {
17 NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize"); 17 NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize");
18} 18}
19 19
20void GetLockHandle() { 20void GetLockHandle(Service::Interface* self) {
21 u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); 21 u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset);
22 cmd_buff[5] = 0x00000000; // TODO: This should be an actual mutex handle 22 cmd_buff[5] = 0x00000000; // TODO: This should be an actual mutex handle
23} 23}
24 24
25const HLE::FunctionDef FunctionTable[] = { 25const Interface::FunctionInfo FunctionTable[] = {
26 {0x00010040, GetLockHandle, "GetLockHandle"}, 26 {0x00010040, GetLockHandle, "GetLockHandle"},
27 {0x00020080, Initialize, "Initialize"}, 27 {0x00020080, Initialize, "Initialize"},
28 {0x00030040, NULL, "Enable"}, 28 {0x00030040, NULL, "Enable"},
diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h
index e74baac0c..4c7dd07e7 100644
--- a/src/core/hle/service/apt.h
+++ b/src/core/hle/service/apt.h
@@ -32,10 +32,6 @@ public:
32 std::string GetPortName() const { 32 std::string GetPortName() const {
33 return "APT:U"; 33 return "APT:U";
34 } 34 }
35
36private:
37
38 DISALLOW_COPY_AND_ASSIGN(Interface);
39}; 35};
40 36
41} // namespace 37} // namespace
diff --git a/src/core/hle/service/hid.cpp b/src/core/hle/service/hid.cpp
index 2d823dd16..5542e5bf2 100644
--- a/src/core/hle/service/hid.cpp
+++ b/src/core/hle/service/hid.cpp
@@ -12,7 +12,7 @@
12 12
13namespace HID_User { 13namespace HID_User {
14 14
15const HLE::FunctionDef FunctionTable[] = { 15const Interface::FunctionInfo FunctionTable[] = {
16 {0x000A0000, NULL, "GetIPCHandles"}, 16 {0x000A0000, NULL, "GetIPCHandles"},
17 {0x00110000, NULL, "EnableAccelerometer"}, 17 {0x00110000, NULL, "EnableAccelerometer"},
18 {0x00130000, NULL, "EnableGyroscopeLow"}, 18 {0x00130000, NULL, "EnableGyroscopeLow"},
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 9cbf8b6fa..9de17beab 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -25,7 +25,7 @@ static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer
25class Manager; 25class Manager;
26 26
27/// Interface to a CTROS service 27/// Interface to a CTROS service
28class Interface { 28class Interface : NonCopyable {
29 friend class Manager; 29 friend class Manager;
30public: 30public:
31 31
@@ -35,6 +35,14 @@ public:
35 virtual ~Interface() { 35 virtual ~Interface() {
36 } 36 }
37 37
38 typedef void (*Function)(Interface*);
39
40 struct FunctionInfo {
41 u32 id;
42 Function func;
43 std::string name;
44 };
45
38 /** 46 /**
39 * Gets the UID for the serice 47 * Gets the UID for the serice
40 * @return UID of service in native format 48 * @return UID of service in native format
@@ -51,6 +59,23 @@ public:
51 return "[UNKNOWN SERVICE PORT]"; 59 return "[UNKNOWN SERVICE PORT]";
52 } 60 }
53 61
62 /// Allocates a new handle for the service
63 Syscall::Handle NewHandle() {
64 Syscall::Handle handle = (m_handles.size() << 16) | m_uid;
65 m_handles.push_back(handle);
66 return handle;
67 }
68
69 /// Frees a handle from the service
70 void DeleteHandle(Syscall::Handle handle) {
71 for(auto iter = m_handles.begin(); iter != m_handles.end(); ++iter) {
72 if(*iter == handle) {
73 m_handles.erase(iter);
74 break;
75 }
76 }
77 }
78
54 /** 79 /**
55 * Called when svcSendSyncRequest is called, loads command buffer and executes comand 80 * Called when svcSendSyncRequest is called, loads command buffer and executes comand
56 * @return Return result of svcSendSyncRequest passed back to user app 81 * @return Return result of svcSendSyncRequest passed back to user app
@@ -70,16 +95,17 @@ public:
70 return -1; 95 return -1;
71 } 96 }
72 97
73 itr->second.func(); 98 itr->second.func(this);
74 99
75 return 0; // TODO: Implement return from actual function 100 return 0; // TODO: Implement return from actual function
76 } 101 }
77 102
78protected: 103protected:
104
79 /** 105 /**
80 * Registers the functions in the service 106 * Registers the functions in the service
81 */ 107 */
82 void Register(const HLE::FunctionDef* functions, int len) { 108 void Register(const FunctionInfo* functions, int len) {
83 for (int i = 0; i < len; i++) { 109 for (int i = 0; i < len; i++) {
84 m_functions[functions[i].id] = functions[i]; 110 m_functions[functions[i].id] = functions[i];
85 } 111 }
@@ -87,9 +113,9 @@ protected:
87 113
88private: 114private:
89 u32 m_uid; 115 u32 m_uid;
90 std::map<u32, HLE::FunctionDef> m_functions; 116
91 117 std::vector<Syscall::Handle> m_handles;
92 DISALLOW_COPY_AND_ASSIGN(Interface); 118 std::map<u32, FunctionInfo> m_functions;
93}; 119};
94 120
95/// Simple class to manage accessing services from ports and UID handles 121/// Simple class to manage accessing services from ports and UID handles
@@ -126,8 +152,6 @@ private:
126 152
127 std::vector<Interface*> m_services; 153 std::vector<Interface*> m_services;
128 std::map<std::string, u32> m_port_map; 154 std::map<std::string, u32> m_port_map;
129
130 DISALLOW_COPY_AND_ASSIGN(Manager);
131}; 155};
132 156
133/// Initialize ServiceManager 157/// Initialize ServiceManager
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index 579ea4a34..9437868c5 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -12,11 +12,11 @@
12 12
13namespace SRV { 13namespace SRV {
14 14
15void Initialize() { 15void Initialize(Service::Interface* self) {
16 NOTICE_LOG(OSHLE, "SRV::Sync - Initialize"); 16 NOTICE_LOG(OSHLE, "SRV::Sync - Initialize");
17} 17}
18 18
19void GetServiceHandle() { 19void GetServiceHandle(Service::Interface* self) {
20 Syscall::Result res = 0; 20 Syscall::Result res = 0;
21 u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset); 21 u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset);
22 22
@@ -37,7 +37,7 @@ void GetServiceHandle() {
37 //return res; 37 //return res;
38} 38}
39 39
40const HLE::FunctionDef FunctionTable[] = { 40const Interface::FunctionInfo FunctionTable[] = {
41 {0x00010002, Initialize, "Initialize"}, 41 {0x00010002, Initialize, "Initialize"},
42 {0x00020000, NULL, "GetProcSemaphore"}, 42 {0x00020000, NULL, "GetProcSemaphore"},
43 {0x00030100, NULL, "RegisterService"}, 43 {0x00030100, NULL, "RegisterService"},