From e01efbcb8a2fbd8ab2b1c4c96d1f55e68a7bd0db Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 10 Sep 2018 22:17:00 +0800 Subject: [PATCH] runtime: merge sync_tsc and wait_tsc_ack --- artiq/firmware/runtime/rtio_mgt.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/artiq/firmware/runtime/rtio_mgt.rs b/artiq/firmware/runtime/rtio_mgt.rs index a8685e1bd..abb3a4fba 100644 --- a/artiq/firmware/runtime/rtio_mgt.rs +++ b/artiq/firmware/runtime/rtio_mgt.rs @@ -76,14 +76,6 @@ pub mod drtio { } } - fn sync_tsc(linkno: u8) { - let linkno = linkno as usize; - unsafe { - (csr::DRTIO[linkno].set_time_write)(1); - while (csr::DRTIO[linkno].set_time_read)() == 1 {} - } - } - fn init_buffer_space(linkno: u8) { let linkidx = linkno as usize; unsafe { @@ -114,7 +106,12 @@ pub mod drtio { } } - fn wait_tsc_ack(linkno: u8, io: &Io) -> Result<(), &'static str> { + fn sync_tsc(linkno: u8, io: &Io) -> Result<(), &'static str> { + unsafe { + (csr::DRTIO[linkno as usize].set_time_write)(1); + while (csr::DRTIO[linkno as usize].set_time_read)() == 1 {} + } + loop { let mut count = 0; if !link_rx_up(linkno) { @@ -191,8 +188,7 @@ pub mod drtio { info!("[LINK#{}] remote replied after {} packets", linkno, ping_count); set_link_up(linkno, true); init_buffer_space(linkno); - sync_tsc(linkno); - if wait_tsc_ack(linkno, &io).is_err() { + if sync_tsc(linkno, &io).is_err() { error!("[LINK#{}] remote failed to ack TSC", linkno); } else { info!("[LINK#{}] link initialization completed", linkno);