From a7ef49da0e07e0a1195794b527fa400c0235fcc7 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 29 Apr 2025 20:59:46 -0400 Subject: tarfs --- kernel/main.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'kernel/main.c') diff --git a/kernel/main.c b/kernel/main.c index c15c38d..a306e2b 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -22,6 +22,36 @@ void kreport(void) gpu_report(); } +void load_init(void) +{ + struct file_system *fs; + struct file *file; + + if (pcb_alloc(&init_pcb)) + return; + + // get root fs + fs = fs_get_root_file_system(); + if (fs == NULL) + return; + + // get init bin + if (fs->open(fs, "bin/apple", &file)) + return; + + if (user_load(init_pcb, file)) { + file->close(file); + return; + } + + // close file + file->close(file); + + // schedule and dispatch init + schedule(init_pcb); + dispatch(); +} + __attribute__((noreturn)) void main(long magic, volatile void *mboot) { // initalize idt and pic @@ -49,11 +79,7 @@ __attribute__((noreturn)) void main(long magic, volatile void *mboot) kreport(); // load init process - pcb_alloc(&init_pcb); - if (user_load(init_pcb, &fs_disks[0])) - panic("failed to load init"); + load_init(); - // schedule and dispatch init - schedule(init_pcb); - dispatch(); + panic("failed to load init"); } -- cgit v1.2.3-freya