send RPC requests to host

core0-buffer
Sebastien Bourdeauducq 2020-06-07 15:13:20 +08:00
parent 1f23a1b86c
commit 4b8bbdc3dc
2 changed files with 8 additions and 1 deletions

View File

@ -147,7 +147,9 @@ async fn handle_connection(stream: &TcpStream, control: Rc<RefCell<kernel::Contr
break;
},
kernel::Message::RpcSend { is_async, data } => {
debug!("RPC: is_async={} data={:?}", is_async, data);
write_header(&stream, Reply::RPCRequest).await?;
write_bool(&stream, is_async).await?;
stream.send(data.iter().copied()).await?;
},
_ => {
error!("received unexpected message from core1 while kernel was running: {:?}", reply);

View File

@ -84,6 +84,11 @@ pub async fn write_i8(stream: &TcpStream, value: i8) -> Result<()> {
Ok(())
}
pub async fn write_bool(stream: &TcpStream, value: bool) -> Result<()> {
stream.send([value as u8].iter().copied()).await?;
Ok(())
}
pub async fn write_i32(stream: &TcpStream, value: i32) -> Result<()> {
stream.send([
(value >> 24) as u8,