restart and communicate with core1 in handle_connection

This commit is contained in:
Sebastien Bourdeauducq 2020-04-17 14:43:50 +08:00
parent 1c67ff50e3
commit abe0a549b5
3 changed files with 24 additions and 14 deletions

10
Cargo.lock generated
View File

@ -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",

View File

@ -154,7 +154,7 @@ async fn handle_connection(stream: &TcpStream, control: Rc<RefCell<kernel::Contr
},
Request::LoadKernel => {
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<RefCell<kernel::Contr
}
println!("length={}, {:?}", length, &kernel_buffer[..256]);
let mut control = control.borrow_mut();
control.restart();
for i in 0..10 {
control.tx.async_send(i).await;
let j = control.rx.async_recv().await;
println!("{} -> {}", 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<RefCell<Option<kernel::Control>>> = Rc::new(RefCell::new(None));
let control: Rc<RefCell<kernel::Control>> = Rc::new(RefCell::new(kernel::Control::start(8192)));
task::spawn(async move {
loop {

View File

@ -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;
}
}