diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.cpp | 19 | ||||
| -rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 3 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 738b6d0f1..549fd8aea 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp | |||
| @@ -345,6 +345,25 @@ std::vector<u8> HLERequestContext::ReadBuffer(std::size_t buffer_index) const { | |||
| 345 | } | 345 | } |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | std::span<const u8> HLERequestContext::ReadBufferSpan(std::size_t buffer_index) const { | ||
| 349 | LOG_CRITICAL(Debug, "called"); | ||
| 350 | const bool is_buffer_a{BufferDescriptorA().size() > buffer_index && | ||
| 351 | BufferDescriptorA()[buffer_index].Size()}; | ||
| 352 | if (is_buffer_a) { | ||
| 353 | ASSERT_OR_EXECUTE_MSG( | ||
| 354 | BufferDescriptorA().size() > buffer_index, { return {}; }, | ||
| 355 | "BufferDescriptorA invalid buffer_index {}", buffer_index); | ||
| 356 | const u8* const mem_ptr = memory.GetPointer(BufferDescriptorA()[buffer_index].Address()); | ||
| 357 | return std::span<const u8>(mem_ptr, BufferDescriptorA()[buffer_index].Size()); | ||
| 358 | } else { | ||
| 359 | ASSERT_OR_EXECUTE_MSG( | ||
| 360 | BufferDescriptorX().size() > buffer_index, { return {}; }, | ||
| 361 | "BufferDescriptorX invalid buffer_index {}", buffer_index); | ||
| 362 | const u8* const mem_ptr = memory.GetPointer(BufferDescriptorX()[buffer_index].Address()); | ||
| 363 | return std::span<const u8>(mem_ptr, BufferDescriptorX()[buffer_index].Size()); | ||
| 364 | } | ||
| 365 | } | ||
| 366 | |||
| 348 | std::size_t HLERequestContext::WriteBuffer(const void* buffer, std::size_t size, | 367 | std::size_t HLERequestContext::WriteBuffer(const void* buffer, std::size_t size, |
| 349 | std::size_t buffer_index) const { | 368 | std::size_t buffer_index) const { |
| 350 | if (size == 0) { | 369 | if (size == 0) { |
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index e252b5f4b..2242ff922 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <functional> | 7 | #include <functional> |
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <optional> | 9 | #include <optional> |
| 10 | #include <span> | ||
| 10 | #include <string> | 11 | #include <string> |
| 11 | #include <type_traits> | 12 | #include <type_traits> |
| 12 | #include <vector> | 13 | #include <vector> |
| @@ -273,6 +274,8 @@ public: | |||
| 273 | /// Helper function to read a buffer using the appropriate buffer descriptor | 274 | /// Helper function to read a buffer using the appropriate buffer descriptor |
| 274 | [[nodiscard]] std::vector<u8> ReadBuffer(std::size_t buffer_index = 0) const; | 275 | [[nodiscard]] std::vector<u8> ReadBuffer(std::size_t buffer_index = 0) const; |
| 275 | 276 | ||
| 277 | [[nodiscard]] std::span<const u8> ReadBufferSpan(std::size_t buffer_index = 0) const; | ||
| 278 | |||
| 276 | /// Helper function to write a buffer using the appropriate buffer descriptor | 279 | /// Helper function to write a buffer using the appropriate buffer descriptor |
| 277 | std::size_t WriteBuffer(const void* buffer, std::size_t size, | 280 | std::size_t WriteBuffer(const void* buffer, std::size_t size, |
| 278 | std::size_t buffer_index = 0) const; | 281 | std::size_t buffer_index = 0) const; |