summaryrefslogtreecommitdiff
path: root/website-kernel/arch/kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'website-kernel/arch/kernel.c')
-rw-r--r--website-kernel/arch/kernel.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/website-kernel/arch/kernel.c b/website-kernel/arch/kernel.c
index fe771ec..32d9dbd 100644
--- a/website-kernel/arch/kernel.c
+++ b/website-kernel/arch/kernel.c
@@ -4,12 +4,45 @@
#define SERIAL_PORT 0x70000000
+#define DRAM_DEVICE 0
+#define UART_DEVICE 1
+
void serial_write(char value) {
*(char *)SERIAL_PORT = value;
}
-void kernel_main() {
+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);
}