forked from AbleOS/ableos
ECALL work and expanded errors on HBVM shutdown
This commit is contained in:
parent
b04ee13185
commit
54844b46a0
|
@ -1,6 +1,6 @@
|
|||
use {
|
||||
alloc::boxed::Box,
|
||||
core::{future::Future, task::Poll},
|
||||
core::{default, future::Future, task::Poll},
|
||||
hbvm::{
|
||||
mem::{
|
||||
softpaging::{icache::ICache, HandlePageFault, SoftPagedMem},
|
||||
|
@ -17,7 +17,6 @@ pub struct ExecThread<'p> {
|
|||
}
|
||||
|
||||
unsafe impl<'p> Send for ExecThread<'p> {}
|
||||
|
||||
impl<'p> ExecThread<'p> {
|
||||
pub unsafe fn new(program: &'p [u8], entrypoint: Address) -> Self {
|
||||
ExecThread {
|
||||
|
@ -44,11 +43,67 @@ impl<'p> Future for ExecThread<'p> {
|
|||
cx: &mut core::task::Context<'_>,
|
||||
) -> Poll<Self::Output> {
|
||||
match self.vm.run() {
|
||||
Err(err) => return Poll::Ready(Err(err)),
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
"HBVM Error\r
|
||||
Register dump: {:?}",
|
||||
self.vm.registers
|
||||
);
|
||||
|
||||
return Poll::Ready(Err(err));
|
||||
}
|
||||
Ok(VmRunOk::End) => return Poll::Ready(Ok(())),
|
||||
Ok(VmRunOk::Ecall) => {
|
||||
log::info!("Ecall");
|
||||
log::info!("{:?}", self.vm.registers);
|
||||
let r255 = self.vm.registers[255];
|
||||
let r254 = self.vm.registers[254];
|
||||
let r253 = self.vm.registers[253];
|
||||
|
||||
log::debug!("Ecall number {:?}", r255);
|
||||
log::trace!("Register dump: {:?}", self.vm.registers);
|
||||
|
||||
match r255.cast::<u64>() {
|
||||
0 => {
|
||||
// TODO: explode computer
|
||||
// hello world ecall
|
||||
for x in 0u64..=255 {
|
||||
self.vm.registers[x as usize] = x.into();
|
||||
}
|
||||
}
|
||||
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
|
||||
)
|
||||
}
|
||||
2 => {
|
||||
// Delete buffer
|
||||
log::warn!("Syscall 2");
|
||||
}
|
||||
3 => {
|
||||
log::warn!("Syscall 3");
|
||||
}
|
||||
4 => {
|
||||
log::warn!("Syscall 4");
|
||||
}
|
||||
|
||||
_ => {
|
||||
log::error!("Syscall unknown {:?}", r255)
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(VmRunOk::Timer) => (),
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use {
|
|||
crossbeam_queue::{ArrayQueue, SegQueue},
|
||||
};
|
||||
|
||||
enum BufferTypes {
|
||||
pub enum BufferTypes {
|
||||
Unbound(SegQueue<Message>),
|
||||
Bound(ArrayQueue<Message>),
|
||||
}
|
||||
|
|
|
@ -63,6 +63,12 @@ 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(|| {
|
||||
let bufs = Vec::new();
|
||||
Mutex::new(bufs)
|
||||
});
|
||||
|
||||
#[test_case]
|
||||
fn trivial_assertion() {
|
||||
trace!("trivial assertion... ");
|
||||
|
|
|
@ -42,6 +42,8 @@ pub const VERSION: Version = Version {
|
|||
|
||||
#[panic_handler]
|
||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||
arch::register_dump();
|
||||
|
||||
if let Some(loc) = info.location() {
|
||||
let _ = crate::arch::log(format_args!(
|
||||
"Location: {}: {}, {}\r\n",
|
||||
|
|
Loading…
Reference in a new issue