mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-06 06:53:39 +00:00
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.
28 lines
701 B
Zig
28 lines
701 B
Zig
const uvm32 = @cImport({
|
|
@cDefine("USE_MAIN", "1");
|
|
@cInclude("uvm32_target.h");
|
|
});
|
|
const std = @import("std");
|
|
|
|
pub inline fn syscall(id: u32, param1: u32, param2: u32) u32 {
|
|
var val: u32 = undefined;
|
|
asm volatile ("ecall"
|
|
: [val] "={a1}" (val),
|
|
: [param1] "{a0}" (param1), [param2] "{a1}" (param2),
|
|
[id] "{a7}" (id),
|
|
: .{ .memory = true });
|
|
return val;
|
|
}
|
|
|
|
pub inline fn println(val: [:0]const u8) void {
|
|
_ = syscall(uvm32.UVM32_SYSCALL_PRINTLN, @intFromPtr(val.ptr), 0);
|
|
}
|
|
|
|
pub inline fn yield() void {
|
|
_ = syscall(uvm32.UVM32_SYSCALL_YIELD, 0, 0);
|
|
}
|
|
|
|
pub inline fn putc(c:u8) void {
|
|
_ = syscall(uvm32.UVM32_SYSCALL_PUTC, c, 0);
|
|
}
|
|
|