runtime: merge sync_tsc and wait_tsc_ack

pull/1212/head
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) {
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);