From b5e2945165c46ae1b13bb817f937e064dde9e488 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Sat, 11 Mar 2023 10:36:55 +0100 Subject: [PATCH] feature (acpi): requesting RSDP from bootloader --- kernel/inc/drivers/acpi/acpi.h | 10 ++++++++++ kernel/inc/drivers/acpi/rsdp.h | 24 ++++++++++++++++++++++++ kernel/src/boot/limine.c | 12 ++++++++++++ kernel/src/drivers/acpi/acpi.c | 8 ++++++++ kernel/src/drivers/acpi/rsdp.c | 1 + kernel/src/kmain.c | 6 ++++++ 6 files changed, 61 insertions(+) create mode 100644 kernel/inc/drivers/acpi/acpi.h create mode 100644 kernel/inc/drivers/acpi/rsdp.h create mode 100644 kernel/src/drivers/acpi/acpi.c create mode 100644 kernel/src/drivers/acpi/rsdp.c diff --git a/kernel/inc/drivers/acpi/acpi.h b/kernel/inc/drivers/acpi/acpi.h new file mode 100644 index 0000000..69bb53b --- /dev/null +++ b/kernel/inc/drivers/acpi/acpi.h @@ -0,0 +1,10 @@ +// This file is part of noxos and licensed under the MIT open source license + +#ifndef NOX_ACPI_H +#define NOX_ACPI_H + +#include "boot/boot_info.h" + +void acpi_init(boot_info_T* boot_info); + +#endif //NOX_ACPI_H diff --git a/kernel/inc/drivers/acpi/rsdp.h b/kernel/inc/drivers/acpi/rsdp.h new file mode 100644 index 0000000..e0b1b3b --- /dev/null +++ b/kernel/inc/drivers/acpi/rsdp.h @@ -0,0 +1,24 @@ +// This file is part of noxos and licensed under the MIT open source license + +#ifndef NOX_RSDP_H +#define NOX_RSDP_H + +#include "utils/stdtypes.h" + +typedef struct { + char signature [8]; + uint8_t checksum; + char oem_id; + uint8_t revision; + uint32_t rsdt_address; +} __attribute__((packed)) rsdp_descriptor_v1_T; + +typedef struct { + rsdp_descriptor_v1_T descriptor_v1; + uint32_t length; + uint64_t xsdt_address; + uint8_t checksum_extended; + uint8_t reserved [3]; +} __attribute__((packed)) rsdp_descriptor_v2_T; + +#endif //NOX_RSDP_H diff --git a/kernel/src/boot/limine.c b/kernel/src/boot/limine.c index ef4c840..fa196de 100644 --- a/kernel/src/boot/limine.c +++ b/kernel/src/boot/limine.c @@ -32,6 +32,11 @@ static volatile struct limine_module_request module_request = { .revision = 4 }; +static volatile struct limine_rsdp_request rsdp_request = { + .id = LIMINE_RSDP_REQUEST, + .revision = 5 +}; + void _start() { boot_info_T boot_info; @@ -85,5 +90,12 @@ void _start() { log(LOG_INFO, "( LimineEntry ) Found Ramdisk File"); boot_info.ramdisk_file = ramdisk_file; + if (rsdp_request.response == NULL) { + log(LOG_ERROR, "( LimineEntry ) no RSDP response!"); + CORE_HALT_FOREVER + } + log(LOG_INFO, "( LimineEntry ) Found RSDP"); + boot_info.rsdp = rsdp_request.response->address; + kmain(boot_info); } \ No newline at end of file diff --git a/kernel/src/drivers/acpi/acpi.c b/kernel/src/drivers/acpi/acpi.c new file mode 100644 index 0000000..dde12e3 --- /dev/null +++ b/kernel/src/drivers/acpi/acpi.c @@ -0,0 +1,8 @@ +// This file is part of noxos and licensed under the MIT open source license + +#include "drivers/acpi/acpi.h" +#include "utils/logger.h" + +void acpi_init(boot_info_T* boot_info) { + log(LOG_DEBUG, "Initializing ACPI - RSDP: 0x%x", boot_info->rsdp); +} \ No newline at end of file diff --git a/kernel/src/drivers/acpi/rsdp.c b/kernel/src/drivers/acpi/rsdp.c new file mode 100644 index 0000000..b92bff6 --- /dev/null +++ b/kernel/src/drivers/acpi/rsdp.c @@ -0,0 +1 @@ +// This file is part of noxos and licensed under the MIT open source license diff --git a/kernel/src/kmain.c b/kernel/src/kmain.c index 9fce1e6..85b6131 100644 --- a/kernel/src/kmain.c +++ b/kernel/src/kmain.c @@ -12,6 +12,8 @@ #include "drivers/time/pit.h" #include "drivers/graphics/renderer.h" #include "drivers/fs/vfs.h" +#include "drivers/acpi/acpi.h" +//#include "drivers/ps2/keyboard.h" #include "proc/scheduler.h" #include "platform/syscall.h" @@ -39,6 +41,10 @@ void kernel_init(boot_info_T* boot_info) { vfs_init(boot_info); + acpi_init(boot_info); + +// ps2_keyboard_init(); + scheduler_init(boot_info); }