mirror of
https://git.uzuy-edge.org/Uzuy/Uzuy-MMJR.git
synced 2024-12-05 00:26:27 +00:00
Kernel/SVC: Implemented svcCreatePort.
This commit is contained in:
parent
3d9fbffbab
commit
7b445ddff0
@ -194,6 +194,16 @@ template<ResultCode func(Handle, u32)> void Wrap() {
|
||||
FuncReturn(func(PARAM(0), PARAM(1)).raw);
|
||||
}
|
||||
|
||||
template<ResultCode func(Handle*, Handle*, const char*, u32)> void Wrap() {
|
||||
Handle param_1 = 0;
|
||||
Handle param_2 = 0;
|
||||
u32 retval = func(¶m_1, ¶m_2, reinterpret_cast<const char*>(Memory::GetPointer(PARAM(2))), PARAM(3)).raw;
|
||||
// The first out parameter is moved into R2 and the second is moved into R1.
|
||||
Core::g_app_core->SetReg(1, param_2);
|
||||
Core::g_app_core->SetReg(2, param_1);
|
||||
FuncReturn(retval);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Function wrappers that return type u32
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class ServerPort;
|
||||
|
||||
class ClientPort : public Object {
|
||||
public:
|
||||
friend class ServerPort;
|
||||
|
@ -35,7 +35,7 @@ enum KernelHandle : Handle {
|
||||
|
||||
enum class HandleType : u32 {
|
||||
Unknown = 0,
|
||||
ServerPort = 1,
|
||||
|
||||
Session = 2,
|
||||
Event = 3,
|
||||
Mutex = 4,
|
||||
@ -49,6 +49,7 @@ enum class HandleType : u32 {
|
||||
ResourceLimit = 12,
|
||||
CodeSet = 13,
|
||||
ClientPort = 14,
|
||||
ServerPort = 15,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -2,8 +2,11 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include "common/assert.h"
|
||||
|
||||
#include "core/hle/kernel/client_port.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/kernel/server_port.h"
|
||||
#include "core/hle/kernel/thread.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
@ -12,10 +13,12 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
class ClientPort;
|
||||
|
||||
class ServerPort final : public WaitObject {
|
||||
public:
|
||||
/**
|
||||
* Creates a pair of a ServerPort and an associated ClientPort.
|
||||
* Creates a pair of ServerPort and an associated ClientPort.
|
||||
* @param max_sessions Maximum number of sessions to the port
|
||||
* @param name Optional name of the ports
|
||||
* @return The created port tuple
|
||||
|
@ -14,12 +14,14 @@
|
||||
#include "core/arm/arm_interface.h"
|
||||
|
||||
#include "core/hle/kernel/address_arbiter.h"
|
||||
#include "core/hle/kernel/client_port.h"
|
||||
#include "core/hle/kernel/event.h"
|
||||
#include "core/hle/kernel/memory.h"
|
||||
#include "core/hle/kernel/mutex.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/kernel/resource_limit.h"
|
||||
#include "core/hle/kernel/semaphore.h"
|
||||
#include "core/hle/kernel/server_port.h"
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/kernel/thread.h"
|
||||
#include "core/hle/kernel/timer.h"
|
||||
@ -834,6 +836,23 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static ResultCode CreatePort(Handle* server_port, Handle* client_port, const char* name, u32 max_sessions) {
|
||||
// TODO(Subv): Implement named ports.
|
||||
ASSERT_MSG(name == nullptr, "Named ports are currently unimplemented");
|
||||
|
||||
using Kernel::ServerPort;
|
||||
using Kernel::ClientPort;
|
||||
using Kernel::SharedPtr;
|
||||
|
||||
auto ports = ServerPort::CreatePortPair(max_sessions);
|
||||
CASCADE_RESULT(*client_port, Kernel::g_handle_table.Create(std::move(std::get<SharedPtr<ClientPort>>(ports))));
|
||||
// Note: The 3DS kernel also leaks the client port handle if the server port handle fails to be created.
|
||||
CASCADE_RESULT(*server_port, Kernel::g_handle_table.Create(std::move(std::get<SharedPtr<ServerPort>>(ports))));
|
||||
|
||||
LOG_TRACE(Kernel_SVC, "called max_sessions=%u", max_sessions);
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static ResultCode GetSystemInfo(s64* out, u32 type, s32 param) {
|
||||
using Kernel::MemoryRegion;
|
||||
|
||||
@ -1011,7 +1030,7 @@ static const FunctionDef SVC_Table[] = {
|
||||
{0x44, nullptr, "Unknown"},
|
||||
{0x45, nullptr, "Unknown"},
|
||||
{0x46, nullptr, "Unknown"},
|
||||
{0x47, nullptr, "CreatePort"},
|
||||
{0x47, HLE::Wrap<CreatePort>, "CreatePort"},
|
||||
{0x48, nullptr, "CreateSessionToPort"},
|
||||
{0x49, nullptr, "CreateSession"},
|
||||
{0x4A, nullptr, "AcceptSession"},
|
||||
|
Loading…
Reference in New Issue
Block a user