WIP: Support CoreMgmt over DRTIO on Zynq Devices #323

Draft
occheung wants to merge 25 commits from occheung/artiq-zynq:drtio-coremgmt into master
2 changed files with 42 additions and 6 deletions
Showing only changes of commit a921755e39 - Show all commits

View File

@ -784,7 +784,11 @@ pub fn main(timer: GlobalTimer, cfg: Config) {
let cfg = Rc::new(cfg);
let restart_idle = Rc::new(Semaphore::new(1, 1));
mgmt::start(cfg.clone(), restart_idle.clone(), Some((&aux_mutex, &drtio_routing_table, timer)));
mgmt::start(
cfg.clone(),
restart_idle.clone(),
Some((&aux_mutex, &drtio_routing_table, timer)),
);
task::spawn(async move {
let connection = Rc::new(Semaphore::new(1, 1));

View File

@ -761,7 +761,13 @@ mod local_coremgmt {
Ok(())
}
pub async fn config_write(stream: &mut TcpStream, cfg: &Rc<Config>, key: &String, value: Vec<u8>, restart_idle: &Rc<Semaphore>) -> Result<()> {
pub async fn config_write(
stream: &mut TcpStream,
cfg: &Rc<Config>,
key: &String,
value: Vec<u8>,
restart_idle: &Rc<Semaphore>,
) -> Result<()> {
let value = cfg.write(&key, value);
if value.is_ok() {
debug!("write success");
@ -777,7 +783,12 @@ mod local_coremgmt {
Ok(())
}
pub async fn config_remove(stream: &mut TcpStream, cfg: &Rc<Config>, key: &String, restart_idle: &Rc<Semaphore>) -> Result<()> {
pub async fn config_remove(
stream: &mut TcpStream,
cfg: &Rc<Config>,
key: &String,
restart_idle: &Rc<Semaphore>,
) -> Result<()> {
debug!("erase key: {}", key);
let value = cfg.remove(&key);
if value.is_ok() {
@ -894,11 +905,28 @@ async fn handle_connection(
buffer.set_len(len);
}
read_chunk(stream, &mut buffer).await?;
process!(stream, _drtio_tuple, _destination, config_write, &cfg, &key, buffer, &restart_idle)
process!(
stream,
_drtio_tuple,
_destination,
config_write,
&cfg,
&key,
buffer,
&restart_idle
)
}
Request::ConfigRemove => {
let key = read_key(stream).await?;
process!(stream, _drtio_tuple, _destination, config_remove, &cfg, &key, &restart_idle)
process!(
stream,
_drtio_tuple,
_destination,
config_remove,
&cfg,
&key,
&restart_idle
)
}
Request::Reboot => {
process!(stream, _drtio_tuple, _destination, reboot)
@ -926,7 +954,11 @@ async fn handle_connection(
}
}
pub fn start(cfg: Rc<Config>, restart_idle: Rc<Semaphore>, drtio_tuple: Option<(&Rc<Mutex<bool>>, &Rc<RefCell<RoutingTable>>, GlobalTimer)>) {
pub fn start(
cfg: Rc<Config>,
restart_idle: Rc<Semaphore>,
drtio_tuple: Option<(&Rc<Mutex<bool>>, &Rc<RefCell<RoutingTable>>, GlobalTimer)>,
) {
let drtio_tuple =
drtio_tuple.map(|(aux_mutex, routing_table, timer)| (aux_mutex.clone(), routing_table.clone(), timer));
task::spawn(async move {