aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/kernel.c
blob: 3bef5c6bb45c081727f738e07847560667293a11 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <kernel/graphics/vesa.h>
#include <kernel/gdt/gdt.h>
#include <kernel/interrupts/interrupts.h>
#include <kernel/io/io.h>
#include <kernel/timer/timer.h>
#include <kernel/paging/paging.h>
#include <kernel/input/input.h>
#include <kernel/acpi/acpi.h>
#include <kernel/fs/initrd.h>
#include <kernel/syscall/syscall.h>
#include <kernel/smbios/smbios.h>

extern void switch_to_user();

void kernel_main() {
    vga_log("Installing basic features of Melvix...", 0);
    // Install features
    timer_install();
    gdt_install();
    init_serial();
    paging_install();
    acpi_install();
    idt_install();
    isrs_install();
    irq_install();
    set_optimal_resolution();

    // Install drivers
    asm volatile ("cli");
    mouse_install();
    keyboard_install();
    asm volatile ("sti");

    // Get hardware information
    get_smbios();

    // Booting process complete - emulate newline key
    vesa_keyboard_char('\n');

    // Setup initial ramdisk
    /*assert(mboot_ptr->mods_count > 0);
    uint32_t initrd_location = *((uint32_t *) mboot_ptr->mods_addr);
    uint32_t initrd_end = *(uint32_t *) (mboot_ptr->mods_addr + 4);
    paging_set_used(0, (initrd_end >> 12) + 1);
    fs_root = initialise_initrd(initrd_location);
    initrd_test();*/

    // User mode!
    /* COMMENTED FOR DEVELOPMENT OF KERNEL
    info("Switching to user mode...");
    syscalls_install();
    switch_to_user();

    panic("This should NOT happen!");
    */

    // asm volatile  ("div %0" :: "r"(0)); // Exception testing x/0
    loop:
    asm volatile ("hlt");
    goto loop;
}