From 426500d2f9478b46a328c5907b6a75677cc7833b Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 17 Mar 2022 20:26:44 +0800 Subject: [PATCH] firmware: support 64-bit moninj probes --- src/libboard_artiq/src/drtioaux_proto.rs | 6 +++--- src/runtime/src/moninj.rs | 12 ++++++------ src/satman/src/main.rs | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libboard_artiq/src/drtioaux_proto.rs b/src/libboard_artiq/src/drtioaux_proto.rs index e2fee29..dc76497 100644 --- a/src/libboard_artiq/src/drtioaux_proto.rs +++ b/src/libboard_artiq/src/drtioaux_proto.rs @@ -34,7 +34,7 @@ pub enum Packet { RoutingAck, MonitorRequest { destination: u8, channel: u16, probe: u8 }, - MonitorReply { value: u32 }, + MonitorReply { value: u64 }, InjectionRequest { destination: u8, channel: u16, overrd: u8, value: u8 }, InjectionStatusRequest { destination: u8, channel: u16, overrd: u8 }, InjectionStatusReply { value: u8 }, @@ -103,7 +103,7 @@ impl Packet { probe: reader.read_u8()? }, 0x41 => Packet::MonitorReply { - value: reader.read_u32()? + value: reader.read_u64()? }, 0x50 => Packet::InjectionRequest { destination: reader.read_u8()?, @@ -247,7 +247,7 @@ impl Packet { }, Packet::MonitorReply { value } => { writer.write_u8(0x41)?; - writer.write_u32(value)?; + writer.write_u64(value)?; }, Packet::InjectionRequest { destination, channel, overrd, value } => { writer.write_u8(0x50)?; diff --git a/src/runtime/src/moninj.rs b/src/runtime/src/moninj.rs index b9c66c4..3163316 100644 --- a/src/runtime/src/moninj.rs +++ b/src/runtime/src/moninj.rs @@ -62,14 +62,14 @@ mod remote_moninj { use crate::rtio_mgt::drtio; use log::error; - pub fn read_probe(aux_mutex: &Rc>, timer: GlobalTimer, linkno: u8, destination: u8, channel: i32, probe: i8) -> i32 { + pub fn read_probe(aux_mutex: &Rc>, timer: GlobalTimer, linkno: u8, destination: u8, channel: i32, probe: i8) -> i64 { let reply = task::block_on(drtio::aux_transact(aux_mutex, linkno, &drtioaux::Packet::MonitorRequest { destination: destination, channel: channel as _, probe: probe as _}, timer)); match reply { - Ok(drtioaux::Packet::MonitorReply { value }) => return value as i32, + Ok(drtioaux::Packet::MonitorReply { value }) => return value as i64, Ok(packet) => error!("received unexpected aux packet: {:?}", packet), Err(e) => error!("aux packet error ({})", e) } @@ -106,12 +106,12 @@ mod remote_moninj { mod local_moninj { use libboard_artiq::pl::csr; - pub fn read_probe(channel: i32, probe: i8) -> i32 { + pub fn read_probe(channel: i32, probe: i8) -> i64 { unsafe { csr::rtio_moninj::mon_chan_sel_write(channel as _); csr::rtio_moninj::mon_probe_sel_write(probe as _); csr::rtio_moninj::mon_value_update_write(1); - csr::rtio_moninj::mon_value_read() as i32 + csr::rtio_moninj::mon_value_read() as i64 } } @@ -162,7 +162,7 @@ async fn handle_connection(stream: &TcpStream, timer: GlobalTimer, } stream.send_slice("e".as_bytes()).await?; - let mut probe_watch_list: BTreeMap<(i32, i8), Option> = BTreeMap::new(); + let mut probe_watch_list: BTreeMap<(i32, i8), Option> = BTreeMap::new(); let mut inject_watch_list: BTreeMap<(i32, i8), Option> = BTreeMap::new(); let mut next_check = Milliseconds(0); loop { @@ -233,7 +233,7 @@ async fn handle_connection(stream: &TcpStream, timer: GlobalTimer, write_i8(&stream, DeviceMessage::MonitorStatus.to_i8().unwrap()).await?; write_i32(&stream, channel).await?; write_i8(&stream, probe).await?; - write_i32(&stream, current).await?; + write_i64(&stream, current).await?; *previous = Some(current); } } diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index 3bd7902..2282616 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -212,13 +212,13 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater], csr::rtio_moninj::mon_chan_sel_write(channel as _); csr::rtio_moninj::mon_probe_sel_write(probe); csr::rtio_moninj::mon_value_update_write(1); - value = csr::rtio_moninj::mon_value_read(); + value = csr::rtio_moninj::mon_value_read() as u64; } #[cfg(not(has_rtio_moninj))] { value = 0; } - let reply = drtioaux::Packet::MonitorReply { value: value as u32 }; + let reply = drtioaux::Packet::MonitorReply { value: value }; drtioaux::send(0, &reply) }, drtioaux::Packet::InjectionRequest { destination: _destination, channel: _channel,