mbr_asm/core/main.c

38 lines
892 B
C
Raw Normal View History

2018-06-30 01:03:40 +02:00
#include "exception.h"
2018-06-30 01:00:25 +02:00
#include "gdt.h"
#include "idt.h"
2018-06-30 01:03:40 +02:00
#include "interrupt.h"
#include "io.h"
#include "irq.h"
#include "pit.h"
#include "types.h"
#include "vga.h"
void cpuid(int code, uint32_t *a, uint32_t *d)
{
2018-06-26 16:41:06 +02:00
asm volatile("cpuid" : "=a"(*a), "=d"(*d) : "0"(code) : "ebx", "ecx");
}
void kmain()
{
2018-07-18 15:06:31 +02:00
initVGA(BLACK, GREEN);
printString("Setting up IDT\n");
2018-06-30 01:00:25 +02:00
gdtSetup();
2018-06-26 16:41:06 +02:00
idtSetup();
irqSetup();
initPit(100);
2018-07-18 15:06:31 +02:00
printString("Setting up IRQ handlers\n");
2018-06-26 16:41:06 +02:00
irqSetRoutine(IRQ_KEYBOARD, keyboard_handler);
irqSetRoutine(IRQ_TIMER, timer_handler);
2018-07-18 15:06:31 +02:00
printString("Enabling HW interrupts\n");
2018-06-30 01:03:40 +02:00
exceptionSetRoutine(EXCEPTION_DOUBLE_FAULT, print_handler);
2018-06-26 16:41:06 +02:00
// Enabling the HW interrupts
2018-06-30 01:03:40 +02:00
asm volatile("sti\n");
int count = 0;
2018-06-26 16:41:06 +02:00
while (1) {
2018-07-18 15:35:49 +02:00
printIntDetails(count++, GREEN, BLACK, 0, VGA_HEIGHT - 1);
2018-06-26 16:41:06 +02:00
}
2018-07-18 15:06:31 +02:00
printString("exiting\n");
}