get it back to working for now

This commit is contained in:
Michael Zhang 2024-02-22 22:19:16 -06:00
parent 4499d611e1
commit b4623a51a9
6 changed files with 16 additions and 9 deletions

View file

@ -14,6 +14,10 @@ impl Console {
impl Write for Console { impl Write for Console {
fn write_str(&mut self, s: &str) -> fmt::Result { fn write_str(&mut self, s: &str) -> fmt::Result {
todo!() // TODO: Lock
Ok(())
// TODO: Release lock
} }
} }

View file

@ -5,6 +5,7 @@ use core::fmt::Write;
use core::{arch::global_asm, ptr}; use core::{arch::global_asm, ptr};
use crate::console::Console; use crate::console::Console;
use crate::memory_layout::UART0;
#[macro_use] #[macro_use]
mod macros; mod macros;
@ -18,11 +19,10 @@ mod uart;
global_asm!(include_str!("start.s")); global_asm!(include_str!("start.s"));
#[no_mangle] #[no_mangle]
pub extern "C" fn not_main() { pub extern "C" fn main() {
let mut console = Console::init(); // let mut console = Console::init();
let _ = writeln!(console, "eos0 is booting..."); // let _ = writeln!(console, "eos0 is booting...");
const UART0: *mut u8 = 0x0900_0000 as *mut u8;
let out_str = b"AArch64 Bare Metal"; let out_str = b"AArch64 Bare Metal";
for byte in out_str { for byte in out_str {
unsafe { unsafe {

View file

@ -1 +1 @@
pub const UART0: u64 = 0x0900_0000; pub const UART0: *mut u8 = 0x0900_0000 as *mut u8;

View file

@ -6,7 +6,7 @@
_start: _start:
ldr x30, =LD_STACK_PTR ldr x30, =LD_STACK_PTR
mov sp, x30 mov sp, x30
bl not_main bl main
.equ PSCI_SYSTEM_OFF, 0x84000008 .equ PSCI_SYSTEM_OFF, 0x84000008
.globl system_off .globl system_off

View file

@ -1,3 +1,5 @@
//! UART (Universal Asynchronous Receiver-Transmitter)
use crate::memory_layout::UART0; use crate::memory_layout::UART0;
/// http://byterunner.com/16550.html /// http://byterunner.com/16550.html
@ -14,7 +16,8 @@ impl Register {
/// address of one of the registers /// address of one of the registers
#[inline] #[inline]
fn register(reg: Register) -> *mut u8 { fn register(reg: Register) -> *mut u8 {
(UART0 + reg.offset()) as *mut u8 // (UART0 + reg.offset()) as *mut u8
UART0
} }
#[inline] #[inline]

2
run.sh
View file

@ -1,5 +1,5 @@
set -euo pipefail set -euo pipefail
cargo build cargo xbuild --target=aarch64-unknown-none.json
exec qemu-system-aarch64 \ exec qemu-system-aarch64 \
-machine virt \ -machine virt \
-m 1024M \ -m 1024M \