summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar bunnei2022-11-25 00:38:17 -0800
committerGravatar GitHub2022-11-25 00:38:17 -0800
commit64965cc658a6266ddb9878ffd53bd69e0a0f5b79 (patch)
tree495b63ec25d2b5e8d5888004e5bca0dcdf67704b /src/core/hle/kernel
parentMerge pull request #9194 from FernandoS27/yfc-fermi2d (diff)
parentservice: Make use of buffer element count helpers (diff)
downloadyuzu-64965cc658a6266ddb9878ffd53bd69e0a0f5b79.tar.gz
yuzu-64965cc658a6266ddb9878ffd53bd69e0a0f5b79.tar.xz
yuzu-64965cc658a6266ddb9878ffd53bd69e0a0f5b79.zip
Merge pull request #9305 from lioncash/request
hle_ipc: Add helper function for determining element counts
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/hle_ipc.h62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index d87be72d6..e252b5f4b 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -199,7 +199,7 @@ public:
199 ~HLERequestContext(); 199 ~HLERequestContext();
200 200
201 /// Returns a pointer to the IPC command buffer for this request. 201 /// Returns a pointer to the IPC command buffer for this request.
202 u32* CommandBuffer() { 202 [[nodiscard]] u32* CommandBuffer() {
203 return cmd_buf.data(); 203 return cmd_buf.data();
204 } 204 }
205 205
@@ -207,7 +207,7 @@ public:
207 * Returns the session through which this request was made. This can be used as a map key to 207 * Returns the session through which this request was made. This can be used as a map key to
208 * access per-client data on services. 208 * access per-client data on services.
209 */ 209 */
210 Kernel::KServerSession* Session() { 210 [[nodiscard]] Kernel::KServerSession* Session() {
211 return server_session; 211 return server_session;
212 } 212 }
213 213
@@ -217,61 +217,61 @@ public:
217 /// Writes data from this context back to the requesting process/thread. 217 /// Writes data from this context back to the requesting process/thread.
218 Result WriteToOutgoingCommandBuffer(KThread& requesting_thread); 218 Result WriteToOutgoingCommandBuffer(KThread& requesting_thread);
219 219
220 u32_le GetHipcCommand() const { 220 [[nodiscard]] u32_le GetHipcCommand() const {
221 return command; 221 return command;
222 } 222 }
223 223
224 u32_le GetTipcCommand() const { 224 [[nodiscard]] u32_le GetTipcCommand() const {
225 return static_cast<u32_le>(command_header->type.Value()) - 225 return static_cast<u32_le>(command_header->type.Value()) -
226 static_cast<u32_le>(IPC::CommandType::TIPC_CommandRegion); 226 static_cast<u32_le>(IPC::CommandType::TIPC_CommandRegion);
227 } 227 }
228 228
229 u32_le GetCommand() const { 229 [[nodiscard]] u32_le GetCommand() const {
230 return command_header->IsTipc() ? GetTipcCommand() : GetHipcCommand(); 230 return command_header->IsTipc() ? GetTipcCommand() : GetHipcCommand();
231 } 231 }
232 232
233 bool IsTipc() const { 233 [[nodiscard]] bool IsTipc() const {
234 return command_header->IsTipc(); 234 return command_header->IsTipc();
235 } 235 }
236 236
237 IPC::CommandType GetCommandType() const { 237 [[nodiscard]] IPC::CommandType GetCommandType() const {
238 return command_header->type; 238 return command_header->type;
239 } 239 }
240 240
241 u64 GetPID() const { 241 [[nodiscard]] u64 GetPID() const {
242 return pid; 242 return pid;
243 } 243 }
244 244
245 u32 GetDataPayloadOffset() const { 245 [[nodiscard]] u32 GetDataPayloadOffset() const {
246 return data_payload_offset; 246 return data_payload_offset;
247 } 247 }
248 248
249 const std::vector<IPC::BufferDescriptorX>& BufferDescriptorX() const { 249 [[nodiscard]] const std::vector<IPC::BufferDescriptorX>& BufferDescriptorX() const {
250 return buffer_x_desciptors; 250 return buffer_x_desciptors;
251 } 251 }
252 252
253 const std::vector<IPC::BufferDescriptorABW>& BufferDescriptorA() const { 253 [[nodiscard]] const std::vector<IPC::BufferDescriptorABW>& BufferDescriptorA() const {
254 return buffer_a_desciptors; 254 return buffer_a_desciptors;
255 } 255 }
256 256
257 const std::vector<IPC::BufferDescriptorABW>& BufferDescriptorB() const { 257 [[nodiscard]] const std::vector<IPC::BufferDescriptorABW>& BufferDescriptorB() const {
258 return buffer_b_desciptors; 258 return buffer_b_desciptors;
259 } 259 }
260 260
261 const std::vector<IPC::BufferDescriptorC>& BufferDescriptorC() const { 261 [[nodiscard]] const std::vector<IPC::BufferDescriptorC>& BufferDescriptorC() const {
262 return buffer_c_desciptors; 262 return buffer_c_desciptors;
263 } 263 }
264 264
265 const IPC::DomainMessageHeader& GetDomainMessageHeader() const { 265 [[nodiscard]] const IPC::DomainMessageHeader& GetDomainMessageHeader() const {
266 return domain_message_header.value(); 266 return domain_message_header.value();
267 } 267 }
268 268
269 bool HasDomainMessageHeader() const { 269 [[nodiscard]] bool HasDomainMessageHeader() const {
270 return domain_message_header.has_value(); 270 return domain_message_header.has_value();
271 } 271 }
272 272
273 /// Helper function to read a buffer using the appropriate buffer descriptor 273 /// Helper function to read a buffer using the appropriate buffer descriptor
274 std::vector<u8> ReadBuffer(std::size_t buffer_index = 0) const; 274 [[nodiscard]] std::vector<u8> ReadBuffer(std::size_t buffer_index = 0) const;
275 275
276 /// Helper function to write a buffer using the appropriate buffer descriptor 276 /// Helper function to write a buffer using the appropriate buffer descriptor
277 std::size_t WriteBuffer(const void* buffer, std::size_t size, 277 std::size_t WriteBuffer(const void* buffer, std::size_t size,
@@ -308,22 +308,34 @@ public:
308 } 308 }
309 309
310 /// Helper function to get the size of the input buffer 310 /// Helper function to get the size of the input buffer
311 std::size_t GetReadBufferSize(std::size_t buffer_index = 0) const; 311 [[nodiscard]] std::size_t GetReadBufferSize(std::size_t buffer_index = 0) const;
312 312
313 /// Helper function to get the size of the output buffer 313 /// Helper function to get the size of the output buffer
314 std::size_t GetWriteBufferSize(std::size_t buffer_index = 0) const; 314 [[nodiscard]] std::size_t GetWriteBufferSize(std::size_t buffer_index = 0) const;
315
316 /// Helper function to derive the number of elements able to be contained in the read buffer
317 template <typename T>
318 [[nodiscard]] std::size_t GetReadBufferNumElements(std::size_t buffer_index = 0) const {
319 return GetReadBufferSize(buffer_index) / sizeof(T);
320 }
321
322 /// Helper function to derive the number of elements able to be contained in the write buffer
323 template <typename T>
324 [[nodiscard]] std::size_t GetWriteBufferNumElements(std::size_t buffer_index = 0) const {
325 return GetWriteBufferSize(buffer_index) / sizeof(T);
326 }
315 327
316 /// Helper function to test whether the input buffer at buffer_index can be read 328 /// Helper function to test whether the input buffer at buffer_index can be read
317 bool CanReadBuffer(std::size_t buffer_index = 0) const; 329 [[nodiscard]] bool CanReadBuffer(std::size_t buffer_index = 0) const;
318 330
319 /// Helper function to test whether the output buffer at buffer_index can be written 331 /// Helper function to test whether the output buffer at buffer_index can be written
320 bool CanWriteBuffer(std::size_t buffer_index = 0) const; 332 [[nodiscard]] bool CanWriteBuffer(std::size_t buffer_index = 0) const;
321 333
322 Handle GetCopyHandle(std::size_t index) const { 334 [[nodiscard]] Handle GetCopyHandle(std::size_t index) const {
323 return incoming_copy_handles.at(index); 335 return incoming_copy_handles.at(index);
324 } 336 }
325 337
326 Handle GetMoveHandle(std::size_t index) const { 338 [[nodiscard]] Handle GetMoveHandle(std::size_t index) const {
327 return incoming_move_handles.at(index); 339 return incoming_move_handles.at(index);
328 } 340 }
329 341
@@ -348,13 +360,13 @@ public:
348 manager = manager_; 360 manager = manager_;
349 } 361 }
350 362
351 std::string Description() const; 363 [[nodiscard]] std::string Description() const;
352 364
353 KThread& GetThread() { 365 [[nodiscard]] KThread& GetThread() {
354 return *thread; 366 return *thread;
355 } 367 }
356 368
357 std::shared_ptr<SessionRequestManager> GetManager() const { 369 [[nodiscard]] std::shared_ptr<SessionRequestManager> GetManager() const {
358 return manager.lock(); 370 return manager.lock();
359 } 371 }
360 372