feature (kernel): Requesting RAMDISK archive module from bootloader

This commit is contained in:
antifallobst 2023-02-23 00:25:00 +01:00
parent c32988aa72
commit 87ee378144
5 changed files with 53 additions and 6 deletions

View File

@ -32,6 +32,11 @@ limine_install() {
echo "" echo ""
} }
generate_initial_ramdisk() {
echo " --> Generating initrd"
tar -C ramdisk -cvf build/initrd.tar .
}
generate_image() { generate_image() {
echo " --> Generating Image" echo " --> Generating Image"
cd build cd build
@ -43,6 +48,7 @@ generate_image() {
cp limine/limine-cd-efi.bin iso cp limine/limine-cd-efi.bin iso
cp limine/limine.sys iso cp limine/limine.sys iso
cp ../limine.cfg iso cp ../limine.cfg iso
cp initrd.tar iso
cp cmake/kernel/kernel iso/kernel.elf cp cmake/kernel/kernel iso/kernel.elf
xorriso -as mkisofs -b limine-cd.bin \ xorriso -as mkisofs -b limine-cd.bin \
@ -64,6 +70,7 @@ echo "!=====[ NoxOS build script ]=====!"
workspace_setup workspace_setup
kernel_build kernel_build
[ ! -d "build/limine" ] && limine_install [ ! -d "build/limine" ] && limine_install
generate_initial_ramdisk
generate_image generate_image
echo "!=====[ Finished ]=====!" echo "!=====[ Finished ]=====!"

View File

@ -23,7 +23,8 @@ typedef struct {
struct limine_framebuffer_response* framebuffer; struct limine_framebuffer_response* framebuffer;
struct limine_terminal_response* terminal; struct limine_terminal_response* terminal;
struct limine_memmap_response* memory_map; struct limine_memmap_response* memory_map;
struct limine_kernel_file_response* kernel_file; struct limine_file* kernel_file;
struct limine_file* ramdisk_file;
void* rsdp; void* rsdp;
} boot_info_T; } boot_info_T;

View File

@ -16,6 +16,7 @@
#include "boot/boot_info.h" #include "boot/boot_info.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "utils/core.h" #include "utils/core.h"
#include "utils/memory.h"
extern void kmain(boot_info_T boot_info); extern void kmain(boot_info_T boot_info);
@ -39,6 +40,11 @@ static volatile struct limine_kernel_file_request kernel_file_request = {
.revision = 3 .revision = 3
}; };
static volatile struct limine_module_request module_request = {
.id = LIMINE_MODULE_REQUEST,
.revision = 4
};
void _start() { void _start() {
boot_info_T boot_info; boot_info_T boot_info;
@ -69,7 +75,28 @@ void _start() {
CORE_HALT_FOREVER CORE_HALT_FOREVER
} }
log(LOG_INFO, "( LimineEntry ) Found Kernel File"); log(LOG_INFO, "( LimineEntry ) Found Kernel File");
boot_info.kernel_file = kernel_file_request.response; boot_info.kernel_file = kernel_file_request.response->kernel_file;
if (module_request.response == NULL) {
log(LOG_ERROR, "( LimineEntry ) no module response!");
CORE_HALT_FOREVER
}
struct limine_file* ramdisk_file = NULL;
for (int i = 0; i < module_request.response->module_count; i++) {
struct limine_file* file = module_request.response->modules[i];
log(LOG_INFO, "( LimineEntry ) MODULE: %s", file->path);
if (memory_compare(file->path, "/initrd.tar", string_length(file->path))) {
ramdisk_file = file;
}
}
if (ramdisk_file == NULL) {
log(LOG_ERROR, "( LimineEntry ) no ramdisk module!");
CORE_HALT_FOREVER
}
log(LOG_INFO, "( LimineEntry ) Found Ramdisk File");
boot_info.ramdisk_file = ramdisk_file;
kmain(boot_info); kmain(boot_info);
} }

View File

@ -3,3 +3,4 @@ TIMEOUT=2
:NoxOS :NoxOS
PROTOCOL=limine PROTOCOL=limine
KERNEL_PATH=boot:///kernel.elf KERNEL_PATH=boot:///kernel.elf
MODULE_PATH=boot:///initrd.tar

11
ramdisk/test.txt Normal file
View File

@ -0,0 +1,11 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin molestie porta erat eu interdum.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
Cras semper porta ligula quis condimentum.
Aliquam sed bibendum diam, sit amet gravida orci.
Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Proin vitae urna vel magna luctus pulvinar.
Etiam diam diam, vulputate nec eros a, bibendum tristique velit.
Donec interdum consectetur vehicula.
Vestibulum gravida varius nisi non fringilla.
Nam eu accumsan erat, ac condimentum massa.