From ffabed8c25490be0e61409cebd1615eedb223c3d Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 15 Apr 2014 23:28:03 -0400 Subject: restructured hle:services completely to use function lookup tables --- src/core/hle/service/service.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/core/hle/service/service.h') diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 9368a9f0..3b256aa3 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -17,7 +17,9 @@ namespace Service { -typedef s32 NativeUID; ///< Native handle for a service +typedef s32 NativeUID; ///< Native handle for a service + +static const int kCommandHeaderOffset = 0x80; ///< Offset into command buffer of header class Manager; @@ -26,6 +28,9 @@ class Interface { friend class Manager; public: + Interface() { + } + virtual ~Interface() { } @@ -49,7 +54,24 @@ public: * Called when svcSendSyncRequest is called, loads command buffer and executes comand * @return Return result of svcSendSyncRequest passed back to user app */ - virtual Syscall::Result Sync() = 0; + Syscall::Result Sync() { + u32* cmd_buff = (u32*)HLE::GetPointer(HLE::CMD_BUFFER_ADDR + kCommandHeaderOffset); + auto itr = m_functions.find(cmd_buff[0]); + + if (itr == m_functions.end()) { + ERROR_LOG(OSHLE, "Unknown/unimplemented function: port=%s, command=0x%08X!", + GetPortName().c_str(), cmd_buff[0]); + return -1; + } + if (itr->second.func == NULL) { + ERROR_LOG(OSHLE, "Unimplemented function: port=%s, name=%s!", + GetPortName().c_str(), itr->second.name.c_str()); + } + + itr->second.func(); + + return 0; // TODO: Implement return from actual function + } protected: /** @@ -64,6 +86,8 @@ protected: private: u32 m_uid; std::map m_functions; + + DISALLOW_COPY_AND_ASSIGN(Interface); }; /// Simple class to manage accessing services from ports and UID handles -- cgit v1.2.3