mbr_asm/main.c
2018-07-12 12:20:27 +02:00

53 lines
1.0 KiB
C

#include "gdt.h"
#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 keyboard_handler(int *id)
{
__asm__("pushal");
(void)id;
const char *tictac = "tic tac";
const short color = RED;
printString(tictac, color, BLACK, 0, 3);
__asm__("popal; leave; iret");
}
void kmain()
{
const short color = GREEN;
clearScreen(BLACK);
printString("Setting up IDT", color, BLACK, 0, 0);
gdtSetup();
idtSetup();
printString("Setting up IRQ", color, BLACK, 0, 1);
irqSetup();
irqSetRoutine(IRQ_KEYBOARD, keyboard_handler);
// Enabling the HW interrupts
//asm volatile("sti\n");
while (1) {
char c = getScancode();
printChar(c, color, BLACK, 0, 5);
}
}