diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-29 20:59:46 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-30 11:44:28 -0400 |
commit | a7ef49da0e07e0a1195794b527fa400c0235fcc7 (patch) | |
tree | ded5d2b9f075411327e6bb573fa754ee5b5720a6 /kernel/main.c | |
parent | fmt (diff) | |
download | comus-a7ef49da0e07e0a1195794b527fa400c0235fcc7.tar.gz comus-a7ef49da0e07e0a1195794b527fa400c0235fcc7.tar.bz2 comus-a7ef49da0e07e0a1195794b527fa400c0235fcc7.zip |
tarfs
Diffstat (limited to 'kernel/main.c')
-rw-r--r-- | kernel/main.c | 38 |
1 files changed, 32 insertions, 6 deletions
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"); } |