diff options
Diffstat (limited to 'src/core/hle/ipc_helpers.h')
| -rw-r--r-- | src/core/hle/ipc_helpers.h | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index aa7ffd036..8a7fa25c8 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h | |||
| @@ -54,18 +54,18 @@ public: | |||
| 54 | } | 54 | } |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | class RequestBuilder : public RequestHelperBase { | 57 | class ResponseBuilder : public RequestHelperBase { |
| 58 | public: | 58 | public: |
| 59 | RequestBuilder(u32* command_buffer) : RequestHelperBase(command_buffer) {} | 59 | ResponseBuilder(u32* command_buffer) : RequestHelperBase(command_buffer) {} |
| 60 | 60 | ||
| 61 | u32 normal_params_size; | 61 | u32 normal_params_size; |
| 62 | u32 num_handles_to_copy; | 62 | u32 num_handles_to_copy; |
| 63 | u32 num_objects_to_move; ///< Domain objects or move handles, context dependent | 63 | u32 num_objects_to_move; ///< Domain objects or move handles, context dependent |
| 64 | std::ptrdiff_t datapayload_index; | 64 | std::ptrdiff_t datapayload_index; |
| 65 | 65 | ||
| 66 | RequestBuilder(Kernel::HLERequestContext& context, u32 normal_params_size, | 66 | ResponseBuilder(Kernel::HLERequestContext& context, u32 normal_params_size, |
| 67 | u32 num_handles_to_copy = 0, u32 num_objects_to_move = 0, | 67 | u32 num_handles_to_copy = 0, u32 num_objects_to_move = 0, |
| 68 | bool always_move_handle = false) | 68 | bool always_move_handles = false) |
| 69 | 69 | ||
| 70 | : RequestHelperBase(context), normal_params_size(normal_params_size), | 70 | : RequestHelperBase(context), normal_params_size(normal_params_size), |
| 71 | num_handles_to_copy(num_handles_to_copy), num_objects_to_move(num_objects_to_move) { | 71 | num_handles_to_copy(num_handles_to_copy), num_objects_to_move(num_objects_to_move) { |
| @@ -83,7 +83,7 @@ public: | |||
| 83 | u32 num_handles_to_move{}; | 83 | u32 num_handles_to_move{}; |
| 84 | u32 num_domain_objects{}; | 84 | u32 num_domain_objects{}; |
| 85 | 85 | ||
| 86 | if (!context.Session()->IsDomain() || always_move_handle) { | 86 | if (!context.Session()->IsDomain() || always_move_handles) { |
| 87 | num_handles_to_move = num_objects_to_move; | 87 | num_handles_to_move = num_objects_to_move; |
| 88 | } else { | 88 | } else { |
| 89 | num_domain_objects = num_objects_to_move; | 89 | num_domain_objects = num_objects_to_move; |
| @@ -154,7 +154,7 @@ public: | |||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | // Validate on destruction, as there shouldn't be any case where we don't want it | 156 | // Validate on destruction, as there shouldn't be any case where we don't want it |
| 157 | ~RequestBuilder() { | 157 | ~ResponseBuilder() { |
| 158 | ValidateHeader(); | 158 | ValidateHeader(); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| @@ -182,52 +182,52 @@ public: | |||
| 182 | /// Push /// | 182 | /// Push /// |
| 183 | 183 | ||
| 184 | template <> | 184 | template <> |
| 185 | inline void RequestBuilder::Push(u32 value) { | 185 | inline void ResponseBuilder::Push(u32 value) { |
| 186 | cmdbuf[index++] = value; | 186 | cmdbuf[index++] = value; |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | template <typename T> | 189 | template <typename T> |
| 190 | void RequestBuilder::PushRaw(const T& value) { | 190 | void ResponseBuilder::PushRaw(const T& value) { |
| 191 | std::memcpy(cmdbuf + index, &value, sizeof(T)); | 191 | std::memcpy(cmdbuf + index, &value, sizeof(T)); |
| 192 | index += (sizeof(T) + 3) / 4; // round up to word length | 192 | index += (sizeof(T) + 3) / 4; // round up to word length |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | template <> | 195 | template <> |
| 196 | inline void RequestBuilder::Push(ResultCode value) { | 196 | inline void ResponseBuilder::Push(ResultCode value) { |
| 197 | // Result codes are actually 64-bit in the IPC buffer, but only the high part is discarded. | 197 | // Result codes are actually 64-bit in the IPC buffer, but only the high part is discarded. |
| 198 | Push(value.raw); | 198 | Push(value.raw); |
| 199 | Push<u32>(0); | 199 | Push<u32>(0); |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | template <> | 202 | template <> |
| 203 | inline void RequestBuilder::Push(u8 value) { | 203 | inline void ResponseBuilder::Push(u8 value) { |
| 204 | PushRaw(value); | 204 | PushRaw(value); |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | template <> | 207 | template <> |
| 208 | inline void RequestBuilder::Push(u16 value) { | 208 | inline void ResponseBuilder::Push(u16 value) { |
| 209 | PushRaw(value); | 209 | PushRaw(value); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | template <> | 212 | template <> |
| 213 | inline void RequestBuilder::Push(u64 value) { | 213 | inline void ResponseBuilder::Push(u64 value) { |
| 214 | Push(static_cast<u32>(value)); | 214 | Push(static_cast<u32>(value)); |
| 215 | Push(static_cast<u32>(value >> 32)); | 215 | Push(static_cast<u32>(value >> 32)); |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | template <> | 218 | template <> |
| 219 | inline void RequestBuilder::Push(bool value) { | 219 | inline void ResponseBuilder::Push(bool value) { |
| 220 | Push(static_cast<u8>(value)); | 220 | Push(static_cast<u8>(value)); |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | template <typename First, typename... Other> | 223 | template <typename First, typename... Other> |
| 224 | void RequestBuilder::Push(const First& first_value, const Other&... other_values) { | 224 | void ResponseBuilder::Push(const First& first_value, const Other&... other_values) { |
| 225 | Push(first_value); | 225 | Push(first_value); |
| 226 | Push(other_values...); | 226 | Push(other_values...); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | template <typename... O> | 229 | template <typename... O> |
| 230 | inline void RequestBuilder::PushCopyObjects(Kernel::SharedPtr<O>... pointers) { | 230 | inline void ResponseBuilder::PushCopyObjects(Kernel::SharedPtr<O>... pointers) { |
| 231 | auto objects = {pointers...}; | 231 | auto objects = {pointers...}; |
| 232 | for (auto& object : objects) { | 232 | for (auto& object : objects) { |
| 233 | context->AddCopyObject(std::move(object)); | 233 | context->AddCopyObject(std::move(object)); |
| @@ -235,7 +235,7 @@ inline void RequestBuilder::PushCopyObjects(Kernel::SharedPtr<O>... pointers) { | |||
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | template <typename... O> | 237 | template <typename... O> |
| 238 | inline void RequestBuilder::PushMoveObjects(Kernel::SharedPtr<O>... pointers) { | 238 | inline void ResponseBuilder::PushMoveObjects(Kernel::SharedPtr<O>... pointers) { |
| 239 | auto objects = {pointers...}; | 239 | auto objects = {pointers...}; |
| 240 | for (auto& object : objects) { | 240 | for (auto& object : objects) { |
| 241 | context->AddMoveObject(std::move(object)); | 241 | context->AddMoveObject(std::move(object)); |
| @@ -254,9 +254,10 @@ public: | |||
| 254 | Skip(CommandIdSize, false); | 254 | Skip(CommandIdSize, false); |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | RequestBuilder MakeBuilder(u32 normal_params_size, u32 num_handles_to_copy, | 257 | ResponseBuilder MakeBuilder(u32 normal_params_size, u32 num_handles_to_copy, |
| 258 | u32 num_handles_to_move, bool validate_header = true) { | 258 | u32 num_handles_to_move, bool always_move_handles = false) { |
| 259 | return {*context, normal_params_size, num_handles_to_copy, num_handles_to_move}; | 259 | return {*context, normal_params_size, num_handles_to_copy, num_handles_to_move, |
| 260 | always_move_handles}; | ||
| 260 | } | 261 | } |
| 261 | 262 | ||
| 262 | template <typename T> | 263 | template <typename T> |