forked from PoliEcho-holding-org/kern
63 lines
1.5 KiB
C
63 lines
1.5 KiB
C
#include "errno.h"
|
|
#include "types.h"
|
|
#include <bootloader.h>
|
|
#include <gdt.h>
|
|
#include <isr.h>
|
|
#include <kernel.h>
|
|
#include <paging.h>
|
|
#include <pmm.h>
|
|
#include <random.h>
|
|
#include <serial.h>
|
|
#include <splash.h>
|
|
#include <string.h>
|
|
#include <system.h>
|
|
#include <vmm.h>
|
|
|
|
__noreturn void _start(void) {
|
|
int err = 0;
|
|
|
|
// Serial console for debugging
|
|
if ((err = serial_init(COM1)) < 0)
|
|
panic(NULL, "Failed to initialize Serial driver. (%d)", err);
|
|
|
|
// Load structures from bootloader
|
|
if ((err = boot_init()) < 0)
|
|
panic(NULL, "Failed to parse bootloader structures. (%d)", err);
|
|
|
|
// CPUID thingy :p
|
|
uint32_t eax = 0;
|
|
char s[12];
|
|
cpuid(&eax, (void*)&s[0], (void*)&s[8], (void*)&s[4]);
|
|
pr_info("[kernel] CPUID_GETVENDORID: %s\n", s);
|
|
|
|
// enable processor extensions
|
|
detect_processor_features();
|
|
|
|
// System init
|
|
if ((err = gdt_init()) < 0)
|
|
panic(NULL, "Failed to initalize GDT. (%d)", err);
|
|
if ((err = isr_init()) < 0)
|
|
panic(NULL, "Failed to initalize ISRs. (%d)", err);
|
|
|
|
// Memory management
|
|
if ((err = pmm_init()) < 0)
|
|
panic(NULL, "Failed to initalize Physical Memory Manager. (%d)",
|
|
err);
|
|
if ((err = pag_init()) < 0)
|
|
panic(NULL, "Failed to initalize Paging. (%d)", err);
|
|
|
|
|
|
// test random number generation
|
|
printk("Random number generation test:\n");
|
|
for (uint8_t i = 0; i <= 16; i++) {
|
|
printk("%d: %lu\n", i, get_random_number());
|
|
}
|
|
|
|
// The most important function in the world.
|
|
splash();
|
|
|
|
// Patiently wait for things to do :)
|
|
while (1)
|
|
;
|
|
};
|