Example #1
0
void kmain(multiboot_info_t* mbd, unsigned int magic){
	// kernel entry point.
	//unsigned char* videoram = (unsigned char*) 0xb8000;
	//videoram[0] = 65;
	//videoram[1] = 0x07;
	//setMode(0x13);
	setMode(320, 200, 8); // HOLY SHIT THIS WORKS
	clrscr();
	gdt_install();
	idt_install();
	isrs_install();
	irq_install();
	timer_install();
	start_paging(mbd);
	keyboard_install();
	init_genrand(get_timer_ticks());
	__asm__ __volatile__ ("sti");
	kprint("Hello, We have booted successfully!\n\tTip: type help for command info\n");
		
	while(1){
		if(todo != NULL){
			void(*function)() = todo;
			function(todoCP);
			todo = NULL;
		}
	}
	
}
Example #2
0
File: kernel.c Project: ajxs/jxos
void kernel_init(boot_info_t bootInfo) {
	tty_init();

	multiboot_init(bootInfo.multiboot_magic, bootInfo.multiboot_addr);
	if(a20_enable()) {
		serial_writestring(1, "A20 enable failed - triggering panic\n");
		kernel_panic();
	};
	gdt_install();
	idt_install();
	irq_install();
	_protected_mode_init();

	paging_init();
	_paging_enable();

	PIC_init();
	serial_init();
	keyboard_init();
	timer_init();

	serial_writestring(1, "End kernel_init\n");

	kernel_main();
};
Example #3
0
File: main.cpp Project: rstat1/Plex
void kernel_main(struct multiboot_info *mboot, int initial_stack)
{
    long int mem = 0;
	mboot_info = mboot;
	start_video();
    putstr("Init Descriptor Tables................."); 
    gdt_install(); 
    idt_install();
    putstr("[OK]\n"); 
    putstr("Init ISRs.............................."); 
    isr_install();    
    putstr("[OK]\n"); 
    putstr("Init IRQs.............................."); 
    irq_install(); 
    __asm__ __volatile__ ("sti");   
    putstr("[OK]\n"); 
    putstr("Init PIT..............................."); 
    timer_install();
    putstr("[OK]\n");    
    putstr("Amount of memory......................");
    mem = mboot->mem_upper / 1024; 
    putnum(mem);
    putstr("MB\n");
	putstr("Init Memory............................");
	init_memory_manager();
    putstr("\n\n");     
    putstr("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWelcome to Plex!");
    for (;;); 
}
Example #4
0
void kmain(unsigned long magic, multiboot_info_t * mbi)
{
   if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
   {
      printk ("Invalid magic number: 0x%x\n", (unsigned) magic);
      return;
   }

   gdt_install();
   idt_install();
   
   init_video();
   isrs_install();
   irq_install();
   timer_install();
   
   sys_setup(mbi);

   test_inode();
   
   __asm__ __volatile__ ("sti");

   printk("EgGS:hello there!\n");

//   int i = 10 / 0;

   for (;;);
}
Example #5
0
void init_descriptors()
{
	gdt_install();
	idt_install();
	init_handlers();
	irq_install();
}
Example #6
0
int irq_init(void)
{
	idt_install();
	isrs_install();
	irq_install();

	return 0;
}
Example #7
0
File: kernel.cpp Project: k1-801/os
void kernel_main(struct mboot_info_struct *mbinfo)
{
	//	addr = (int*) kernel_main;
	//
	log("[LOAD] " DISTNAME " kernel is started. Disabling interrupts...");
	log("[DISCLAIMER] " DISTNAME " is totally free. If you have bought it, please report us seller's contact information to prevent further project law violation.");
	asm("cli");
	log("done.");
	log("[INFO] Setting up GDT...");
	gdt_install();
	log("done.");
	log("[INFO] Setting up IDT...");
	idt_install();
	log("done.");
	log("[INFO] Setting up ISRs...");
	isrs_install();
	log("done.");
	log("[INFO] Setting up IRQ handlers...");
	irq_install();
	log("done.");
	asm("sti");
	log("[INFO] Setting up fonts...");
	setupFonts();
	log("done.");
	log("[INFO] Initializing PIC...");
	//kprint("OS365 Kernel 1.0 is loaded.\nInitializing PIC...",0,0);
	init_pics(0x20,0x28);
	log("done.");
	//setupPaging();
	//asm("int $8");
	//kprint("\nAll pre-start processes are finished. Preparing to load shell...\n",0,8);
	log("[INFO] Setting VBE graphics mode...");
	//sleep(18);
	//setGraphicsMode();
	vbe_info_t* vbeInfo=(vbe_info_t*)(uint32_t)mbinfo->vbe_mode;
	framebuffer        =(uint8_t*)(mbinfo->framebuffer_addr);
	fbpitch            =mbinfo->framebuffer_pitch;
	fbbpp              =mbinfo->framebuffer_bpp;

	//memset((void*)framebuffer,0x004DFF,1024*768*3);
	initKbd();
	log("done.");
	//mouse_install();
	log("[INFO] Setting up the timer...");
	setupPIT();
	log("done.");
	log("[INFO] Loading Z Window System...");
	//abort();
	while(true)
	{
		shellStart();
		fRun=true;
		log("[WARNING] Error in program: Not returned to Z");
		log("[INFO] Getting back to Z...");
	}
}
Example #8
0
File: isr.c Project: bajdcc/MiniOS
void isr_init() {
    fault_init();
    /* treat unkown interrupt as fault */
    int i;
    for (i = ISR_IRQ0; i < NIDT; i++) {
        idt_install(i,(uint32_t)isr_unknown, SEL_KCODE << 3, GATE_INT, IDT_PR|IDT_DPL_KERN);
    }

    irq_init();
    sys_init();
}
Example #9
0
File: main.c Project: reijnden/rho
/*
 * Called from boot.S, after global constructor
 */
