2020-04-05 20:41:04 +02:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-02-13 01:21:12 +01:00
|
|
|
namespace Kernel {
|
2020-04-05 20:41:04 +02:00
|
|
|
|
2021-05-21 03:15:59 +02:00
|
|
|
class KernelCore;
|
2020-04-05 20:41:04 +02:00
|
|
|
|
2021-05-21 03:15:59 +02:00
|
|
|
/// This is a placeholder class to manage slab heaps for kernel objects. For now, we just allocate
|
|
|
|
/// these with new/delete, but this can be re-implemented later to allocate these in emulated
|
|
|
|
/// memory.
|
2020-04-05 20:41:04 +02:00
|
|
|
|
|
|
|
template <typename T>
|
2021-05-21 03:15:59 +02:00
|
|
|
class KSlabHeap final : NonCopyable {
|
2020-04-05 20:41:04 +02:00
|
|
|
public:
|
2021-05-21 03:15:59 +02:00
|
|
|
KSlabHeap() = default;
|
2020-04-05 20:41:04 +02:00
|
|
|
|
2021-05-21 03:15:59 +02:00
|
|
|
void Initialize([[maybe_unused]] void* memory, [[maybe_unused]] std::size_t memory_size) {
|
|
|
|
// Placeholder that should initialize the backing slab heap implementation.
|
2020-04-05 20:41:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
T* Allocate() {
|
2021-05-21 03:15:59 +02:00
|
|
|
return new T();
|
2020-04-05 20:41:04 +02:00
|
|
|
}
|
|
|
|
|
2021-04-04 04:11:46 +02:00
|
|
|
T* AllocateWithKernel(KernelCore& kernel) {
|
2021-05-21 03:15:59 +02:00
|
|
|
return new T(kernel);
|
2021-04-04 04:11:46 +02:00
|
|
|
}
|
|
|
|
|
2020-04-05 20:41:04 +02:00
|
|
|
void Free(T* obj) {
|
2021-05-21 03:15:59 +02:00
|
|
|
delete obj;
|
2020-04-05 20:41:04 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-13 01:21:12 +01:00
|
|
|
} // namespace Kernel
|