1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2024-10-30 12:03:52 -04:00
kernel/arch/main.c

39 lines
1,023 B
C
Raw Normal View History

2017-11-01 04:37:39 -04:00
#include <kernelmq/multiboot.h>
2017-11-01 01:01:29 -04:00
#include "logger.h"
2017-11-01 01:26:22 -04:00
#include "gdt.h"
2017-11-01 02:07:03 -04:00
#include "idt.h"
2017-11-01 01:01:29 -04:00
2017-11-01 07:43:52 -04:00
void main(unsigned int multiboot_magic, unsigned long multiboot_info)
2017-11-01 00:43:42 -04:00
{
2017-11-01 01:01:29 -04:00
logger_initialize();
2017-11-01 04:25:39 -04:00
if (multiboot_magic == KERNELMQ_MULTIBOOT_2_MAGIC) {
2017-11-01 08:50:46 -04:00
logger_info("Loaded with Multiboot-compliant bootloader, specification version 2.");
print_multiboot_info(multiboot_info);
}
else if (multiboot_magic == KERNELMQ_MULTIBOOT_1_MAGIC) {
logger_fail("Loaded with Multiboot-compliant bootloader, but specification version 1.");
return;
2017-11-01 04:25:39 -04:00
}
else {
logger_fail("Loaded with no Multiboot-compliant bootloader.");
return;
2017-11-01 04:25:39 -04:00
}
2017-11-01 01:01:29 -04:00
logger_info("Kernel initialization started.");
2017-11-01 01:26:22 -04:00
gdt_initialize();
2017-11-01 02:07:03 -04:00
idt_initialize();
2017-11-01 06:59:18 -04:00
asm volatile ("int $0x0");
2017-11-01 02:07:03 -04:00
asm volatile ("int $0x3");
asm volatile ("int $0x4");
2017-11-01 06:59:18 -04:00
asm volatile ("int $0xF");
asm volatile ("int $0x10");
asm volatile ("int $0x1F");
2017-11-01 01:26:22 -04:00
2017-11-01 01:01:29 -04:00
logger_warn("Nothing to do.");
logger_fail("Halt.");
2017-11-01 00:43:42 -04:00
}