2025-05-29 03:19:50 +00:00
|
|
|
//Our own code, at this point...
|
2025-05-23 05:18:12 +00:00
|
|
|
#include <stdint.h>
|
2025-06-29 05:13:43 +00:00
|
|
|
#include "vga.h"
|
|
|
|
|
#include "io.h"
|
2025-06-08 05:27:41 +00:00
|
|
|
#include "kttools.h"
|
2025-06-09 02:44:17 +00:00
|
|
|
#include "kmultiboot.h"
|
2025-06-28 04:14:42 +00:00
|
|
|
#include "idt.h"
|
2025-07-02 23:48:33 +00:00
|
|
|
#include "serial.h"
|
2025-06-11 03:41:51 +00:00
|
|
|
void kern_main(uint32_t multiboot_magic, mb_info_t* multiboot_info)
|
2025-05-23 05:18:12 +00:00
|
|
|
{
|
2025-06-11 04:27:15 +00:00
|
|
|
//Hello C! Let's get to work in cleaning up our environment a bit and creating some safety.
|
|
|
|
|
//First interrupts.
|
2025-06-28 04:14:42 +00:00
|
|
|
setup_idt();
|
2025-07-02 23:48:33 +00:00
|
|
|
|
2025-07-03 05:36:47 +00:00
|
|
|
//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);
|
|
|
|
|
|
2025-06-08 05:27:41 +00:00
|
|
|
|
2025-07-03 05:36:47 +00:00
|
|
|
printf(&vga_writer, "Entry eax:%X\n", multiboot_magic);
|
2025-06-08 20:18:06 +00:00
|
|
|
|
|
|
|
|
if(multiboot_magic != 0x2BADB002) {
|
2025-07-03 05:36:47 +00:00
|
|
|
println(&vga_writer, "Bootloader not multiboot1 compliant! Needed for mmap, etc. Can't work without it, kthxbye!");
|
2025-06-08 20:18:06 +00:00
|
|
|
return;
|
|
|
|
|
} else {
|
2025-07-03 05:36:47 +00:00
|
|
|
println(&vga_writer, "Multiboot detected! Continuing...");
|
2025-06-08 20:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 05:36:47 +00:00
|
|
|
printf(&vga_writer, "MEM_LOWER:%X\n", multiboot_info->mem_lower);
|
|
|
|
|
printf(&vga_writer, "MEM_UPPER:%X\n", multiboot_info->mem_upper);
|
2025-05-23 05:18:12 +00:00
|
|
|
}
|
|
|
|
|
|