Kernel: MMU::get() is now MMU::kernel

MMU is can now be locked with RecursiveSpinLock.

Scheduler now has get_current_tid() that works before the Scheduler
is initialized. This allows RecursiveSpinLock usage early on.
This commit is contained in:
Bananymous
2023-05-28 16:18:18 +03:00
parent a2ee543fa1
commit 869de7283f
11 changed files with 100 additions and 63 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <kernel/Memory/Heap.h>
#include <kernel/Memory/Types.h>
#include <kernel/SpinLock.h>
namespace Kernel
{
@@ -18,7 +19,7 @@ namespace Kernel
public:
static void initialize();
static MMU& get();
static MMU& kernel();
static MMU& current();
@@ -44,12 +45,16 @@ namespace Kernel
void load();
void lock() const { m_lock.lock(); }
void unlock() const { m_lock.unlock(); }
private:
uint64_t get_page_data(vaddr_t) const;
void initialize_kernel();
private:
uint64_t* m_highest_paging_struct;
uint64_t* m_highest_paging_struct { nullptr };
mutable RecursiveSpinLock m_lock;
};
}

View File

@@ -68,7 +68,7 @@ namespace Kernel
static Process& current() { return Thread::current().process(); }
MMU& mmu() { return m_mmu ? *m_mmu : MMU::get(); }
MMU& mmu() { return m_mmu ? *m_mmu : MMU::kernel(); }
private:
Process(pid_t);

View File

@@ -26,6 +26,7 @@ namespace Kernel
void unblock_threads(Semaphore*);
Thread& current_thread();
static pid_t current_tid();
private:
Scheduler() = default;

View File

@@ -49,6 +49,8 @@ namespace Kernel
uintptr_t interrupt_stack_size() const { return m_interrupt_stack_size; }
static Thread& current() ;
static pid_t current_tid();
Process& process();
bool has_process() const { return m_process; }