-
Notifications
You must be signed in to change notification settings - Fork 0
/
kmain.c
58 lines (46 loc) · 1.29 KB
/
kmain.c
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
58
#include "defs.h"
#include "common.h"
#include "write.h"
#include "descriptor_tables.h"
#include "proc.h"
#include "multiboot.h"
#include "file.h"
#include "fs.h"
uint32_t placement_address;
struct multiboot mboothdr;
uint32_t *initrd;
extern struct inode* dirlookup(struct inode*, char*);
int kmain(struct multiboot *mboot_ptr)
{
fb_clear(); // screen
fb_init(0);
// grab and copy multiboot header (its somewhere in low memory)
memcpy(&mboothdr, mboot_ptr, sizeof(struct multiboot));
initrd = *((uint32_t*)mboothdr.mods_addr);
uint32_t initrdend = *(uint32_t*)(mboothdr.mods_addr+4);
placement_address = initrdend;
kprintf("kmain: initrd: %h", initrd);
initgdt(); // setup gdt
init_idt(); // setup the interrup tables
initpic(); // reprogram PIC
init_timer(500000000); // setup timer interrupt handler
// up till now paging is still off, lets turn it on
initpaging();
initkheap(); // Create the kernel heap; without it you get stuck quickly
iinitrd(initrd); // initialise ramdsk
initconsole();
initptable();
struct inode *root;
struct file *fd;
struct dirent dd[10];
char *data[512];
kprintf("kmain: writing: %h", 0x5000);
kprintf("kmain: and then still writing",0);
userinit();
scheduler();
for(;;) {
asm("hlt");
}
fb_write("EXECUTION FINISHED.\n");
return 0;
}