mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-04 00:49:02 -06:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -21,4 +21,6 @@ void SessionRequestHandler::ClientDisconnected(SharedPtr<ServerSession> server_s
 | 
			
		||||
    boost::range::remove_erase(connected_sessions, server_session);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
HLERequestContext::~HLERequestContext() = default;
 | 
			
		||||
 | 
			
		||||
} // namespace Kernel
 | 
			
		||||
 
 | 
			
		||||
@@ -7,11 +7,14 @@
 | 
			
		||||
#include <memory>
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include "core/hle/kernel/kernel.h"
 | 
			
		||||
#include "core/hle/kernel/server_session.h"
 | 
			
		||||
 | 
			
		||||
namespace Service {
 | 
			
		||||
class ServiceFrameworkBase;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace Kernel {
 | 
			
		||||
 | 
			
		||||
class ServerSession;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Interface implemented by HLE Session handlers.
 | 
			
		||||
 * This can be provided to a ServerSession in order to hook into several relevant events
 | 
			
		||||
@@ -52,4 +55,33 @@ protected:
 | 
			
		||||
    std::vector<SharedPtr<ServerSession>> connected_sessions;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Class containing information about an in-flight IPC request being handled by an HLE service
 | 
			
		||||
 * implementation. Services should avoid using old global APIs (e.g. Kernel::GetCommandBuffer()) and
 | 
			
		||||
 * when possible use the APIs in this class to service the request.
 | 
			
		||||
 */
 | 
			
		||||
class HLERequestContext {
 | 
			
		||||
public:
 | 
			
		||||
    ~HLERequestContext();
 | 
			
		||||
 | 
			
		||||
    /// Returns a pointer to the IPC command buffer for this request.
 | 
			
		||||
    u32* CommandBuffer() const {
 | 
			
		||||
        return cmd_buf;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Returns the session through which this request was made. This can be used as a map key to
 | 
			
		||||
     * access per-client data on services.
 | 
			
		||||
     */
 | 
			
		||||
    SharedPtr<ServerSession> Session() const {
 | 
			
		||||
        return session;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    friend class Service::ServiceFrameworkBase;
 | 
			
		||||
 | 
			
		||||
    u32* cmd_buf = nullptr;
 | 
			
		||||
    SharedPtr<ServerSession> session;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace Kernel
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user