41 lines
759 B
Rust
41 lines
759 B
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
use crate::uart::Uart0;
|
|
use core::arch::asm;
|
|
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();
|
|
}
|
|
|
|
for val in 0..64 {
|
|
unsafe {
|
|
asm!("dc cvac, {val}", val = in(reg) &val);
|
|
asm!("dsb sy");
|
|
}
|
|
}
|
|
|
|
loop {
|
|
atomic::compiler_fence(Ordering::SeqCst);
|
|
}
|
|
}
|
|
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
writeln!(Uart0, "{info}").unwrap();
|
|
|
|
loop {
|
|
atomic::compiler_fence(Ordering::SeqCst);
|
|
}
|
|
}
|