49 lines
1.4 KiB
C
49 lines
1.4 KiB
C
//Our own code, at this point...
|
|
#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 get some output schemas ready.
|
|
|
|
//VGA prep
|
|
vga_ctx_t vga_ctx;
|
|
vga_ctx.attributes = DEFAULT_ATTRIBUTES;
|
|
vga_ctx.cursor_row = 0;
|
|
vga_ctx.cursor_col = 0;
|
|
char_writer_t vga_writer;
|
|
vga_writer.ctx = &vga_ctx;
|
|
vga_writer.putChar = vga_out;
|
|
default_vga = &vga_writer;
|
|
vga_clear_ctx(&vga_ctx);
|
|
|
|
//Serial prep
|
|
serial_ctx_t serial_ctx;
|
|
serial_ctx.port = COM1;
|
|
char_writer_t serial_writer;
|
|
serial_writer.ctx = &serial_ctx;
|
|
serial_writer.putChar = serial_send8;
|
|
default_COM = &serial_writer;
|
|
serial_init(&serial_ctx);
|
|
|
|
|
|
printf(&vga_writer, "Entry eax:%X\n", multiboot_magic);
|
|
|
|
if(multiboot_magic != 0x2BADB002) {
|
|
println(&vga_writer, "Bootloader not multiboot1 compliant! Needed for mmap, etc. Can't work without it, kthxbye!");
|
|
return;
|
|
} else {
|
|
println(&vga_writer, "Multiboot detected! Continuing...");
|
|
}
|
|
printf(&vga_writer, "MEM_LOWER:%X\n", multiboot_info->mem_lower);
|
|
printf(&vga_writer, "MEM_UPPER:%X\n", multiboot_info->mem_upper);
|
|
}
|
|
|