From aff569b2c3662a9eb98b07efa75f369d3ee84e32 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 17 Mar 2022 19:56:07 +0800 Subject: [PATCH] firmware: support 64-bit moninj probes --- artiq/coredevice/comm_moninj.py | 5 ++--- artiq/firmware/libproto_artiq/drtioaux_proto.rs | 6 +++--- artiq/firmware/libproto_artiq/moninj_proto.rs | 4 ++-- artiq/firmware/runtime/moninj.rs | 8 ++++---- artiq/firmware/satman/main.rs | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/artiq/coredevice/comm_moninj.py b/artiq/coredevice/comm_moninj.py index f03e91bbc..d25da82e8 100644 --- a/artiq/coredevice/comm_moninj.py +++ b/artiq/coredevice/comm_moninj.py @@ -84,9 +84,8 @@ class CommMonInj: if not ty: return if ty == b"\x00": - payload = await self._reader.readexactly(9) - channel, probe, value = struct.unpack( - self.endian + "lbl", payload) + payload = await self._reader.readexactly(13) + channel, probe, value = struct.unpack(self.endian + "lbq", payload) self.monitor_cb(channel, probe, value) elif ty == b"\x01": payload = await self._reader.readexactly(6) diff --git a/artiq/firmware/libproto_artiq/drtioaux_proto.rs b/artiq/firmware/libproto_artiq/drtioaux_proto.rs index 36e2cb45b..dbfe4a5ad 100644 --- a/artiq/firmware/libproto_artiq/drtioaux_proto.rs +++ b/artiq/firmware/libproto_artiq/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 }, @@ -105,7 +105,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()?, @@ -259,7 +259,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/artiq/firmware/libproto_artiq/moninj_proto.rs b/artiq/firmware/libproto_artiq/moninj_proto.rs index dba2f84bc..c5b76f2bd 100644 --- a/artiq/firmware/libproto_artiq/moninj_proto.rs +++ b/artiq/firmware/libproto_artiq/moninj_proto.rs @@ -40,7 +40,7 @@ pub enum HostMessage { #[derive(Debug)] pub enum DeviceMessage { - MonitorStatus { channel: u32, probe: u8, value: u32 }, + MonitorStatus { channel: u32, probe: u8, value: u64 }, InjectionStatus { channel: u32, overrd: u8, value: u8 } } @@ -82,7 +82,7 @@ impl DeviceMessage { writer.write_u8(0)?; writer.write_u32(channel)?; writer.write_u8(probe)?; - writer.write_u32(value)?; + writer.write_u64(value)?; }, DeviceMessage::InjectionStatus { channel, overrd, value } => { writer.write_u8(1)?; diff --git a/artiq/firmware/runtime/moninj.rs b/artiq/firmware/runtime/moninj.rs index c1bba04fc..76a209f63 100644 --- a/artiq/firmware/runtime/moninj.rs +++ b/artiq/firmware/runtime/moninj.rs @@ -13,12 +13,12 @@ use board_artiq::drtio_routing; mod local_moninj { use board_misoc::csr; - pub fn read_probe(channel: u16, probe: u8) -> u32 { + pub fn read_probe(channel: u16, probe: u8) -> u64 { unsafe { 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); - csr::rtio_moninj::mon_value_read() as u32 + csr::rtio_moninj::mon_value_read() as u64 } } @@ -41,7 +41,7 @@ mod local_moninj { #[cfg(not(has_rtio_moninj))] mod local_moninj { - pub fn read_probe(_channel: u16, _probe: u8) -> u32 { 0 } + pub fn read_probe(_channel: u16, _probe: u8) -> u64 { 0 } pub fn inject(_channel: u16, _overrd: u8, _value: u8) { } @@ -54,7 +54,7 @@ mod remote_moninj { use rtio_mgt::drtio; use sched::{Io, Mutex}; - pub fn read_probe(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, channel: u16, probe: u8) -> u32 { + pub fn read_probe(io: &Io, aux_mutex: &Mutex, linkno: u8, destination: u8, channel: u16, probe: u8) -> u64 { let reply = drtio::aux_transact(io, aux_mutex, linkno, &drtioaux::Packet::MonitorRequest { destination: destination, channel: channel, diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index a99e3d5b3..10beb6695 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -207,13 +207,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, overrd, value } => {