Simple hello world

This commit is contained in:
2023-10-28 16:46:38 +02:00
commit a179a01270
7 changed files with 98 additions and 0 deletions

32
src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
#![no_std]
#![no_main]
use crate::uart::Uart0;
use core::sync::atomic::{self, Ordering};
use core::{arch::global_asm, fmt::Write, panic::PanicInfo};
mod uart;
global_asm!(include_str!("start.s"));
#[no_mangle]
pub extern "C" fn entry() -> ! {
let mut uart = Uart0 {};
for i in 0..3 {
writeln!(&mut uart, "Hello from Rust {i}!").unwrap();
}
loop {
atomic::compiler_fence(Ordering::SeqCst);
}
}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
writeln!(Uart0, "{info}").unwrap();
loop {
atomic::compiler_fence(Ordering::SeqCst);
}
}