diff options
| author | 2021-05-08 02:21:50 -0700 | |
|---|---|---|
| committer | 2021-05-10 15:05:10 -0700 | |
| commit | d08bd3e062e629e34afa4e4947cfb6c28377e12f (patch) | |
| tree | ff3593e6e79c253eea3fac6c0cfaa4b9d05e5131 /src | |
| parent | Merge pull request #6291 from lioncash/kern-shadow (diff) | |
| download | yuzu-d08bd3e062e629e34afa4e4947cfb6c28377e12f.tar.gz yuzu-d08bd3e062e629e34afa4e4947cfb6c28377e12f.tar.xz yuzu-d08bd3e062e629e34afa4e4947cfb6c28377e12f.zip | |
hle: ipc_helpers: Update IPC response generation for TIPC.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/ipc_helpers.h | 48 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 10 |
2 files changed, 39 insertions, 19 deletions
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index d136be452..d1eb8b075 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h | |||
| @@ -26,7 +26,7 @@ class RequestHelperBase { | |||
| 26 | protected: | 26 | protected: |
| 27 | Kernel::HLERequestContext* context = nullptr; | 27 | Kernel::HLERequestContext* context = nullptr; |
| 28 | u32* cmdbuf; | 28 | u32* cmdbuf; |
| 29 | ptrdiff_t index = 0; | 29 | u32 index = 0; |
| 30 | 30 | ||
| 31 | public: | 31 | public: |
| 32 | explicit RequestHelperBase(u32* command_buffer) : cmdbuf(command_buffer) {} | 32 | explicit RequestHelperBase(u32* command_buffer) : cmdbuf(command_buffer) {} |
| @@ -38,7 +38,7 @@ public: | |||
| 38 | if (set_to_null) { | 38 | if (set_to_null) { |
| 39 | memset(cmdbuf + index, 0, size_in_words * sizeof(u32)); | 39 | memset(cmdbuf + index, 0, size_in_words * sizeof(u32)); |
| 40 | } | 40 | } |
| 41 | index += static_cast<ptrdiff_t>(size_in_words); | 41 | index += size_in_words; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| @@ -51,11 +51,11 @@ public: | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | u32 GetCurrentOffset() const { | 53 | u32 GetCurrentOffset() const { |
| 54 | return static_cast<u32>(index); | 54 | return index; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | void SetCurrentOffset(u32 offset) { | 57 | void SetCurrentOffset(u32 offset) { |
| 58 | index = static_cast<ptrdiff_t>(offset); | 58 | index = offset; |
| 59 | } | 59 | } |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| @@ -84,7 +84,9 @@ public: | |||
| 84 | 84 | ||
| 85 | // The entire size of the raw data section in u32 units, including the 16 bytes of mandatory | 85 | // The entire size of the raw data section in u32 units, including the 16 bytes of mandatory |
| 86 | // padding. | 86 | // padding. |
| 87 | u64 raw_data_size = sizeof(IPC::DataPayloadHeader) / 4 + 4 + normal_params_size; | 87 | u32 raw_data_size = ctx.IsTipc() |
| 88 | ? normal_params_size - 1 | ||
| 89 | : sizeof(IPC::DataPayloadHeader) / 4 + 4 + normal_params_size; | ||
| 88 | 90 | ||
| 89 | u32 num_handles_to_move{}; | 91 | u32 num_handles_to_move{}; |
| 90 | u32 num_domain_objects{}; | 92 | u32 num_domain_objects{}; |
| @@ -100,6 +102,10 @@ public: | |||
| 100 | raw_data_size += sizeof(DomainMessageHeader) / 4 + num_domain_objects; | 102 | raw_data_size += sizeof(DomainMessageHeader) / 4 + num_domain_objects; |
| 101 | } | 103 | } |
| 102 | 104 | ||
| 105 | if (ctx.IsTipc()) { | ||
| 106 | header.type.Assign(ctx.GetCommandType()); | ||
| 107 | } | ||
| 108 | |||
| 103 | header.data_size.Assign(static_cast<u32>(raw_data_size)); | 109 | header.data_size.Assign(static_cast<u32>(raw_data_size)); |
| 104 | if (num_handles_to_copy || num_handles_to_move) { | 110 | if (num_handles_to_copy || num_handles_to_move) { |
| 105 | header.enable_handle_descriptor.Assign(1); | 111 | header.enable_handle_descriptor.Assign(1); |
| @@ -111,22 +117,30 @@ public: | |||
| 111 | handle_descriptor_header.num_handles_to_copy.Assign(num_handles_to_copy); | 117 | handle_descriptor_header.num_handles_to_copy.Assign(num_handles_to_copy); |
| 112 | handle_descriptor_header.num_handles_to_move.Assign(num_handles_to_move); | 118 | handle_descriptor_header.num_handles_to_move.Assign(num_handles_to_move); |
| 113 | PushRaw(handle_descriptor_header); | 119 | PushRaw(handle_descriptor_header); |
| 120 | |||
| 121 | ctx.handles_offset = index; | ||
| 122 | |||
| 114 | Skip(num_handles_to_copy + num_handles_to_move, true); | 123 | Skip(num_handles_to_copy + num_handles_to_move, true); |
| 115 | } | 124 | } |
| 116 | 125 | ||
| 117 | AlignWithPadding(); | 126 | if (!ctx.IsTipc()) { |
| 127 | AlignWithPadding(); | ||
| 128 | |||
| 129 | if (ctx.Session()->IsDomain() && ctx.HasDomainMessageHeader()) { | ||
| 130 | IPC::DomainMessageHeader domain_header{}; | ||
| 131 | domain_header.num_objects = num_domain_objects; | ||
| 132 | PushRaw(domain_header); | ||
| 133 | } | ||
| 118 | 134 | ||
| 119 | if (ctx.Session()->IsDomain() && ctx.HasDomainMessageHeader()) { | 135 | IPC::DataPayloadHeader data_payload_header{}; |
| 120 | IPC::DomainMessageHeader domain_header{}; | 136 | data_payload_header.magic = Common::MakeMagic('S', 'F', 'C', 'O'); |
| 121 | domain_header.num_objects = num_domain_objects; | 137 | PushRaw(data_payload_header); |
| 122 | PushRaw(domain_header); | ||
| 123 | } | 138 | } |
| 124 | 139 | ||
| 125 | IPC::DataPayloadHeader data_payload_header{}; | 140 | data_payload_index = index; |
| 126 | data_payload_header.magic = Common::MakeMagic('S', 'F', 'C', 'O'); | ||
| 127 | PushRaw(data_payload_header); | ||
| 128 | 141 | ||
| 129 | datapayload_index = index; | 142 | ctx.data_payload_offset = index; |
| 143 | ctx.domain_offset = index + raw_data_size / 4; | ||
| 130 | } | 144 | } |
| 131 | 145 | ||
| 132 | template <class T> | 146 | template <class T> |
| @@ -152,7 +166,7 @@ public: | |||
| 152 | const std::size_t num_move_objects = context->NumMoveObjects(); | 166 | const std::size_t num_move_objects = context->NumMoveObjects(); |
| 153 | ASSERT_MSG(!num_domain_objects || !num_move_objects, | 167 | ASSERT_MSG(!num_domain_objects || !num_move_objects, |
| 154 | "cannot move normal handles and domain objects"); | 168 | "cannot move normal handles and domain objects"); |
| 155 | ASSERT_MSG((index - datapayload_index) == normal_params_size, | 169 | ASSERT_MSG((index - data_payload_index) == normal_params_size, |
| 156 | "normal_params_size value is incorrect"); | 170 | "normal_params_size value is incorrect"); |
| 157 | ASSERT_MSG((num_domain_objects + num_move_objects) == num_objects_to_move, | 171 | ASSERT_MSG((num_domain_objects + num_move_objects) == num_objects_to_move, |
| 158 | "num_objects_to_move value is incorrect"); | 172 | "num_objects_to_move value is incorrect"); |
| @@ -229,14 +243,14 @@ private: | |||
| 229 | u32 normal_params_size{}; | 243 | u32 normal_params_size{}; |
| 230 | u32 num_handles_to_copy{}; | 244 | u32 num_handles_to_copy{}; |
| 231 | u32 num_objects_to_move{}; ///< Domain objects or move handles, context dependent | 245 | u32 num_objects_to_move{}; ///< Domain objects or move handles, context dependent |
| 232 | std::ptrdiff_t datapayload_index{}; | 246 | u32 data_payload_index{}; |
| 233 | Kernel::KernelCore& kernel; | 247 | Kernel::KernelCore& kernel; |
| 234 | }; | 248 | }; |
| 235 | 249 | ||
| 236 | /// Push /// | 250 | /// Push /// |
| 237 | 251 | ||
| 238 | inline void ResponseBuilder::PushImpl(s32 value) { | 252 | inline void ResponseBuilder::PushImpl(s32 value) { |
| 239 | cmdbuf[index++] = static_cast<u32>(value); | 253 | cmdbuf[index++] = value; |
| 240 | } | 254 | } |
| 241 | 255 | ||
| 242 | inline void ResponseBuilder::PushImpl(u32 value) { | 256 | inline void ResponseBuilder::PushImpl(u32 value) { |
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 21e384706..7cdde2294 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -132,6 +132,10 @@ public: | |||
| 132 | return command; | 132 | return command; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | bool IsTipc() const { | ||
| 136 | return command_header->IsTipc(); | ||
| 137 | } | ||
| 138 | |||
| 135 | IPC::CommandType GetCommandType() const { | 139 | IPC::CommandType GetCommandType() const { |
| 136 | return command_header->type; | 140 | return command_header->type; |
| 137 | } | 141 | } |
| @@ -291,8 +295,10 @@ private: | |||
| 291 | std::vector<IPC::BufferDescriptorABW> buffer_w_desciptors; | 295 | std::vector<IPC::BufferDescriptorABW> buffer_w_desciptors; |
| 292 | std::vector<IPC::BufferDescriptorC> buffer_c_desciptors; | 296 | std::vector<IPC::BufferDescriptorC> buffer_c_desciptors; |
| 293 | 297 | ||
| 294 | unsigned data_payload_offset{}; | 298 | u32 data_payload_offset{}; |
| 295 | unsigned buffer_c_offset{}; | 299 | u32 buffer_c_offset{}; |
| 300 | u32 handles_offset{}; | ||
| 301 | u32 domain_offset{}; | ||
| 296 | u32_le command{}; | 302 | u32_le command{}; |
| 297 | 303 | ||
| 298 | std::vector<std::shared_ptr<SessionRequestHandler>> domain_request_handlers; | 304 | std::vector<std::shared_ptr<SessionRequestHandler>> domain_request_handlers; |