forked from M-Labs/artiq
1
0
Fork 0

runtime: merge sync_tsc and wait_tsc_ack

This commit is contained in:
Sebastien Bourdeauducq 2018-09-10 22:17:00 +08:00
parent 4d889c0c4e
commit e01efbcb8a
1 changed files with 7 additions and 11 deletions

View File

@ -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) { fn init_buffer_space(linkno: u8) {
let linkidx = linkno as usize; let linkidx = linkno as usize;
unsafe { 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 { loop {
let mut count = 0; let mut count = 0;
if !link_rx_up(linkno) { if !link_rx_up(linkno) {
@ -191,8 +188,7 @@ pub mod drtio {
info!("[LINK#{}] remote replied after {} packets", linkno, ping_count); info!("[LINK#{}] remote replied after {} packets", linkno, ping_count);
set_link_up(linkno, true); set_link_up(linkno, true);
init_buffer_space(linkno); init_buffer_space(linkno);
sync_tsc(linkno); if sync_tsc(linkno, &io).is_err() {
if wait_tsc_ack(linkno, &io).is_err() {
error!("[LINK#{}] remote failed to ack TSC", linkno); error!("[LINK#{}] remote failed to ack TSC", linkno);
} else { } else {
info!("[LINK#{}] link initialization completed", linkno); info!("[LINK#{}] link initialization completed", linkno);