summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-07-05 16:22:03 +0200
committerbunnei <bunneidev@gmail.com>2014-07-05 16:24:54 +0200
commit7ff92c36ed70e75a54d8a15a7806ab9be34b3168 (patch)
treefe2d322dc00edc55786956e5c94588205ae332b6 /src/core/hle/kernel
parentMemory: Removed deprecated MapBlock_Shared function. (diff)
downloadyuzu-7ff92c36ed70e75a54d8a15a7806ab9be34b3168.tar
yuzu-7ff92c36ed70e75a54d8a15a7806ab9be34b3168.tar.gz
yuzu-7ff92c36ed70e75a54d8a15a7806ab9be34b3168.tar.bz2
yuzu-7ff92c36ed70e75a54d8a15a7806ab9be34b3168.tar.lz
yuzu-7ff92c36ed70e75a54d8a15a7806ab9be34b3168.tar.xz
yuzu-7ff92c36ed70e75a54d8a15a7806ab9be34b3168.tar.zst
yuzu-7ff92c36ed70e75a54d8a15a7806ab9be34b3168.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/shared_memory.cpp21
-rw-r--r--src/core/hle/kernel/shared_memory.h12
2 files changed, 27 insertions, 6 deletions
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 3030d66fa..52823048f 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -27,10 +27,10 @@ public:
return 0;
}
- u32 base_address; ///< Address of shared memory block in RAM
- u32 permissions; ///< Permissions of shared memory block (specified by SVC field)
- u32 other_permissions; ///< Other permissions of shared memory block (specified by SVC field)
- std::string name; ///< Name of shared memory object (optional)
+ u32 base_address; ///< Address of shared memory block in RAM
+ MemoryPermission permissions; ///< Permissions of shared memory block (SVC field)
+ MemoryPermission other_permissions; ///< Other permissions of shared memory block (SVC field)
+ std::string name; ///< Name of shared memory object (optional)
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -67,11 +67,21 @@ Handle CreateSharedMemory(const std::string& name) {
* @param other_permissions Memory block map other permissions (specified by SVC field)
* @return Result of operation, 0 on success, otherwise error code
*/
-Result MapSharedMemory(u32 handle, u32 address, u32 permissions, u32 other_permissions) {
+Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions,
+ MemoryPermission other_permissions) {
+
+ if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) {
+ ERROR_LOG(KERNEL, "cannot map handle=0x%08X, address=0x%08X outside of shared mem bounds!",
+ handle);
+ return -1;
+ }
SharedMemory* shared_memory = Kernel::g_object_pool.GetFast<SharedMemory>(handle);
+ _assert_msg_(KERNEL, (shared_memory != nullptr), "handle 0x%08X is not valid!", handle);
+
shared_memory->base_address = address;
shared_memory->permissions = permissions;
shared_memory->other_permissions = other_permissions;
+
return 0;
}
@@ -84,6 +94,7 @@ Result MapSharedMemory(u32 handle, u32 address, u32 permissions, u32 other_permi
u8* GetSharedMemoryPointer(Handle handle, u32 offset) {
SharedMemory* shared_memory = Kernel::g_object_pool.GetFast<SharedMemory>(handle);
_assert_msg_(KERNEL, (shared_memory != nullptr), "handle 0x%08X is not valid!", handle);
+
if (0 != shared_memory->base_address)
return Memory::GetPointer(shared_memory->base_address + offset);
diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h
index 4e235f605..5312b8854 100644
--- a/src/core/hle/kernel/shared_memory.h
+++ b/src/core/hle/kernel/shared_memory.h
@@ -10,6 +10,15 @@
namespace Kernel {
+/// Permissions for mapped shared memory blocks
+enum class MemoryPermission : u32 {
+ None = 0,
+ Read = (1u << 0),
+ Write = (1u << 1),
+ ReadWrite = (Read | Write),
+ DontCare = (1u << 28)
+};
+
/**
* Creates a shared memory object
* @param name Optional name of shared memory object
@@ -25,7 +34,8 @@ Handle CreateSharedMemory(const std::string& name="Unknown");
* @param other_permissions Memory block map other permissions (specified by SVC field)
* @return Result of operation, 0 on success, otherwise error code
*/
-Result MapSharedMemory(u32 handle, u32 address, u32 permissions, u32 other_permissions);
+Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions,
+ MemoryPermission other_permissions);
/**
* Gets a pointer to the shared memory block