summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-06-09 08:52:30 +0200
committerYuri Kunde Schlesner <yuriks@yuriks.net>2017-06-11 22:07:33 +0200
commit20e5abb30807d4e0e34c79c049252f0872e47ca7 (patch)
tree54284838ca89629576a046807b6965fe11507880 /src/core/hle/service
parentRemove unused import in break_points.cpp (#2763) (diff)
downloadyuzu-20e5abb30807d4e0e34c79c049252f0872e47ca7.tar
yuzu-20e5abb30807d4e0e34c79c049252f0872e47ca7.tar.gz
yuzu-20e5abb30807d4e0e34c79c049252f0872e47ca7.tar.bz2
yuzu-20e5abb30807d4e0e34c79c049252f0872e47ca7.tar.lz
yuzu-20e5abb30807d4e0e34c79c049252f0872e47ca7.tar.xz
yuzu-20e5abb30807d4e0e34c79c049252f0872e47ca7.tar.zst
yuzu-20e5abb30807d4e0e34c79c049252f0872e47ca7.zip
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/service.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index d34968428..35582b0ff 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -2,9 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <algorithm>
#include <fmt/format.h>
+#include "common/assert.h"
#include "common/logging/log.h"
#include "common/string_util.h"
+#include "core/hle/ipc.h"
#include "core/hle/kernel/client_port.h"
#include "core/hle/kernel/server_port.h"
#include "core/hle/kernel/server_session.h"
@@ -160,12 +163,6 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(u32* cmd_buf, const Funct
void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_session) {
u32* cmd_buf = Kernel::GetCommandBuffer();
- // TODO(yuriks): The kernel should be the one handling this as part of translation after
- // everything else is migrated
- Kernel::HLERequestContext context;
- context.cmd_buf = cmd_buf;
- context.session = std::move(server_session);
-
u32 header_code = cmd_buf[0];
auto itr = handlers.find(header_code);
const FunctionInfoBase* info = itr == handlers.end() ? nullptr : &itr->second;
@@ -173,9 +170,26 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
return ReportUnimplementedFunction(cmd_buf, info);
}
+ // TODO(yuriks): The kernel should be the one handling this as part of translation after
+ // everything else is migrated
+ IPC::Header request_header{cmd_buf[0]};
+ size_t request_size =
+ 1 + request_header.normal_params_size + request_header.translate_params_size;
+ ASSERT(request_size <= IPC::COMMAND_BUFFER_LENGTH); // TODO(yuriks): Return error
+
+ Kernel::HLERequestContext context;
+ std::copy_n(cmd_buf, request_size, context.cmd_buf.begin());
+ context.session = std::move(server_session);
+
LOG_TRACE(Service, "%s",
MakeFunctionString(info->name, GetServiceName().c_str(), cmd_buf).c_str());
handler_invoker(this, info->handler_callback, context);
+
+ IPC::Header response_header{context.cmd_buf[0]};
+ size_t response_size =
+ 1 + response_header.normal_params_size + response_header.translate_params_size;
+ ASSERT(response_size <= IPC::COMMAND_BUFFER_LENGTH);
+ std::copy_n(context.cmd_buf.begin(), response_size, cmd_buf);
}
////////////////////////////////////////////////////////////////////////////////////////////////////