diff --git a/artiq/firmware/libproto_artiq/drtioaux_proto.rs b/artiq/firmware/libproto_artiq/drtioaux_proto.rs index ba826873a..4aeeaec12 100644 --- a/artiq/firmware/libproto_artiq/drtioaux_proto.rs +++ b/artiq/firmware/libproto_artiq/drtioaux_proto.rs @@ -141,8 +141,7 @@ pub enum Packet { CoreMgmtAllocatorDebugRequest { destination: u8 }, CoreMgmtGetLogReply { last: bool, length: u16, data: [u8; SAT_PAYLOAD_MAX_SIZE] }, CoreMgmtConfigReadReply { last: bool, length: u16, value: [u8; SAT_PAYLOAD_MAX_SIZE] }, - CoreMgmtAck, - CoreMgmtNack, + CoreMgmtReply { succeeded: bool }, } impl Packet { @@ -505,8 +504,9 @@ impl Packet { value: value, } }, - 0xdd => Packet::CoreMgmtAck, - 0xde => Packet::CoreMgmtNack, + 0xdd => Packet::CoreMgmtReply { + succeeded: reader.read_bool()?, + }, ty => return Err(Error::UnknownPacket(ty)) }) @@ -876,8 +876,10 @@ impl Packet { writer.write_u16(length)?; writer.write_all(&value[0..length as usize])?; }, - Packet::CoreMgmtAck => writer.write_u8(0xdd)?, - Packet::CoreMgmtNack => writer.write_u8(0xde)?, + Packet::CoreMgmtReply { succeeded } => { + writer.write_u8(0xdd)?; + writer.write_bool(succeeded)?; + }, } Ok(()) } diff --git a/artiq/firmware/runtime/mgmt.rs b/artiq/firmware/runtime/mgmt.rs index 95ac3870b..3fd70079d 100644 --- a/artiq/firmware/runtime/mgmt.rs +++ b/artiq/firmware/runtime/mgmt.rs @@ -216,7 +216,7 @@ mod remote_coremgmt { ); match reply { - Ok(Packet::CoreMgmtAck) => { + Ok(Packet::CoreMgmtReply { succeeded: true }) => { Reply::Success.write_to(stream)?; Ok(()) } @@ -267,7 +267,7 @@ mod remote_coremgmt { ); match reply { - Ok(Packet::CoreMgmtAck) => { + Ok(Packet::CoreMgmtReply { succeeded: true }) => { Reply::Success.write_to(stream)?; Ok(()) } @@ -293,7 +293,7 @@ mod remote_coremgmt { ); match reply { - Ok(Packet::CoreMgmtAck) => { + Ok(Packet::CoreMgmtReply { succeeded: true }) => { Reply::Success.write_to(stream)?; Ok(()) } @@ -371,7 +371,7 @@ mod remote_coremgmt { &Packet::CoreMgmtConfigWriteRequest { destination: destination, length: len as u16, last: status.is_last(), data: *slice}); match reply { - Ok(Packet::CoreMgmtAck) => Ok(()), + Ok(Packet::CoreMgmtReply { succeeded: true }) => Ok(()), Ok(packet) => { error!("received unexpected aux packet: {:?}", packet); Err(drtio::Error::UnexpectedReply) @@ -410,7 +410,7 @@ mod remote_coremgmt { }); match reply { - Ok(Packet::CoreMgmtAck) => { + Ok(Packet::CoreMgmtReply { succeeded: true }) => { Reply::Success.write_to(stream)?; Ok(()) } @@ -437,7 +437,7 @@ mod remote_coremgmt { }); match reply { - Ok(Packet::CoreMgmtAck) => { + Ok(Packet::CoreMgmtReply { succeeded: true }) => { Reply::Success.write_to(stream)?; Ok(()) } @@ -464,7 +464,7 @@ mod remote_coremgmt { }); match reply { - Ok(Packet::CoreMgmtAck) => { + Ok(Packet::CoreMgmtReply { succeeded: true }) => { Reply::RebootImminent.write_to(stream)?; Ok(()) } @@ -491,7 +491,7 @@ mod remote_coremgmt { }); match reply { - Ok(Packet::CoreMgmtAck) => Ok(()), + Ok(Packet::CoreMgmtReply { succeeded: true }) => Ok(()), Ok(packet) => { error!("received unexpected aux packet: {:?}", packet); Err(drtio::Error::UnexpectedReply.into()) diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index c7ca63775..16ccf31fb 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -504,13 +504,13 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet); error!("RISC-V satellite devices do not support buffered logging"); - drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false }) } drtioaux::Packet::CoreMgmtSetUartLogLevelRequest { destination: _destination, .. } => { forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet); error!("RISC-V satellite devices has fixed UART log level fixed at TRACE"); - drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false }) } drtioaux::Packet::CoreMgmtConfigReadRequest { destination: _destination, @@ -524,7 +524,7 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg let key_slice = &key[..length as usize]; if !key_slice.is_ascii() { error!("invalid key"); - drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false }) } else { let key = core::str::from_utf8(key_slice).unwrap(); if coremgr.fetch_config_value(key).is_ok() { @@ -538,7 +538,7 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg }, ) } else { - drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false }) } } } @@ -565,7 +565,7 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg if last { coremgr.write_config() } else { - drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck) + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true }) } } drtioaux::Packet::CoreMgmtConfigRemoveRequest { destination: _destination, length, key } => { @@ -576,16 +576,12 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg .map_err(|err| warn!("error on removing config: {:?}", err)) .is_ok(); - if succeeded { - drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck) - } else { - drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) - } + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded }) } drtioaux::Packet::CoreMgmtRebootRequest { destination: _destination } => { forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet); - drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)?; + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })?; warn!("restarting"); unsafe { spiflash::reload(); } } diff --git a/artiq/firmware/satman/mgmt.rs b/artiq/firmware/satman/mgmt.rs index 1c0641493..86e5794e3 100644 --- a/artiq/firmware/satman/mgmt.rs +++ b/artiq/firmware/satman/mgmt.rs @@ -45,7 +45,7 @@ impl Manager { Err(err) => { self.clear_data(); error!("error on reading key: {:?}", err); - return drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack); + return drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: false }); } }; @@ -53,7 +53,7 @@ impl Manager { match key.as_str() { "gateware" | "bootloader" | "firmware" => { - drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)?; + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded: true })?; #[cfg(not(soc_platform = "efc"))] unsafe { clock::spin_us(10000); @@ -71,11 +71,7 @@ impl Manager { self.clear_data(); - if succeeded { - drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck) - } else { - drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack) - } + drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded }) } } }