mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-15 10:50:06 +00:00
hle: kernel: Migrate SlabHeap to KSlabHeap.
This commit is contained in:
parent
1d162f28d1
commit
9e520e8f12
@ -181,6 +181,7 @@ add_library(core STATIC
|
||||
hle/kernel/k_scoped_scheduler_lock_and_sleep.h
|
||||
hle/kernel/k_shared_memory.cpp
|
||||
hle/kernel/k_shared_memory.h
|
||||
hle/kernel/k_slab_heap.h
|
||||
hle/kernel/k_spin_lock.cpp
|
||||
hle/kernel/k_spin_lock.h
|
||||
hle/kernel/k_synchronization_object.cpp
|
||||
@ -205,7 +206,6 @@ add_library(core STATIC
|
||||
hle/kernel/memory/page_heap.h
|
||||
hle/kernel/memory/page_table.cpp
|
||||
hle/kernel/memory/page_table.h
|
||||
hle/kernel/memory/slab_heap.h
|
||||
hle/kernel/object.cpp
|
||||
hle/kernel/object.h
|
||||
hle/kernel/physical_core.cpp
|
||||
|
@ -2,9 +2,6 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
// This file references various implementation details from Atmosphere, an open-source firmware for
|
||||
// the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
@ -12,17 +9,17 @@
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Kernel::Memory {
|
||||
namespace Kernel {
|
||||
|
||||
namespace impl {
|
||||
|
||||
class SlabHeapImpl final : NonCopyable {
|
||||
class KSlabHeapImpl final : NonCopyable {
|
||||
public:
|
||||
struct Node {
|
||||
Node* next{};
|
||||
};
|
||||
|
||||
constexpr SlabHeapImpl() = default;
|
||||
constexpr KSlabHeapImpl() = default;
|
||||
|
||||
void Initialize(std::size_t size) {
|
||||
ASSERT(head == nullptr);
|
||||
@ -65,9 +62,9 @@ private:
|
||||
|
||||
} // namespace impl
|
||||
|
||||
class SlabHeapBase : NonCopyable {
|
||||
class KSlabHeapBase : NonCopyable {
|
||||
public:
|
||||
constexpr SlabHeapBase() = default;
|
||||
constexpr KSlabHeapBase() = default;
|
||||
|
||||
constexpr bool Contains(uintptr_t addr) const {
|
||||
return start <= addr && addr < end;
|
||||
@ -126,7 +123,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
using Impl = impl::SlabHeapImpl;
|
||||
using Impl = impl::KSlabHeapImpl;
|
||||
|
||||
Impl impl;
|
||||
uintptr_t peak{};
|
||||
@ -135,9 +132,9 @@ private:
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class SlabHeap final : public SlabHeapBase {
|
||||
class KSlabHeap final : public KSlabHeapBase {
|
||||
public:
|
||||
constexpr SlabHeap() : SlabHeapBase() {}
|
||||
constexpr KSlabHeap() : KSlabHeapBase() {}
|
||||
|
||||
void Initialize(void* memory, std::size_t memory_size) {
|
||||
InitializeImpl(sizeof(T), memory, memory_size);
|
||||
@ -160,4 +157,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Kernel::Memory
|
||||
} // namespace Kernel
|
@ -31,10 +31,10 @@
|
||||
#include "core/hle/kernel/k_resource_limit.h"
|
||||
#include "core/hle/kernel/k_scheduler.h"
|
||||
#include "core/hle/kernel/k_shared_memory.h"
|
||||
#include "core/hle/kernel/k_slab_heap.h"
|
||||
#include "core/hle/kernel/k_thread.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/kernel/memory/memory_manager.h"
|
||||
#include "core/hle/kernel/memory/slab_heap.h"
|
||||
#include "core/hle/kernel/physical_core.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/kernel/service_thread.h"
|
||||
@ -306,7 +306,7 @@ struct KernelCore::Impl {
|
||||
Memory::MemoryPermission::Read, time_addr, time_size, "Time:SharedMemory");
|
||||
|
||||
// Allocate slab heaps
|
||||
user_slab_heap_pages = std::make_unique<Memory::SlabHeap<Memory::Page>>();
|
||||
user_slab_heap_pages = std::make_unique<KSlabHeap<Memory::Page>>();
|
||||
|
||||
constexpr u64 user_slab_heap_size{0x1ef000};
|
||||
// Reserve slab heaps
|
||||
@ -349,7 +349,7 @@ struct KernelCore::Impl {
|
||||
|
||||
// Kernel memory management
|
||||
std::unique_ptr<Memory::MemoryManager> memory_manager;
|
||||
std::unique_ptr<Memory::SlabHeap<Memory::Page>> user_slab_heap_pages;
|
||||
std::unique_ptr<KSlabHeap<Memory::Page>> user_slab_heap_pages;
|
||||
|
||||
// Shared memory for services
|
||||
std::shared_ptr<Kernel::KSharedMemory> hid_shared_mem;
|
||||
@ -581,11 +581,11 @@ const Memory::MemoryManager& KernelCore::MemoryManager() const {
|
||||
return *impl->memory_manager;
|
||||
}
|
||||
|
||||
Memory::SlabHeap<Memory::Page>& KernelCore::GetUserSlabHeapPages() {
|
||||
KSlabHeap<Memory::Page>& KernelCore::GetUserSlabHeapPages() {
|
||||
return *impl->user_slab_heap_pages;
|
||||
}
|
||||
|
||||
const Memory::SlabHeap<Memory::Page>& KernelCore::GetUserSlabHeapPages() const {
|
||||
const KSlabHeap<Memory::Page>& KernelCore::GetUserSlabHeapPages() const {
|
||||
return *impl->user_slab_heap_pages;
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,7 @@ namespace Kernel {
|
||||
|
||||
namespace Memory {
|
||||
class MemoryManager;
|
||||
template <typename T>
|
||||
class SlabHeap;
|
||||
|
||||
} // namespace Memory
|
||||
|
||||
class ClientPort;
|
||||
@ -46,6 +45,9 @@ class Synchronization;
|
||||
class KThread;
|
||||
class TimeManager;
|
||||
|
||||
template <typename T>
|
||||
class KSlabHeap;
|
||||
|
||||
using EmuThreadHandle = uintptr_t;
|
||||
constexpr EmuThreadHandle EmuThreadHandleInvalid{};
|
||||
constexpr EmuThreadHandle EmuThreadHandleReserved{1ULL << 63};
|
||||
@ -184,10 +186,10 @@ public:
|
||||
const Memory::MemoryManager& MemoryManager() const;
|
||||
|
||||
/// Gets the slab heap allocated for user space pages.
|
||||
Memory::SlabHeap<Memory::Page>& GetUserSlabHeapPages();
|
||||
KSlabHeap<Memory::Page>& GetUserSlabHeapPages();
|
||||
|
||||
/// Gets the slab heap allocated for user space pages.
|
||||
const Memory::SlabHeap<Memory::Page>& GetUserSlabHeapPages() const;
|
||||
const KSlabHeap<Memory::Page>& GetUserSlabHeapPages() const;
|
||||
|
||||
/// Gets the shared memory object for HID services.
|
||||
Kernel::KSharedMemory& GetHidSharedMem();
|
||||
|
Loading…
Reference in New Issue
Block a user