mbr_asm/main.c
Mathieu Maret f1341d3d72 Add some "kernel" code written in C
Draw few message on VGA
Setup Interruption Description Table
Setup IRQ
2017-11-27 14:51:51 +01:00

38 lines
617 B
C

#include "idt.h"
#include "io.h"
#include "irq.h"
#include "types.h"
#include "vga.h"
char getScancode()
{
char c = 0;
do {
if (inb(0x60) != c) {
c = inb(0x60);
if (c > 0)
return c;
}
} while (1);
}
void cpuid(int code, uint32_t *a, uint32_t *d)
{
asm volatile("cpuid" : "=a"(*a), "=d"(*d) : "0"(code) : "ebx", "ecx");
}
void kmain()
{
const short color = GREEN;
clearScreen(BLACK);
printString("Setting up IDT", color, BLACK, 0, 0);
idtSetup();
printString("Setting up IRQ", color, BLACK, 0, 1);
irqSetup();
while (1) {
char c = getScancode();
printChar(c, color, BLACK, 0, 5);
}
}