diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index a7438da8bd..6cd5e41fd8 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -113,6 +113,13 @@ if("${BANAN_ARCH}" STREQUAL "x86_64") arch/x86_64/Syscall.S arch/x86_64/Thread.S ) + file(GLOB_RECURSE LAI_SOURCES + lai/*.c + ) + set(LAI_SOURCES + ${LAI_SOURCES} + kernel/lai_host.cpp + ) elseif("${BANAN_ARCH}" STREQUAL "i386") set(KERNEL_SOURCES ${KERNEL_SOURCES} @@ -125,14 +132,6 @@ else() message(FATAL_ERROR "unsupported architecure ${BANAN_ARCH}") endif() -file(GLOB_RECURSE LAI_SOURCES - lai/*.c -) -set(LAI_SOURCES - ${LAI_SOURCES} - kernel/lai_host.cpp -) - set(BAN_SOURCES ../BAN/BAN/Assert.cpp ../BAN/BAN/New.cpp @@ -177,7 +176,7 @@ if(ENABLE_KERNEL_UBSAN) endif() if("${BANAN_ARCH}" STREQUAL "x86_64") - target_compile_options(kernel PUBLIC -mcmodel=kernel -mno-red-zone -mno-mmx) + target_compile_options(kernel PUBLIC -mcmodel=kernel -mno-red-zone) target_link_options(kernel PUBLIC LINKER:-z,max-page-size=4096) target_link_options(kernel PUBLIC LINKER:-T,${CMAKE_CURRENT_SOURCE_DIR}/arch/x86_64/linker.ld) elseif("${BANAN_ARCH}" STREQUAL "i386") diff --git a/kernel/kernel/ACPI.cpp b/kernel/kernel/ACPI.cpp index fabd8e38a6..2d8ccf33a3 100644 --- a/kernel/kernel/ACPI.cpp +++ b/kernel/kernel/ACPI.cpp @@ -31,7 +31,9 @@ namespace Kernel if (s_instance == nullptr) return BAN::Error::from_errno(ENOMEM); TRY(s_instance->initialize_impl()); +#if ARCH(x86_64) lai_create_namespace(); +#endif return {}; } @@ -93,7 +95,9 @@ namespace Kernel const RSDP* rsdp = locate_rsdp(); if (rsdp == nullptr) return BAN::Error::from_error_code(ErrorCode::ACPI_NoRootSDT); +#if ARCH(x86_64) lai_set_acpi_revision(rsdp->revision); +#endif uint32_t root_entry_count = 0; diff --git a/kernel/kernel/InterruptController.cpp b/kernel/kernel/InterruptController.cpp index 7989e4c1ed..6cd043925f 100644 --- a/kernel/kernel/InterruptController.cpp +++ b/kernel/kernel/InterruptController.cpp @@ -42,7 +42,9 @@ namespace Kernel void InterruptController::enter_acpi_mode() { +#if ARCH(x86_64) if (lai_enable_acpi(m_using_apic ? 1 : 0) != 0) +#endif dwarnln("could not enter acpi mode"); } diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 73a85bdba5..9bb7431bf7 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -1187,7 +1187,9 @@ namespace Kernel [[noreturn]] static void reset_system() { +#if ARCH(x86_64) lai_acpi_reset(); +#endif // acpi reset did not work @@ -1206,21 +1208,17 @@ namespace Kernel DevFileSystem::get().initiate_sync(true); - lai_api_error_t error; - switch (command) - { - case POWEROFF_REBOOT: - reset_system(); - break; - case POWEROFF_SHUTDOWN: - error = lai_enter_sleep(5); - break; - default: - ASSERT_NOT_REACHED(); - } + if (command == POWEROFF_REBOOT) + reset_system(); +#if ARCH(x86_64) + auto error = lai_enter_sleep(5); // If we reach here, there was an error dprintln("{}", lai_api_error_to_string(error)); +#else + dprintln("poweroff available only on x86_64"); +#endif + return BAN::Error::from_errno(EUNKNOWN); }