kernel: Fix implementation of ConvertSessionToDomain.

This commit is contained in:
bunnei 2017-12-29 00:36:22 -05:00
parent b67cbb8d92
commit dcdaac8a0b
10 changed files with 90 additions and 54 deletions

View file

@ -13,7 +13,6 @@
#include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/server_port.h"
#include "core/hle/kernel/server_session.h"
#include "core/hle/kernel/thread.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/aoc/aoc_u.h"
@ -29,7 +28,6 @@
using Kernel::ClientPort;
using Kernel::ServerPort;
using Kernel::ServerSession;
using Kernel::SharedPtr;
namespace Service {
@ -124,15 +122,7 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) {
handler_invoker(this, info->handler_callback, ctx);
}
ResultCode ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_session) {
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);
ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) {
switch (context.GetCommandType()) {
case IPC::CommandType::Close: {
IPC::RequestBuilder rb{context, 1};
@ -151,6 +141,7 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> serv
UNIMPLEMENTED_MSG("command_type=%d", context.GetCommandType());
}
u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
context.WriteToOutgoingCommandBuffer(cmd_buf, *Kernel::g_current_process,
Kernel::g_handle_table);

View file

@ -63,7 +63,7 @@ public:
void InvokeRequest(Kernel::HLERequestContext& ctx);
ResultCode HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
ResultCode HandleSyncRequest(Kernel::HLERequestContext& context) override;
protected:
/// Member-function pointer type of SyncRequest handlers.

View file

@ -4,27 +4,21 @@
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/domain.h"
#include "core/hle/service/sm/controller.h"
namespace Service {
namespace SM {
/**
* Controller::ConvertSessionToDomain service function
* Inputs:
* 0: 0x00000000
* Outputs:
* 0: ResultCode
* 2: Handle of domain
*/
void Controller::ConvertSessionToDomain(Kernel::HLERequestContext& ctx) {
ctx.Session()->ConvertToDomain();
auto domain = Kernel::Domain::CreateFromSession(*ctx.ServerSession()->parent).Unwrap();
IPC::RequestBuilder rb{ctx, 3};
rb.Push(RESULT_SUCCESS);
rb.Skip(1, true);
Kernel::Handle handle = Kernel::g_handle_table.Create(ctx.Session()).Unwrap();
rb.Push(handle);
LOG_DEBUG(Service, "called, handle=0x%08x", handle);
rb.Push<u32>(static_cast<u32>(domain->request_handlers.size()));
LOG_DEBUG(Service, "called, domain=%d", domain->GetObjectId());
}
/**