summaryrefslogtreecommitdiff
path: root/website-kernel
diff options
context:
space:
mode:
Diffstat (limited to 'website-kernel')
-rw-r--r--website-kernel/Makefile3
-rw-r--r--website-kernel/arch/kernel.c12
-rw-r--r--website-kernel/include/int.h3
-rw-r--r--website-kernel/include/sys.h16
4 files changed, 29 insertions, 5 deletions
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 <int.h>
#include <log.h>
+#include <sys.h>
#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 <int.h>
+
+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;
+};