mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 13:17:34 +00:00
Kernel: Turn Thread::current and Process::current into functions
This allows us to query the current thread and process on a per processor basis
This commit is contained in:
parent
cdc78515b6
commit
16783bd14d
39 changed files with 518 additions and 369 deletions
|
@ -267,7 +267,7 @@ Region* MemoryManager::region_from_vaddr(VirtualAddress vaddr)
|
|||
PageFaultResponse MemoryManager::handle_page_fault(const PageFault& fault)
|
||||
{
|
||||
ASSERT_INTERRUPTS_DISABLED();
|
||||
ASSERT(Thread::current);
|
||||
ASSERT(Thread::current() != nullptr);
|
||||
ScopedSpinLock lock(s_lock);
|
||||
if (Processor::current().in_irq()) {
|
||||
dbg() << "CPU[" << Processor::current().id() << "] BUG! Page fault while handling IRQ! code=" << fault.code() << ", vaddr=" << fault.vaddr() << ", irq level: " << Processor::current().in_irq();
|
||||
|
@ -519,10 +519,11 @@ RefPtr<PhysicalPage> MemoryManager::allocate_supervisor_physical_page()
|
|||
|
||||
void MemoryManager::enter_process_paging_scope(Process& process)
|
||||
{
|
||||
ASSERT(Thread::current);
|
||||
auto current_thread = Thread::current();
|
||||
ASSERT(current_thread != nullptr);
|
||||
ScopedSpinLock lock(s_lock);
|
||||
|
||||
Thread::current->tss().cr3 = process.page_directory().cr3();
|
||||
current_thread->tss().cr3 = process.page_directory().cr3();
|
||||
write_cr3(process.page_directory().cr3());
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Kernel {
|
|||
|
||||
ProcessPagingScope::ProcessPagingScope(Process& process)
|
||||
{
|
||||
ASSERT(Thread::current);
|
||||
ASSERT(Thread::current() != nullptr);
|
||||
m_previous_cr3 = read_cr3();
|
||||
MM.enter_process_paging_scope(process);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ ProcessPagingScope::ProcessPagingScope(Process& process)
|
|||
ProcessPagingScope::~ProcessPagingScope()
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
Thread::current->tss().cr3 = m_previous_cr3;
|
||||
Thread::current()->tss().cr3 = m_previous_cr3;
|
||||
write_cr3(m_previous_cr3);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ Region::~Region()
|
|||
|
||||
NonnullOwnPtr<Region> Region::clone()
|
||||
{
|
||||
ASSERT(Process::current);
|
||||
ASSERT(Process::current());
|
||||
|
||||
if (m_inherit_mode == InheritMode::ZeroedOnFork) {
|
||||
ASSERT(m_mmap);
|
||||
|
@ -367,8 +367,9 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region)
|
|||
return PageFaultResponse::Continue;
|
||||
}
|
||||
|
||||
if (Thread::current)
|
||||
Thread::current->did_zero_fault();
|
||||
auto current_thread = Thread::current();
|
||||
if (current_thread != nullptr)
|
||||
current_thread->did_zero_fault();
|
||||
|
||||
auto page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::Yes);
|
||||
if (page.is_null()) {
|
||||
|
@ -397,8 +398,9 @@ PageFaultResponse Region::handle_cow_fault(size_t page_index_in_region)
|
|||
return PageFaultResponse::Continue;
|
||||
}
|
||||
|
||||
if (Thread::current)
|
||||
Thread::current->did_cow_fault();
|
||||
auto current_thread = Thread::current();
|
||||
if (current_thread)
|
||||
current_thread->did_cow_fault();
|
||||
|
||||
#ifdef PAGE_FAULT_DEBUG
|
||||
dbg() << " >> It's a COW page and it's time to COW!";
|
||||
|
@ -446,8 +448,9 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
|
|||
return PageFaultResponse::Continue;
|
||||
}
|
||||
|
||||
if (Thread::current)
|
||||
Thread::current->did_inode_fault();
|
||||
auto current_thread = Thread::current();
|
||||
if (current_thread)
|
||||
current_thread->did_inode_fault();
|
||||
|
||||
#ifdef MM_DEBUG
|
||||
dbg() << "MM: page_in_from_inode ready to read from inode";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue