Barebones rust example working in user space.

Requires manually copying the executable over to the image.
This commit is contained in:
Drew Galbraith 2024-06-08 15:47:58 -07:00
parent 844f55c7d0
commit b0048b0a4f
13 changed files with 707 additions and 1 deletions

View file

@ -0,0 +1,28 @@
#![no_std]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use core::ffi::c_void;
use core::panic::PanicInfo;
include!("bindings.rs");
fn syscall<T>(id: u64, req: &T) -> u64 {
unsafe { SysCall1(id, req as *const T as *const c_void) }
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
let req = ZProcessExitReq { code: 1 };
syscall(kZionProcessExit, &req);
unreachable!()
}
pub fn debug(msg: &str) {
let req = ZDebugReq {
message: msg.as_ptr() as *const i8,
size: msg.len() as u64,
};
syscall(kZionDebug, &req);
}