summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-02-14 06:14:17 +0100
committerbunnei <bunneidev@gmail.com>2018-02-14 06:14:17 +0100
commit6fd19f05f1eba884a20e79ee43fce1af388204d4 (patch)
treebbda0c9e467045c4bef0fc576846339d43ebe26a /src
parentservice: Remove remaining uses of BufferDescriptor*. (diff)
downloadyuzu-6fd19f05f1eba884a20e79ee43fce1af388204d4.tar
yuzu-6fd19f05f1eba884a20e79ee43fce1af388204d4.tar.gz
yuzu-6fd19f05f1eba884a20e79ee43fce1af388204d4.tar.bz2
yuzu-6fd19f05f1eba884a20e79ee43fce1af388204d4.tar.lz
yuzu-6fd19f05f1eba884a20e79ee43fce1af388204d4.tar.xz
yuzu-6fd19f05f1eba884a20e79ee43fce1af388204d4.tar.zst
yuzu-6fd19f05f1eba884a20e79ee43fce1af388204d4.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp7
-rw-r--r--src/core/hle/kernel/hle_ipc.h3
2 files changed, 10 insertions, 0 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 0a9986c18..d592f502d 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -229,6 +229,8 @@ std::vector<u8> HLERequestContext::ReadBuffer() const {
size_t HLERequestContext::WriteBuffer(const void* buffer, const size_t size) const {
const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
+ ASSERT_MSG(size <= GetWriteBufferSize(), "Size %d is too big", size);
+
if (is_buffer_b) {
Memory::WriteBlock(BufferDescriptorB()[0].Address(), buffer, size);
} else {
@@ -242,6 +244,11 @@ size_t HLERequestContext::WriteBuffer(const std::vector<u8>& buffer) const {
return WriteBuffer(buffer.data(), buffer.size());
}
+size_t HLERequestContext::GetReadBufferSize() const {
+ const bool is_buffer_a{BufferDescriptorA().size() && BufferDescriptorA()[0].Size()};
+ return is_buffer_a ? BufferDescriptorA()[0].Size() : BufferDescriptorX()[0].Size();
+}
+
size_t HLERequestContext::GetWriteBufferSize() const {
const bool is_buffer_b{BufferDescriptorB().size() && BufferDescriptorB()[0].Size()};
return is_buffer_b ? BufferDescriptorB()[0].Size() : BufferDescriptorC()[0].Size();
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index 0cc270909..5b1eae74a 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -152,6 +152,9 @@ public:
/// Helper function to write a buffer using the appropriate buffer descriptor
size_t WriteBuffer(const std::vector<u8>& buffer) const;
+ /// Helper function to get the size of the input buffer
+ size_t GetReadBufferSize() const;
+
/// Helper function to get the size of the output buffer
size_t GetWriteBufferSize() const;