kernel/kernel.c

47 lines
1.3 KiB
C
Raw Normal View History

2023-06-14 05:13:21 +03:00
#include "multiboot.h"
2023-06-13 09:45:04 +03:00
#include "vga.h"
// static inline void outb(unsigned int port, unsigned char val) {
// asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
// }
2023-06-14 05:13:21 +03:00
void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
2023-06-13 09:45:04 +03:00
// Cursor disabling
// TODO: outb function
//outb(0x3D4, 0x0A);
//outb(0x3D5, 0x20);
//cls();
vga_init(VGA_COLOR_GREY, VGA_COLOR_BLACK);
vga_write_line("=== KoalemOS ===");
2023-06-14 05:13:21 +03:00
vga_write("Checking multiboot loader: ");
// Check multiboot header
if (mbootmagick != MULTIBOOT_BOOTLOADER_MAGIC) {
vga_write_color("INVALID MAGIC", VGA_COLOR_BLACK, VGA_COLOR_RED);
return;
}
vga_write(mbootinfo->boot_loader_name);
// Check videomode
vga_write("\nVideomode: ");
switch (mbootinfo->vbe_mode) {
case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
vga_write("Indexed");
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
vga_write("RGB");
break;
case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
vga_write("EGA TEXT");
break;
default:
vga_write_color("UNKNOWN", VGA_COLOR_BLACK, VGA_COLOR_RED);
return;
}
vga_write_line("\nExecution finished, halting...");
2023-06-12 11:46:47 +03:00
}