Kernel: Only compile lai for x86_64 targets

I will be dropping lai entirely soon. Once I get to writing AML
interpreter.
This commit is contained in:
Bananymous 2024-03-22 13:32:07 +02:00
parent 2352c86048
commit 0424082e7b
4 changed files with 24 additions and 21 deletions

View File

@ -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")

View File

@ -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;

View File

@ -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");
}

View File

@ -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);
}