diff options
author | Alexis211 <alexis211@gmail.com> | 2009-11-14 13:16:01 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-11-14 13:16:01 +0100 |
commit | 4d5c1fcf9b1616db662a5cab0cec5ac878ce5175 (patch) | |
tree | 5ae433b358f933a9cec5bc9ef3c30ba9395fe322 /Source/Kernel/Core | |
parent | 2b9e97b8635c20c5a2b87789b1014489863d1994 (diff) | |
download | Melon-4d5c1fcf9b1616db662a5cab0cec5ac878ce5175.tar.gz Melon-4d5c1fcf9b1616db662a5cab0cec5ac878ce5175.zip |
Changed some things in the way init is handled.
Also :
- Modified stuff in the GOL simulator
- Added support for a kernel-built-in keymap
Diffstat (limited to 'Source/Kernel/Core')
-rw-r--r-- | Source/Kernel/Core/kmain.wtf.cpp | 93 |
1 files changed, 57 insertions, 36 deletions
diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp index e3344f1..d812c9a 100644 --- a/Source/Kernel/Core/kmain.wtf.cpp +++ b/Source/Kernel/Core/kmain.wtf.cpp @@ -133,6 +133,8 @@ void kmain(multiboot_info_t* mbd, u32int magic) { Mem::placementAddress = mods[i].mod_end + 0x1000; } + //************************************** BASIC KERNEL SETUP + //Create text output VGATextOutput *vgaout = new VGATextOutput(); Disp::setText(vgaout); @@ -151,58 +153,77 @@ void kmain(multiboot_info_t* mbd, u32int magic) { PhysMem::removeTemporaryPages(); //Remove useless page mapping Mem::createHeap(); //Create kernel heap + Dev::registerDevice(vgaout); Dev::registerDevice(new Timer()); //Initialize timer - Task::initialize(String((char*)mbd->cmdline), kvt); //Initialize multitasking + String kcmdline((char*)mbd->cmdline); + Task::initialize(kcmdline, kvt); //Initialize multitasking - FileSystem* fs = RamFS::mount((u8int*)mods[0].mod_start, 1024 * 1024, NULL); - DirectoryNode* cwd; - cwd = fs->getRootNode(); - Task::currProcess()->setCwd(cwd); - VFS::setRootNode(cwd); + asm volatile("sti"); - Log::init(KL_STATUS); //Setup logging - Log::log(KL_STATUS, "kmail : Melon booting."); + //*************************************** PARSE COMMAND LINE + + Vector<String> opts = kcmdline.split(" "); + String keymap = "fr", init = "/System/Applications/PaperWork.app"; + bool enableVESA = true; + for (u32int i = 0; i < opts.size(); i++) { + Vector<String> opt = opts[i].split(":"); + if (opt[0] == "vesa" && opt[1] != "enabled") enableVESA = false; + if (opt[0] == "keymap") keymap = opt[1]; + if (opt[0] == "init") init = opt[1]; + } - Dev::registerDevice(vgaout); - Log::log(KL_STATUS, "kmain : Registered textual VGA output"); - Dev::registerDevice(new VESADisplay()); - Log::log(KL_STATUS, "kmain : Created VESA display"); + //*************************************** DEVICE SETUP + if (enableVESA) Dev::registerDevice(new VESADisplay()); + FloppyController::detect(); Dev::registerDevice(new PS2Keyboard()); //Initialize keyboard driver - if (!Kbd::loadKeymap("fr")) Log::log(KL_ERROR, "kmain : could not load french keymap."); Kbd::setFocus(kvt); //Set focus to virtual terminal - Log::log(KL_STATUS, "kmain : Keyboard set up"); - asm volatile("sti"); + //*************************************** MOUNT ROOT FILESYSTEM - selectVideoMode(*kvt); //////////////////////// SETUP VIDEO MODE + FileSystem* fs = RamFS::mount((u8int*)mods[0].mod_start, 1024 * 1024, NULL); + DirectoryNode* cwd; + cwd = fs->getRootNode(); + Task::currProcess()->setCwd(cwd); + VFS::setRootNode(cwd); - //Create a VT for handling the Melon bootup logo - SimpleVT *melonLogoVT = new SimpleVT(melonLogoLines, melonLogoCols, TXTLOGO_FGCOLOR, TXTLOGO_BGCOLOR); - melonLogoVT->map(1); - new Thread(logoAnimation, (void*)melonLogoVT, true); + if (keymap != "builtin") { + if (!Kbd::loadKeymap(keymap)) *kvt << "\nWARNING : Could not load keymap " << keymap << ", using built-in keymap instead."; + } - FloppyController::detect(); - Log::log(KL_STATUS, "kmain : Floppy drives detected"); + Log::init(KL_STATUS); //Setup logging + Log::log(KL_STATUS, "kmain : Melon booting."); - Usr::load(); + Usr::load(); //Setup user managment Log::log(KL_STATUS, "kmain : User list loaded"); - Process* p = Process::run("/System/Applications/PaperWork.app", 0); - if (p == 0) { - PANIC("Could not launch PaperWork !"); + if (init.empty()) { + *kvt << "\n\n"; + new KernelShell(cwd, kvt); + while (1) asm volatile("sti; hlt"); } else { - Log::log(KL_STATUS, "kmain : Starting PaperWork (init)"); - VirtualTerminal* vt = new ScrollableVT(Disp::textRows() - 10, Disp::textCols() - 4, - 200, SHELL_FGCOLOR, SHELL_BGCOLOR); - Kbd::setFocus(vt); - ((ScrollableVT*)vt)->map(9); - p->setInVT(vt); - p->setOutVT(vt); - p->start(); - while (p->getState() != P_FINISHED) Task::currThread()->sleep(100); - PANIC("PaperWork finished."); + selectVideoMode(*kvt); + //Create a VT for handling the Melon bootup logo + SimpleVT *melonLogoVT = new SimpleVT(melonLogoLines, melonLogoCols, TXTLOGO_FGCOLOR, TXTLOGO_BGCOLOR); + melonLogoVT->map(1); + new Thread(logoAnimation, (void*)melonLogoVT, true); + + Process* p = Process::run(init, 0); + if (p == 0) { + PANIC((char*)(u8int*)ByteArray(String("Could not launch init : ") += init)); + } else { + Log::log(KL_STATUS, String("kmain : Starting init : ") += init); + VirtualTerminal* vt = new ScrollableVT(Disp::textRows() - 10, Disp::textCols() - 4, + 200, SHELL_FGCOLOR, SHELL_BGCOLOR); + Kbd::setFocus(vt); + ((ScrollableVT*)vt)->map(9); + p->setInVT(vt); + p->setOutVT(vt); + p->start(); + while (p->getState() != P_FINISHED) Task::currThread()->sleep(100); + Sys::halt(); + } } PANIC("END OF KMAIN"); |