forked from koniifer/ableos
Update ecalls to match the spec
This commit is contained in:
parent
d90016f28e
commit
a511e99606
|
@ -18,12 +18,12 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn handler(vm: &mut Vm) {
|
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);
|
// trace!("Register dump: {:?}", vm.registers);
|
||||||
|
|
||||||
match r1 {
|
match ecall_number {
|
||||||
0 => {
|
0 => {
|
||||||
// TODO: explode computer
|
// TODO: explode computer
|
||||||
// hello world ecall
|
// hello world ecall
|
||||||
|
@ -34,7 +34,7 @@ pub fn handler(vm: &mut Vm) {
|
||||||
1 => {
|
1 => {
|
||||||
// Make buffer
|
// Make buffer
|
||||||
|
|
||||||
let bounded = match vm.registers[2].cast::<u64>() {
|
let bounded = match vm.registers[3].cast::<u64>() {
|
||||||
0 => false,
|
0 => false,
|
||||||
1 => true,
|
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 mut buffs = IPC_BUFFERS.lock();
|
||||||
let abc;
|
let abc;
|
||||||
|
@ -65,13 +65,9 @@ pub fn handler(vm: &mut Vm) {
|
||||||
}
|
}
|
||||||
3 => {
|
3 => {
|
||||||
// Send a message to a buffer
|
// Send a message to a buffer
|
||||||
let r2 = vm.registers[2].cast::<u64>();
|
let buffer_id = vm.registers[3].cast::<u64>();
|
||||||
let r3 = vm.registers[3].cast::<u64>();
|
let mem_addr = vm.registers[4].cast::<u64>();
|
||||||
let r4 = vm.registers[4].cast::<u64>();
|
let length = vm.registers[5].cast::<u64>() as usize;
|
||||||
|
|
||||||
let buffer_id = r2;
|
|
||||||
let mem_addr = r3;
|
|
||||||
let length = r4 as usize;
|
|
||||||
trace!("IPC address: {:?}", mem_addr);
|
trace!("IPC address: {:?}", mem_addr);
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
|
@ -119,12 +115,12 @@ pub fn handler(vm: &mut Vm) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
4 => {
|
4 => {
|
||||||
let r2 = vm.registers[2].cast::<u64>();
|
let buffer_id = vm.registers[3].cast::<u64>();
|
||||||
|
|
||||||
let mut buffs = IPC_BUFFERS.lock();
|
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();
|
let msg = buff.pop();
|
||||||
info!("Recieve {:?} from Buffer({})", msg, r2);
|
info!("Recieve {:?} from Buffer({})", msg, buffer_id);
|
||||||
}
|
}
|
||||||
5 => {
|
5 => {
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
|
@ -141,7 +137,7 @@ pub fn handler(vm: &mut Vm) {
|
||||||
}
|
}
|
||||||
// 5
|
// 5
|
||||||
_ => {
|
_ => {
|
||||||
log::error!("Syscall unknown {:?}{:?}", r1, vm.registers);
|
log::error!("Syscall unknown {:?}{:?}", ecall_number, vm.registers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue