74 lines
1.6 KiB
C
74 lines
1.6 KiB
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <kernel/_kernel.h>
|
|
#include <kernel/tty.h>
|
|
#include <kernel/serial.h>
|
|
#include <kernel/paging.h>
|
|
#include <kernel/x86/gdt.h>
|
|
#include <kernel/x86/idt.h>
|
|
#include <kernel/x86/io.h>
|
|
#include <kernel/x86/keyb.h>
|
|
#include <kernel/x86/pit.h>
|
|
#include <kernel/x86/pci.h>
|
|
#include <kernel/pmm.h>
|
|
|
|
#include "multiboot.h"
|
|
|
|
void verify_memmap(multiboot_info_t* mbd, uint32_t magic)
|
|
{
|
|
if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
|
|
panic("Invalid magic number!");
|
|
|
|
if (!(mbd->flags >> 6 & 0x1))
|
|
panic("Invalid memory map given by GRUB bootloader!");
|
|
|
|
if (!(mbd->flags & (1 << 0)))
|
|
panic("Memory info not passed to kernel!");
|
|
|
|
puts("Printing available memory map...");
|
|
uint32_t i;
|
|
for (i = 0; i < mbd->mmap_length; i += sizeof(multiboot_memory_map_t)) {
|
|
multiboot_memory_map_t* mmmt = (multiboot_memory_map_t*) (mbd->mmap_addr + i);
|
|
|
|
printf("Start Addr: %4 | Length: %4 | Size: %2 | Type: %d\n",
|
|
mmmt->addr, mmmt->len, mmmt->size, mmmt->type);
|
|
|
|
// mmmt-> len is in bytes (according to multiboot specification0
|
|
// mmmt->len / 1024 == kib // block size == blocks
|
|
|
|
}
|
|
}
|
|
|
|
void _main(multiboot_info_t* mbd, uint32_t magic)
|
|
{
|
|
#ifdef __TESTING__ // important components should be declared first, but if we're testing we want to log all of that
|
|
terminal_initialize();
|
|
serial_initialize();
|
|
#endif
|
|
verify_memmap(mbd, magic);
|
|
|
|
gdt_init();
|
|
idt_init();
|
|
|
|
#ifndef __TESTING__
|
|
terminal_initialize();
|
|
serial_initialize();
|
|
#endif
|
|
|
|
//setup_paging();
|
|
|
|
init_kb();
|
|
|
|
init_pit(0x36, PIT_CHANNEL_0, 0);
|
|
|
|
printf("Entering loop...\n");
|
|
while (1) {
|
|
|
|
continue;
|
|
}
|
|
printf("Exiting loop...\n");
|
|
|
|
}
|