session: send host any async errors detection if found

This commit is contained in:
Steve Fan 2021-12-06 15:00:59 +08:00
parent dbc3f581e5
commit 851ed095df
3 changed files with 13 additions and 7 deletions

View File

@ -224,13 +224,14 @@ async fn handle_run_kernel(stream: Option<&TcpStream>, control: &Rc<RefCell<kern
} }
} }
}, },
kernel::Message::KernelFinished => { kernel::Message::KernelFinished { async_errors } => {
if let Some(stream) = stream { if let Some(stream) = stream {
write_header(stream, Reply::KernelFinished).await?; write_header(stream, Reply::KernelFinished).await?;
write_i8(stream, async_errors as i8).await?;
} }
break; break;
}, },
kernel::Message::KernelException(exception, backtrace) => { kernel::Message::KernelException(exception, backtrace, async_errors) => {
match stream { match stream {
Some(stream) => { Some(stream) => {
// only send the exception data to host if there is host, // only send the exception data to host if there is host,
@ -249,6 +250,7 @@ async fn handle_run_kernel(stream: Option<&TcpStream>, control: &Rc<RefCell<kern
for &addr in backtrace { for &addr in backtrace {
write_i32(stream, addr as i32).await?; write_i32(stream, addr as i32).await?;
} }
write_i8(stream, async_errors as i8).await?;
}, },
None => { None => {
error!("Uncaught kernel exception: {:?}", exception); error!("Uncaught kernel exception: {:?}", exception);

View File

@ -14,7 +14,7 @@ use libcortex_a9::{
use libboard_zynq::{mpcore, gic}; use libboard_zynq::{mpcore, gic};
use libsupport_zynq::ram; use libsupport_zynq::ram;
use dyld::{self, Library}; use dyld::{self, Library};
use crate::{eh_artiq, rtio}; use crate::{eh_artiq, get_async_errors, rtio};
use super::{ use super::{
api::resolve, api::resolve,
rpc::rpc_send_async, rpc::rpc_send_async,
@ -192,7 +192,8 @@ pub extern "C" fn main_core1() {
} }
} }
info!("kernel finished"); info!("kernel finished");
core1_tx.send(Message::KernelFinished); let async_errors = unsafe { get_async_errors() };
core1_tx.send(Message::KernelFinished { async_errors });
} }
_ => error!("Core1 received unexpected message: {:?}", message), _ => error!("Core1 received unexpected message: {:?}", message),
} }
@ -216,7 +217,8 @@ pub fn terminate(exception: &'static eh_artiq::Exception<'static>, backtrace: &'
{ {
let core1_tx = unsafe { KERNEL_CHANNEL_1TO0.as_mut().unwrap() }; let core1_tx = unsafe { KERNEL_CHANNEL_1TO0.as_mut().unwrap() };
core1_tx.send(Message::KernelException(exception, &backtrace[..cursor])); let errors = unsafe { get_async_errors() };
core1_tx.send(Message::KernelException(exception, &backtrace[..cursor], errors));
} }
loop {} loop {}
} }

View File

@ -30,8 +30,10 @@ pub enum Message {
LoadCompleted, LoadCompleted,
LoadFailed, LoadFailed,
StartRequest, StartRequest,
KernelFinished, KernelFinished {
KernelException(&'static eh_artiq::Exception<'static>, &'static [usize]), async_errors: u8
},
KernelException(&'static eh_artiq::Exception<'static>, &'static [usize], u8),
RpcSend { is_async: bool, data: Vec<u8> }, RpcSend { is_async: bool, data: Vec<u8> },
RpcRecvRequest(*mut ()), RpcRecvRequest(*mut ()),
RpcRecvReply(Result<usize, RPCException>), RpcRecvReply(Result<usize, RPCException>),