63 lines
1.2 KiB
C
63 lines
1.2 KiB
C
#include "multiboot.h"
|
|
#include "interrupts.h"
|
|
#include "elf.h"
|
|
#include "gdt.h"
|
|
#include "scheduler.h"
|
|
|
|
#include <lib/print.h>
|
|
#include <lib/stream.h>
|
|
#include <lib/memory.h>
|
|
|
|
#include <memory/mm.h>
|
|
|
|
#include <drivers/iso/iso.h>
|
|
#include <drivers/ide/ide.h>
|
|
#include <drivers/pic/pic.h>
|
|
#include <drivers/ps2/ps2.h>
|
|
#include <drivers/pit/pit.h>
|
|
#include <drivers/vga/vga.h>
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
extern void enable_interrupts();
|
|
extern void disable_interrupts();
|
|
extern uint32_t fetch_cr3();
|
|
|
|
extern char __kernel_start;
|
|
extern char __kernel_end;
|
|
|
|
void kernel_test_task() {
|
|
while (1) {
|
|
kprintf("task sleeping...\n");
|
|
sleep(10000000);
|
|
}
|
|
}
|
|
|
|
void kmain(uint32_t magic, multiboot_info* mbi) {
|
|
if (!(mbi->flags & (1 << 6))) {
|
|
return;
|
|
}
|
|
|
|
vga_init();
|
|
|
|
uint32_t mmap_virtual_addr = mbi->mmap_addr + 0xC0000000;
|
|
init_pmm((void*)mmap_virtual_addr, mbi->mmap_length);
|
|
kprintf("memory detection complete. total free memory: %dMB\n", total_free_memory() / 1024 / 1024);
|
|
|
|
init_gdt();
|
|
init_idt();
|
|
init_pic();
|
|
init_pit();
|
|
|
|
init_page_tables();
|
|
|
|
kprintf("basic initializations complete\n");
|
|
|
|
disable_interrupts();
|
|
init_scheduler();
|
|
enable_interrupts();
|
|
|
|
while(1) yield();
|
|
}
|