mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:24:57 +00:00
Revert "Kernel: Fix regression where MemoryManager is initialized twice"
This reverts commit 8a75e0b892
.
This commit is contained in:
parent
68580d5a8d
commit
b0a24a83be
2 changed files with 6 additions and 7 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Memory.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Arch/i386/CPU.h>
|
||||
#include <Kernel/CMOS.h>
|
||||
|
@ -50,11 +51,7 @@ extern FlatPtr end_of_kernel_bss;
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
// NOTE: We can NOT use AK::Singleton for this class, because
|
||||
// MemoryManager::initialize is called *before* global constructors are
|
||||
// run. If we do, then AK::Singleton would get re-initialized, causing
|
||||
// the memory manager to be initialized twice!
|
||||
static MemoryManager* s_the;
|
||||
static auto s_the = AK::make_singleton<MemoryManager>();
|
||||
RecursiveSpinLock s_mm_lock;
|
||||
|
||||
MemoryManager& MM
|
||||
|
@ -64,6 +61,8 @@ MemoryManager& MM
|
|||
|
||||
MemoryManager::MemoryManager()
|
||||
{
|
||||
ASSERT(!s_the.is_initialized());
|
||||
|
||||
ScopedSpinLock lock(s_mm_lock);
|
||||
m_kernel_page_directory = PageDirectory::create_kernel_page_directory();
|
||||
parse_memory_map();
|
||||
|
@ -221,7 +220,7 @@ void MemoryManager::initialize(u32 cpu)
|
|||
Processor::current().set_mm_data(*mm_data);
|
||||
|
||||
if (cpu == 0)
|
||||
s_the = new MemoryManager;
|
||||
s_the.ensure_instance();
|
||||
}
|
||||
|
||||
Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr)
|
||||
|
|
|
@ -85,6 +85,7 @@ class MemoryManager {
|
|||
friend Optional<KBuffer> procfs$memstat(InodeIdentifier);
|
||||
|
||||
public:
|
||||
MemoryManager();
|
||||
static MemoryManager& the();
|
||||
|
||||
static void initialize(u32 cpu);
|
||||
|
@ -160,7 +161,6 @@ public:
|
|||
PageDirectory& kernel_page_directory() { return *m_kernel_page_directory; }
|
||||
|
||||
private:
|
||||
MemoryManager();
|
||||
~MemoryManager();
|
||||
|
||||
enum class AccessSpace { Kernel,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue