summaryrefslogtreecommitdiff
path: root/src/nrvn.c
blob: 84b297f2dedb0f97bf2a052d9a9866dc350543af (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include <nrvn.h>
#include <vga.h>
#include <idt.h>
#include <pic.h>
#include <acpi.h>
#include <ps2.h>
#include <multiboot.h>
#include <mem.h>
#include <memory.h>

/* Check if the compiler thinks you are targeting the wrong operating system. */
#if defined(__linux__)
#error "You are not using a cross-compiler, you will most certainly run into trouble"
#endif

/* This tutorial will only work for the 32-bit ix86 targets. */
//#if !defined(__i386__) | !defined(__x86_64__)
//#error "This tutorial needs to be compiled with a ix86-elf compiler"
//#endif

void kernel_main(void) {
	vga_init();
	vga_puts("hello world\n");
	vga_puts("welcome to nirvanna\n\n");

	vga_puts("initializing interrupt tables...");
	idt_init();
	vga_puts("interrupt tables initialized\n");


	vga_puts("initializing the pic...");
	pic_init();
	vga_puts("pic initialized\n");

	vga_puts("initializing memory pages... ");
	if (paging_init()) {
		vga_puts("memory pages allocated\n");
	} else {
		vga_puts("failed to allocate memory pages\n");
		asm volatile ("cli");
		asm volatile ("hlt");
	}

	// TODO -- fix acpi

	vga_puts("initializing ps/2...\n");
	if (ps2_init(NULL))
		vga_puts("ps/2 initialized.\n");
	else
		vga_puts("ps/2 initialization failed.\n");

	while (1);
}