summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorbunnei <ericbunnie@gmail.com>2014-04-25 04:16:54 +0200
committerbunnei <ericbunnie@gmail.com>2014-04-25 04:16:54 +0200
commitcd0664eb77e14a801fe1f15be50c3a90b98ee5ef (patch)
treecddeb131b3ff7e43cc638ff0b8817b746b284491 /src/core/hle/service
parentremoved "COVERAGE_" from "GCC_COVERAGE_COMPILE_FLAGS" (diff)
downloadyuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.tar
yuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.tar.gz
yuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.tar.bz2
yuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.tar.lz
yuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.tar.xz
yuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.tar.zst
yuzu-cd0664eb77e14a801fe1f15be50c3a90b98ee5ef.zip
Diffstat (limited to 'src/core/hle/service')
-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 @@
namespace APT_U {
-void Initialize() {
+void Initialize(Service::Interface* self) {
NOTICE_LOG(OSHLE, "APT_U::Sync - Initialize");
}
-void GetLockHandle() {
+void GetLockHandle(Service::Interface* self) {
u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset);
cmd_buff[5] = 0x00000000; // TODO: This should be an actual mutex handle
}
-const HLE::FunctionDef FunctionTable[] = {
+const Interface::FunctionInfo FunctionTable[] = {
{0x00010040, GetLockHandle, "GetLockHandle"},
{0x00020080, Initialize, "Initialize"},
{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:
std::string GetPortName() const {
return "APT:U";
}
-
-private:
-
- DISALLOW_COPY_AND_ASSIGN(Interface);
};
} // 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 @@
namespace HID_User {
-const HLE::FunctionDef FunctionTable[] = {
+const Interface::FunctionInfo FunctionTable[] = {
{0x000A0000, NULL, "GetIPCHandles"},
{0x00110000, NULL, "EnableAccelerometer"},
{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
class Manager;
/// Interface to a CTROS service
-class Interface {
+class Interface : NonCopyable {
friend class Manager;
public:
@@ -35,6 +35,14 @@ public:
virtual ~Interface() {
}
+ typedef void (*Function)(Interface*);
+
+ struct FunctionInfo {
+ u32 id;
+ Function func;
+ std::string name;
+ };
+
/**
* Gets the UID for the serice
* @return UID of service in native format
@@ -51,6 +59,23 @@ public:
return "[UNKNOWN SERVICE PORT]";
}
+ /// Allocates a new handle for the service
+ Syscall::Handle NewHandle() {
+ Syscall::Handle handle = (m_handles.size() << 16) | m_uid;
+ m_handles.push_back(handle);
+ return handle;
+ }
+
+ /// Frees a handle from the service
+ void DeleteHandle(Syscall::Handle handle) {
+ for(auto iter = m_handles.begin(); iter != m_handles.end(); ++iter) {
+ if(*iter == handle) {
+ m_handles.erase(iter);
+ break;
+ }
+ }
+ }
+
/**
* Called when svcSendSyncRequest is called, loads command buffer and executes comand
* @return Return result of svcSendSyncRequest passed back to user app
@@ -70,16 +95,17 @@ public:
return -1;
}
- itr->second.func();
+ itr->second.func(this);
return 0; // TODO: Implement return from actual function
}
protected:
+
/**
* Registers the functions in the service
*/
- void Register(const HLE::FunctionDef* functions, int len) {
+ void Register(const FunctionInfo* functions, int len) {
for (int i = 0; i < len; i++) {
m_functions[functions[i].id] = functions[i];
}
@@ -87,9 +113,9 @@ protected:
private:
u32 m_uid;
- std::map<u32, HLE::FunctionDef> m_functions;
-
- DISALLOW_COPY_AND_ASSIGN(Interface);
+
+ std::vector<Syscall::Handle> m_handles;
+ std::map<u32, FunctionInfo> m_functions;
};
/// Simple class to manage accessing services from ports and UID handles
@@ -126,8 +152,6 @@ private:
std::vector<Interface*> m_services;
std::map<std::string, u32> m_port_map;
-
- DISALLOW_COPY_AND_ASSIGN(Manager);
};
/// 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 @@
namespace SRV {
-void Initialize() {
+void Initialize(Service::Interface* self) {
NOTICE_LOG(OSHLE, "SRV::Sync - Initialize");
}
-void GetServiceHandle() {
+void GetServiceHandle(Service::Interface* self) {
Syscall::Result res = 0;
u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + Service::kCommandHeaderOffset);
@@ -37,7 +37,7 @@ void GetServiceHandle() {
//return res;
}
-const HLE::FunctionDef FunctionTable[] = {
+const Interface::FunctionInfo FunctionTable[] = {
{0x00010002, Initialize, "Initialize"},
{0x00020000, NULL, "GetProcSemaphore"},
{0x00030100, NULL, "RegisterService"},