diff options
| author | 2017-06-06 21:20:52 -0700 | |
|---|---|---|
| committer | 2017-06-08 00:11:37 -0700 | |
| commit | 84c497292a27d75b83305d053e734ab5659ffe41 (patch) | |
| tree | e70832478490b0531bd2b85924fd57e18ab6157b /src/core/hle/kernel | |
| parent | Kernel: Remove some unnecessary namespace qualifications (diff) | |
| download | yuzu-84c497292a27d75b83305d053e734ab5659ffe41.tar.gz yuzu-84c497292a27d75b83305d053e734ab5659ffe41.tar.xz yuzu-84c497292a27d75b83305d053e734ab5659ffe41.zip | |
Service: Add new ServiceFramework framework for writing HLE services
The old "Interface" class had a few problems such as using free
functions (Which didn't allow you to write the service handler as if it
were a regular class.) which weren't very extensible. (Only received one
parameter with a pointer to the Interface object.)
The new ServiceFramework aims to solve these problems by working with
member functions and passing a generic context struct as parameter. This
struct can be extended in the future without having to update all
existing service implementations.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 36 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 0922b3f47..a60b8ef00 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -21,4 +21,6 @@ void SessionRequestHandler::ClientDisconnected(SharedPtr<ServerSession> server_s | |||
| 21 | boost::range::remove_erase(connected_sessions, server_session); | 21 | boost::range::remove_erase(connected_sessions, server_session); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | HLERequestContext::~HLERequestContext() = default; | ||
| 25 | |||
| 24 | } // namespace Kernel | 26 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 5de9d59d3..c30184eab 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -7,10 +7,13 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/kernel.h" |
| 10 | #include "core/hle/kernel/server_session.h" | ||
| 10 | 11 | ||
| 11 | namespace Kernel { | 12 | namespace Service { |
| 13 | class ServiceFrameworkBase; | ||
| 14 | } | ||
| 12 | 15 | ||
| 13 | class ServerSession; | 16 | namespace Kernel { |
| 14 | 17 | ||
| 15 | /** | 18 | /** |
| 16 | * Interface implemented by HLE Session handlers. | 19 | * Interface implemented by HLE Session handlers. |
| @@ -52,4 +55,33 @@ protected: | |||
| 52 | std::vector<SharedPtr<ServerSession>> connected_sessions; | 55 | std::vector<SharedPtr<ServerSession>> connected_sessions; |
| 53 | }; | 56 | }; |
| 54 | 57 | ||
| 58 | /** | ||
| 59 | * Class containing information about an in-flight IPC request being handled by an HLE service | ||
| 60 | * implementation. Services should avoid using old global APIs (e.g. Kernel::GetCommandBuffer()) and | ||
| 61 | * when possible use the APIs in this class to service the request. | ||
| 62 | */ | ||
| 63 | class HLERequestContext { | ||
| 64 | public: | ||
| 65 | ~HLERequestContext(); | ||
| 66 | |||
| 67 | /// Returns a pointer to the IPC command buffer for this request. | ||
| 68 | u32* CommandBuffer() const { | ||
| 69 | return cmd_buf; | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Returns the session through which this request was made. This can be used as a map key to | ||
| 74 | * access per-client data on services. | ||
| 75 | */ | ||
| 76 | SharedPtr<ServerSession> Session() const { | ||
| 77 | return session; | ||
| 78 | } | ||
| 79 | |||
| 80 | private: | ||
| 81 | friend class Service::ServiceFrameworkBase; | ||
| 82 | |||
| 83 | u32* cmd_buf = nullptr; | ||
| 84 | SharedPtr<ServerSession> session; | ||
| 85 | }; | ||
| 86 | |||
| 55 | } // namespace Kernel | 87 | } // namespace Kernel |