aboutsummaryrefslogtreecommitdiff
path: root/kernel/main.c
blob: 62fa8caa9bc3edac2de99686341df272cc32ff3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdint.h>
#include <stdio.h>
#include "gdt.h"
#include "idt.h"
#include "isr.h"
#include "irq.h"
#include "ps2.h"
#include "timer.h"
#include "tty.h"

void main(struct multiboot_header *hdr, uint32_t magic)
{
    /* init the terminal first so we can get some output */
    tty_init();

    /* then the descriptor tables so we can do more useful stuff */
    gdt_init();
    idt_init();

    /* install all the interrupt stubs */
    isr_init();
    irq_init();

    /* initialize other drivers */
    timer_init();
    ps2_init();

    asm("sti");

    printf("Boot finished.\n");
    while(1)
    {
        ps2_set_leds(0x01);
        for(int i=0;i<1000000;++i);
        ps2_set_leds(0x02);
        for(int i=0;i<1000000;++i);
        ps2_set_leds(0x04);
        for(int i=0;i<1000000;++i);
        ps2_set_leds(0x02);
        for(int i=0;i<1000000;++i);
    }
}