Kernel: Enter ACPI mode with lai
This commit is contained in:
parent
1abf787596
commit
d45bf363f1
|
@ -16,6 +16,11 @@ public:
|
|||
|
||||
static void initialize(bool force_pic);
|
||||
static InterruptController& get();
|
||||
|
||||
void enter_acpi_mode();
|
||||
|
||||
private:
|
||||
bool m_using_apic { false };
|
||||
};
|
||||
|
||||
bool interrupts_enabled();
|
|
@ -94,7 +94,7 @@ namespace Kernel
|
|||
void validate_stack() const;
|
||||
|
||||
private:
|
||||
static constexpr size_t m_kernel_stack_size = PAGE_SIZE * 1;
|
||||
static constexpr size_t m_kernel_stack_size = PAGE_SIZE * 4;
|
||||
static constexpr size_t m_userspace_stack_size = PAGE_SIZE * 2;
|
||||
static constexpr size_t m_interrupt_stack_size = PAGE_SIZE * 2;
|
||||
BAN::UniqPtr<VirtualRange> m_interrupt_stack;
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <kernel/APIC.h>
|
||||
#include <kernel/PIC.h>
|
||||
|
||||
#include <lai/helpers/sci.h>
|
||||
|
||||
static InterruptController* s_instance = nullptr;
|
||||
|
||||
InterruptController& InterruptController::get()
|
||||
|
@ -19,11 +21,26 @@ void InterruptController::initialize(bool force_pic)
|
|||
PIC::remap();
|
||||
|
||||
if (!force_pic)
|
||||
{
|
||||
s_instance = APIC::create();
|
||||
if (s_instance)
|
||||
return;
|
||||
if (s_instance)
|
||||
{
|
||||
s_instance->m_using_apic = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dprintln("Using PIC instead of APIC");
|
||||
s_instance = PIC::create();
|
||||
ASSERT(s_instance);
|
||||
|
||||
s_instance->m_using_apic = false;
|
||||
}
|
||||
|
||||
void InterruptController::enter_acpi_mode()
|
||||
{
|
||||
if (lai_enable_acpi(m_using_apic ? 1 : 0) != 0)
|
||||
dwarnln("could not enter acpi mode");
|
||||
}
|
||||
|
||||
bool interrupts_enabled()
|
||||
|
@ -31,4 +48,4 @@ bool interrupts_enabled()
|
|||
uintptr_t flags;
|
||||
asm volatile("pushf; pop %0" : "=r"(flags) :: "memory");
|
||||
return flags & (1 << 9);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,6 +161,8 @@ static void init2(void*)
|
|||
|
||||
dprintln("Scheduler started");
|
||||
|
||||
InterruptController::get().enter_acpi_mode();
|
||||
|
||||
auto console = MUST(DevFileSystem::get().root_inode()->find_inode(cmdline.console));
|
||||
ASSERT(console->is_tty());
|
||||
((TTY*)console.ptr())->set_as_current();
|
||||
|
|
Loading…
Reference in New Issue