From abe0a549b588bc3a6a25a0489b6a3f4d005f87b5 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 17 Apr 2020 14:43:50 +0800 Subject: [PATCH] restart and communicate with core1 in handle_connection --- Cargo.lock | 10 +++++----- runtime/src/comms.rs | 17 ++++++++++------- runtime/src/kernel.rs | 11 +++++++++-- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c62896..da7edc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,7 +43,7 @@ version = "0.1.0" [[package]] name = "libasync" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zc706.git#bcedd02ad95f6afd241e0759f5c3a33a1b26d32d" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#50667f0a13839bee519bd5e55dbad60a91b38a67" dependencies = [ "libcortex_a9", "pin-utils", @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "libboard_zynq" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zc706.git#bcedd02ad95f6afd241e0759f5c3a33a1b26d32d" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#50667f0a13839bee519bd5e55dbad60a91b38a67" dependencies = [ "bit_field", "libcortex_a9", @@ -65,7 +65,7 @@ dependencies = [ [[package]] name = "libcortex_a9" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zc706.git#bcedd02ad95f6afd241e0759f5c3a33a1b26d32d" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#50667f0a13839bee519bd5e55dbad60a91b38a67" dependencies = [ "bit_field", "libregister", @@ -74,7 +74,7 @@ dependencies = [ [[package]] name = "libregister" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zc706.git#bcedd02ad95f6afd241e0759f5c3a33a1b26d32d" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#50667f0a13839bee519bd5e55dbad60a91b38a67" dependencies = [ "bit_field", "vcell", @@ -84,7 +84,7 @@ dependencies = [ [[package]] name = "libsupport_zynq" version = "0.0.0" -source = "git+https://git.m-labs.hk/M-Labs/zc706.git#bcedd02ad95f6afd241e0759f5c3a33a1b26d32d" +source = "git+https://git.m-labs.hk/M-Labs/zc706.git#50667f0a13839bee519bd5e55dbad60a91b38a67" dependencies = [ "compiler_builtins", "libboard_zynq", diff --git a/runtime/src/comms.rs b/runtime/src/comms.rs index 651ff7e..b1465d1 100644 --- a/runtime/src/comms.rs +++ b/runtime/src/comms.rs @@ -154,7 +154,7 @@ async fn handle_connection(stream: &TcpStream, control: Rc { let length = read_i32(&stream).await? as usize; - let mut kernel_buffer = unsafe { &mut kernel::KERNEL_BUFFER }; + let kernel_buffer = unsafe { &mut kernel::KERNEL_BUFFER }; if kernel_buffer.len() < length { read_drain(&stream, length).await?; send_header(&stream, Reply::LoadFailed).await?; @@ -164,13 +164,16 @@ async fn handle_connection(stream: &TcpStream, control: Rc {}", i, j); + } + // TODO: dyld - control.borrow_mut() - .take() - .map(|control| control.reset()); - - *control.borrow_mut() = Some(kernel::Control::start(8192)); } _ => return Err(Error::UnrecognizedPacket) } @@ -217,7 +220,7 @@ pub fn main() { Sockets::init(32); - let control: Rc>> = Rc::new(RefCell::new(None)); + let control: Rc> = Rc::new(RefCell::new(kernel::Control::start(8192))); task::spawn(async move { loop { diff --git a/runtime/src/kernel.rs b/runtime/src/kernel.rs index 342794a..1f648a8 100644 --- a/runtime/src/kernel.rs +++ b/runtime/src/kernel.rs @@ -29,11 +29,18 @@ impl Control { } } - pub fn reset(self) { + pub fn restart(&mut self) { *CHANNEL_0TO1.lock() = None; *CHANNEL_1TO0.lock() = None; - self.core1.reset(); + self.core1.restart(); + + let (core0_tx, core1_rx) = sync_channel(4); + let (core1_tx, core0_rx) = sync_channel(4); + *CHANNEL_0TO1.lock() = Some(core1_rx); + *CHANNEL_1TO0.lock() = Some(core1_tx); + self.tx = core0_tx; + self.rx = core0_rx; } }