2018-01-13 21:22:39 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-15 02:18:42 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-09-25 21:14:19 +00:00
|
|
|
#include "common/assert.h"
|
2017-10-15 02:18:42 +00:00
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/hle/ipc_helpers.h"
|
2018-09-25 21:14:19 +00:00
|
|
|
#include "core/hle/kernel/client_session.h"
|
|
|
|
#include "core/hle/kernel/server_session.h"
|
2018-02-03 17:09:33 +00:00
|
|
|
#include "core/hle/kernel/session.h"
|
2017-10-15 02:18:42 +00:00
|
|
|
#include "core/hle/service/sm/controller.h"
|
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
namespace Service::SM {
|
2017-10-15 02:18:42 +00:00
|
|
|
|
2020-06-29 02:01:34 +00:00
|
|
|
void Controller::ConvertCurrentObjectToDomain(Kernel::HLERequestContext& ctx) {
|
2018-08-15 10:50:22 +00:00
|
|
|
ASSERT_MSG(ctx.Session()->IsSession(), "Session is already a domain");
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service, "called, server_session={}", ctx.Session()->GetObjectId());
|
2018-01-23 23:03:09 +00:00
|
|
|
ctx.Session()->ConvertToDomain();
|
2017-12-29 05:36:22 +00:00
|
|
|
|
2018-01-24 00:52:18 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2017-10-15 05:24:22 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-01-23 23:03:09 +00:00
|
|
|
rb.Push<u32>(1); // Converted sessions start with 1 request handler
|
2017-10-15 05:24:22 +00:00
|
|
|
}
|
|
|
|
|
2020-06-29 02:01:34 +00:00
|
|
|
void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) {
|
2018-02-03 17:09:33 +00:00
|
|
|
// TODO(bunnei): This is just creating a new handle to the same Session. I assume this is wrong
|
|
|
|
// and that we probably want to actually make an entirely new Session, but we still need to
|
|
|
|
// verify this on hardware.
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service, "called");
|
|
|
|
|
2018-01-24 03:33:30 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
|
2017-12-29 05:39:34 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-11-25 23:28:48 +00:00
|
|
|
rb.PushMoveObjects(ctx.Session()->GetParent()->Client());
|
2017-12-29 05:39:34 +00:00
|
|
|
}
|
|
|
|
|
2020-06-29 02:01:34 +00:00
|
|
|
void Controller::CloneCurrentObjectEx(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service, "(STUBBED) called, using CloneCurrentObject");
|
2018-02-03 17:09:33 +00:00
|
|
|
|
2020-06-29 02:01:34 +00:00
|
|
|
CloneCurrentObject(ctx);
|
2018-01-17 19:41:43 +00:00
|
|
|
}
|
|
|
|
|
2017-10-15 02:18:42 +00:00
|
|
|
void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_WARNING(Service, "(STUBBED) called");
|
|
|
|
|
2018-01-24 00:52:18 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
2017-10-15 02:18:42 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2020-03-23 02:19:30 +00:00
|
|
|
rb.Push<u16>(0x1000);
|
2017-10-15 02:18:42 +00:00
|
|
|
}
|
|
|
|
|
2020-06-29 02:01:34 +00:00
|
|
|
// https://switchbrew.org/wiki/IPC_Marshalling
|
2020-11-26 20:19:08 +00:00
|
|
|
Controller::Controller(Core::System& system_) : ServiceFramework{system_, "IpcController"} {
|
2017-10-15 02:18:42 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
2020-06-29 02:21:10 +00:00
|
|
|
{0, &Controller::ConvertCurrentObjectToDomain, "ConvertCurrentObjectToDomain"},
|
|
|
|
{1, nullptr, "CopyFromCurrentDomain"},
|
|
|
|
{2, &Controller::CloneCurrentObject, "CloneCurrentObject"},
|
|
|
|
{3, &Controller::QueryPointerBufferSize, "QueryPointerBufferSize"},
|
|
|
|
{4, &Controller::CloneCurrentObjectEx, "CloneCurrentObjectEx"},
|
2017-10-15 02:18:42 +00:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
2018-09-06 18:32:25 +00:00
|
|
|
Controller::~Controller() = default;
|
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
} // namespace Service::SM
|