citra-emu
/
citra-canary
Archived
1
0
Fork 0

IPC: Add basic HLERequestContext support to RequestParser/Builder

This commit is contained in:
Yuri Kunde Schlesner 2017-06-08 21:30:39 -07:00
parent 05fee70211
commit 1c4b0ebb1f
1 changed files with 32 additions and 1 deletions

View File

@ -6,17 +6,22 @@
#include "core/hle/ipc.h" #include "core/hle/ipc.h"
#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/hle_ipc.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
namespace IPC { namespace IPC {
class RequestHelperBase { class RequestHelperBase {
protected: protected:
Kernel::HLERequestContext* context = nullptr;
u32* cmdbuf; u32* cmdbuf;
ptrdiff_t index = 1; ptrdiff_t index = 1;
Header header; Header header;
public: public:
RequestHelperBase(Kernel::HLERequestContext& context, Header desired_header)
: context(&context), cmdbuf(context.CommandBuffer()), header(desired_header) {}
RequestHelperBase(u32* command_buffer, Header command_header) RequestHelperBase(u32* command_buffer, Header command_header)
: cmdbuf(command_buffer), header(command_header) {} : cmdbuf(command_buffer), header(command_header) {}
@ -51,12 +56,24 @@ public:
class RequestBuilder : public RequestHelperBase { class RequestBuilder : public RequestHelperBase {
public: public:
RequestBuilder(Kernel::HLERequestContext& context, Header command_header)
: RequestHelperBase(context, command_header) {
cmdbuf[0] = header.raw;
}
RequestBuilder(Kernel::HLERequestContext& context, u16 command_id, unsigned normal_params_size,
unsigned translate_params_size)
: RequestBuilder(
context, Header{MakeHeader(command_id, normal_params_size, translate_params_size)}) {}
RequestBuilder(u32* command_buffer, Header command_header) RequestBuilder(u32* command_buffer, Header command_header)
: RequestHelperBase(command_buffer, command_header) { : RequestHelperBase(command_buffer, command_header) {
cmdbuf[0] = header.raw; cmdbuf[0] = header.raw;
} }
explicit RequestBuilder(u32* command_buffer, u32 command_header) explicit RequestBuilder(u32* command_buffer, u32 command_header)
: RequestBuilder(command_buffer, Header{command_header}) {} : RequestBuilder(command_buffer, Header{command_header}) {}
RequestBuilder(u32* command_buffer, u16 command_id, unsigned normal_params_size, RequestBuilder(u32* command_buffer, u16 command_id, unsigned normal_params_size,
unsigned translate_params_size) unsigned translate_params_size)
: RequestBuilder(command_buffer, : RequestBuilder(command_buffer,
@ -171,10 +188,21 @@ inline void RequestBuilder::PushMappedBuffer(VAddr buffer_vaddr, u32 size,
class RequestParser : public RequestHelperBase { class RequestParser : public RequestHelperBase {
public: public:
RequestParser(Kernel::HLERequestContext& context, Header desired_header)
: RequestHelperBase(context, desired_header) {}
RequestParser(Kernel::HLERequestContext& context, u16 command_id, unsigned normal_params_size,
unsigned translate_params_size)
: RequestParser(context,
Header{MakeHeader(command_id, normal_params_size, translate_params_size)}) {
}
RequestParser(u32* command_buffer, Header command_header) RequestParser(u32* command_buffer, Header command_header)
: RequestHelperBase(command_buffer, command_header) {} : RequestHelperBase(command_buffer, command_header) {}
explicit RequestParser(u32* command_buffer, u32 command_header) explicit RequestParser(u32* command_buffer, u32 command_header)
: RequestParser(command_buffer, Header{command_header}) {} : RequestParser(command_buffer, Header{command_header}) {}
RequestParser(u32* command_buffer, u16 command_id, unsigned normal_params_size, RequestParser(u32* command_buffer, u16 command_id, unsigned normal_params_size,
unsigned translate_params_size) unsigned translate_params_size)
: RequestParser(command_buffer, : RequestParser(command_buffer,
@ -186,7 +214,10 @@ public:
ValidateHeader(); ValidateHeader();
Header builderHeader{ Header builderHeader{
MakeHeader(header.command_id, normal_params_size, translate_params_size)}; MakeHeader(header.command_id, normal_params_size, translate_params_size)};
return {cmdbuf, builderHeader}; if (context != nullptr)
return {*context, builderHeader};
else
return {cmdbuf, builderHeader};
} }
template <typename T> template <typename T>