2018-06-30 01:03:40 +02:00
|
|
|
#include "exception.h"
|
2018-06-30 01:00:25 +02:00
|
|
|
#include "gdt.h"
|
2017-11-24 23:41:14 +01:00
|
|
|
#include "idt.h"
|
2018-06-30 01:03:40 +02:00
|
|
|
#include "interrupt.h"
|
2017-11-24 23:41:14 +01:00
|
|
|
#include "io.h"
|
|
|
|
#include "irq.h"
|
2018-07-16 14:20:12 +02:00
|
|
|
#include "pit.h"
|
2017-11-24 23:41:14 +01:00
|
|
|
#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");
|
|
|
|
}
|
|
|
|
|
2017-11-24 23:41:14 +01:00
|
|
|
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();
|
2018-07-16 14:20:12 +02:00
|
|
|
initPit(100);
|
2017-11-24 23:41:14 +01:00
|
|
|
|
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);
|
2018-07-16 14:20:12 +02:00
|
|
|
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");
|
2018-07-16 14:20:12 +02:00
|
|
|
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");
|
2017-11-24 23:41:14 +01:00
|
|
|
}
|