Simple hello world
This commit is contained in:
32
src/main.rs
Normal file
32
src/main.rs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user