Kernel: Per processor information is now stored in class Processor

This allows us to allocate processor stacks, and other per processor
structures dynamically in runtime. Giving processor stack to
ap_trampoline feels super hacky, but it works for now.
This commit is contained in:
2024-03-03 22:30:06 +02:00
parent c035d3c82c
commit 8141b9977d
11 changed files with 171 additions and 83 deletions

View File

@@ -9,11 +9,11 @@ namespace Kernel
InterruptState SpinLock::lock()
{
auto id = get_processor_id();
auto id = Processor::current_id();
ASSERT_NEQ(m_locker.load(), id);
auto state = get_interrupt_state();
set_interrupt_state(InterruptState::Disabled);
auto state = Processor::get_interrupt_state();
Processor::set_interrupt_state(InterruptState::Disabled);
while (!m_locker.compare_exchange(PROCESSOR_NONE, id, BAN::MemoryOrder::memory_order_acquire))
__builtin_ia32_pause();
@@ -23,17 +23,17 @@ namespace Kernel
void SpinLock::unlock(InterruptState state)
{
ASSERT_EQ(m_locker.load(), get_processor_id());
ASSERT_EQ(m_locker.load(), Processor::current_id());
m_locker.store(PROCESSOR_NONE, BAN::MemoryOrder::memory_order_release);
set_interrupt_state(state);
Processor::set_interrupt_state(state);
}
InterruptState RecursiveSpinLock::lock()
{
auto id = get_processor_id();
auto id = Processor::current_id();
auto state = get_interrupt_state();
set_interrupt_state(InterruptState::Disabled);
auto state = Processor::get_interrupt_state();
Processor::set_interrupt_state(InterruptState::Disabled);
if (id == m_locker)
ASSERT_GT(m_lock_depth, 0);
@@ -51,11 +51,11 @@ namespace Kernel
void RecursiveSpinLock::unlock(InterruptState state)
{
ASSERT_EQ(m_locker.load(), get_processor_id());
ASSERT_EQ(m_locker.load(), Processor::current_id());
ASSERT_GT(m_lock_depth, 0);
if (--m_lock_depth == 0)
m_locker.store(PROCESSOR_NONE, BAN::MemoryOrder::memory_order_release);
set_interrupt_state(state);
Processor::set_interrupt_state(state);
}
}