Ecall work
This commit is contained in:
parent
8fec90db95
commit
1be13d30d1
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -425,12 +425,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
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]]
|
||||
name = "hbvm"
|
||||
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 = [
|
||||
"hbbytecode",
|
||||
]
|
||||
|
|
41
kernel/src/holeybytes/ecalls.rs
Normal file
41
kernel/src/holeybytes/ecalls.rs
Normal 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
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
use crate::kmain::IPC_BUFFERS;
|
||||
|
||||
use {
|
||||
alloc::boxed::Box,
|
||||
core::{default, future::Future, task::Poll},
|
||||
|
@ -10,6 +12,8 @@ use {
|
|||
},
|
||||
};
|
||||
|
||||
mod ecalls;
|
||||
|
||||
const TIMER_QUOTIENT: usize = 100;
|
||||
|
||||
pub struct ExecThread<'p> {
|
||||
|
@ -71,33 +75,11 @@ Register dump: {:?}",
|
|||
}
|
||||
1 => {
|
||||
// Make buffer
|
||||
log::trace!(
|
||||
"bounded: {}\n\r
|
||||
length: {:?}",
|
||||
match unsafe { r254.u64 } {
|
||||
0 => {
|
||||
false
|
||||
}
|
||||
1 => {
|
||||
true
|
||||
}
|
||||
_ => {
|
||||
// TODO: throw this back to the runtime
|
||||
panic!("Bad");
|
||||
}
|
||||
},
|
||||
r253
|
||||
)
|
||||
ecalls::make_ipc_buffer(self.vm.registers);
|
||||
}
|
||||
2 => {
|
||||
// Delete buffer
|
||||
log::warn!("Syscall 2");
|
||||
}
|
||||
3 => {
|
||||
log::warn!("Syscall 3");
|
||||
}
|
||||
4 => {
|
||||
log::warn!("Syscall 4");
|
||||
ecalls::delete_ipc_buffer(self.vm.registers);
|
||||
}
|
||||
|
||||
_ => {
|
|
@ -16,6 +16,34 @@ pub struct 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`
|
||||
pub fn validate_messages(&mut self) -> Result<(), IpcError> {
|
||||
Ok(())
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
use hbvm::mem::Address;
|
||||
|
||||
use crate::holeybytes::ExecThread;
|
||||
|
||||
use crate::{capabilities, holeybytes::ExecThread, ipc::buffer::IpcBuffer};
|
||||
// use crate::arch::sloop;
|
||||
use {
|
||||
crate::{
|
||||
|
@ -27,6 +26,7 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
|
|||
let _bmcmd: XMLElement;
|
||||
if bm.cmd.len() >= 2 {
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,6 @@ pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
|
|||
// TODO: schedule the filesystem driver from the initramfs
|
||||
// TODO: schedule the init system from the initramfs
|
||||
|
||||
// capabilities::example();
|
||||
|
||||
let mut executor = crate::task::Executor::default();
|
||||
unsafe {
|
||||
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)
|
||||
});
|
||||
|
||||
use {crate::ipc::buffer::BufferTypes, alloc::vec::Vec};
|
||||
pub static IPC_BUFFERS: Lazy<Mutex<Vec<BufferTypes>>> = Lazy::new(|| {
|
||||
use alloc::vec::Vec;
|
||||
pub static IPC_BUFFERS: Lazy<Mutex<Vec<IpcBuffer>>> = Lazy::new(|| {
|
||||
let bufs = Vec::new();
|
||||
Mutex::new(bufs)
|
||||
});
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue