From b4623a51a9d60eff5b3a438b5068c0d30a9f3d3b Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Thu, 22 Feb 2024 22:19:16 -0600 Subject: [PATCH] get it back to working for now --- kernel/src/console.rs | 6 +++++- kernel/src/main.rs | 8 ++++---- kernel/src/memory_layout.rs | 2 +- kernel/src/start.s | 2 +- kernel/src/uart.rs | 5 ++++- run.sh | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/kernel/src/console.rs b/kernel/src/console.rs index 64912a1..ce345ac 100644 --- a/kernel/src/console.rs +++ b/kernel/src/console.rs @@ -14,6 +14,10 @@ impl Console { impl Write for Console { fn write_str(&mut self, s: &str) -> fmt::Result { - todo!() + // TODO: Lock + + Ok(()) + + // TODO: Release lock } } diff --git a/kernel/src/main.rs b/kernel/src/main.rs index aca4640..04d937b 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -5,6 +5,7 @@ use core::fmt::Write; use core::{arch::global_asm, ptr}; use crate::console::Console; +use crate::memory_layout::UART0; #[macro_use] mod macros; @@ -18,11 +19,10 @@ mod uart; global_asm!(include_str!("start.s")); #[no_mangle] -pub extern "C" fn not_main() { - let mut console = Console::init(); - let _ = writeln!(console, "eos0 is booting..."); +pub extern "C" fn main() { + // let mut console = Console::init(); + // let _ = writeln!(console, "eos0 is booting..."); - const UART0: *mut u8 = 0x0900_0000 as *mut u8; let out_str = b"AArch64 Bare Metal"; for byte in out_str { unsafe { diff --git a/kernel/src/memory_layout.rs b/kernel/src/memory_layout.rs index 50e15b3..947a0e1 100644 --- a/kernel/src/memory_layout.rs +++ b/kernel/src/memory_layout.rs @@ -1 +1 @@ -pub const UART0: u64 = 0x0900_0000; +pub const UART0: *mut u8 = 0x0900_0000 as *mut u8; diff --git a/kernel/src/start.s b/kernel/src/start.s index 40680ed..88f0196 100644 --- a/kernel/src/start.s +++ b/kernel/src/start.s @@ -6,7 +6,7 @@ _start: ldr x30, =LD_STACK_PTR mov sp, x30 - bl not_main + bl main .equ PSCI_SYSTEM_OFF, 0x84000008 .globl system_off diff --git a/kernel/src/uart.rs b/kernel/src/uart.rs index 6f756fe..a9d1db4 100644 --- a/kernel/src/uart.rs +++ b/kernel/src/uart.rs @@ -1,3 +1,5 @@ +//! UART (Universal Asynchronous Receiver-Transmitter) + use crate::memory_layout::UART0; /// http://byterunner.com/16550.html @@ -14,7 +16,8 @@ impl Register { /// address of one of the registers #[inline] fn register(reg: Register) -> *mut u8 { - (UART0 + reg.offset()) as *mut u8 + // (UART0 + reg.offset()) as *mut u8 + UART0 } #[inline] diff --git a/run.sh b/run.sh index 26df59f..3a62632 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,5 @@ set -euo pipefail -cargo build +cargo xbuild --target=aarch64-unknown-none.json exec qemu-system-aarch64 \ -machine virt \ -m 1024M \