forked from Bananymous/banan-os
Kernel: Remove lai as a dependecy
I don't think lai is needed anymore, since my own AML interpreter can do ACPI poweroff which was all that lai was used for.
This commit is contained in:
parent
7a2be05c69
commit
cdbdc1a822
|
@ -1,4 +0,0 @@
|
||||||
[submodule "kernel/lai"]
|
|
||||||
path = kernel/lai
|
|
||||||
url = https://github.com/managarm/lai.git
|
|
||||||
ignore = untracked
|
|
|
@ -14,9 +14,9 @@ This is my hobby operating system written in C++. Currently supports x86\_64 and
|
||||||
- [x] Linear framebuffer (VESA and GOP)
|
- [x] Linear framebuffer (VESA and GOP)
|
||||||
- [x] Network stack
|
- [x] Network stack
|
||||||
- [x] ELF executable loading
|
- [x] ELF executable loading
|
||||||
|
- [x] AML interpreter (partial)
|
||||||
- [ ] ELF dynamic linking
|
- [ ] ELF dynamic linking
|
||||||
- [ ] Graphical desktop
|
- [ ] Graphical desktop
|
||||||
- [ ] AML interpreter (currenly using [lai](https://github.com/managarm/lai))
|
|
||||||
|
|
||||||
#### Drivers
|
#### Drivers
|
||||||
- [x] NVMe disks
|
- [x] NVMe disks
|
||||||
|
|
|
@ -119,13 +119,6 @@ if("${BANAN_ARCH}" STREQUAL "x86_64")
|
||||||
arch/x86_64/Syscall.S
|
arch/x86_64/Syscall.S
|
||||||
arch/x86_64/Thread.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 "i686")
|
elseif("${BANAN_ARCH}" STREQUAL "i686")
|
||||||
set(KERNEL_SOURCES
|
set(KERNEL_SOURCES
|
||||||
${KERNEL_SOURCES}
|
${KERNEL_SOURCES}
|
||||||
|
@ -197,7 +190,6 @@ set_source_files_properties(${LAI_SOURCES} PROPERTIES COMPILE_FLAGS -Wno-stack-u
|
||||||
|
|
||||||
add_custom_target(kernel-headers
|
add_custom_target(kernel-headers
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/
|
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/lai/include/ ${BANAN_INCLUDE}/
|
|
||||||
DEPENDS sysroot
|
DEPENDS sysroot
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ namespace Kernel
|
||||||
|
|
||||||
bool is_using_apic() const { return m_using_apic; }
|
bool is_using_apic() const { return m_using_apic; }
|
||||||
|
|
||||||
void enter_acpi_mode();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_using_apic { false };
|
bool m_using_apic { false };
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
#include <kernel/IO.h>
|
#include <kernel/IO.h>
|
||||||
#include <kernel/Memory/PageTable.h>
|
#include <kernel/Memory/PageTable.h>
|
||||||
|
|
||||||
#include <lai/core.h>
|
|
||||||
|
|
||||||
#define RSPD_SIZE 20
|
#define RSPD_SIZE 20
|
||||||
#define RSPDv2_SIZE 36
|
#define RSPDv2_SIZE 36
|
||||||
|
|
||||||
|
@ -42,9 +40,6 @@ namespace Kernel::ACPI
|
||||||
ASSERT(dsdt);
|
ASSERT(dsdt);
|
||||||
s_instance->m_namespace = AML::initialize_namespace(*dsdt);
|
s_instance->m_namespace = AML::initialize_namespace(*dsdt);
|
||||||
|
|
||||||
#if ARCH(x86_64)
|
|
||||||
lai_create_namespace();
|
|
||||||
#endif
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +101,6 @@ namespace Kernel::ACPI
|
||||||
const RSDP* rsdp = locate_rsdp();
|
const RSDP* rsdp = locate_rsdp();
|
||||||
if (rsdp == nullptr)
|
if (rsdp == nullptr)
|
||||||
return BAN::Error::from_error_code(ErrorCode::ACPI_NoRootSDT);
|
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;
|
uint32_t root_entry_count = 0;
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
#include <kernel/APIC.h>
|
#include <kernel/APIC.h>
|
||||||
#include <kernel/PIC.h>
|
#include <kernel/PIC.h>
|
||||||
|
|
||||||
#include <lai/helpers/sci.h>
|
|
||||||
|
|
||||||
namespace Kernel
|
namespace Kernel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -45,12 +43,4 @@ namespace Kernel
|
||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <BAN/ScopeGuard.h>
|
#include <BAN/ScopeGuard.h>
|
||||||
#include <BAN/StringView.h>
|
#include <BAN/StringView.h>
|
||||||
|
#include <kernel/ACPI/ACPI.h>
|
||||||
#include <kernel/FS/DevFS/FileSystem.h>
|
#include <kernel/FS/DevFS/FileSystem.h>
|
||||||
#include <kernel/FS/ProcFS/FileSystem.h>
|
#include <kernel/FS/ProcFS/FileSystem.h>
|
||||||
#include <kernel/FS/VirtualFileSystem.h>
|
#include <kernel/FS/VirtualFileSystem.h>
|
||||||
|
@ -17,8 +18,6 @@
|
||||||
|
|
||||||
#include <LibELF/LoadableELF.h>
|
#include <LibELF/LoadableELF.h>
|
||||||
|
|
||||||
#include <lai/helpers/pm.h>
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/banan-os.h>
|
#include <sys/banan-os.h>
|
||||||
|
@ -1191,11 +1190,7 @@ namespace Kernel
|
||||||
|
|
||||||
[[noreturn]] static void reset_system()
|
[[noreturn]] static void reset_system()
|
||||||
{
|
{
|
||||||
#if ARCH(x86_64)
|
// TODO: ACPI reset
|
||||||
lai_acpi_reset();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// acpi reset did not work
|
|
||||||
|
|
||||||
dwarnln("Could not reset with ACPI, crashing the cpu");
|
dwarnln("Could not reset with ACPI, crashing the cpu");
|
||||||
|
|
||||||
|
@ -1215,13 +1210,7 @@ namespace Kernel
|
||||||
if (command == POWEROFF_REBOOT)
|
if (command == POWEROFF_REBOOT)
|
||||||
reset_system();
|
reset_system();
|
||||||
|
|
||||||
#if ARCH(x86_64)
|
ACPI::ACPI::get().poweroff();
|
||||||
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);
|
return BAN::Error::from_errno(EUNKNOWN);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,149 +0,0 @@
|
||||||
#include <kernel/ACPI/ACPI.h>
|
|
||||||
#include <kernel/IO.h>
|
|
||||||
#include <kernel/Memory/kmalloc.h>
|
|
||||||
#include <kernel/Memory/PageTable.h>
|
|
||||||
#include <kernel/PCI.h>
|
|
||||||
#include <kernel/Timer/Timer.h>
|
|
||||||
|
|
||||||
#include <lai/host.h>
|
|
||||||
|
|
||||||
using namespace Kernel;
|
|
||||||
|
|
||||||
void* laihost_malloc(size_t size)
|
|
||||||
{
|
|
||||||
return kmalloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* laihost_realloc(void* ptr, size_t newsize, size_t oldsize)
|
|
||||||
{
|
|
||||||
if (ptr == nullptr)
|
|
||||||
return laihost_malloc(newsize);
|
|
||||||
|
|
||||||
void* new_ptr = laihost_malloc(newsize);
|
|
||||||
if (new_ptr == nullptr)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
memcpy(new_ptr, ptr, BAN::Math::min(newsize, oldsize));
|
|
||||||
kfree(ptr);
|
|
||||||
|
|
||||||
return new_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_free(void* ptr, size_t)
|
|
||||||
{
|
|
||||||
kfree(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_log(int level, const char* msg)
|
|
||||||
{
|
|
||||||
if (level == LAI_DEBUG_LOG)
|
|
||||||
dprintln(msg);
|
|
||||||
else if (level == LAI_WARN_LOG)
|
|
||||||
dwarnln(msg);
|
|
||||||
else
|
|
||||||
ASSERT_NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_panic(const char* msg)
|
|
||||||
{
|
|
||||||
Kernel::panic(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* laihost_scan(const char* sig, size_t index)
|
|
||||||
{
|
|
||||||
return (void*)ACPI::ACPI::get().get_header(sig, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* laihost_map(size_t address, size_t count)
|
|
||||||
{
|
|
||||||
size_t needed_pages = range_page_count(address, count);
|
|
||||||
vaddr_t vaddr = PageTable::kernel().reserve_free_contiguous_pages(needed_pages, KERNEL_OFFSET);
|
|
||||||
ASSERT(vaddr);
|
|
||||||
|
|
||||||
PageTable::kernel().map_range_at(address & PAGE_ADDR_MASK, vaddr, needed_pages * PAGE_SIZE, PageTable::Flags::ReadWrite | PageTable::Flags::Present);
|
|
||||||
|
|
||||||
return (void*)(vaddr + (address % PAGE_SIZE));
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_unmap(void* ptr, size_t count)
|
|
||||||
{
|
|
||||||
PageTable::kernel().unmap_range((vaddr_t)ptr, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_outb(uint16_t port, uint8_t val)
|
|
||||||
{
|
|
||||||
IO::outb(port, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_outw(uint16_t port, uint16_t val)
|
|
||||||
{
|
|
||||||
IO::outw(port, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_outd(uint16_t port, uint32_t val)
|
|
||||||
{
|
|
||||||
IO::outl(port, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t laihost_inb(uint16_t port)
|
|
||||||
{
|
|
||||||
return IO::inb(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t laihost_inw(uint16_t port)
|
|
||||||
{
|
|
||||||
return IO::inw(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t laihost_ind(uint16_t port)
|
|
||||||
{
|
|
||||||
return IO::inl(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_pci_writeb(uint16_t seg, uint8_t bus, uint8_t slot, uint8_t fun, uint16_t offset, uint8_t val)
|
|
||||||
{
|
|
||||||
ASSERT(seg == 0);
|
|
||||||
PCI::PCIManager::write_config_byte(bus, slot, fun, offset, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_pci_writew(uint16_t seg, uint8_t bus, uint8_t slot, uint8_t fun, uint16_t offset, uint16_t val)
|
|
||||||
{
|
|
||||||
ASSERT(seg == 0);
|
|
||||||
PCI::PCIManager::write_config_word(bus, slot, fun, offset, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_pci_writed(uint16_t seg, uint8_t bus, uint8_t slot, uint8_t fun, uint16_t offset, uint32_t val)
|
|
||||||
{
|
|
||||||
ASSERT(seg == 0);
|
|
||||||
PCI::PCIManager::write_config_dword(bus, slot, fun, offset, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t laihost_pci_readb(uint16_t seg, uint8_t bus, uint8_t slot, uint8_t fun, uint16_t offset)
|
|
||||||
{
|
|
||||||
ASSERT(seg == 0);
|
|
||||||
return PCI::PCIManager::read_config_byte(bus, slot, fun, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t laihost_pci_readw(uint16_t seg, uint8_t bus, uint8_t slot, uint8_t fun, uint16_t offset)
|
|
||||||
{
|
|
||||||
ASSERT(seg == 0);
|
|
||||||
return PCI::PCIManager::read_config_word(bus, slot, fun, offset);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t laihost_pci_readd(uint16_t seg, uint8_t bus, uint8_t slot, uint8_t fun, uint16_t offset)
|
|
||||||
{
|
|
||||||
ASSERT(seg == 0);
|
|
||||||
return PCI::PCIManager::read_config_dword(bus, slot, fun, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
void laihost_sleep(uint64_t ms)
|
|
||||||
{
|
|
||||||
SystemTimer::get().sleep(ms);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t laihost_timer(void)
|
|
||||||
{
|
|
||||||
auto time = SystemTimer::get().time_since_boot();
|
|
||||||
return (1'000'000'000ull * time.tv_sec + time.tv_nsec) / 100;
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit a228465314ee3a542f62d4bdefeb8fbe2b48da41
|
|
Loading…
Reference in New Issue