uvm32 initial version

This commit is contained in:
Toby Jaffey 2025-12-06 16:44:23 +00:00
commit c9d30b6d28
34 changed files with 2088 additions and 0 deletions

View file

@ -0,0 +1,48 @@
#![no_std]
#![no_main]
use core::arch::global_asm;
use core::arch::asm;
use core::panic::PanicInfo;
// fetch IOREQ definitions from C header
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
// startup code
global_asm!(include_str!("../../crt0.s"));
fn println(message: &str) {
unsafe {
asm!(
"csrw {i}, {x}",
i = const IOREQ_PRINTLN,
x = in(reg) message.as_ptr(),
);
}
}
fn printd(n: u32) {
unsafe {
asm!(
"csrw {i}, {x}",
i = const IOREQ_PRINTD,
x = in(reg) n,
);
}
}
#[no_mangle]
pub extern "C" fn main() {
for i in 0..10 {
printd(i);
}
println("Hello, world!");
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
//println("Something went wrong");
loop {
continue;
}
}