mirror of
				https://git.zaroz.cloud/nintendo-back-up/yuzu/yuzu-mainline.git
				synced 2025-03-21 01:53:15 +00:00 
			
		
		
		
	kernel: Fix implementation of ConvertSessionToDomain.
This commit is contained in:
		
							parent
							
								
									b67cbb8d92
								
							
						
					
					
						commit
						dcdaac8a0b
					
				@ -9,6 +9,7 @@
 | 
				
			|||||||
#include <type_traits>
 | 
					#include <type_traits>
 | 
				
			||||||
#include <utility>
 | 
					#include <utility>
 | 
				
			||||||
#include "core/hle/ipc.h"
 | 
					#include "core/hle/ipc.h"
 | 
				
			||||||
 | 
					#include "core/hle/kernel/domain.h"
 | 
				
			||||||
#include "core/hle/kernel/handle_table.h"
 | 
					#include "core/hle/kernel/handle_table.h"
 | 
				
			||||||
#include "core/hle/kernel/hle_ipc.h"
 | 
					#include "core/hle/kernel/hle_ipc.h"
 | 
				
			||||||
#include "core/hle/kernel/kernel.h"
 | 
					#include "core/hle/kernel/kernel.h"
 | 
				
			||||||
@ -80,11 +81,24 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        AlignWithPadding();
 | 
					        AlignWithPadding();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (context.IsDomain()) {
 | 
				
			||||||
 | 
					            PushRaw(IPC::DomainMessageHeader{});
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        IPC::DataPayloadHeader data_payload_header{};
 | 
					        IPC::DataPayloadHeader data_payload_header{};
 | 
				
			||||||
        data_payload_header.magic = Common::MakeMagic('S', 'F', 'C', 'O');
 | 
					        data_payload_header.magic = Common::MakeMagic('S', 'F', 'C', 'O');
 | 
				
			||||||
        PushRaw(data_payload_header);
 | 
					        PushRaw(data_payload_header);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    template <class T>
 | 
				
			||||||
 | 
					    void PushIpcInterface() {
 | 
				
			||||||
 | 
					        auto& request_handlers = context->Domain()->request_handlers;
 | 
				
			||||||
 | 
					        request_handlers.push_back(std::move(std::make_shared<T>()->shared_from_this()));
 | 
				
			||||||
 | 
					        Push(RESULT_SUCCESS);
 | 
				
			||||||
 | 
					        AlignWithPadding();
 | 
				
			||||||
 | 
					        Push<u32>(static_cast<u32>(request_handlers.size()));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Validate on destruction, as there shouldn't be any case where we don't want it
 | 
					    // Validate on destruction, as there shouldn't be any case where we don't want it
 | 
				
			||||||
    ~RequestBuilder() {
 | 
					    ~RequestBuilder() {
 | 
				
			||||||
        ValidateHeader();
 | 
					        ValidateHeader();
 | 
				
			||||||
 | 
				
			|||||||
@ -5,10 +5,12 @@
 | 
				
			|||||||
#include <utility>
 | 
					#include <utility>
 | 
				
			||||||
#include "common/assert.h"
 | 
					#include "common/assert.h"
 | 
				
			||||||
#include "common/logging/log.h"
 | 
					#include "common/logging/log.h"
 | 
				
			||||||
 | 
					#include "core/hle/kernel/client_session.h"
 | 
				
			||||||
#include "core/hle/kernel/errors.h"
 | 
					#include "core/hle/kernel/errors.h"
 | 
				
			||||||
#include "core/hle/kernel/handle_table.h"
 | 
					#include "core/hle/kernel/handle_table.h"
 | 
				
			||||||
#include "core/hle/kernel/kernel.h"
 | 
					#include "core/hle/kernel/kernel.h"
 | 
				
			||||||
#include "core/hle/kernel/process.h"
 | 
					#include "core/hle/kernel/process.h"
 | 
				
			||||||
 | 
					#include "core/hle/kernel/session.h"
 | 
				
			||||||
#include "core/hle/kernel/thread.h"
 | 
					#include "core/hle/kernel/thread.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Kernel {
 | 
					namespace Kernel {
 | 
				
			||||||
@ -53,6 +55,14 @@ ResultVal<Handle> HandleTable::Duplicate(Handle handle) {
 | 
				
			|||||||
    return Create(std::move(object));
 | 
					    return Create(std::move(object));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void HandleTable::ConvertSessionToDomain(const Session& session, SharedPtr<Object> domain) {
 | 
				
			||||||
 | 
					    for (auto& object : objects) {
 | 
				
			||||||
 | 
					        if (DynamicObjectCast<ClientSession>(object) == session.client) {
 | 
				
			||||||
 | 
					            object = domain;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ResultCode HandleTable::Close(Handle handle) {
 | 
					ResultCode HandleTable::Close(Handle handle) {
 | 
				
			||||||
    if (!IsValid(handle))
 | 
					    if (!IsValid(handle))
 | 
				
			||||||
        return ERR_INVALID_HANDLE;
 | 
					        return ERR_INVALID_HANDLE;
 | 
				
			||||||
 | 
				
			|||||||
@ -17,6 +17,8 @@ enum KernelHandle : Handle {
 | 
				
			|||||||
    CurrentProcess = 0xFFFF8001,
 | 
					    CurrentProcess = 0xFFFF8001,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Session;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * This class allows the creation of Handles, which are references to objects that can be tested
 | 
					 * This class allows the creation of Handles, which are references to objects that can be tested
 | 
				
			||||||
 * for validity and looked up. Here they are used to pass references to kernel objects to/from the
 | 
					 * for validity and looked up. Here they are used to pass references to kernel objects to/from the
 | 
				
			||||||
@ -59,6 +61,11 @@ public:
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    ResultVal<Handle> Duplicate(Handle handle);
 | 
					    ResultVal<Handle> Duplicate(Handle handle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Convert all handles of the specified Session to the specified Domain.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    void ConvertSessionToDomain(const Session& session, SharedPtr<Object> domain);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Closes a handle, removing it from the table and decreasing the object's ref-count.
 | 
					     * Closes a handle, removing it from the table and decreasing the object's ref-count.
 | 
				
			||||||
     * @return `RESULT_SUCCESS` or one of the following errors:
 | 
					     * @return `RESULT_SUCCESS` or one of the following errors:
 | 
				
			||||||
 | 
				
			|||||||
@ -7,6 +7,7 @@
 | 
				
			|||||||
#include "common/common_funcs.h"
 | 
					#include "common/common_funcs.h"
 | 
				
			||||||
#include "common/common_types.h"
 | 
					#include "common/common_types.h"
 | 
				
			||||||
#include "core/hle/ipc_helpers.h"
 | 
					#include "core/hle/ipc_helpers.h"
 | 
				
			||||||
 | 
					#include "core/hle/kernel/domain.h"
 | 
				
			||||||
#include "core/hle/kernel/handle_table.h"
 | 
					#include "core/hle/kernel/handle_table.h"
 | 
				
			||||||
#include "core/hle/kernel/hle_ipc.h"
 | 
					#include "core/hle/kernel/hle_ipc.h"
 | 
				
			||||||
#include "core/hle/kernel/kernel.h"
 | 
					#include "core/hle/kernel/kernel.h"
 | 
				
			||||||
@ -25,8 +26,12 @@ void SessionRequestHandler::ClientDisconnected(SharedPtr<ServerSession> server_s
 | 
				
			|||||||
    boost::range::remove_erase(connected_sessions, server_session);
 | 
					    boost::range::remove_erase(connected_sessions, server_session);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HLERequestContext::HLERequestContext(SharedPtr<ServerSession> session)
 | 
					HLERequestContext::HLERequestContext(SharedPtr<Kernel::Domain> domain) : domain(std::move(domain)) {
 | 
				
			||||||
    : session(std::move(session)) {
 | 
					    cmd_buf[0] = 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					HLERequestContext::HLERequestContext(SharedPtr<Kernel::ServerSession> server_session)
 | 
				
			||||||
 | 
					    : server_session(std::move(server_session)) {
 | 
				
			||||||
    cmd_buf[0] = 0;
 | 
					    cmd_buf[0] = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -66,16 +71,16 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) {
 | 
				
			|||||||
        rp.Skip(handle_descriptor_header->num_handles_to_move, false);
 | 
					        rp.Skip(handle_descriptor_header->num_handles_to_move, false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int i = 0; i < command_header->num_buf_x_descriptors; ++i) {
 | 
					    for (unsigned i = 0; i < command_header->num_buf_x_descriptors; ++i) {
 | 
				
			||||||
        buffer_x_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorX>());
 | 
					        buffer_x_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorX>());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (int i = 0; i < command_header->num_buf_a_descriptors; ++i) {
 | 
					    for (unsigned i = 0; i < command_header->num_buf_a_descriptors; ++i) {
 | 
				
			||||||
        buffer_a_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
 | 
					        buffer_a_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (int i = 0; i < command_header->num_buf_b_descriptors; ++i) {
 | 
					    for (unsigned i = 0; i < command_header->num_buf_b_descriptors; ++i) {
 | 
				
			||||||
        buffer_b_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
 | 
					        buffer_b_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (int i = 0; i < command_header->num_buf_w_descriptors; ++i) {
 | 
					    for (unsigned i = 0; i < command_header->num_buf_w_descriptors; ++i) {
 | 
				
			||||||
        buffer_w_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
 | 
					        buffer_w_desciptors.push_back(rp.PopRaw<IPC::BufferDescriptorABW>());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (command_header->buf_c_descriptor_flags !=
 | 
					    if (command_header->buf_c_descriptor_flags !=
 | 
				
			||||||
@ -85,6 +90,12 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Padding to align to 16 bytes
 | 
					    // Padding to align to 16 bytes
 | 
				
			||||||
    rp.AlignWithPadding();
 | 
					    rp.AlignWithPadding();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (IsDomain() && (command_header->type == IPC::CommandType::Request || !incoming)) {
 | 
				
			||||||
 | 
					        // If this is an incoming message, only CommandType "Request" has a domain header
 | 
				
			||||||
 | 
					        // All outgoing domain messages have the domain header
 | 
				
			||||||
 | 
					        domain_message_header =
 | 
				
			||||||
 | 
					            std::make_unique<IPC::DomainMessageHeader>(rp.PopRaw<IPC::DomainMessageHeader>());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    data_payload_header =
 | 
					    data_payload_header =
 | 
				
			||||||
@ -106,13 +117,6 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(u32_le* src_cmdb
 | 
				
			|||||||
    ParseCommandBuffer(src_cmdbuf, true);
 | 
					    ParseCommandBuffer(src_cmdbuf, true);
 | 
				
			||||||
    size_t untranslated_size = data_payload_offset + command_header->data_size;
 | 
					    size_t untranslated_size = data_payload_offset + command_header->data_size;
 | 
				
			||||||
    std::copy_n(src_cmdbuf, untranslated_size, cmd_buf.begin());
 | 
					    std::copy_n(src_cmdbuf, untranslated_size, cmd_buf.begin());
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (command_header->enable_handle_descriptor) {
 | 
					 | 
				
			||||||
        if (handle_descriptor_header->num_handles_to_copy ||
 | 
					 | 
				
			||||||
            handle_descriptor_header->num_handles_to_move) {
 | 
					 | 
				
			||||||
            UNIMPLEMENTED();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return RESULT_SUCCESS;
 | 
					    return RESULT_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -20,7 +20,9 @@ class ServiceFrameworkBase;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Kernel {
 | 
					namespace Kernel {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Domain;
 | 
				
			||||||
class HandleTable;
 | 
					class HandleTable;
 | 
				
			||||||
 | 
					class HLERequestContext;
 | 
				
			||||||
class Process;
 | 
					class Process;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -40,7 +42,7 @@ public:
 | 
				
			|||||||
     * this request (ServerSession, Originator thread, Translated command buffer, etc).
 | 
					     * this request (ServerSession, Originator thread, Translated command buffer, etc).
 | 
				
			||||||
     * @returns ResultCode the result code of the translate operation.
 | 
					     * @returns ResultCode the result code of the translate operation.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    virtual ResultCode HandleSyncRequest(SharedPtr<ServerSession> server_session) = 0;
 | 
					    virtual ResultCode HandleSyncRequest(Kernel::HLERequestContext& context) = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Signals that a client has just connected to this HLE handler and keeps the
 | 
					     * Signals that a client has just connected to this HLE handler and keeps the
 | 
				
			||||||
@ -84,7 +86,8 @@ protected:
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class HLERequestContext {
 | 
					class HLERequestContext {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    HLERequestContext(SharedPtr<ServerSession> session);
 | 
					    HLERequestContext(SharedPtr<Kernel::Domain> domain);
 | 
				
			||||||
 | 
					    HLERequestContext(SharedPtr<Kernel::ServerSession> session);
 | 
				
			||||||
    ~HLERequestContext();
 | 
					    ~HLERequestContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Returns a pointer to the IPC command buffer for this request.
 | 
					    /// Returns a pointer to the IPC command buffer for this request.
 | 
				
			||||||
@ -92,12 +95,19 @@ public:
 | 
				
			|||||||
        return cmd_buf.data();
 | 
					        return cmd_buf.data();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Returns the domain through which this request was made.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    const SharedPtr<Kernel::Domain>& Domain() const {
 | 
				
			||||||
 | 
					        return domain;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Returns the session through which this request was made. This can be used as a map key to
 | 
					     * Returns the session through which this request was made. This can be used as a map key to
 | 
				
			||||||
     * access per-client data on services.
 | 
					     * access per-client data on services.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    SharedPtr<ServerSession> Session() const {
 | 
					    const SharedPtr<Kernel::ServerSession>& ServerSession() const {
 | 
				
			||||||
        return session;
 | 
					        return server_session;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -144,9 +154,18 @@ public:
 | 
				
			|||||||
        return buffer_x_desciptors;
 | 
					        return buffer_x_desciptors;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const std::unique_ptr<IPC::DomainMessageHeader>& GetDomainMessageHeader() const {
 | 
				
			||||||
 | 
					        return domain_message_header;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool IsDomain() const {
 | 
				
			||||||
 | 
					        return domain != nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf;
 | 
					    std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf;
 | 
				
			||||||
    SharedPtr<ServerSession> session;
 | 
					    SharedPtr<Kernel::Domain> domain;
 | 
				
			||||||
 | 
					    SharedPtr<Kernel::ServerSession> server_session;
 | 
				
			||||||
    // TODO(yuriks): Check common usage of this and optimize size accordingly
 | 
					    // TODO(yuriks): Check common usage of this and optimize size accordingly
 | 
				
			||||||
    boost::container::small_vector<SharedPtr<Object>, 8> request_handles;
 | 
					    boost::container::small_vector<SharedPtr<Object>, 8> request_handles;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "core/hle/kernel/client_port.h"
 | 
					#include "core/hle/kernel/client_port.h"
 | 
				
			||||||
#include "core/hle/kernel/client_session.h"
 | 
					#include "core/hle/kernel/client_session.h"
 | 
				
			||||||
 | 
					#include "core/hle/kernel/handle_table.h"
 | 
				
			||||||
#include "core/hle/kernel/hle_ipc.h"
 | 
					#include "core/hle/kernel/hle_ipc.h"
 | 
				
			||||||
 | 
					#include "core/hle/kernel/process.h"
 | 
				
			||||||
#include "core/hle/kernel/server_session.h"
 | 
					#include "core/hle/kernel/server_session.h"
 | 
				
			||||||
#include "core/hle/kernel/session.h"
 | 
					#include "core/hle/kernel/session.h"
 | 
				
			||||||
#include "core/hle/kernel/thread.h"
 | 
					#include "core/hle/kernel/thread.h"
 | 
				
			||||||
@ -66,8 +68,13 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
 | 
				
			|||||||
        ResultCode translate_result = TranslateHLERequest(this);
 | 
					        ResultCode translate_result = TranslateHLERequest(this);
 | 
				
			||||||
        if (translate_result.IsError())
 | 
					        if (translate_result.IsError())
 | 
				
			||||||
            return translate_result;
 | 
					            return translate_result;
 | 
				
			||||||
        result = hle_handler->HandleSyncRequest(SharedPtr<ServerSession>(this));
 | 
					
 | 
				
			||||||
        // TODO(Subv): Translate the response command buffer.
 | 
					        Kernel::HLERequestContext context(this);
 | 
				
			||||||
 | 
					        u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
 | 
				
			||||||
 | 
					        context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
 | 
				
			||||||
 | 
					                                                  Kernel::g_handle_table);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        result = hle_handler->HandleSyncRequest(context);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        // Add the thread to the list of threads that have issued a sync request with this
 | 
					        // Add the thread to the list of threads that have issued a sync request with this
 | 
				
			||||||
        // server.
 | 
					        // server.
 | 
				
			||||||
 | 
				
			|||||||
@ -91,14 +91,6 @@ public:
 | 
				
			|||||||
    /// TODO(Subv): Find a better name for this.
 | 
					    /// TODO(Subv): Find a better name for this.
 | 
				
			||||||
    SharedPtr<Thread> currently_handling;
 | 
					    SharedPtr<Thread> currently_handling;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void ConvertToDomain() {
 | 
					 | 
				
			||||||
        is_domain = true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    bool IsDomain() const {
 | 
					 | 
				
			||||||
        return is_domain;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    ServerSession();
 | 
					    ServerSession();
 | 
				
			||||||
    ~ServerSession() override;
 | 
					    ~ServerSession() override;
 | 
				
			||||||
@ -110,8 +102,6 @@ private:
 | 
				
			|||||||
     * @return The created server session
 | 
					     * @return The created server session
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown");
 | 
					    static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown");
 | 
				
			||||||
 | 
					 | 
				
			||||||
    bool is_domain{};
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,6 @@
 | 
				
			|||||||
#include "core/hle/kernel/handle_table.h"
 | 
					#include "core/hle/kernel/handle_table.h"
 | 
				
			||||||
#include "core/hle/kernel/process.h"
 | 
					#include "core/hle/kernel/process.h"
 | 
				
			||||||
#include "core/hle/kernel/server_port.h"
 | 
					#include "core/hle/kernel/server_port.h"
 | 
				
			||||||
#include "core/hle/kernel/server_session.h"
 | 
					 | 
				
			||||||
#include "core/hle/kernel/thread.h"
 | 
					#include "core/hle/kernel/thread.h"
 | 
				
			||||||
#include "core/hle/service/am/am.h"
 | 
					#include "core/hle/service/am/am.h"
 | 
				
			||||||
#include "core/hle/service/aoc/aoc_u.h"
 | 
					#include "core/hle/service/aoc/aoc_u.h"
 | 
				
			||||||
@ -29,7 +28,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using Kernel::ClientPort;
 | 
					using Kernel::ClientPort;
 | 
				
			||||||
using Kernel::ServerPort;
 | 
					using Kernel::ServerPort;
 | 
				
			||||||
using Kernel::ServerSession;
 | 
					 | 
				
			||||||
using Kernel::SharedPtr;
 | 
					using Kernel::SharedPtr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Service {
 | 
					namespace Service {
 | 
				
			||||||
@ -124,15 +122,7 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) {
 | 
				
			|||||||
    handler_invoker(this, info->handler_callback, ctx);
 | 
					    handler_invoker(this, info->handler_callback, ctx);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ResultCode ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_session) {
 | 
					ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) {
 | 
				
			||||||
    u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // TODO(yuriks): The kernel should be the one handling this as part of translation after
 | 
					 | 
				
			||||||
    // everything else is migrated
 | 
					 | 
				
			||||||
    Kernel::HLERequestContext context(std::move(server_session));
 | 
					 | 
				
			||||||
    context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
 | 
					 | 
				
			||||||
                                              Kernel::g_handle_table);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    switch (context.GetCommandType()) {
 | 
					    switch (context.GetCommandType()) {
 | 
				
			||||||
    case IPC::CommandType::Close: {
 | 
					    case IPC::CommandType::Close: {
 | 
				
			||||||
        IPC::RequestBuilder rb{context, 1};
 | 
					        IPC::RequestBuilder rb{context, 1};
 | 
				
			||||||
@ -151,6 +141,7 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> serv
 | 
				
			|||||||
        UNIMPLEMENTED_MSG("command_type=%d", context.GetCommandType());
 | 
					        UNIMPLEMENTED_MSG("command_type=%d", context.GetCommandType());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
 | 
				
			||||||
    context.WriteToOutgoingCommandBuffer(cmd_buf, *Kernel::g_current_process,
 | 
					    context.WriteToOutgoingCommandBuffer(cmd_buf, *Kernel::g_current_process,
 | 
				
			||||||
                                         Kernel::g_handle_table);
 | 
					                                         Kernel::g_handle_table);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -63,7 +63,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    void InvokeRequest(Kernel::HLERequestContext& ctx);
 | 
					    void InvokeRequest(Kernel::HLERequestContext& ctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ResultCode HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
 | 
					    ResultCode HandleSyncRequest(Kernel::HLERequestContext& context) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
    /// Member-function pointer type of SyncRequest handlers.
 | 
					    /// Member-function pointer type of SyncRequest handlers.
 | 
				
			||||||
 | 
				
			|||||||
@ -4,27 +4,21 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "common/logging/log.h"
 | 
					#include "common/logging/log.h"
 | 
				
			||||||
#include "core/hle/ipc_helpers.h"
 | 
					#include "core/hle/ipc_helpers.h"
 | 
				
			||||||
 | 
					#include "core/hle/kernel/domain.h"
 | 
				
			||||||
#include "core/hle/service/sm/controller.h"
 | 
					#include "core/hle/service/sm/controller.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Service {
 | 
					namespace Service {
 | 
				
			||||||
namespace SM {
 | 
					namespace SM {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Controller::ConvertSessionToDomain service function
 | 
					 | 
				
			||||||
 *  Inputs:
 | 
					 | 
				
			||||||
 *      0: 0x00000000
 | 
					 | 
				
			||||||
 *  Outputs:
 | 
					 | 
				
			||||||
 *      0: ResultCode
 | 
					 | 
				
			||||||
 *      2: Handle of domain
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) {
 | 
					void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) {
 | 
				
			||||||
    ctx.Session()->ConvertToDomain();
 | 
					    auto domain = Kernel::Domain::CreateFromSession(*ctx.ServerSession()->parent).Unwrap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    IPC::RequestBuilder rb{ctx, 3};
 | 
					    IPC::RequestBuilder rb{ctx, 3};
 | 
				
			||||||
    rb.Push(RESULT_SUCCESS);
 | 
					    rb.Push(RESULT_SUCCESS);
 | 
				
			||||||
    rb.Skip(1, true);
 | 
					    rb.Skip(1, true);
 | 
				
			||||||
    Kernel::Handle handle = Kernel::g_handle_table.Create(ctx.Session()).Unwrap();
 | 
					    rb.Push<u32>(static_cast<u32>(domain->request_handlers.size()));
 | 
				
			||||||
    rb.Push(handle);
 | 
					
 | 
				
			||||||
    LOG_DEBUG(Service, "called, handle=0x%08x", handle);
 | 
					    LOG_DEBUG(Service, "called, domain=%d", domain->GetObjectId());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user