summaryrefslogtreecommitdiff
path: root/website-kernel/arch/kernel.c
blob: 32d9dbd391ad41742fa962dc1df45d93512b67aa (plain)
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
#include <int.h>
#include <log.h>
#include <sys.h>

#define SERIAL_PORT 0x70000000

#define DRAM_DEVICE 0
#define UART_DEVICE 1

void serial_write(char value) {
    *(char *)SERIAL_PORT = value;
}

void kernel_main(int hart, struct boot_args *args) {
    if (hart != 0) {
        return;
    }
    register_console_callback(serial_write);

    printk("webkernel version %s (Compiler %s, Linker %s) on %s\n", VERSION, COMPILER_NAME, LINKER_NAME, ARCH_NAME);
    printk("Command line: %s\n", args->cmd_line);

    printk("BIOS provided device map:\n");
    struct device *root = args->devices;

    while (root != NULL) {
        printk("....Device at 0x%x to 0x%x is ",
               (uintptr_t)root->start,
               (uintptr_t)root->start + root->size
        );
        switch(root->device_type) {
            case DRAM_DEVICE:
                printk("generic DRAM device, usable\n");
                break;
            case UART_DEVICE:
                printk("Web OS UART character device, not ns16550a compatible, MMIO device\n");
                break;
            default:
                printk("unknown\n");

        }
        root = root->next;
    }
}

void panic(char *cause) {
    printk("PANIC: %s\n", cause);
}