91 lines
1.9 KiB
C
91 lines
1.9 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/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 "multiboot.h"
|
|
|
|
void verify_memmap(multiboot_info_t* mbd, uint32_t magic)
|
|
{
|
|
if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
|
|
panic("Invalid magic number!");
|
|
else
|
|
printf("%2\n", magic);
|
|
|
|
if (!(mbd->flags >> 6 & 0x1))
|
|
panic("Invalid memory map given by GRUB bootloader!");
|
|
|
|
#ifdef __TESTING__
|
|
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: ",
|
|
mmmt->addr, mmmt->len, mmmt->size);
|
|
switch (mmmt->type) {
|
|
case MULTIBOOT_MEMORY_AVAILABLE:
|
|
puts("Available");
|
|
break;
|
|
case MULTIBOOT_MEMORY_RESERVED:
|
|
puts("Reserved");
|
|
break;
|
|
case MULTIBOOT_MEMORY_ACPI_RECLAIMABLE:
|
|
puts("ACPI Reclaimable");
|
|
break;
|
|
case MULTIBOOT_MEMORY_NVS:
|
|
puts("NVS");
|
|
break;
|
|
case MULTIBOOT_MEMORY_BADRAM:
|
|
puts("Bad ram");
|
|
break;
|
|
default:
|
|
puts("Unknown");
|
|
break;
|
|
}
|
|
|
|
// if (mmmt->type == MULTIBOOT_MEMORY_AVAILABLE) -> DO SOMETHING
|
|
}
|
|
#endif
|
|
}
|
|
|
|
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
|
|
|
|
init_kb();
|
|
|
|
init_pit(0x36, PIT_CHANNEL_0, 0);
|
|
|
|
printf("Entering loop...\n");
|
|
while (1) {
|
|
|
|
continue;
|
|
}
|
|
printf("Exiting loop...\n");
|
|
|
|
}
|