@ -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 ) ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////