1
0
Fork 0
forked from koniifer/ableos

Ecall work

This commit is contained in:
able 2023-09-09 02:35:16 -05:00
parent 8fec90db95
commit 1be13d30d1
7 changed files with 84 additions and 35 deletions

4
Cargo.lock generated
View file

@ -425,12 +425,12 @@ dependencies = [
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#0b9601e10565c1d368ec75c1e7e7606054037371" source = "git+https://git.ablecorp.us/ableos/holey-bytes#35f3d59a547e285310551177e31bd3522d62fa08"
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/ableos/holey-bytes#0b9601e10565c1d368ec75c1e7e7606054037371" source = "git+https://git.ablecorp.us/ableos/holey-bytes#35f3d59a547e285310551177e31bd3522d62fa08"
dependencies = [ dependencies = [
"hbbytecode", "hbbytecode",
] ]

View file

@ -0,0 +1,41 @@
use {
crate::{
ipc::buffer::{BufferTypes, IpcBuffer},
kmain::IPC_BUFFERS,
},
hbvm::value::Value,
};
pub fn make_ipc_buffer(registers: [Value; 256]) {
let r255 = registers[255];
let r254 = registers[254];
let r253 = registers[253];
let bounded = match unsafe { r254.u64 } {
0 => false,
1 => true,
_ => {
panic!("Bad");
}
};
let length = unsafe { r254.u64 };
let mut buffs = IPC_BUFFERS.lock();
match bounded {
false => {
let abc = IpcBuffer::new(false, 0);
buffs.push(abc);
}
true => {
let abc = IpcBuffer::new(true, length);
buffs.push(abc);
}
};
}
pub fn delete_ipc_buffer(registers: [Value; 256]) {
log::warn!("Unstable ecall");
//TODO: fully define out how to layout the ecall for deleting buffers
//and figure out what happens if there are still messages in the queue
}

View file

@ -1,3 +1,5 @@
use crate::kmain::IPC_BUFFERS;
use { use {
alloc::boxed::Box, alloc::boxed::Box,
core::{default, future::Future, task::Poll}, core::{default, future::Future, task::Poll},
@ -10,6 +12,8 @@ use {
}, },
}; };
mod ecalls;
const TIMER_QUOTIENT: usize = 100; const TIMER_QUOTIENT: usize = 100;
pub struct ExecThread<'p> { pub struct ExecThread<'p> {
@ -71,33 +75,11 @@ Register dump: {:?}",
} }
1 => { 1 => {
// Make buffer // Make buffer
log::trace!( ecalls::make_ipc_buffer(self.vm.registers);
"bounded: {}\n\r
length: {:?}",
match unsafe { r254.u64 } {
0 => {
false
}
1 => {
true
}
_ => {
// TODO: throw this back to the runtime
panic!("Bad");
}
},
r253
)
} }
2 => { 2 => {
// Delete buffer // Delete buffer
log::warn!("Syscall 2"); ecalls::delete_ipc_buffer(self.vm.registers);
}
3 => {
log::warn!("Syscall 3");
}
4 => {
log::warn!("Syscall 4");
} }
_ => { _ => {

View file

@ -16,6 +16,34 @@ pub struct IpcBuffer {
} }
impl IpcBuffer { impl IpcBuffer {
pub fn new(bounded: bool, length: u64) -> Self {
log::debug!(
"New IPCBuffer\r
bounded: {}\r
length: {:?}\r",
bounded,
length
);
match (bounded, length) {
(false, a) => {
let buftype = BufferTypes::Unbound(SegQueue::new());
Self {
protocol: Protocol {},
buffer: buftype,
}
}
(true, length) => {
let buftype = BufferTypes::Bound(ArrayQueue::new(length as usize));
Self {
protocol: Protocol {},
buffer: buftype,
}
}
}
}
/// Validate a message to match the `IPC.protocol` /// Validate a message to match the `IPC.protocol`
pub fn validate_messages(&mut self) -> Result<(), IpcError> { pub fn validate_messages(&mut self) -> Result<(), IpcError> {
Ok(()) Ok(())

View file

@ -2,8 +2,7 @@
use hbvm::mem::Address; use hbvm::mem::Address;
use crate::holeybytes::ExecThread; use crate::{capabilities, holeybytes::ExecThread, ipc::buffer::IpcBuffer};
// use crate::arch::sloop; // use crate::arch::sloop;
use { use {
crate::{ crate::{
@ -27,6 +26,7 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
let _bmcmd: XMLElement; let _bmcmd: XMLElement;
if bm.cmd.len() >= 2 { if bm.cmd.len() >= 2 {
// TODO: pass into the program // TODO: pass into the program
// Pass CMDLine into an IPCBuffer and put the ptr to the IPCBuffer in r200
_bmcmd = build_cmd(name, bm.cmd.clone()); _bmcmd = build_cmd(name, bm.cmd.clone());
} }
} }
@ -40,8 +40,6 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
// TODO: schedule the filesystem driver from the initramfs // TODO: schedule the filesystem driver from the initramfs
// TODO: schedule the init system from the initramfs // TODO: schedule the init system from the initramfs
// capabilities::example();
let mut executor = crate::task::Executor::default(); let mut executor = crate::task::Executor::default();
unsafe { unsafe {
for module in boot_modules.into_iter().take(2) { for module in boot_modules.into_iter().take(2) {
@ -63,8 +61,8 @@ pub static DEVICE_TREE: Lazy<Mutex<DeviceTree>> = Lazy::new(|| {
Mutex::new(dt) Mutex::new(dt)
}); });
use {crate::ipc::buffer::BufferTypes, alloc::vec::Vec}; use alloc::vec::Vec;
pub static IPC_BUFFERS: Lazy<Mutex<Vec<BufferTypes>>> = Lazy::new(|| { pub static IPC_BUFFERS: Lazy<Mutex<Vec<IpcBuffer>>> = Lazy::new(|| {
let bufs = Vec::new(); let bufs = Vec::new();
Mutex::new(bufs) Mutex::new(bufs)
}); });

Binary file not shown.