Untitled_Kernel/src/main.c

51 lines
1.4 KiB
C
Raw Normal View History

//Our own code, at this point...
//Output table:
//0: VGA
//1: COM1
#define OUTPUT_TYPE 1
#include <stdint.h>
#include "vga.h"
#include "io.h"
#include "kttools.h"
#include "kmultiboot.h"
#include "idt.h"
#include "serial.h"
void kern_main(uint32_t multiboot_magic, mb_info_t* multiboot_info)
{
//Hello C! Let's get to work in cleaning up our environment a bit and creating some safety.
//First interrupts.
setup_idt();
//Let's pick an output schema.
int (*outWriter)(char) = 0;
int comstatus = 1234;
switch(OUTPUT_TYPE) {
case 1:
comstatus = serial_init(COM1);
if(comstatus) {
//Fail...
break;
}
outWriter = serial_send8;
break;
}
//VGA is selected or the selected option failed, falling back
if(outWriter == 0){
outWriter = vga_out;
vga_clear();
}
printf(outWriter, "Entry eax:%X\n", multiboot_magic);
if(multiboot_magic != 0x2BADB002) {
println(outWriter, writerState, "Bootloader not multiboot1 compliant! Needed for mmap, etc. Can't work without it, kthxbye!");
return;
} else {
println(outWriter, writerState, "Multiboot detected! Continuing...");
}
printf(outWriter, writerState, "MEM_LOWER:%X\n", multiboot_info->mem_lower);
printf(outWriter, writerState"MEM_UPPER:%X\n", multiboot_info->mem_upper);
}