void kernel_main(multiboot_info *mbt)
{
	/*
	 * second argument is an 8 bit flag. low bit sets verbosity.
	 */
	boot_info(mbt,MB_DRIVE | MB_DEV);
	printf ("Setting up Global Descriptor Table... ");
	gdt_install();
	puts ("OK");
	printf ("Setting up Interrupt Descriptor Table... ");
	idt_install();
	puts ("OK");
	printf ("Setting up IRQ... ");
	irq_install();
	puts ("OK");
	printf ("Configuring system clock... ");
	timer_install(100);
	puts ("OK");
	printf ("Enabling keyboard... ");
	keyboard_install();
	puts ("OK");
	printf ("Enabling interrupts... ");
	irq_enable();
	if (irq_on()) {
		puts ("OK");
	} else {
		abort();
	}
	/*
	 * Testing cr0 register
	 */
	uint32_t _cr0 = cr0();
	printf("PE (Protection Enabled, lowest bit of cr0 register) set? 0x%lx, %s\n",
			_cr0,_cr0&0x00000001?"yes":"no");

	printf("Rho version %d.%d.%d booted\n",RHO_MAJOR,RHO_MINOR,RHO_PATCH);
	checkAllBuses();
	/*
	 * Wait until interrupted
	 */
//	mem_inspect(1024,1536);
	while ( 1 ) {
		/*
		 * Update the cursos position
		 */
		upd_c();
		/*
		 * Wait for interrupts
		 */
		irq_wait();
	}
	/* */
}
Example #10
0
void x86_init()
{
	gdt_install();
	idt_install();
	isrs_install();
	apic_init();	/* apic */
	irq_install();
	
	console_init();
	
	timer_install();
	init_keyboard();
}
Example #11
0
void kernel_main(multiboot_info_t* mbd,unsigned int magic) {
	/* Initialization */
	terminal_initialize();
	kprint("Kernel Loading...\nInitializing GDT......");
 	gdt_install();
	kprint("DONE\nInitializing IDT......");
	idt_install();
	kprint("DONE\n");
	total_memory=mbd->mem_upper;
	total_memory*=1024;
	
	enter_pmode();	
	
}
Example #12
0
int main () {
	
	screen_setup ();
	idt_install ();
	__asm__ __volatile__ ("sti");
	
	sleep (5);
	cls ();
	puts ("> ");
	putsbar ("\t\t\t\tchat with CPU...", -1);
	
	while (1);
	return 0;

}
Example #13
0
void kmain(struct multiboot_info *mbt)
{
    vga_init();

    gdt_install();
    idt_install();
    isr_install();
    irq_install();
    syscalls_install();

    puts_c(__kernel_name " kernel v" __kernel_version_str "\n\n", COLOR_LIGHT_BLUE, COLOR_DEFAULT_BG);

    uint64_t mem;
    get_multiboot_info(mbt, &mem);

    extern uint32_t _kernel_memory_end[];
    kprintf("End of kernel's memory: 0x%x\n", (uint64_t) (uint32_t) _kernel_memory_end);
    kprintf("Memory:\n%l B\n%l KB\n%l MB\n%l GB\n", mem, mem / 1024, mem / 1024 / 1024, mem / 1024 / 1024 / 1024);
    
    init_paging();
    map_page(0xFD7FF000, 0x60000, 3);
    int *p = (int *) 0xFD7FF000;
    *p = 12;
    kprintf("*(0x%x) = %i\n", (uint64_t) (uint32_t) p, *p);

    map_page(0x10000000, 0x60000, 3);
    int *p2 = (int *) 0x10000000;
    kprintf("*(0x%x) = %i\n", (uint64_t) (uint32_t) p2, *p2);

    print_next_available_page();
    uint32_t ap = allocate_page(203);
    map_page(ap, 0x60000, 3);
    int *p3 = (int *) ap;
    kprintf("*(0x%x) = %i\n", (uint64_t) ap, *p3);

    print_next_available_page();
    ap = allocate_page(203);
    kprintf("ap = 0x%x\n", (uint32_t) ap);

    struct kthread thread;
    create_kthread(thread_test, &thread);
    start_kthread(&thread);
    kprintf("Returned from thread.\n");

    _asm_print_test();

    return;
}
Example #14
0
File: main.c Project: pranas/jaos64
void kernel_entry (multiboot_info* bootinfo) 
{
	clear_screen();	puts("Kernel loaded.\n");
	gdt_install();  puts("GDT initialised.\n");
	idt_install();	puts("IDT initialised.\n");
    memman_init(bootinfo);
	kheap_init();
	fat32_init();
	// TODO: figure out how to do it safely
	//acpi_init();
	apic_init();
	ioapic_init(); // keyboard only for now

	register_handler(0x21, keyboard_handler);
	register_handler(0xD, gpf_handler);

	syscalls_init(); // maybe syscalls_init() like acpi_init, apic_init, etc... there should be common naming

	timer_init(0x20, 0x002fffff, 0xB, 1); // vector, counter, divider, periodic -- check manual before using

	// sets up kernel task and registers handler for timer
	scheduler_init();
	// registers locking sys
	monitor_init();
	keyboard_init();

	// testing scheduler
    if (fork_kernel() == 0)
    {
        if (!exec("SHELL"))
        {
            // something horrible happend
            // exit()
        }
        exit();
    }
    else
    {
        for(;;)
        {
			asm volatile("hlt");
        }
    }
	
	asm ("sti"); // release monsters, it can be set earlier, but fails horribly if set before acpi_init
    for(;;);
}
Example #15
0
void main()
{
	gdt_install(3) ;
	init_video(&sc) ;  
	idt_install() ; 
	isrs_install() ; 
	irq_install() ; 
	timer_install() ; 
	keyboard_install() ;
	__asm__ __volatile__ ("sti"); 
	int state = 0 ; 
	screen sc  ;  
	//puts(&sc, "Hello world in new functions\n") ; 
	print_int(&sc, state) ;  
	/* Since there is no support for newlines in terminal_putchar yet, \n will
	   produce some VGA specific character instead. This is normal. */
}
Example #16
0
int kernel_main(uint32_t esp) {
  initial_esp = esp;

  gdt_install();
  idt_install();
  isrs_install();
  irq_install();

  asm volatile("sti");

  timer_install();

  keyboard_install();

  ASSERT(mboot_ptr != 0);
  ASSERT(mboot_ptr->mods_count > 0);
  uint32_t initrd_location = *((uint32_t*)mboot_ptr->mods_addr);
  uint32_t initrd_end = *(uint32_t*)(mboot_ptr->mods_addr + 4);
  // move the start of our kernel heap to past the initrd
  placement_address = initrd_end;

  initialize_paging();

  initialize_tasking();

  fs_root = initialize_initrd(initrd_location);

  // Create a new process in a new address space which is a clone of this.
  int ret = fork();

  printf("fork() returned %x, ", ret);
  printf(" getpid() returned %x\n", getpid());

  printf("Loading initial ramdisk...\n");

  asm volatile("cli");
  traverse_initrd();
  asm volatile("sti");

  printf("That's all folks\n");

  for(;;);

  return 0;
}
Example #17
0
int kmain(void* UNUSED(mbd), unsigned int UNUSED(magic))
{
    cpu_init();					//set up GDT
    idt_install();				//set up IDT
	interrupts_init();			//set up callback table
	pic_init();					//set up PIC

    print_clear();
    print_string_static("Hello... I'm a C Kernel!1!!\nAnd I have a PIC and PIT intialized.\n");
    
	interrupts_enable();
	interrupts_registerHandler(IRQ_TIMER, timerHandler);
	pit_init(50);
	pic_unmask_irq(IRQ_TIMER);
    
	for(;;);
    return 0;
}
Example #18
0
void main(void)
{

   gdt_install();
   idt_install();
   isrs_install();
   irq_install();
   timer_install();
   keyboard_install();
   mouse_install();

   __asm__ __volatile__ ("sti");

   clear_keyboard_buffers();
   clear(BLACK,BLACK);
   bscreen();
   for (;;);
}
Example #19
0
void kernel_main(){

    console_initialize();

    gdt_install();
    idt_install();
    isrs_install();
    irq_install();
    timer_install();
    keyboard_install();
    __asm__ __volatile__ ("sti");
    
	console_putString("Hello, kernel World!\n");

    for (;;){
        
    }
}
Example #20
0
void kernel_main()
{
	terminal_initialize();
	kprintf("Identifying CPU...", COLOR_WHITE);
	cpuid_t cpu_data = get_cpuid();
	kprintf(cpu_data.make, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Type: ", COLOR_WHITE);
	kprintf(itoa(cpu_data.family), COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Family: ", COLOR_WHITE);
	kprintf(cpu_data.family, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Model: ", COLOR_WHITE);
	kprintf(cpu_data.model, COLOR_WHITE);
	kprintf("\n", COLOR_WHITE);
	kprintf("Enabling A20 Line...\n", COLOR_WHITE);
	enable_a20();
	kprintf("Initilizing VGA Driver....\n",COLOR_WHITE);
	kprintf("Installing Global Descriptor Table....\n",COLOR_WHITE);
	gdt_install();
	kprintf("Installing Interrupt Descriptor Table....\n",COLOR_WHITE);
	idt_install();
	kprintf("Enabling paging...\n", COLOR_WHITE);
	init_paging();
	kprintf("Setting up ISRs...\n",COLOR_WHITE);
	isrs_install();
	kprintf("Remapping the PIC and setting up IRQs...\n",COLOR_WHITE);
	install_irq();
	kprintf("Initializing the Kernel Address Translation Table...\n", COLOR_WHITE);
	kATT_Init();
	kprintf("Identifying ATA drives.....\n", COLOR_WHITE);
	ATA_Init();
	kprintf(DRIVE_DATA, COLOR_WHITE);
        kprintf("Installing Timer ISR....\n",COLOR_WHITE);
 	timer_install();
//	kprintf("Checking PCI device vendors....\n",COLOR_WHITE);
//	init_PCI();
	kprintf("Starting shell....\n",COLOR_WHITE);

	init_shell();

	for (;;);
}
Example #21
0
void kmain ( void* mbd, unsigned int magic )
{
        if ( magic != 0x2BADB002 )
        {
		/* there is something wrong */
        } 
	else 
	{
		clearscreen();
		printline ("akv's - code is running");
		gdt_install ();
		idt_install ();
		isrs_install ();
		irq_install ();
		__asm__ __volatile__ ("sti");
		timer_install (2);
		keyboard_install ();
		for(;;);
	}
}
Example #22
0
void kmain( void* mbd, unsigned int magic )
{
	/* Installations */
	gdt_install();
	idt_install();
	isrs_install();
	irq_install();
	timer_install();
	keyboard_install();
	init_video();
	
	__asm__ __volatile__ ("sti"); // Disable interrupts

	settextcolor(0x0F, 0x00);

	unsigned char string[] = "Welcome to Gulinux 0.01. For a list of commands, type help.\n";

	putsa(string);
	for(;;);
}
Example #23
0
void kernel_main() {
  gdt_install();
  idt_install();
  isrs_install();
  irq_install();
  terminal_initialize();
  memory_manager_init();
  enable_interrupts();
  timer_install();
  keyboard_install();
  shell_init();

  terminal_writestring("Hello, kernel World!\n");
  terminal_writestring("Here is some text in a new line\n");
  terminal_writestring("Here is some more text\n");
  terminal_writestring("Here is a new line\n");
  terminal_writestring("Here is some text after terminal scroll\n");
  char str[] = "A string";
  char ch = 'c';
  int integer = 45;
  printf("This is a test for printf.\nThis is a char %c and this a string %s\n", ch, str);
  printf("This is an int %d. This is the same in hex %x\n", integer, integer);

  for (size_t i = 0; i < 5; i++) {
    printf("This is line number %d\n", i);
  }

  puts("waiting for 2 sec\n");
  timer_wait(2);
  puts("waiting complete\n");

  char buffer[200];
  gets(buffer);
  printf("%s\n", buffer);
  while(1) {
    shell();
  }

}
Example #24
0
File: kernel.c Project: drewt/Telos
//-----------------------------------------------------------------------------
void kmain(struct multiboot_info *info, unsigned long magic)
{
	#define bprintf(fmt, ...) _kprintf(0xA, fmt, ## __VA_ARGS__)

	mb_info = info;

	// initialize console so we can print boot status
	console_clear(0);

	// check multiboot magic number
	if (magic != MULTIBOOT_BOOTLOADER_MAGIC) {
		kprintf("Invalid Multiboot magic number\n");
		return;
	}

	bprintf("32 bit Telos " VERSION "\n");

	bprintf("Initializing machine state...\n");
	idt_install();
	gdt_install();
	pic_init(0x20, 0x28);	// map IRQs after exceptions/reserved vectors
	pit_init(100);		// 10ms timer
	clock_init();

	bprintf("Initializing kernel subsystems...\n");
	init_subsystems();

	bprintf("\n----------- MEMORY -----------\n");
	bprintf("Kernel:    %p - %p\n", &_kstart, &_kend);
	bprintf("Userspace: %p - %p\n", &_ustart, &_uend);
	bprintf("Total:     %lx bytes\n", MULTIBOOT_MEM_MAX(mb_info));

	mount_root();

	bprintf("Starting Telos...\n\n");
	sched_start();

	#undef bprintf
}
Example #25
0
void
idt_init(void)
{
	extern struct Segdesc gdt[];

	// Setup a TSS so that we get the right stack
	// when we trap to the kernel.
	ts.ts_esp0 = KSTACKTOP;
	ts.ts_ss0 = GD_KD;

	// Love to put this code in the initialization of gdt,
	// but the compiler generates an error incorrectly.
	gdt[GD_TSS >> 3] = SEG16(STS_T32A, (u_long) (&ts),
					sizeof(struct Taskstate), 0);
	gdt[GD_TSS >> 3].sd_s = 0;

	// Load the TSS
	ltr(GD_TSS);
    idt_install();
	// Load the IDT
	asm volatile("lidt idt_pd+2");
}
Example #26
0
File: main.c Project: ayllon/dalek
void main(BootInformation* boot_info)
{
    asm("cli");
    // Memory
    mm_initialize(boot_info);
    // IDT and IRQ
    idt_install();
    irq_install();
    // Install handlers
    timer_init();
    // Re-enable interrupts
    asm("sti");
    // Initialize IO
    io_init();
    // Initialize modules
    mod_init_all();

    // Welcome
    printf("Stage 2 loaded from drive %i\n", boot_info->boot_drive);

    printf("%d entries found for the memory\n", boot_info->smap_size);
    int i = 0;
    for (i = 0; i < boot_info->smap_size; ++i) {
        SMAPEntry *ent = &(boot_info->smap_entries[i]);
        printf("\tACPI Flags 0x%x Type %d ",
                ent->acpi & 0x03, ent->type);
        printf("Base 0x%016llx\tSize %lld\n", ent->base, ent->length);
    }

    // Launch command line interpreter
    cli_start();

    // Should never reach this, but just in case...
    while (1)
        asm("hlt");
}
Example #27
0
void main()
{
	char *video_memory = (char *)0xb8000;
	*video_memory = 'X';
	some_function();

	init_video();

	idt_install();
	isr_install();
	irq_install();

	timer_install();
	keyboard_install();

	__asm__ __volatile__ ("sti");

	print("Hello World\n");

	print("\n\tFrom Ajay Saini!\n");

	// test : running of exception handlers
	//print(20/0);
}
Example #28
0
/* This is the entry point to the bulk of the kernel.
 * @mb is a pointer to a <multiboot_info> structure which has important
 * information about the layout of memory which is passed along from the
 * bootloader.
 * First, the kernel sets up the <gdt> or Global Descriptor Table which
 * describes the layout of memory.
 * Next, it installs the <idt> or interrupt descriptor table, which declares
 * which interrupts are available, and whether they can be accessed from user
 * mode.
 * After the basic CPU state has been initialized, logging and the VGA terminal
 * are initialized, and the kernel heap is installed. Next, the physical memory
 * allocator and the keyboard drivers are initialized. Note that the kernel
 * heap must be initialized before the physical memory allocator since certain
 * parts of the allocator live on the heap. Finally the init process page table
 * is created, and multi-processing is initialized.
 * @return this function should never return.
*/
void kernel_main(struct multiboot_info *mb) {
    gdt_install();
    idt_install();
    terminal_initialize();
    initialize_klog();
    kheap_install((struct kheap_metadata*)KHEAP_PHYS_ROOT, PAGE_SIZE);
    physical_allocator_init(mb->mem_upper + mb->mem_lower);
    keyboard_install();
    char *hi = "Hello kernel!\n";
    void *testing = kmalloc(16);
    memcpy(testing, hi, 16);
    kputs(testing);
    klog(testing);
    kfree(testing);
    (void)kernel_page_table_install(mb);

    proc_init();
    struct process *worker_proc = create_proc(worker);
    schedule_proc(worker_proc);

    while (1) {
        klog("kernel\n");
    }
}
Example #29
0
/**
 * Run kernel.
 */
void kmain()
{
    gdt_install();
    idt_install();
    isr_install();
    irq_install();
    clock_install();

    vga_init();
    vga_write("Bandit Kernel v0.0.1\n");
    vga_write("Developer: Matheus Vieira Portela\n");
    vga_write("Contact: matheusvportela at gmail dot com\n\n");

    clock_set_frequency(1);

    /* test_division_by_zero_exception(); */

    /* Kernel infinite loop */
    while(1)
    {
        vga_write("tick\n");
        clock_wait(18);
    }
}
Example #30
0
File: main.c Project: etel/ponyos
/*
 * multiboot i386 (pc) kernel entry point
 */
int kmain(struct multiboot *mboot, uint32_t mboot_mag, uintptr_t esp) {
	initial_esp = esp;
	extern char * cmdline;

	uint32_t mboot_mods_count = 0;
	mboot_mod_t * mboot_mods = NULL;
	mboot_ptr = mboot;

	ENABLE_EARLY_BOOT_LOG(0);

	assert(mboot_mag == MULTIBOOT_EAX_MAGIC && "Didn't boot with multiboot, not sure how we got here.");
	debug_print(NOTICE, "Processing Multiboot information.");

	/* Initialize core modules */
	gdt_install();      /* Global descriptor table */
	idt_install();      /* IDT */
	isrs_install();     /* Interrupt service requests */
	irq_install();      /* Hardware interrupt requests */

	if (mboot_ptr->flags & (1 << 3)) {
		debug_print(NOTICE, "There %s %d module%s starting at 0x%x.", mboot_ptr->mods_count == 1 ? "is" : "are", mboot_ptr->mods_count, mboot_ptr->mods_count == 1 ? "" : "s", mboot_ptr->mods_addr);
		debug_print(NOTICE, "Current kernel heap start point would be 0x%x.", &end);
		if (mboot_ptr->mods_count > 0) {
			uintptr_t last_mod = (uintptr_t)&end;
			uint32_t i;
			mboot_mods = (mboot_mod_t *)mboot_ptr->mods_addr;
			mboot_mods_count = mboot_ptr->mods_count;
			for (i = 0; i < mboot_ptr->mods_count; ++i ) {
				mboot_mod_t * mod = &mboot_mods[i];
				uint32_t module_start = mod->mod_start;
				uint32_t module_end   = mod->mod_end;
				if ((uintptr_t)mod + sizeof(mboot_mod_t) > last_mod) {
					/* Just in case some silly person put this *behind* the modules... */
					last_mod = (uintptr_t)mod + sizeof(mboot_mod_t);
				}
				debug_print(NOTICE, "Module %d is at 0x%x:0x%x", i, module_start, module_end);
				if (last_mod < module_end) {
					last_mod = module_end;
				}
			}
			debug_print(NOTICE, "Moving kernel heap start to 0x%x", last_mod);
			kmalloc_startat(last_mod);
		}
	}

	paging_install(mboot_ptr->mem_upper + mboot_ptr->mem_lower);
	if (mboot_ptr->flags & (1 << 6)) {
		debug_print(NOTICE, "Parsing memory map.");
		mboot_memmap_t * mmap = (void *)mboot_ptr->mmap_addr;
		while ((uintptr_t)mmap < mboot_ptr->mmap_addr + mboot_ptr->mmap_length) {
			if (mmap->type == 2) {
				for (unsigned long long int i = 0; i < mmap->length; i += 0x1000) {
					if (mmap->base_addr + i > 0xFFFFFFFF) break; /* xxx */
					debug_print(INFO, "Marking 0x%x", (uint32_t)(mmap->base_addr + i));
					paging_mark_system((mmap->base_addr + i) & 0xFFFFF000);
				}
			}
			mmap = (mboot_memmap_t *) ((uintptr_t)mmap + mmap->size + sizeof(uintptr_t));
		}
	}
	paging_finalize();

	{
		char cmdline_[1024];

		size_t len = strlen((char *)mboot_ptr->cmdline);
		memmove(cmdline_, (char *)mboot_ptr->cmdline, len + 1);

		/* Relocate the command line */
		cmdline = (char *)kmalloc(len + 1);
		memcpy(cmdline, cmdline_, len + 1);
	}

	/* Memory management */
	heap_install();     /* Kernel heap */

	if (cmdline) {
		args_parse(cmdline);
	}

	vfs_install();
	tasking_install();  /* Multi-tasking */
	timer_install();    /* PIC driver */
	fpu_install();      /* FPU/SSE magic */
	syscalls_install(); /* Install the system calls */
	shm_install();      /* Install shared memory */
	modules_install();  /* Modules! */

	DISABLE_EARLY_BOOT_LOG();

	/* Load modules from bootloader */
	debug_print(NOTICE, "%d modules to load", mboot_mods_count);
	for (unsigned int i = 0; i < mboot_ptr->mods_count; ++i ) {
		mboot_mod_t * mod = &mboot_mods[i];
		uint32_t module_start = mod->mod_start;
		uint32_t module_end = mod->mod_end;
		size_t   module_size = module_end - module_start;

		if (!module_quickcheck((void *)module_start)) {
			debug_print(NOTICE, "Loading ramdisk: 0x%x:0x%x", module_start, module_end);
			ramdisk_mount(module_start, module_size);
		} else {

			debug_print(NOTICE, "Loading a module: 0x%x:0x%x", module_start, module_end);
			module_data_t * mod_info = (module_data_t *)module_load_direct((void *)(module_start), module_size);
			if (mod_info) {
				debug_print(NOTICE, "Loaded: %s", mod_info->mod_info->name);
			}
		}
	}

	/* Map /dev to a device mapper */
	map_vfs_directory("/dev");

	if (args_present("root")) {
		vfs_mount_type("ext2", args_value("root"), "/");
	}

	if (args_present("start")) {
		char * c = args_value("start");
		if (!c) {
			debug_print(WARNING, "Expected an argument to kernel option `start`. Ignoring.");
		} else {
			debug_print(NOTICE, "Got start argument: %s", c);
			boot_arg = strdup(c);
		}
	}

	if (!fs_root) {
		debug_print(CRITICAL, "No root filesystem is mounted. Skipping init.");
		map_vfs_directory("/");
		switch_task(0);
	}

	/* Prepare to run /bin/init */
	char * argv[] = {
		"/bin/init",
		boot_arg,
		NULL
	};
	int argc = 0;
	while (argv[argc]) {
		argc++;
	}
	system(argv[0], argc, argv); /* Run init */

	return 0;
}