mirror of https://github.com/m-labs/artiq.git
firmware: simplify drtioaux function names
This commit is contained in:
parent
ae72e3a51e
commit
d19550daf8
|
@ -80,7 +80,7 @@ fn receive<F, T>(linkno: u8, f: F) -> Result<Option<T>, Error<!>>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recv_link(linkno: u8) -> Result<Option<Packet>, Error<!>> {
|
pub fn recv(linkno: u8) -> Result<Option<Packet>, Error<!>> {
|
||||||
if has_rx_error(linkno) {
|
if has_rx_error(linkno) {
|
||||||
return Err(Error::GatewareError)
|
return Err(Error::GatewareError)
|
||||||
}
|
}
|
||||||
|
@ -104,11 +104,11 @@ pub fn recv_link(linkno: u8) -> Result<Option<Packet>, Error<!>> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recv_timeout_link(linkno: u8, timeout_ms: Option<u64>) -> Result<Packet, Error<!>> {
|
pub fn recv_timeout(linkno: u8, timeout_ms: Option<u64>) -> Result<Packet, Error<!>> {
|
||||||
let timeout_ms = timeout_ms.unwrap_or(10);
|
let timeout_ms = timeout_ms.unwrap_or(10);
|
||||||
let limit = clock::get_ms() + timeout_ms;
|
let limit = clock::get_ms() + timeout_ms;
|
||||||
while clock::get_ms() < limit {
|
while clock::get_ms() < limit {
|
||||||
match recv_link(linkno)? {
|
match recv(linkno)? {
|
||||||
None => (),
|
None => (),
|
||||||
Some(packet) => return Ok(packet),
|
Some(packet) => return Ok(packet),
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ fn transmit<F>(linkno: u8, f: F) -> Result<(), Error<!>>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_link(linkno: u8, packet: &Packet) -> Result<(), Error<!>> {
|
pub fn send(linkno: u8, packet: &Packet) -> Result<(), Error<!>> {
|
||||||
transmit(linkno, |buffer| {
|
transmit(linkno, |buffer| {
|
||||||
let mut writer = Cursor::new(buffer);
|
let mut writer = Cursor::new(buffer);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ mod remote_i2c {
|
||||||
use drtioaux;
|
use drtioaux;
|
||||||
|
|
||||||
fn basic_reply(linkno: u8) -> Result<(), ()> {
|
fn basic_reply(linkno: u8) -> Result<(), ()> {
|
||||||
match drtioaux::recv_timeout_link(linkno, None) {
|
match drtioaux::recv_timeout(linkno, None) {
|
||||||
Ok(drtioaux::Packet::I2cBasicReply { succeeded }) => {
|
Ok(drtioaux::Packet::I2cBasicReply { succeeded }) => {
|
||||||
if succeeded { Ok(()) } else { Err(()) }
|
if succeeded { Ok(()) } else { Err(()) }
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ mod remote_i2c {
|
||||||
destination: destination,
|
destination: destination,
|
||||||
busno: busno
|
busno: busno
|
||||||
};
|
};
|
||||||
if drtioaux::send_link(linkno, &request).is_err() {
|
if drtioaux::send(linkno, &request).is_err() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
basic_reply(linkno)
|
basic_reply(linkno)
|
||||||
|
@ -42,7 +42,7 @@ mod remote_i2c {
|
||||||
destination: destination,
|
destination: destination,
|
||||||
busno: busno
|
busno: busno
|
||||||
};
|
};
|
||||||
if drtioaux::send_link(linkno, &request).is_err() {
|
if drtioaux::send(linkno, &request).is_err() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
basic_reply(linkno)
|
basic_reply(linkno)
|
||||||
|
@ -53,7 +53,7 @@ mod remote_i2c {
|
||||||
destination: destination,
|
destination: destination,
|
||||||
busno: busno
|
busno: busno
|
||||||
};
|
};
|
||||||
if drtioaux::send_link(linkno, &request).is_err() {
|
if drtioaux::send(linkno, &request).is_err() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
basic_reply(linkno)
|
basic_reply(linkno)
|
||||||
|
@ -65,10 +65,10 @@ mod remote_i2c {
|
||||||
busno: busno,
|
busno: busno,
|
||||||
data: data
|
data: data
|
||||||
};
|
};
|
||||||
if drtioaux::send_link(linkno, &request).is_err() {
|
if drtioaux::send(linkno, &request).is_err() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
match drtioaux::recv_timeout_link(linkno, None) {
|
match drtioaux::recv_timeout(linkno, None) {
|
||||||
Ok(drtioaux::Packet::I2cWriteReply { succeeded, ack }) => {
|
Ok(drtioaux::Packet::I2cWriteReply { succeeded, ack }) => {
|
||||||
if succeeded { Ok(ack) } else { Err(()) }
|
if succeeded { Ok(ack) } else { Err(()) }
|
||||||
}
|
}
|
||||||
|
@ -89,10 +89,10 @@ mod remote_i2c {
|
||||||
busno: busno,
|
busno: busno,
|
||||||
ack: ack
|
ack: ack
|
||||||
};
|
};
|
||||||
if drtioaux::send_link(linkno, &request).is_err() {
|
if drtioaux::send(linkno, &request).is_err() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
match drtioaux::recv_timeout_link(linkno, None) {
|
match drtioaux::recv_timeout(linkno, None) {
|
||||||
Ok(drtioaux::Packet::I2cReadReply { succeeded, data }) => {
|
Ok(drtioaux::Packet::I2cReadReply { succeeded, data }) => {
|
||||||
if succeeded { Ok(data) } else { Err(()) }
|
if succeeded { Ok(data) } else { Err(()) }
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ mod remote_spi {
|
||||||
use drtioaux;
|
use drtioaux;
|
||||||
|
|
||||||
fn basic_reply(linkno: u8) -> Result<(), ()> {
|
fn basic_reply(linkno: u8) -> Result<(), ()> {
|
||||||
match drtioaux::recv_timeout_link(linkno, None) {
|
match drtioaux::recv_timeout(linkno, None) {
|
||||||
Ok(drtioaux::Packet::SpiBasicReply { succeeded }) => {
|
Ok(drtioaux::Packet::SpiBasicReply { succeeded }) => {
|
||||||
if succeeded { Ok(()) } else { Err(()) }
|
if succeeded { Ok(()) } else { Err(()) }
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ mod remote_spi {
|
||||||
div: div,
|
div: div,
|
||||||
cs: cs
|
cs: cs
|
||||||
};
|
};
|
||||||
if drtioaux::send_link(linkno, &request).is_err() {
|
if drtioaux::send(linkno, &request).is_err() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
basic_reply(linkno)
|
basic_reply(linkno)
|
||||||
|
@ -149,7 +149,7 @@ mod remote_spi {
|
||||||
busno: busno,
|
busno: busno,
|
||||||
data: data
|
data: data
|
||||||
};
|
};
|
||||||
if drtioaux::send_link(linkno, &request).is_err() {
|
if drtioaux::send(linkno, &request).is_err() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
basic_reply(linkno)
|
basic_reply(linkno)
|
||||||
|
@ -160,10 +160,10 @@ mod remote_spi {
|
||||||
destination: destination,
|
destination: destination,
|
||||||
busno: busno
|
busno: busno
|
||||||
};
|
};
|
||||||
if drtioaux::send_link(linkno, &request).is_err() {
|
if drtioaux::send(linkno, &request).is_err() {
|
||||||
return Err(())
|
return Err(())
|
||||||
}
|
}
|
||||||
match drtioaux::recv_timeout_link(linkno, None) {
|
match drtioaux::recv_timeout(linkno, None) {
|
||||||
Ok(drtioaux::Packet::SpiReadReply { succeeded, data }) => {
|
Ok(drtioaux::Packet::SpiReadReply { succeeded, data }) => {
|
||||||
if succeeded { Ok(data) } else { Err(()) }
|
if succeeded { Ok(data) } else { Err(()) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,14 +57,14 @@ mod remote_moninj {
|
||||||
channel: channel,
|
channel: channel,
|
||||||
probe: probe
|
probe: probe
|
||||||
};
|
};
|
||||||
match drtioaux::send_link(linkno, &request) {
|
match drtioaux::send(linkno, &request) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("aux packet error ({})", e);
|
error!("aux packet error ({})", e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match drtioaux::recv_timeout_link(linkno, None) {
|
match drtioaux::recv_timeout(linkno, None) {
|
||||||
Ok(drtioaux::Packet::MonitorReply { value }) => return value,
|
Ok(drtioaux::Packet::MonitorReply { value }) => return value,
|
||||||
Ok(_) => error!("received unexpected aux packet"),
|
Ok(_) => error!("received unexpected aux packet"),
|
||||||
Err(e) => error!("aux packet error ({})", e)
|
Err(e) => error!("aux packet error ({})", e)
|
||||||
|
@ -79,7 +79,7 @@ mod remote_moninj {
|
||||||
overrd: overrd,
|
overrd: overrd,
|
||||||
value: value
|
value: value
|
||||||
};
|
};
|
||||||
match drtioaux::send_link(linkno, &request) {
|
match drtioaux::send(linkno, &request) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => error!("aux packet error ({})", e)
|
Err(e) => error!("aux packet error ({})", e)
|
||||||
}
|
}
|
||||||
|
@ -91,14 +91,14 @@ mod remote_moninj {
|
||||||
channel: channel,
|
channel: channel,
|
||||||
overrd: overrd
|
overrd: overrd
|
||||||
};
|
};
|
||||||
match drtioaux::send_link(linkno, &request) {
|
match drtioaux::send(linkno, &request) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("aux packet error ({})", e);
|
error!("aux packet error ({})", e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
match drtioaux::recv_timeout_link(linkno, None) {
|
match drtioaux::recv_timeout(linkno, None) {
|
||||||
Ok(drtioaux::Packet::InjectionStatusReply { value }) => return value,
|
Ok(drtioaux::Packet::InjectionStatusReply { value }) => return value,
|
||||||
Ok(_) => error!("received unexpected aux packet"),
|
Ok(_) => error!("received unexpected aux packet"),
|
||||||
Err(e) => error!("aux packet error ({})", e)
|
Err(e) => error!("aux packet error ({})", e)
|
||||||
|
|
|
@ -93,9 +93,9 @@ pub mod drtio {
|
||||||
if count > 200 {
|
if count > 200 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
drtioaux::send_link(linkno, &drtioaux::Packet::EchoRequest).unwrap();
|
drtioaux::send(linkno, &drtioaux::Packet::EchoRequest).unwrap();
|
||||||
io.sleep(100).unwrap();
|
io.sleep(100).unwrap();
|
||||||
let pr = drtioaux::recv_link(linkno);
|
let pr = drtioaux::recv(linkno);
|
||||||
match pr {
|
match pr {
|
||||||
Ok(Some(drtioaux::Packet::EchoReply)) => return count,
|
Ok(Some(drtioaux::Packet::EchoReply)) => return count,
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -112,7 +112,7 @@ pub mod drtio {
|
||||||
if clock::get_ms() > max_time {
|
if clock::get_ms() > max_time {
|
||||||
return Err("timeout");
|
return Err("timeout");
|
||||||
}
|
}
|
||||||
match drtioaux::recv_link(linkno) {
|
match drtioaux::recv(linkno) {
|
||||||
Ok(Some(packet)) => return Ok(packet),
|
Ok(Some(packet)) => return Ok(packet),
|
||||||
Ok(None) => (),
|
Ok(None) => (),
|
||||||
Err(_) => return Err("aux packet error")
|
Err(_) => return Err("aux packet error")
|
||||||
|
@ -139,7 +139,7 @@ pub mod drtio {
|
||||||
fn load_routing_table(io: &Io, linkno: u8, routing_table: &drtio_routing::RoutingTable)
|
fn load_routing_table(io: &Io, linkno: u8, routing_table: &drtio_routing::RoutingTable)
|
||||||
-> Result<(), &'static str> {
|
-> Result<(), &'static str> {
|
||||||
for i in 0..drtio_routing::DEST_COUNT {
|
for i in 0..drtio_routing::DEST_COUNT {
|
||||||
drtioaux::send_link(linkno, &drtioaux::Packet::RoutingSetPath {
|
drtioaux::send(linkno, &drtioaux::Packet::RoutingSetPath {
|
||||||
destination: i as u8,
|
destination: i as u8,
|
||||||
hops: routing_table.0[i]
|
hops: routing_table.0[i]
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
@ -152,7 +152,7 @@ pub mod drtio {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_rank(io: &Io, linkno: u8, rank: u8) -> Result<(), &'static str> {
|
fn set_rank(io: &Io, linkno: u8, rank: u8) -> Result<(), &'static str> {
|
||||||
drtioaux::send_link(linkno, &drtioaux::Packet::RoutingSetRank {
|
drtioaux::send(linkno, &drtioaux::Packet::RoutingSetRank {
|
||||||
rank: rank
|
rank: rank
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
let reply = recv_aux_timeout(io, linkno, 200)?;
|
let reply = recv_aux_timeout(io, linkno, 200)?;
|
||||||
|
@ -176,7 +176,7 @@ pub mod drtio {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_unsolicited_aux(linkno: u8) {
|
fn process_unsolicited_aux(linkno: u8) {
|
||||||
match drtioaux::recv_link(linkno) {
|
match drtioaux::recv(linkno) {
|
||||||
Ok(Some(packet)) => warn!("[LINK#{}] unsolicited aux packet: {:?}", linkno, packet),
|
Ok(Some(packet)) => warn!("[LINK#{}] unsolicited aux packet: {:?}", linkno, packet),
|
||||||
Ok(None) => (),
|
Ok(None) => (),
|
||||||
Err(_) => warn!("[LINK#{}] aux packet error", linkno)
|
Err(_) => warn!("[LINK#{}] aux packet error", linkno)
|
||||||
|
@ -219,7 +219,7 @@ pub mod drtio {
|
||||||
let linkno = hop - 1;
|
let linkno = hop - 1;
|
||||||
if up_destinations[destination] {
|
if up_destinations[destination] {
|
||||||
if link_up(linkno) {
|
if link_up(linkno) {
|
||||||
drtioaux::send_link(linkno, &drtioaux::Packet::DestinationStatusRequest {
|
drtioaux::send(linkno, &drtioaux::Packet::DestinationStatusRequest {
|
||||||
destination: destination as u8
|
destination: destination as u8
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
match recv_aux_timeout(io, linkno, 200) {
|
match recv_aux_timeout(io, linkno, 200) {
|
||||||
|
@ -243,7 +243,7 @@ pub mod drtio {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if link_up(linkno) {
|
if link_up(linkno) {
|
||||||
drtioaux::send_link(linkno, &drtioaux::Packet::DestinationStatusRequest {
|
drtioaux::send(linkno, &drtioaux::Packet::DestinationStatusRequest {
|
||||||
destination: destination as u8
|
destination: destination as u8
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
match recv_aux_timeout(io, linkno, 200) {
|
match recv_aux_timeout(io, linkno, 200) {
|
||||||
|
@ -309,9 +309,9 @@ pub mod drtio {
|
||||||
for linkno in 0..csr::DRTIO.len() {
|
for linkno in 0..csr::DRTIO.len() {
|
||||||
let linkno = linkno as u8;
|
let linkno = linkno as u8;
|
||||||
if link_up(linkno) {
|
if link_up(linkno) {
|
||||||
drtioaux::send_link(linkno,
|
drtioaux::send(linkno,
|
||||||
&drtioaux::Packet::ResetRequest { phy: false }).unwrap();
|
&drtioaux::Packet::ResetRequest { phy: false }).unwrap();
|
||||||
match drtioaux::recv_timeout_link(linkno, None) {
|
match drtioaux::recv_timeout(linkno, None) {
|
||||||
Ok(drtioaux::Packet::ResetAck) => (),
|
Ok(drtioaux::Packet::ResetAck) => (),
|
||||||
Ok(_) => error!("[LINK#{}] reset failed, received unexpected aux packet", linkno),
|
Ok(_) => error!("[LINK#{}] reset failed, received unexpected aux packet", linkno),
|
||||||
Err(e) => error!("[LINK#{}] reset failed, aux packet error ({})", linkno, e)
|
Err(e) => error!("[LINK#{}] reset failed, aux packet error ({})", linkno, e)
|
||||||
|
|
|
@ -74,7 +74,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
// and u16 otherwise; hence the `as _` conversion.
|
// and u16 otherwise; hence the `as _` conversion.
|
||||||
match packet {
|
match packet {
|
||||||
drtioaux::Packet::EchoRequest =>
|
drtioaux::Packet::EchoRequest =>
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::EchoReply),
|
drtioaux::send(0, &drtioaux::Packet::EchoReply),
|
||||||
drtioaux::Packet::ResetRequest { phy } => {
|
drtioaux::Packet::ResetRequest { phy } => {
|
||||||
info!("resetting RTIO");
|
info!("resetting RTIO");
|
||||||
if phy {
|
if phy {
|
||||||
|
@ -89,7 +89,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
error!("failed to issue RTIO reset ({})", e);
|
error!("failed to issue RTIO reset ({})", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::ResetAck)
|
drtioaux::send(0, &drtioaux::Packet::ResetAck)
|
||||||
},
|
},
|
||||||
|
|
||||||
drtioaux::Packet::DestinationStatusRequest { destination } => {
|
drtioaux::Packet::DestinationStatusRequest { destination } => {
|
||||||
|
@ -109,7 +109,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
channel = csr::drtiosat::sequence_error_channel_read();
|
channel = csr::drtiosat::sequence_error_channel_read();
|
||||||
csr::drtiosat::rtio_error_write(1);
|
csr::drtiosat::rtio_error_write(1);
|
||||||
}
|
}
|
||||||
drtioaux::send_link(0,
|
drtioaux::send(0,
|
||||||
&drtioaux::Packet::DestinationSequenceErrorReply { channel })?;
|
&drtioaux::Packet::DestinationSequenceErrorReply { channel })?;
|
||||||
} else if errors & 2 != 0 {
|
} else if errors & 2 != 0 {
|
||||||
let channel;
|
let channel;
|
||||||
|
@ -117,7 +117,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
channel = csr::drtiosat::collision_channel_read();
|
channel = csr::drtiosat::collision_channel_read();
|
||||||
csr::drtiosat::rtio_error_write(2);
|
csr::drtiosat::rtio_error_write(2);
|
||||||
}
|
}
|
||||||
drtioaux::send_link(0,
|
drtioaux::send(0,
|
||||||
&drtioaux::Packet::DestinationCollisionReply { channel })?;
|
&drtioaux::Packet::DestinationCollisionReply { channel })?;
|
||||||
} else if errors & 4 != 0 {
|
} else if errors & 4 != 0 {
|
||||||
let channel;
|
let channel;
|
||||||
|
@ -125,11 +125,11 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
channel = csr::drtiosat::busy_channel_read();
|
channel = csr::drtiosat::busy_channel_read();
|
||||||
csr::drtiosat::rtio_error_write(4);
|
csr::drtiosat::rtio_error_write(4);
|
||||||
}
|
}
|
||||||
drtioaux::send_link(0,
|
drtioaux::send(0,
|
||||||
&drtioaux::Packet::DestinationBusyReply { channel })?;
|
&drtioaux::Packet::DestinationBusyReply { channel })?;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::DestinationOkReply)?;
|
drtioaux::send(0, &drtioaux::Packet::DestinationOkReply)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,14 +143,14 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
destination: destination
|
destination: destination
|
||||||
}) {
|
}) {
|
||||||
Ok(()) => (),
|
Ok(()) => (),
|
||||||
Err(drtioaux::Error::LinkDown) => drtioaux::send_link(0, &drtioaux::Packet::DestinationDownReply)?,
|
Err(drtioaux::Error::LinkDown) => drtioaux::send(0, &drtioaux::Packet::DestinationDownReply)?,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::DestinationDownReply)?;
|
drtioaux::send(0, &drtioaux::Packet::DestinationDownReply)?;
|
||||||
error!("aux error when handling destination status request: {}", e);
|
error!("aux error when handling destination status request: {}", e);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::DestinationDownReply)?;
|
drtioaux::send(0, &drtioaux::Packet::DestinationDownReply)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
error!("failed to set path ({})", e);
|
error!("failed to set path ({})", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::RoutingAck)
|
drtioaux::send(0, &drtioaux::Packet::RoutingAck)
|
||||||
}
|
}
|
||||||
#[cfg(has_drtio_routing)]
|
#[cfg(has_drtio_routing)]
|
||||||
drtioaux::Packet::RoutingSetRank { rank } => {
|
drtioaux::Packet::RoutingSetRank { rank } => {
|
||||||
|
@ -183,16 +183,16 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
info!("rank: {}", rank);
|
info!("rank: {}", rank);
|
||||||
info!("routing table: {}", _routing_table);
|
info!("routing table: {}", _routing_table);
|
||||||
|
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::RoutingAck)
|
drtioaux::send(0, &drtioaux::Packet::RoutingAck)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(has_drtio_routing))]
|
#[cfg(not(has_drtio_routing))]
|
||||||
drtioaux::Packet::RoutingSetPath { destination, hops } => {
|
drtioaux::Packet::RoutingSetPath { destination, hops } => {
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::RoutingAck)
|
drtioaux::send(0, &drtioaux::Packet::RoutingAck)
|
||||||
}
|
}
|
||||||
#[cfg(not(has_drtio_routing))]
|
#[cfg(not(has_drtio_routing))]
|
||||||
drtioaux::Packet::RoutingSetRank { rank } => {
|
drtioaux::Packet::RoutingSetRank { rank } => {
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::RoutingAck)
|
drtioaux::send(0, &drtioaux::Packet::RoutingAck)
|
||||||
}
|
}
|
||||||
|
|
||||||
drtioaux::Packet::MonitorRequest { destination, channel, probe } => {
|
drtioaux::Packet::MonitorRequest { destination, channel, probe } => {
|
||||||
|
@ -210,7 +210,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
value = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
let reply = drtioaux::Packet::MonitorReply { value: value as u32 };
|
let reply = drtioaux::Packet::MonitorReply { value: value as u32 };
|
||||||
drtioaux::send_link(0, &reply)
|
drtioaux::send(0, &reply)
|
||||||
},
|
},
|
||||||
drtioaux::Packet::InjectionRequest { destination, channel, overrd, value } => {
|
drtioaux::Packet::InjectionRequest { destination, channel, overrd, value } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
|
@ -235,39 +235,39 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
{
|
{
|
||||||
value = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::InjectionStatusReply { value: value })
|
drtioaux::send(0, &drtioaux::Packet::InjectionStatusReply { value: value })
|
||||||
},
|
},
|
||||||
|
|
||||||
drtioaux::Packet::I2cStartRequest { destination, busno } => {
|
drtioaux::Packet::I2cStartRequest { destination, busno } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
let succeeded = i2c::start(busno).is_ok();
|
let succeeded = i2c::start(busno).is_ok();
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||||
}
|
}
|
||||||
drtioaux::Packet::I2cRestartRequest { destination, busno } => {
|
drtioaux::Packet::I2cRestartRequest { destination, busno } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
let succeeded = i2c::restart(busno).is_ok();
|
let succeeded = i2c::restart(busno).is_ok();
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||||
}
|
}
|
||||||
drtioaux::Packet::I2cStopRequest { destination, busno } => {
|
drtioaux::Packet::I2cStopRequest { destination, busno } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
let succeeded = i2c::stop(busno).is_ok();
|
let succeeded = i2c::stop(busno).is_ok();
|
||||||
drtioaux::send_link(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
drtioaux::send(0, &drtioaux::Packet::I2cBasicReply { succeeded: succeeded })
|
||||||
}
|
}
|
||||||
drtioaux::Packet::I2cWriteRequest { destination, busno, data } => {
|
drtioaux::Packet::I2cWriteRequest { destination, busno, data } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
match i2c::write(busno, data) {
|
match i2c::write(busno, data) {
|
||||||
Ok(ack) => drtioaux::send_link(0,
|
Ok(ack) => drtioaux::send(0,
|
||||||
&drtioaux::Packet::I2cWriteReply { succeeded: true, ack: ack }),
|
&drtioaux::Packet::I2cWriteReply { succeeded: true, ack: ack }),
|
||||||
Err(_) => drtioaux::send_link(0,
|
Err(_) => drtioaux::send(0,
|
||||||
&drtioaux::Packet::I2cWriteReply { succeeded: false, ack: false })
|
&drtioaux::Packet::I2cWriteReply { succeeded: false, ack: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::Packet::I2cReadRequest { destination, busno, ack } => {
|
drtioaux::Packet::I2cReadRequest { destination, busno, ack } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
match i2c::read(busno, ack) {
|
match i2c::read(busno, ack) {
|
||||||
Ok(data) => drtioaux::send_link(0,
|
Ok(data) => drtioaux::send(0,
|
||||||
&drtioaux::Packet::I2cReadReply { succeeded: true, data: data }),
|
&drtioaux::Packet::I2cReadReply { succeeded: true, data: data }),
|
||||||
Err(_) => drtioaux::send_link(0,
|
Err(_) => drtioaux::send(0,
|
||||||
&drtioaux::Packet::I2cReadReply { succeeded: false, data: 0xff })
|
&drtioaux::Packet::I2cReadReply { succeeded: false, data: 0xff })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,21 +275,21 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
drtioaux::Packet::SpiSetConfigRequest { destination, busno, flags, length, div, cs } => {
|
drtioaux::Packet::SpiSetConfigRequest { destination, busno, flags, length, div, cs } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
let succeeded = spi::set_config(busno, flags, length, div, cs).is_ok();
|
let succeeded = spi::set_config(busno, flags, length, div, cs).is_ok();
|
||||||
drtioaux::send_link(0,
|
drtioaux::send(0,
|
||||||
&drtioaux::Packet::SpiBasicReply { succeeded: succeeded })
|
&drtioaux::Packet::SpiBasicReply { succeeded: succeeded })
|
||||||
},
|
},
|
||||||
drtioaux::Packet::SpiWriteRequest { destination, busno, data } => {
|
drtioaux::Packet::SpiWriteRequest { destination, busno, data } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
let succeeded = spi::write(busno, data).is_ok();
|
let succeeded = spi::write(busno, data).is_ok();
|
||||||
drtioaux::send_link(0,
|
drtioaux::send(0,
|
||||||
&drtioaux::Packet::SpiBasicReply { succeeded: succeeded })
|
&drtioaux::Packet::SpiBasicReply { succeeded: succeeded })
|
||||||
}
|
}
|
||||||
drtioaux::Packet::SpiReadRequest { destination, busno } => {
|
drtioaux::Packet::SpiReadRequest { destination, busno } => {
|
||||||
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
forward!(_routing_table, destination, *_rank, _repeaters, &packet);
|
||||||
match spi::read(busno) {
|
match spi::read(busno) {
|
||||||
Ok(data) => drtioaux::send_link(0,
|
Ok(data) => drtioaux::send(0,
|
||||||
&drtioaux::Packet::SpiReadReply { succeeded: true, data: data }),
|
&drtioaux::Packet::SpiReadReply { succeeded: true, data: data }),
|
||||||
Err(_) => drtioaux::send_link(0,
|
Err(_) => drtioaux::send(0,
|
||||||
&drtioaux::Packet::SpiReadReply { succeeded: false, data: 0 })
|
&drtioaux::Packet::SpiReadReply { succeeded: false, data: 0 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,7 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater],
|
||||||
fn process_aux_packets(repeaters: &mut [repeater::Repeater],
|
fn process_aux_packets(repeaters: &mut [repeater::Repeater],
|
||||||
routing_table: &mut drtio_routing::RoutingTable, rank: &mut u8) {
|
routing_table: &mut drtio_routing::RoutingTable, rank: &mut u8) {
|
||||||
let result =
|
let result =
|
||||||
drtioaux::recv_link(0).and_then(|packet| {
|
drtioaux::recv(0).and_then(|packet| {
|
||||||
if let Some(packet) = packet {
|
if let Some(packet) = packet {
|
||||||
process_aux_packet(repeaters, routing_table, rank, packet)
|
process_aux_packet(repeaters, routing_table, rank, packet)
|
||||||
} else {
|
} else {
|
||||||
|
@ -463,7 +463,7 @@ pub extern fn main() -> i32 {
|
||||||
error!("failed to sync TSC ({})", e);
|
error!("failed to sync TSC ({})", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Err(e) = drtioaux::send_link(0, &drtioaux::Packet::TSCAck) {
|
if let Err(e) = drtioaux::send(0, &drtioaux::Packet::TSCAck) {
|
||||||
error!("aux packet error: {}", e);
|
error!("aux packet error: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl Repeater {
|
||||||
}
|
}
|
||||||
RepeaterState::SendPing { ping_count } => {
|
RepeaterState::SendPing { ping_count } => {
|
||||||
if rep_link_rx_up(self.repno) {
|
if rep_link_rx_up(self.repno) {
|
||||||
drtioaux::send_link(self.auxno, &drtioaux::Packet::EchoRequest).unwrap();
|
drtioaux::send(self.auxno, &drtioaux::Packet::EchoRequest).unwrap();
|
||||||
self.state = RepeaterState::WaitPingReply {
|
self.state = RepeaterState::WaitPingReply {
|
||||||
ping_count: ping_count + 1,
|
ping_count: ping_count + 1,
|
||||||
timeout: clock::get_ms() + 100
|
timeout: clock::get_ms() + 100
|
||||||
|
@ -63,7 +63,7 @@ impl Repeater {
|
||||||
}
|
}
|
||||||
RepeaterState::WaitPingReply { ping_count, timeout } => {
|
RepeaterState::WaitPingReply { ping_count, timeout } => {
|
||||||
if rep_link_rx_up(self.repno) {
|
if rep_link_rx_up(self.repno) {
|
||||||
if let Ok(Some(drtioaux::Packet::EchoReply)) = drtioaux::recv_link(self.auxno) {
|
if let Ok(Some(drtioaux::Packet::EchoReply)) = drtioaux::recv(self.auxno) {
|
||||||
info!("[REP#{}] remote replied after {} packets", self.repno, ping_count);
|
info!("[REP#{}] remote replied after {} packets", self.repno, ping_count);
|
||||||
self.state = RepeaterState::Up;
|
self.state = RepeaterState::Up;
|
||||||
if let Err(e) = self.sync_tsc() {
|
if let Err(e) = self.sync_tsc() {
|
||||||
|
@ -113,7 +113,7 @@ impl Repeater {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_unsolicited_aux(&self) {
|
fn process_unsolicited_aux(&self) {
|
||||||
match drtioaux::recv_link(self.auxno) {
|
match drtioaux::recv(self.auxno) {
|
||||||
Ok(Some(packet)) => warn!("[REP#{}] unsolicited aux packet: {:?}", self.repno, packet),
|
Ok(Some(packet)) => warn!("[REP#{}] unsolicited aux packet: {:?}", self.repno, packet),
|
||||||
Ok(None) => (),
|
Ok(None) => (),
|
||||||
Err(_) => warn!("[REP#{}] aux packet error", self.repno)
|
Err(_) => warn!("[REP#{}] aux packet error", self.repno)
|
||||||
|
@ -162,7 +162,7 @@ impl Repeater {
|
||||||
if clock::get_ms() > max_time {
|
if clock::get_ms() > max_time {
|
||||||
return Err(drtioaux::Error::TimedOut);
|
return Err(drtioaux::Error::TimedOut);
|
||||||
}
|
}
|
||||||
match drtioaux::recv_link(self.auxno) {
|
match drtioaux::recv(self.auxno) {
|
||||||
Ok(Some(packet)) => return Ok(packet),
|
Ok(Some(packet)) => return Ok(packet),
|
||||||
Ok(None) => (),
|
Ok(None) => (),
|
||||||
Err(e) => return Err(e)
|
Err(e) => return Err(e)
|
||||||
|
@ -174,9 +174,9 @@ impl Repeater {
|
||||||
if self.state != RepeaterState::Up {
|
if self.state != RepeaterState::Up {
|
||||||
return Err(drtioaux::Error::LinkDown);
|
return Err(drtioaux::Error::LinkDown);
|
||||||
}
|
}
|
||||||
drtioaux::send_link(self.auxno, request).unwrap();
|
drtioaux::send(self.auxno, request).unwrap();
|
||||||
let reply = self.recv_aux_timeout(200)?;
|
let reply = self.recv_aux_timeout(200)?;
|
||||||
drtioaux::send_link(0, &reply).unwrap();
|
drtioaux::send(0, &reply).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ impl Repeater {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
drtioaux::send_link(self.auxno, &drtioaux::Packet::RoutingSetPath {
|
drtioaux::send(self.auxno, &drtioaux::Packet::RoutingSetPath {
|
||||||
destination: destination,
|
destination: destination,
|
||||||
hops: *hops
|
hops: *hops
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
|
@ -228,7 +228,7 @@ impl Repeater {
|
||||||
if self.state != RepeaterState::Up {
|
if self.state != RepeaterState::Up {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
drtioaux::send_link(self.auxno, &drtioaux::Packet::RoutingSetRank {
|
drtioaux::send(self.auxno, &drtioaux::Packet::RoutingSetRank {
|
||||||
rank: rank
|
rank: rank
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
let reply = self.recv_aux_timeout(200)?;
|
let reply = self.recv_aux_timeout(200)?;
|
||||||
|
@ -242,7 +242,7 @@ impl Repeater {
|
||||||
if self.state != RepeaterState::Up {
|
if self.state != RepeaterState::Up {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
drtioaux::send_link(self.auxno, &drtioaux::Packet::ResetRequest {
|
drtioaux::send(self.auxno, &drtioaux::Packet::ResetRequest {
|
||||||
phy: phy
|
phy: phy
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
let reply = self.recv_aux_timeout(200)?;
|
let reply = self.recv_aux_timeout(200)?;
|
||||||
|
|
Loading…
Reference in New Issue