forked from koniifer/ableos
ECALL work and expanded errors on HBVM shutdown
This commit is contained in:
parent
b04ee13185
commit
54844b46a0
|
@ -1,6 +1,6 @@
|
||||||
use {
|
use {
|
||||||
alloc::boxed::Box,
|
alloc::boxed::Box,
|
||||||
core::{future::Future, task::Poll},
|
core::{default, future::Future, task::Poll},
|
||||||
hbvm::{
|
hbvm::{
|
||||||
mem::{
|
mem::{
|
||||||
softpaging::{icache::ICache, HandlePageFault, SoftPagedMem},
|
softpaging::{icache::ICache, HandlePageFault, SoftPagedMem},
|
||||||
|
@ -17,7 +17,6 @@ pub struct ExecThread<'p> {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<'p> Send for ExecThread<'p> {}
|
unsafe impl<'p> Send for ExecThread<'p> {}
|
||||||
|
|
||||||
impl<'p> ExecThread<'p> {
|
impl<'p> ExecThread<'p> {
|
||||||
pub unsafe fn new(program: &'p [u8], entrypoint: Address) -> Self {
|
pub unsafe fn new(program: &'p [u8], entrypoint: Address) -> Self {
|
||||||
ExecThread {
|
ExecThread {
|
||||||
|
@ -44,11 +43,67 @@ impl<'p> Future for ExecThread<'p> {
|
||||||
cx: &mut core::task::Context<'_>,
|
cx: &mut core::task::Context<'_>,
|
||||||
) -> Poll<Self::Output> {
|
) -> Poll<Self::Output> {
|
||||||
match self.vm.run() {
|
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::End) => return Poll::Ready(Ok(())),
|
||||||
Ok(VmRunOk::Ecall) => {
|
Ok(VmRunOk::Ecall) => {
|
||||||
log::info!("Ecall");
|
let r255 = self.vm.registers[255];
|
||||||
log::info!("{:?}", self.vm.registers);
|
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) => (),
|
Ok(VmRunOk::Timer) => (),
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use {
|
||||||
crossbeam_queue::{ArrayQueue, SegQueue},
|
crossbeam_queue::{ArrayQueue, SegQueue},
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BufferTypes {
|
pub enum BufferTypes {
|
||||||
Unbound(SegQueue<Message>),
|
Unbound(SegQueue<Message>),
|
||||||
Bound(ArrayQueue<Message>),
|
Bound(ArrayQueue<Message>),
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,12 @@ pub static DEVICE_TREE: Lazy<Mutex<DeviceTree>> = Lazy::new(|| {
|
||||||
Mutex::new(dt)
|
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]
|
#[test_case]
|
||||||
fn trivial_assertion() {
|
fn trivial_assertion() {
|
||||||
trace!("trivial assertion... ");
|
trace!("trivial assertion... ");
|
||||||
|
|
|
@ -42,6 +42,8 @@ pub const VERSION: Version = Version {
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||||
|
arch::register_dump();
|
||||||
|
|
||||||
if let Some(loc) = info.location() {
|
if let Some(loc) = info.location() {
|
||||||
let _ = crate::arch::log(format_args!(
|
let _ = crate::arch::log(format_args!(
|
||||||
"Location: {}: {}, {}\r\n",
|
"Location: {}: {}, {}\r\n",
|
||||||
|
|
Loading…
Reference in a new issue