loading initrd now...

This commit is contained in:
2026-06-30 00:03:21 -05:00
parent 5983212da0
commit ce81d4eb31
8 changed files with 247 additions and 17 deletions

View File

@@ -3,7 +3,7 @@
#include "gdt.h"
#include "scheduler.h"
#include "common.h"
#include "initrd.h"
#include "vfs.h"
#include <lib/print.h>
#include <lib/stream.h>
@@ -17,6 +17,7 @@
#include <drivers/ps2/ps2.h>
#include <drivers/pit/pit.h>
#include <drivers/vga/vga.h>
#include <drivers/cpio/cpio.h>
#include <stddef.h>
#include <stdint.h>
@@ -44,12 +45,32 @@ void parse_multiboot_modules(uint32_t mbi_vaddr) {
}
}
void load_initrd() {
vfs_node_t* load_initrd() {
multiboot_module_t* initrd_module = &multiboot_module_info_table[0];
kprintf("initrd found @ [v] 0x%x\n", initrd_module->mod_start);
kprintf("reading initrd\n");
return cpio_read_fs(initrd_module->mod_start);
}
parse_cpio((void*)initrd_module->mod_start);
void load_origin_program() {
vfs_node_t* vfs_root = vfs_create_root();
vfs_node_t* initrd_root = load_initrd();
if (initrd_root) {
mount(vfs_root, initrd_root);
kprintf("initrd read, mounted @ /\n");
int fd = open("/origin.elf", 0);
if (fd == -1) {
kprintf("failed to read origin program\n");
}
void* buf = kalloc(512);
int rd = read(fd, buf, 512);
if (rd > 0) {
kprintf("read %d bytes from origin.elf\n", rd);
}
}
exit();
}
void kmain(uint32_t magic, multiboot_info* mbi) {
@@ -72,12 +93,12 @@ void kmain(uint32_t magic, multiboot_info* mbi) {
init_page_tables();
parse_multiboot_modules((uint32_t)mbi);
load_initrd();
kprintf("basic initializations complete\n");
disable_interrupts(); // just paranoid... do it again
disable_interrupts();
init_scheduler();
enable_interrupts();
create_task((uint32_t)load_origin_program, fetch_cr3());
}