summaryrefslogtreecommitdiff
path: root/kernel/src
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-02-24 22:03:49 -0600
committerNathan Ringo <nathan@remexre.com>2024-02-24 22:03:49 -0600
commitc8de43bf43242c4ebac3d0ecb8e7951fe2371506 (patch)
treeb438bb1b47b41241702f5783fb7ec3326a4e8ab7 /kernel/src
Initial commit
Diffstat (limited to 'kernel/src')
-rw-r--r--kernel/src/lib.rs16
-rw-r--r--kernel/src/panic.rs12
2 files changed, 28 insertions, 0 deletions
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs
new file mode 100644
index 0000000..bd5a19f
--- /dev/null
+++ b/kernel/src/lib.rs
@@ -0,0 +1,16 @@
+#![no_std]
+
+mod panic;
+
+/// The entrypoint to the kernel. This should be executed by hart0 alone. It performs some early
+/// boot tasks, then wakes up any other harts.
+#[no_mangle]
+pub extern "C" fn hart0_boot() {
+ for byte in "Hello, world!\n".bytes() {
+ unsafe {
+ core::ptr::write_volatile(0x10000000 as *mut u8, byte);
+ }
+ }
+
+ todo!()
+}
diff --git a/kernel/src/panic.rs b/kernel/src/panic.rs
new file mode 100644
index 0000000..ed6e5d4
--- /dev/null
+++ b/kernel/src/panic.rs
@@ -0,0 +1,12 @@
+use core::panic::PanicInfo;
+
+#[panic_handler]
+fn panic(_info: &PanicInfo) -> ! {
+ loop {
+ for byte in "panic\n".bytes() {
+ unsafe {
+ core::ptr::write_volatile(0x10000000 as *mut u8, byte);
+ }
+ }
+ }
+}