mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Rework syscall ABI.
Syscalls now accept two parameters, allowing for things like "int count = read(buf, len)" Rather than providing safe signatures for syscalls, the user is now given helper functions to safely parse incoming values, c-strings and slices.
This commit is contained in:
parent
f046a590c0
commit
76fba39a21
28 changed files with 543 additions and 537 deletions
|
|
@ -11,13 +11,13 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
|||
// startup code
|
||||
global_asm!(include_str!("../../crt0.S"), UVM32_SYSCALL_HALT = const UVM32_SYSCALL_HALT);
|
||||
|
||||
fn syscall(id: u32, n: u32) -> u32 {
|
||||
fn syscall(id: u32, param1: u32, param2: u32) -> u32 {
|
||||
let mut value;
|
||||
unsafe {
|
||||
asm!("ecall",
|
||||
in("a0") n,
|
||||
in("a0") param1, in("a1") param2,
|
||||
in("a7") id,
|
||||
lateout("a1") value,
|
||||
lateout("a2") value,
|
||||
);
|
||||
}
|
||||
return value;
|
||||
|
|
@ -25,17 +25,18 @@ fn syscall(id: u32, n: u32) -> u32 {
|
|||
|
||||
fn println(message: &str) {
|
||||
let addr_value = message.as_ptr() as u32;
|
||||
syscall(UVM32_SYSCALL_PRINTLN, addr_value);
|
||||
syscall(UVM32_SYSCALL_PRINTLN, addr_value, 0);
|
||||
}
|
||||
|
||||
fn printdec(n: u32) {
|
||||
syscall(UVM32_SYSCALL_PRINTDEC, n);
|
||||
syscall(UVM32_SYSCALL_PRINTDEC, n, 0);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn main() {
|
||||
for i in 0..10 {
|
||||
printdec(i);
|
||||
println("\0");
|
||||
}
|
||||
println("Hello, world!\0");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue