diff options
author | bunnei <bunneidev@gmail.com> | 2020-04-23 17:37:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-23 17:37:12 +0200 |
commit | ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c (patch) | |
tree | f3108877d77c64d4456b7ad27d500aa1e82da33d /src/core/hle/kernel/memory/memory_block.h | |
parent | Merge pull request #3730 from lioncash/time (diff) | |
download | yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.gz yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.bz2 yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.lz yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.xz yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.tar.zst yuzu-ff0c49e1cee3c1dc21d56f6ca73963da5ceec80c.zip |
Diffstat (limited to 'src/core/hle/kernel/memory/memory_block.h')
-rw-r--r-- | src/core/hle/kernel/memory/memory_block.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/core/hle/kernel/memory/memory_block.h b/src/core/hle/kernel/memory/memory_block.h index e11043b60..9db1f7b39 100644 --- a/src/core/hle/kernel/memory/memory_block.h +++ b/src/core/hle/kernel/memory/memory_block.h @@ -17,7 +17,7 @@ namespace Kernel::Memory { enum class MemoryState : u32 { None = 0, - Mask = 0xFFFFFFFF, // TODO(bunnei): This should probable be 0xFF + Mask = 0xFF, All = ~None, FlagCanReprotect = (1 << 8), @@ -253,6 +253,23 @@ public: }; } + void ShareToDevice(MemoryPermission /*new_perm*/) { + ASSERT((attribute & MemoryAttribute::DeviceShared) == MemoryAttribute::DeviceShared || + device_use_count == 0); + attribute |= MemoryAttribute::DeviceShared; + const u16 new_use_count{++device_use_count}; + ASSERT(new_use_count > 0); + } + + void UnshareToDevice(MemoryPermission /*new_perm*/) { + ASSERT((attribute & MemoryAttribute::DeviceShared) == MemoryAttribute::DeviceShared); + const u16 prev_use_count{device_use_count--}; + ASSERT(prev_use_count > 0); + if (prev_use_count == 1) { + attribute &= ~MemoryAttribute::DeviceShared; + } + } + private: constexpr bool HasProperties(MemoryState s, MemoryPermission p, MemoryAttribute a) const { constexpr MemoryAttribute AttributeIgnoreMask{MemoryAttribute::DontCareMask | @@ -287,9 +304,9 @@ private: state = new_state; perm = new_perm; - // TODO(bunnei): Is this right? attribute = static_cast<MemoryAttribute>( - new_attribute /*| (attribute & (MemoryAttribute::IpcLocked | MemoryAttribute::DeviceShared))*/); + new_attribute | + (attribute & (MemoryAttribute::IpcLocked | MemoryAttribute::DeviceShared))); } constexpr MemoryBlock Split(VAddr split_addr) { |