From 7d5a38ada35ac196919c26675f211adb995b84ae Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Fri, 18 May 2012 14:47:44 +0200 Subject: Added initrd. Status: VFS support, totally useless shell. --- src/kernel/core/kmain.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/kernel/core') diff --git a/src/kernel/core/kmain.cpp b/src/kernel/core/kmain.cpp index 9ec06df..58a3c48 100644 --- a/src/kernel/core/kmain.cpp +++ b/src/kernel/core/kmain.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -76,16 +77,30 @@ extern "C" void kmain(multiboot_info_t* mbd, int32_t magic) { // Load modules *ke_vt << "Loading modules :\n"; for (unsigned i = 0; i < mbd->mods_count; i++) { - *ke_vt << " * " << (char*)mods[i].string; + char* cmd = (char*)mods[i].string; + *ke_vt << " * " << cmd << " \t"; if (elf_check((uint8_t*)mods[i].mod_start) == 0) { process *pr = elf_exec((uint8_t*)mods[i].mod_start, PL_USER); if (pr == 0) { - *ke_vt << " : Error loading\n"; + *ke_vt << "Error loading\n"; } else { - *ke_vt << " : OK, pid=" << (int)pr->pid << "\n"; + *ke_vt << "OK, pid=" << (int)pr->pid << "\n"; + } + } else if (initrd_check((uint8_t*)mods[i].mod_start) == 0) { + vdir* fs = new vdir(root); + int e = initrd_load((uint8_t*)mods[i].mod_start, fs); + if (e == 0) { + char* name = cmd; + for (char* i = name; *i != 0; i++) { + if (*i == '/' || *i == ' ') name = i + 1; + } + root->add_child(name, fs); + *ke_vt << "OK, initrd as /" << name << "/\n"; + } else { + *ke_vt << "initrd but error " << e << "\n"; } } else { - *ke_vt << " : Invalid ELF file\n"; + *ke_vt << "Invalid file, neither ELF nor initrd.\n"; } } -- cgit v1.2.3