From 9660366219c28fc827c24ce7b428ad7e2534ead0 Mon Sep 17 00:00:00 2001 From: Nathan Lee Date: Sat, 26 Sep 2026 16:22:04 -0500 Subject: scaffold rest of website --- website-kernel/Makefile | 3 ++- website-kernel/arch/kernel.c | 12 +++++++++--- website-kernel/include/int.h | 3 ++- website-kernel/include/sys.h | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 website-kernel/include/sys.h (limited to 'website-kernel') diff --git a/website-kernel/Makefile b/website-kernel/Makefile index eb5a76e..01f259c 100644 --- a/website-kernel/Makefile +++ b/website-kernel/Makefile @@ -5,6 +5,7 @@ OBJCOPY = llvm-objcopy COMPILER = $(shell $(CC) --version | head -n 1) LINKER = $(shell $(LD) --version | head -n 1) ARCH_NAME = 32-bit RISC-V, IM_Zicsr ISA, little endian, unknown ELF, System V ABI +VERSION = 0.1.0-alpha CFLAGS = \ --target=riscv32-unknown-elf \ @@ -60,7 +61,7 @@ $(KERNEL_ELF): $(ALL_OBJECTS) $(LINKER_SCRIPT) $(LD) $(LD_FLAGS) -o $@ $(ALL_OBJECTS) $(KERNEL_BINARY): $(KERNEL_ELF) @echo " OBJCOPY $@" - $(OBJCOPY) $(OBJCOPY_FLAGS) $(KERNEL_ELF) $(KERNEL_BIN) + $(OBJCOPY) $(OBJCOPY_FLAGS) $(KERNEL_ELF) $(KERNEL_BINARY) clean: @echo " CLEAN $(ALL_OBJECTS)" $(RM) $(ALL_OBJECTS) diff --git a/website-kernel/arch/kernel.c b/website-kernel/arch/kernel.c index 28c94d3..fe771ec 100644 --- a/website-kernel/arch/kernel.c +++ b/website-kernel/arch/kernel.c @@ -1,9 +1,15 @@ #include #include +#include #define SERIAL_PORT 0x70000000 -void kernel_main(size_t hart) { - (void)hart; - printk("wkern version %s (Compiler %s, Linker %s) on %s\n", VERSION, COMPILER_NAME, LINKER_NAME, ARCH_NAME); +void serial_write(char value) { + *(char *)SERIAL_PORT = value; +} + +void kernel_main() { + register_console_callback(serial_write); + + printk("webkernel version %s (Compiler %s, Linker %s) on %s\n", VERSION, COMPILER_NAME, LINKER_NAME, ARCH_NAME); } diff --git a/website-kernel/include/int.h b/website-kernel/include/int.h index 2a378e7..754b43e 100644 --- a/website-kernel/include/int.h +++ b/website-kernel/include/int.h @@ -1,7 +1,8 @@ #pragma once #define NULL (void*)0 -typedef __UINTPTR_TYPE__ size_t; +typedef __SIZE_TYPE__ size_t; +typedef __UINTPTR_TYPE__ uintptr_t; typedef __UINT8_TYPE__ uint8_t; typedef __UINT16_TYPE__ uint16_t; typedef __UINT32_TYPE__ uint32_t; diff --git a/website-kernel/include/sys.h b/website-kernel/include/sys.h new file mode 100644 index 0000000..1aa4a03 --- /dev/null +++ b/website-kernel/include/sys.h @@ -0,0 +1,16 @@ +#pragma once +#include + +typedef uint8_t device_type_t; + +struct boot_args { + char *cmd_line; + struct device *devices; +}; + +struct device { + device_type_t device_type; + uintptr_t start; + size_t size; + struct device *next; +}; -- cgit v1.2.3