summaryrefslogtreecommitdiff
path: root/kernel/main.c
blob: d6de534e1845eeb850fa56d0481e9a6cf7b7d4cb (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
#include "kernel.h"
#include "printf.h"
#include "palloc.h"
#include "paging.h"
#include "gdt.h"
#include "idt.h"
#include "irq.h"

void main() {
	printf("main()\n");
	
	palloc_init();
	printf("Page allocator initiated.\n");
	
	paging_reinit();
	printf("Paging reinitialized.\n");
	
	gdt_init();
	printf("GDT set.\n");
	
	idt_init();
	printf("IDT set.\n");
	
	irq_init();
	printf("IRQs set.\n");
	
	printf("Multiboot flags: %08x\n", multiboot_info.flags);
	for(unsigned int i = 0; i < multiboot_info.mods_count; i++) {
		printf("Module %u: %08x %08x %s\n", i, multiboot_info.mods_addr[0].mod_start, multiboot_info.mods_addr[0].mod_end, multiboot_info.mods_addr[0].string);
	}
	
	asm volatile("sti");
	
	/*
	asm volatile(
		"push $0x23\n"
		"push $entry_stack_top\n"
		"pushf\n"
		"push $0x1b\n"
		"push %0\n"
		"iret\n"
		:: "r" (multiboot_info.mods_addr[0].mod_start)
	); */
	
	printf("Halting.\n");
	
	asm volatile(
		"cli\n"
		"hlt\n"
	);
	while(1);
}