1
0
Fork 0
forked from AbleOS/ableos

Update ecalls to match the spec

This commit is contained in:
able 2024-05-31 09:15:55 -05:00
parent d90016f28e
commit a511e99606

View file

@ -18,12 +18,12 @@ use {
};
pub fn handler(vm: &mut Vm) {
let r1 = vm.registers[1].cast::<u64>();
let ecall_number = vm.registers[2].cast::<u64>();
// debug!("Ecall number {:?}", r1);
// debug!("Ecall number {:?}", ecall_number);
// trace!("Register dump: {:?}", vm.registers);
match r1 {
match ecall_number {
0 => {
// TODO: explode computer
// hello world ecall
@ -34,7 +34,7 @@ pub fn handler(vm: &mut Vm) {
1 => {
// Make buffer
let bounded = match vm.registers[2].cast::<u64>() {
let bounded = match vm.registers[3].cast::<u64>() {
0 => false,
1 => true,
_ => {
@ -42,7 +42,7 @@ pub fn handler(vm: &mut Vm) {
}
};
let length = vm.registers[3].cast::<u64>();
let length = vm.registers[4].cast::<u64>();
let mut buffs = IPC_BUFFERS.lock();
let abc;
@ -65,13 +65,9 @@ pub fn handler(vm: &mut Vm) {
}
3 => {
// Send a message to a buffer
let r2 = vm.registers[2].cast::<u64>();
let r3 = vm.registers[3].cast::<u64>();
let r4 = vm.registers[4].cast::<u64>();
let buffer_id = r2;
let mem_addr = r3;
let length = r4 as usize;
let buffer_id = vm.registers[3].cast::<u64>();
let mem_addr = vm.registers[4].cast::<u64>();
let length = vm.registers[5].cast::<u64>() as usize;
trace!("IPC address: {:?}", mem_addr);
use alloc::vec::Vec;
@ -119,12 +115,12 @@ pub fn handler(vm: &mut Vm) {
}
}
4 => {
let r2 = vm.registers[2].cast::<u64>();
let buffer_id = vm.registers[3].cast::<u64>();
let mut buffs = IPC_BUFFERS.lock();
let mut buff = buffs.get_mut(&r2).unwrap();
let mut buff = buffs.get_mut(&buffer_id).unwrap();
let msg = buff.pop();
info!("Recieve {:?} from Buffer({})", msg, r2);
info!("Recieve {:?} from Buffer({})", msg, buffer_id);
}
5 => {
#[cfg(target_arch = "x86_64")]
@ -141,7 +137,7 @@ pub fn handler(vm: &mut Vm) {
}
// 5
_ => {
log::error!("Syscall unknown {:?}{:?}", r1, vm.registers);
log::error!("Syscall unknown {:?}{:?}", ecall_number, vm.registers);
}
}
}