Kernel: Cleanup entering acpi mode

There is no need to pass the current mode as an argument as ACPI has
access to that info either way.

Only route INTx objects when using ACPI, they won't be used otherwise
This commit is contained in:
2026-07-20 09:02:18 +03:00
parent b611c3fe48
commit d46d7a5123
3 changed files with 15 additions and 16 deletions
+1 -5
View File
@@ -23,11 +23,7 @@ namespace Kernel::ACPI
const SDTHeader* get_header(BAN::StringView signature, uint32_t index); const SDTHeader* get_header(BAN::StringView signature, uint32_t index);
// mode BAN::ErrorOr<void> enter_acpi_mode();
// 0: PIC
// 1: APIC
// 2: SAPIC
BAN::ErrorOr<void> enter_acpi_mode(uint8_t mode);
BAN::ErrorOr<void> initialize_acpi_devices(); BAN::ErrorOr<void> initialize_acpi_devices();
+13 -10
View File
@@ -934,7 +934,7 @@ acpi_release_global_lock:
return false; return false;
} }
BAN::ErrorOr<void> ACPI::enter_acpi_mode(uint8_t mode) BAN::ErrorOr<void> ACPI::enter_acpi_mode()
{ {
ASSERT(!m_namespace); ASSERT(!m_namespace);
@@ -1013,7 +1013,7 @@ acpi_release_global_lock:
AML::Reference arg_ref; AML::Reference arg_ref;
arg_ref.node.type = AML::Node::Type::Integer; arg_ref.node.type = AML::Node::Type::Integer;
arg_ref.node.as.integer.value = mode; arg_ref.node.as.integer.value = InterruptController::get().is_using_apic() ? 1 : 0;
arg_ref.ref_count = 2; arg_ref.ref_count = 2;
BAN::Array<AML::Reference*, 7> arguments(nullptr); BAN::Array<AML::Reference*, 7> arguments(nullptr);
@@ -1021,7 +1021,7 @@ acpi_release_global_lock:
TRY(AML::method_call(pic_path, pic_node, BAN::move(arguments))); TRY(AML::method_call(pic_path, pic_node, BAN::move(arguments)));
} }
dprintln("Evaluated \\_PIC({})", mode); dprintln("Evaluated \\_PIC({})", InterruptController::get().is_using_apic() ? 1 : 0);
uint8_t irq = fadt().sci_int; uint8_t irq = fadt().sci_int;
if (auto ret = InterruptController::get().reserve_irq(irq); ret.is_error()) if (auto ret = InterruptController::get().reserve_irq(irq); ret.is_error())
@@ -1097,14 +1097,17 @@ acpi_release_global_lock:
dprintln("Initialized ACPI interrupts"); dprintln("Initialized ACPI interrupts");
if (auto interrupt_link_devices_or_error = m_namespace->find_device_with_eisa_id("PNP0C0F"_sv); !interrupt_link_devices_or_error.is_error()) if (InterruptController::get().is_using_apic())
{ {
uint64_t routed_irq_mask = 0; if (auto interrupt_link_devices_or_error = m_namespace->find_device_with_eisa_id("PNP0C0F"_sv); !interrupt_link_devices_or_error.is_error())
auto interrupt_link_devices = interrupt_link_devices_or_error.release_value(); {
for (const auto& device : interrupt_link_devices) uint64_t routed_irq_mask = 0;
if (auto ret = route_interrupt_link_device(device, routed_irq_mask); ret.is_error()) auto interrupt_link_devices = interrupt_link_devices_or_error.release_value();
dwarnln("failed to route interrupt link device: {}", ret.error()); for (const auto& device : interrupt_link_devices)
dprintln("Routed interrupt link devices"); if (auto ret = route_interrupt_link_device(device, routed_irq_mask); ret.is_error())
dwarnln("failed to route interrupt link device: {}", ret.error());
dprintln("Routed interrupt link devices");
}
} }
return {}; return {};
+1 -1
View File
@@ -230,7 +230,7 @@ static void init2(void*)
if (!cmdline.disable_acpi) if (!cmdline.disable_acpi)
{ {
if (auto ret = ACPI::ACPI::get().enter_acpi_mode(InterruptController::get().is_using_apic()); ret.is_error()) if (auto ret = ACPI::ACPI::get().enter_acpi_mode(); ret.is_error())
dprintln("Failed to enter ACPI mode: {}", ret.error()); dprintln("Failed to enter ACPI mode: {}", ret.error());
if (auto ret = ACPI::ACPI::get().initialize_acpi_devices(); ret.is_error()) if (auto ret = ACPI::ACPI::get().initialize_acpi_devices(); ret.is_error())
dwarnln("Could not initialize ACPI devices: {}", ret.error()); dwarnln("Could not initialize ACPI devices: {}", ret.error());