diff options
author | bunnei <bunneidev@gmail.com> | 2021-04-04 04:11:46 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-05-06 01:40:50 +0200 |
commit | da7e9553dea4b1eaefb71aca8642ccce7c7f50fb (patch) | |
tree | 3da10a60005ddcc4237900eb5e7473fe7b006152 /src/core/hle/kernel/slab_helpers.h | |
parent | hle: kernel: svc: Migrate GetThreadPriority, StartThread, and ExitThread. (diff) | |
download | yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.gz yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.bz2 yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.lz yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.xz yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.tar.zst yuzu-da7e9553dea4b1eaefb71aca8642ccce7c7f50fb.zip |
Diffstat (limited to 'src/core/hle/kernel/slab_helpers.h')
-rw-r--r-- | src/core/hle/kernel/slab_helpers.h | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/core/hle/kernel/slab_helpers.h b/src/core/hle/kernel/slab_helpers.h index d95095da3..ae9d097da 100644 --- a/src/core/hle/kernel/slab_helpers.h +++ b/src/core/hle/kernel/slab_helpers.h @@ -14,6 +14,7 @@ #include "core/hle/kernel/k_auto_object_container.h" #include "core/hle/kernel/k_light_lock.h" #include "core/hle/kernel/k_slab_heap.h" +#include "core/hle/kernel/kernel.h" namespace Kernel { @@ -66,13 +67,17 @@ class KAutoObjectWithSlabHeapAndContainer : public Base { private: static inline KSlabHeap<Derived> s_slab_heap; - static inline KAutoObjectWithListContainer s_container; + KernelCore& m_kernel; private: static Derived* Allocate() { return s_slab_heap.Allocate(); } + static Derived* AllocateWithKernel(KernelCore& kernel) { + return s_slab_heap.AllocateWithKernel(kernel); + } + static void Free(Derived* obj) { s_slab_heap.Free(obj); } @@ -80,19 +85,20 @@ private: public: class ListAccessor : public KAutoObjectWithListContainer::ListAccessor { public: - ListAccessor() : KAutoObjectWithListContainer::ListAccessor(s_container) {} + ListAccessor() + : KAutoObjectWithListContainer::ListAccessor(m_kernel.ObjectListContainer()) {} ~ListAccessor() = default; }; public: - constexpr KAutoObjectWithSlabHeapAndContainer() : Base() {} + KAutoObjectWithSlabHeapAndContainer(KernelCore& kernel) : Base(kernel), m_kernel(kernel) {} virtual ~KAutoObjectWithSlabHeapAndContainer() {} virtual void Destroy() override { const bool is_initialized = this->IsInitialized(); uintptr_t arg = 0; if (is_initialized) { - s_container.Unregister(this); + m_kernel.ObjectListContainer().Unregister(this); arg = this->GetPostDestroyArgument(); this->Finalize(); } @@ -114,21 +120,29 @@ public: } public: - static void InitializeSlabHeap(void* memory, size_t memory_size) { + static void InitializeSlabHeap(KernelCore& kernel, void* memory, size_t memory_size) { s_slab_heap.Initialize(memory, memory_size); - s_container.Initialize(); + kernel.ObjectListContainer().Initialize(); } static Derived* Create() { Derived* obj = Allocate(); - if (AMS_LIKELY(obj != nullptr)) { + if (obj != nullptr) { + KAutoObject::Create(obj); + } + return obj; + } + + static Derived* CreateWithKernel(KernelCore& kernel) { + Derived* obj = AllocateWithKernel(kernel); + if (obj != nullptr) { KAutoObject::Create(obj); } return obj; } - static void Register(Derived* obj) { - return s_container.Register(obj); + static void Register(KernelCore& kernel, Derived* obj) { + return kernel.ObjectListContainer().Register(obj); } static size_t GetObjectSize() { |