forked from M-Labs/artiq-zynq
Compare commits
No commits in common. "b3b092838c338f48bed2d7b396745a8c262b3cb9" and "5a8db1dcf62911e922e225b101e1900913babc23" have entirely different histories.
b3b092838c
...
5a8db1dcf6
|
@ -8,6 +8,11 @@ const MAX_PACKET: usize = 1024;
|
||||||
pub const SAT_PAYLOAD_MAX_SIZE: usize = /*max size*/MAX_PACKET - /*CRC*/4 - /*packet ID*/1 - /*last*/1 - /*length*/2;
|
pub const SAT_PAYLOAD_MAX_SIZE: usize = /*max size*/MAX_PACKET - /*CRC*/4 - /*packet ID*/1 - /*last*/1 - /*length*/2;
|
||||||
// used by DDMA, subkernel program data (need to provide extra ID and destination)
|
// used by DDMA, subkernel program data (need to provide extra ID and destination)
|
||||||
pub const MASTER_PAYLOAD_MAX_SIZE: usize = SAT_PAYLOAD_MAX_SIZE - /*source*/1 - /*destination*/1 - /*ID*/4;
|
pub const MASTER_PAYLOAD_MAX_SIZE: usize = SAT_PAYLOAD_MAX_SIZE - /*source*/1 - /*destination*/1 - /*ID*/4;
|
||||||
|
// used by core device management, core_mgmt packet
|
||||||
|
// FIXME: packet size
|
||||||
|
pub const CORE_MGMT_PAYLOAD_MAX_SIZE: usize = MASTER_PAYLOAD_MAX_SIZE;
|
||||||
|
// pub const CORE_MGMT_CONFIG_MAX_SIZE: usize = /*max size*/MAX_PACKET - /*destination*/1 - /*last*/1 - /*length*/2;
|
||||||
|
pub const CORE_MGMT_CONFIG_MAX_SIZE: usize = MASTER_PAYLOAD_MAX_SIZE;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
@ -292,6 +297,11 @@ pub enum Packet {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
clear: bool,
|
clear: bool,
|
||||||
},
|
},
|
||||||
|
CoreMgmtGetLogReply {
|
||||||
|
last: bool,
|
||||||
|
length: u16,
|
||||||
|
data: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE],
|
||||||
|
},
|
||||||
CoreMgmtClearLogRequest {
|
CoreMgmtClearLogRequest {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
},
|
},
|
||||||
|
@ -306,21 +316,27 @@ pub enum Packet {
|
||||||
CoreMgmtConfigReadRequest {
|
CoreMgmtConfigReadRequest {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
length: u16,
|
length: u16,
|
||||||
key: [u8; MASTER_PAYLOAD_MAX_SIZE],
|
key: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE],
|
||||||
},
|
},
|
||||||
CoreMgmtConfigReadContinue {
|
CoreMgmtConfigReadContinue {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
},
|
},
|
||||||
|
CoreMgmtConfigReadReply {
|
||||||
|
succeeded: bool,
|
||||||
|
length: u16,
|
||||||
|
last: bool,
|
||||||
|
value: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE],
|
||||||
|
},
|
||||||
CoreMgmtConfigWriteRequest {
|
CoreMgmtConfigWriteRequest {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
last: bool,
|
|
||||||
length: u16,
|
length: u16,
|
||||||
data: [u8; MASTER_PAYLOAD_MAX_SIZE],
|
last: bool,
|
||||||
|
data: [u8; CORE_MGMT_CONFIG_MAX_SIZE],
|
||||||
},
|
},
|
||||||
CoreMgmtConfigRemoveRequest {
|
CoreMgmtConfigRemoveRequest {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
length: u16,
|
length: u16,
|
||||||
key: [u8; MASTER_PAYLOAD_MAX_SIZE],
|
key: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE],
|
||||||
},
|
},
|
||||||
CoreMgmtConfigEraseRequest {
|
CoreMgmtConfigEraseRequest {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
|
@ -331,18 +347,9 @@ pub enum Packet {
|
||||||
CoreMgmtAllocatorDebugRequest {
|
CoreMgmtAllocatorDebugRequest {
|
||||||
destination: u8,
|
destination: u8,
|
||||||
},
|
},
|
||||||
CoreMgmtGetLogReply {
|
CoreMgmtAck {
|
||||||
last: bool,
|
succeeded: bool,
|
||||||
length: u16,
|
|
||||||
data: [u8; SAT_PAYLOAD_MAX_SIZE],
|
|
||||||
},
|
},
|
||||||
CoreMgmtConfigReadReply {
|
|
||||||
last: bool,
|
|
||||||
length: u16,
|
|
||||||
value: [u8; SAT_PAYLOAD_MAX_SIZE],
|
|
||||||
},
|
|
||||||
CoreMgmtAck,
|
|
||||||
CoreMgmtNack,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Packet {
|
impl Packet {
|
||||||
|
@ -623,68 +630,10 @@ impl Packet {
|
||||||
destination: reader.read_u8()?,
|
destination: reader.read_u8()?,
|
||||||
clear: reader.read_bool()?,
|
clear: reader.read_bool()?,
|
||||||
},
|
},
|
||||||
0xd1 => Packet::CoreMgmtClearLogRequest {
|
0xd1 => {
|
||||||
destination: reader.read_u8()?,
|
|
||||||
},
|
|
||||||
0xd2 => Packet::CoreMgmtSetLogLevelRequest {
|
|
||||||
destination: reader.read_u8()?,
|
|
||||||
log_level: reader.read_u8()?,
|
|
||||||
},
|
|
||||||
0xd3 => Packet::CoreMgmtSetUartLogLevelRequest {
|
|
||||||
destination: reader.read_u8()?,
|
|
||||||
log_level: reader.read_u8()?,
|
|
||||||
},
|
|
||||||
0xd4 => {
|
|
||||||
let destination = reader.read_u8()?;
|
|
||||||
let length = reader.read_u16()?;
|
|
||||||
let mut key: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
|
||||||
reader.read_exact(&mut key[0..length as usize])?;
|
|
||||||
Packet::CoreMgmtConfigReadRequest {
|
|
||||||
destination: destination,
|
|
||||||
length: length,
|
|
||||||
key: key,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
0xd5 => Packet::CoreMgmtConfigReadContinue {
|
|
||||||
destination: reader.read_u8()?,
|
|
||||||
},
|
|
||||||
0xd6 => {
|
|
||||||
let destination = reader.read_u8()?;
|
|
||||||
let last = reader.read_bool()?;
|
let last = reader.read_bool()?;
|
||||||
let length = reader.read_u16()?;
|
let length = reader.read_u16()?;
|
||||||
let mut data: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
let mut data: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE] = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
reader.read_exact(&mut data[0..length as usize])?;
|
|
||||||
Packet::CoreMgmtConfigWriteRequest {
|
|
||||||
destination: destination,
|
|
||||||
last: last,
|
|
||||||
length: length,
|
|
||||||
data: data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
0xd7 => {
|
|
||||||
let destination = reader.read_u8()?;
|
|
||||||
let length = reader.read_u16()?;
|
|
||||||
let mut key: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
|
||||||
reader.read_exact(&mut key[0..length as usize])?;
|
|
||||||
Packet::CoreMgmtConfigRemoveRequest {
|
|
||||||
destination: destination,
|
|
||||||
length: length,
|
|
||||||
key: key,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
0xd8 => Packet::CoreMgmtConfigEraseRequest {
|
|
||||||
destination: reader.read_u8()?,
|
|
||||||
},
|
|
||||||
0xd9 => Packet::CoreMgmtRebootRequest {
|
|
||||||
destination: reader.read_u8()?,
|
|
||||||
},
|
|
||||||
0xda => Packet::CoreMgmtAllocatorDebugRequest {
|
|
||||||
destination: reader.read_u8()?,
|
|
||||||
},
|
|
||||||
0xdb => {
|
|
||||||
let last = reader.read_bool()?;
|
|
||||||
let length = reader.read_u16()?;
|
|
||||||
let mut data: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE];
|
|
||||||
reader.read_exact(&mut data[0..length as usize])?;
|
reader.read_exact(&mut data[0..length as usize])?;
|
||||||
Packet::CoreMgmtGetLogReply {
|
Packet::CoreMgmtGetLogReply {
|
||||||
last: last,
|
last: last,
|
||||||
|
@ -692,19 +641,80 @@ impl Packet {
|
||||||
data: data,
|
data: data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0xdc => {
|
0xd2 => Packet::CoreMgmtClearLogRequest {
|
||||||
let last = reader.read_bool()?;
|
destination: reader.read_u8()?,
|
||||||
|
},
|
||||||
|
0xd5 => Packet::CoreMgmtSetLogLevelRequest {
|
||||||
|
destination: reader.read_u8()?,
|
||||||
|
log_level: reader.read_u8()?,
|
||||||
|
},
|
||||||
|
0xd6 => Packet::CoreMgmtSetUartLogLevelRequest {
|
||||||
|
destination: reader.read_u8()?,
|
||||||
|
log_level: reader.read_u8()?,
|
||||||
|
},
|
||||||
|
0xd7 => {
|
||||||
|
let destination = reader.read_u8()?;
|
||||||
let length = reader.read_u16()?;
|
let length = reader.read_u16()?;
|
||||||
let mut value: [u8; SAT_PAYLOAD_MAX_SIZE] = [0; SAT_PAYLOAD_MAX_SIZE];
|
let mut key: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE] = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
|
reader.read_exact(&mut key[0..length as usize])?;
|
||||||
|
Packet::CoreMgmtConfigReadRequest {
|
||||||
|
destination: destination,
|
||||||
|
length: length,
|
||||||
|
key: key,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0xd8 => {
|
||||||
|
let succeeded = reader.read_bool()?;
|
||||||
|
let length = reader.read_u16()?;
|
||||||
|
let last = reader.read_bool()?;
|
||||||
|
let mut value: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE] = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
reader.read_exact(&mut value[0..length as usize])?;
|
reader.read_exact(&mut value[0..length as usize])?;
|
||||||
Packet::CoreMgmtConfigReadReply {
|
Packet::CoreMgmtConfigReadReply {
|
||||||
last: last,
|
succeeded: succeeded,
|
||||||
length: length,
|
length: length,
|
||||||
|
last: last,
|
||||||
value: value,
|
value: value,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0xdd => Packet::CoreMgmtAck,
|
0xd9 => {
|
||||||
0xde => Packet::CoreMgmtNack,
|
let destination = reader.read_u8()?;
|
||||||
|
let length = reader.read_u16()?;
|
||||||
|
let last = reader.read_bool()?;
|
||||||
|
let mut data: [u8; CORE_MGMT_CONFIG_MAX_SIZE] = [0; CORE_MGMT_CONFIG_MAX_SIZE];
|
||||||
|
reader.read_exact(&mut data[0..length as usize])?;
|
||||||
|
Packet::CoreMgmtConfigWriteRequest {
|
||||||
|
destination: destination,
|
||||||
|
length: length,
|
||||||
|
last: last,
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0xda => {
|
||||||
|
let destination = reader.read_u8()?;
|
||||||
|
let length = reader.read_u16()?;
|
||||||
|
let mut key: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE] = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
|
reader.read_exact(&mut key[0..length as usize])?;
|
||||||
|
Packet::CoreMgmtConfigRemoveRequest {
|
||||||
|
destination: destination,
|
||||||
|
length: length,
|
||||||
|
key: key,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
0xdb => Packet::CoreMgmtConfigEraseRequest {
|
||||||
|
destination: reader.read_u8()?,
|
||||||
|
},
|
||||||
|
0xdc => Packet::CoreMgmtRebootRequest {
|
||||||
|
destination: reader.read_u8()?,
|
||||||
|
},
|
||||||
|
0xdd => Packet::CoreMgmtAllocatorDebugRequest {
|
||||||
|
destination: reader.read_u8()?,
|
||||||
|
},
|
||||||
|
0xde => Packet::CoreMgmtAck {
|
||||||
|
succeeded: reader.read_bool()?,
|
||||||
|
},
|
||||||
|
0xdf => Packet::CoreMgmtConfigReadContinue {
|
||||||
|
destination: reader.read_u8()?,
|
||||||
|
},
|
||||||
|
|
||||||
ty => return Err(Error::UnknownPacket(ty)),
|
ty => return Err(Error::UnknownPacket(ty)),
|
||||||
})
|
})
|
||||||
|
@ -1081,53 +1091,32 @@ impl Packet {
|
||||||
writer.write_u8(0xcc)?;
|
writer.write_u8(0xcc)?;
|
||||||
writer.write_u8(destination)?;
|
writer.write_u8(destination)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet::CoreMgmtGetLogRequest { destination, clear } => {
|
Packet::CoreMgmtGetLogRequest { destination, clear } => {
|
||||||
writer.write_u8(0xd0)?;
|
writer.write_u8(0xd0)?;
|
||||||
writer.write_u8(destination)?;
|
writer.write_u8(destination)?;
|
||||||
writer.write_bool(clear)?;
|
writer.write_bool(clear)?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtClearLogRequest { destination } => {
|
Packet::CoreMgmtGetLogReply { last, length, data } => {
|
||||||
writer.write_u8(0xd1)?;
|
writer.write_u8(0xd1)?;
|
||||||
writer.write_u8(destination)?;
|
|
||||||
}
|
|
||||||
Packet::CoreMgmtSetLogLevelRequest { destination, log_level } => {
|
|
||||||
writer.write_u8(0xd2)?;
|
|
||||||
writer.write_u8(destination)?;
|
|
||||||
writer.write_u8(log_level)?;
|
|
||||||
}
|
|
||||||
Packet::CoreMgmtSetUartLogLevelRequest { destination, log_level } => {
|
|
||||||
writer.write_u8(0xd3)?;
|
|
||||||
writer.write_u8(destination)?;
|
|
||||||
writer.write_u8(log_level)?;
|
|
||||||
}
|
|
||||||
Packet::CoreMgmtConfigReadRequest {
|
|
||||||
destination,
|
|
||||||
length,
|
|
||||||
key,
|
|
||||||
} => {
|
|
||||||
writer.write_u8(0xd4)?;
|
|
||||||
writer.write_u8(destination)?;
|
|
||||||
writer.write_u16(length)?;
|
|
||||||
writer.write_all(&key[0..length as usize])?;
|
|
||||||
}
|
|
||||||
Packet::CoreMgmtConfigReadContinue { destination } => {
|
|
||||||
writer.write_u8(0xd5)?;
|
|
||||||
writer.write_u8(destination)?;
|
|
||||||
}
|
|
||||||
Packet::CoreMgmtConfigWriteRequest {
|
|
||||||
destination,
|
|
||||||
last,
|
|
||||||
length,
|
|
||||||
data,
|
|
||||||
} => {
|
|
||||||
writer.write_u8(0xd6)?;
|
|
||||||
writer.write_u8(destination)?;
|
|
||||||
writer.write_bool(last)?;
|
writer.write_bool(last)?;
|
||||||
writer.write_u16(length)?;
|
writer.write_u16(length)?;
|
||||||
writer.write_all(&data[0..length as usize])?;
|
writer.write_all(&data[0..length as usize])?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtConfigRemoveRequest {
|
Packet::CoreMgmtClearLogRequest { destination } => {
|
||||||
|
writer.write_u8(0xd2)?;
|
||||||
|
writer.write_u8(destination)?;
|
||||||
|
}
|
||||||
|
Packet::CoreMgmtSetLogLevelRequest { destination, log_level } => {
|
||||||
|
writer.write_u8(0xd5)?;
|
||||||
|
writer.write_u8(destination)?;
|
||||||
|
writer.write_u8(log_level)?;
|
||||||
|
}
|
||||||
|
Packet::CoreMgmtSetUartLogLevelRequest { destination, log_level } => {
|
||||||
|
writer.write_u8(0xd6)?;
|
||||||
|
writer.write_u8(destination)?;
|
||||||
|
writer.write_u8(log_level)?;
|
||||||
|
}
|
||||||
|
Packet::CoreMgmtConfigReadRequest {
|
||||||
destination,
|
destination,
|
||||||
length,
|
length,
|
||||||
key,
|
key,
|
||||||
|
@ -1137,32 +1126,60 @@ impl Packet {
|
||||||
writer.write_u16(length)?;
|
writer.write_u16(length)?;
|
||||||
writer.write_all(&key[0..length as usize])?;
|
writer.write_all(&key[0..length as usize])?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtConfigEraseRequest { destination } => {
|
Packet::CoreMgmtConfigReadReply {
|
||||||
|
succeeded,
|
||||||
|
length,
|
||||||
|
last,
|
||||||
|
value,
|
||||||
|
} => {
|
||||||
writer.write_u8(0xd8)?;
|
writer.write_u8(0xd8)?;
|
||||||
|
writer.write_bool(succeeded)?;
|
||||||
|
writer.write_u16(length)?;
|
||||||
|
writer.write_bool(last)?;
|
||||||
|
writer.write_all(&value[0..length as usize])?;
|
||||||
|
}
|
||||||
|
Packet::CoreMgmtConfigWriteRequest {
|
||||||
|
destination,
|
||||||
|
length,
|
||||||
|
last,
|
||||||
|
data,
|
||||||
|
} => {
|
||||||
|
writer.write_u8(0xd9)?;
|
||||||
|
writer.write_u8(destination)?;
|
||||||
|
writer.write_u16(length)?;
|
||||||
|
writer.write_bool(last)?;
|
||||||
|
writer.write_all(&data[0..length as usize])?;
|
||||||
|
}
|
||||||
|
Packet::CoreMgmtConfigRemoveRequest {
|
||||||
|
destination,
|
||||||
|
length,
|
||||||
|
key,
|
||||||
|
} => {
|
||||||
|
writer.write_u8(0xda)?;
|
||||||
|
writer.write_u8(destination)?;
|
||||||
|
writer.write_u16(length)?;
|
||||||
|
writer.write_all(&key[0..length as usize])?;
|
||||||
|
}
|
||||||
|
Packet::CoreMgmtConfigEraseRequest { destination } => {
|
||||||
|
writer.write_u8(0xdb)?;
|
||||||
writer.write_u8(destination)?;
|
writer.write_u8(destination)?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtRebootRequest { destination } => {
|
Packet::CoreMgmtRebootRequest { destination } => {
|
||||||
writer.write_u8(0xd9)?;
|
writer.write_u8(0xdc)?;
|
||||||
writer.write_u8(destination)?;
|
writer.write_u8(destination)?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtAllocatorDebugRequest { destination } => {
|
Packet::CoreMgmtAllocatorDebugRequest { destination } => {
|
||||||
writer.write_u8(0xda)?;
|
writer.write_u8(0xdd)?;
|
||||||
writer.write_u8(destination)?;
|
writer.write_u8(destination)?;
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtGetLogReply { last, length, data } => {
|
Packet::CoreMgmtAck { succeeded } => {
|
||||||
writer.write_u8(0xdb)?;
|
writer.write_u8(0xde)?;
|
||||||
writer.write_bool(last)?;
|
writer.write_bool(succeeded)?;
|
||||||
writer.write_u16(length)?;
|
|
||||||
writer.write_all(&data[0..length as usize])?;
|
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtConfigReadReply { last, length, value } => {
|
Packet::CoreMgmtConfigReadContinue { destination } => {
|
||||||
writer.write_u8(0xdc)?;
|
writer.write_u8(0xdf)?;
|
||||||
writer.write_bool(last)?;
|
writer.write_u8(destination)?;
|
||||||
writer.write_u16(length)?;
|
|
||||||
writer.write_all(&value[0..length as usize])?;
|
|
||||||
}
|
}
|
||||||
Packet::CoreMgmtAck => writer.write_u8(0xdd)?,
|
|
||||||
Packet::CoreMgmtNack => writer.write_u8(0xde)?,
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ async fn read_key(stream: &mut TcpStream) -> Result<String> {
|
||||||
#[cfg(has_drtio)]
|
#[cfg(has_drtio)]
|
||||||
mod remote_coremgmt {
|
mod remote_coremgmt {
|
||||||
use io::{Cursor, ProtoWrite};
|
use io::{Cursor, ProtoWrite};
|
||||||
use libboard_artiq::drtioaux_proto::{Packet, MASTER_PAYLOAD_MAX_SIZE};
|
use libboard_artiq::drtioaux_proto::{Packet, CORE_MGMT_PAYLOAD_MAX_SIZE};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::rtio_mgt::drtio;
|
use crate::rtio_mgt::drtio;
|
||||||
|
@ -200,7 +200,7 @@ mod remote_coremgmt {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Packet::CoreMgmtAck { succeeded: true } => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ mod remote_coremgmt {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Packet::CoreMgmtAck { succeeded: true } => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ mod remote_coremgmt {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Packet::CoreMgmtAck { succeeded: true } => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ mod remote_coremgmt {
|
||||||
_cfg: &Rc<Config>,
|
_cfg: &Rc<Config>,
|
||||||
key: &String,
|
key: &String,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut config_key: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
let mut config_key: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE] = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
let len = key.len();
|
let len = key.len();
|
||||||
config_key[..len].clone_from_slice(key.as_bytes());
|
config_key[..len].clone_from_slice(key.as_bytes());
|
||||||
|
|
||||||
|
@ -351,12 +351,17 @@ mod remote_coremgmt {
|
||||||
let mut buffer = Vec::<u8>::new();
|
let mut buffer = Vec::<u8>::new();
|
||||||
loop {
|
loop {
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtConfigReadReply { last, length, value } => {
|
Packet::CoreMgmtConfigReadReply {
|
||||||
|
succeeded: true,
|
||||||
|
length,
|
||||||
|
last,
|
||||||
|
value,
|
||||||
|
} => {
|
||||||
buffer.extend(&value[..length as usize]);
|
buffer.extend(&value[..length as usize]);
|
||||||
|
|
||||||
if last {
|
if last {
|
||||||
write_i8(stream, Reply::ConfigData as i8).await?;
|
write_i8(stream, Reply::ConfigData as i8).await?;
|
||||||
write_chunk(stream, &buffer).await?;
|
write_chunk(stream, &value).await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,12 +408,12 @@ mod remote_coremgmt {
|
||||||
message.get_ref(),
|
message.get_ref(),
|
||||||
|slice, status, len: usize| Packet::CoreMgmtConfigWriteRequest {
|
|slice, status, len: usize| Packet::CoreMgmtConfigWriteRequest {
|
||||||
destination: destination,
|
destination: destination,
|
||||||
last: status.is_last(),
|
|
||||||
length: len as u16,
|
length: len as u16,
|
||||||
|
last: status.is_last(),
|
||||||
data: *slice,
|
data: *slice,
|
||||||
},
|
},
|
||||||
|reply| match reply {
|
|reply| match reply {
|
||||||
Packet::CoreMgmtAck => Ok(()),
|
Packet::CoreMgmtAck { succeeded: true } => Ok(()),
|
||||||
_ => {
|
_ => {
|
||||||
error!("received unknown packet");
|
error!("received unknown packet");
|
||||||
Err(drtio::Error::UnexpectedReply.into())
|
Err(drtio::Error::UnexpectedReply.into())
|
||||||
|
@ -438,7 +443,7 @@ mod remote_coremgmt {
|
||||||
_cfg: &Rc<Config>,
|
_cfg: &Rc<Config>,
|
||||||
key: &String,
|
key: &String,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut config_key: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
let mut config_key: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE] = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
let len = key.len();
|
let len = key.len();
|
||||||
config_key[..len].clone_from_slice(key.as_bytes());
|
config_key[..len].clone_from_slice(key.as_bytes());
|
||||||
|
|
||||||
|
@ -456,7 +461,7 @@ mod remote_coremgmt {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Packet::CoreMgmtAck { succeeded: true } => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -487,7 +492,7 @@ mod remote_coremgmt {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Packet::CoreMgmtAck { succeeded: true } => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -519,7 +524,7 @@ mod remote_coremgmt {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Packet::CoreMgmtAck { succeeded: true } => {
|
||||||
write_i8(stream, Reply::RebootImminent as i8).await?;
|
write_i8(stream, Reply::RebootImminent as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -551,7 +556,7 @@ mod remote_coremgmt {
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
match reply {
|
match reply {
|
||||||
Packet::CoreMgmtAck => {
|
Packet::CoreMgmtAck { succeeded: true } => {
|
||||||
write_i8(stream, Reply::Success as i8).await?;
|
write_i8(stream, Reply::Success as i8).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ use libboard_artiq::si5324;
|
||||||
#[cfg(has_si549)]
|
#[cfg(has_si549)]
|
||||||
use libboard_artiq::si549;
|
use libboard_artiq::si549;
|
||||||
use libboard_artiq::{drtio_routing, drtioaux,
|
use libboard_artiq::{drtio_routing, drtioaux,
|
||||||
drtioaux_proto::{MASTER_PAYLOAD_MAX_SIZE, SAT_PAYLOAD_MAX_SIZE},
|
drtioaux_proto::{CORE_MGMT_PAYLOAD_MAX_SIZE, MASTER_PAYLOAD_MAX_SIZE, SAT_PAYLOAD_MAX_SIZE},
|
||||||
identifier_read, logger,
|
identifier_read, logger,
|
||||||
pl::csr};
|
pl::csr};
|
||||||
#[cfg(feature = "target_kasli_soc")]
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
|
@ -1030,7 +1030,7 @@ fn process_aux_packet(
|
||||||
&packet,
|
&packet,
|
||||||
timer
|
timer
|
||||||
);
|
);
|
||||||
let mut data_slice = [0; SAT_PAYLOAD_MAX_SIZE];
|
let mut data_slice: [u8; CORE_MGMT_PAYLOAD_MAX_SIZE] = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
let meta = core_manager.log_get_slice(&mut data_slice);
|
let meta = core_manager.log_get_slice(&mut data_slice);
|
||||||
if clear && meta.status.is_first() {
|
if clear && meta.status.is_first() {
|
||||||
mgmt::clear_log();
|
mgmt::clear_log();
|
||||||
|
@ -1058,7 +1058,7 @@ fn process_aux_packet(
|
||||||
timer
|
timer
|
||||||
);
|
);
|
||||||
mgmt::clear_log();
|
mgmt::clear_log();
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: true })
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtSetLogLevelRequest {
|
drtioaux::Packet::CoreMgmtSetLogLevelRequest {
|
||||||
destination: _destination,
|
destination: _destination,
|
||||||
|
@ -1076,11 +1076,11 @@ fn process_aux_packet(
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Ok(level_filter) = mgmt::byte_to_level_filter(log_level) {
|
if let Ok(level_filter) = mgmt::byte_to_level_filter(log_level) {
|
||||||
info!("Changing log level to {}", level_filter);
|
info!("Changing log level to {}", log_level);
|
||||||
log::set_max_level(level_filter);
|
log::set_max_level(level_filter);
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: true })
|
||||||
} else {
|
} else {
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtSetUartLogLevelRequest {
|
drtioaux::Packet::CoreMgmtSetUartLogLevelRequest {
|
||||||
|
@ -1099,16 +1099,16 @@ fn process_aux_packet(
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Ok(level_filter) = mgmt::byte_to_level_filter(log_level) {
|
if let Ok(level_filter) = mgmt::byte_to_level_filter(log_level) {
|
||||||
info!("Changing log level to {}", level_filter);
|
info!("Changing log level to {}", log_level);
|
||||||
unsafe {
|
unsafe {
|
||||||
logger::BufferLogger::get_logger()
|
logger::BufferLogger::get_logger()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.set_uart_log_level(level_filter);
|
.set_uart_log_level(level_filter);
|
||||||
}
|
}
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: true })
|
||||||
} else {
|
} else {
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtConfigReadRequest {
|
drtioaux::Packet::CoreMgmtConfigReadRequest {
|
||||||
|
@ -1127,12 +1127,20 @@ fn process_aux_packet(
|
||||||
timer
|
timer
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut value_slice = [0; SAT_PAYLOAD_MAX_SIZE];
|
let mut value_slice = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
|
|
||||||
let key_slice = &key[..length as usize];
|
let key_slice = &key[..length as usize];
|
||||||
if !key_slice.is_ascii() {
|
if !key_slice.is_ascii() {
|
||||||
error!("invalid key");
|
error!("invalid key");
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(
|
||||||
|
0,
|
||||||
|
&drtioaux::Packet::CoreMgmtConfigReadReply {
|
||||||
|
succeeded: false,
|
||||||
|
length: 0,
|
||||||
|
last: true,
|
||||||
|
value: value_slice,
|
||||||
|
},
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
let key = core::str::from_utf8(key_slice).unwrap();
|
let key = core::str::from_utf8(key_slice).unwrap();
|
||||||
if core_manager.fetch_config_value(key).is_ok() {
|
if core_manager.fetch_config_value(key).is_ok() {
|
||||||
|
@ -1140,13 +1148,22 @@ fn process_aux_packet(
|
||||||
drtioaux::send(
|
drtioaux::send(
|
||||||
0,
|
0,
|
||||||
&drtioaux::Packet::CoreMgmtConfigReadReply {
|
&drtioaux::Packet::CoreMgmtConfigReadReply {
|
||||||
last: meta.status.is_last(),
|
succeeded: true,
|
||||||
length: meta.len as u16,
|
length: meta.len as u16,
|
||||||
|
last: meta.status.is_last(),
|
||||||
value: value_slice,
|
value: value_slice,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(
|
||||||
|
0,
|
||||||
|
&drtioaux::Packet::CoreMgmtConfigReadReply {
|
||||||
|
succeeded: false,
|
||||||
|
length: 0,
|
||||||
|
last: true,
|
||||||
|
value: value_slice,
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1164,21 +1181,22 @@ fn process_aux_packet(
|
||||||
timer
|
timer
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut value_slice = [0; SAT_PAYLOAD_MAX_SIZE];
|
let mut value_slice = [0; CORE_MGMT_PAYLOAD_MAX_SIZE];
|
||||||
let meta = core_manager.get_config_value_slice(&mut value_slice);
|
let meta = core_manager.get_config_value_slice(&mut value_slice);
|
||||||
drtioaux::send(
|
drtioaux::send(
|
||||||
0,
|
0,
|
||||||
&drtioaux::Packet::CoreMgmtConfigReadReply {
|
&drtioaux::Packet::CoreMgmtConfigReadReply {
|
||||||
last: meta.status.is_last(),
|
succeeded: true,
|
||||||
length: meta.len as u16,
|
length: meta.len as u16,
|
||||||
|
last: meta.status.is_last(),
|
||||||
value: value_slice,
|
value: value_slice,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtConfigWriteRequest {
|
drtioaux::Packet::CoreMgmtConfigWriteRequest {
|
||||||
destination: _destination,
|
destination: _destination,
|
||||||
last,
|
|
||||||
length,
|
length,
|
||||||
|
last,
|
||||||
data,
|
data,
|
||||||
} => {
|
} => {
|
||||||
forward!(
|
forward!(
|
||||||
|
@ -1200,11 +1218,7 @@ fn process_aux_packet(
|
||||||
core_manager.clear_data();
|
core_manager.clear_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
if succeeded {
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: succeeded })
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
|
||||||
} else {
|
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtConfigRemoveRequest {
|
drtioaux::Packet::CoreMgmtConfigRemoveRequest {
|
||||||
destination: _destination,
|
destination: _destination,
|
||||||
|
@ -1225,14 +1239,11 @@ fn process_aux_packet(
|
||||||
let key_slice = &key[..length as usize];
|
let key_slice = &key[..length as usize];
|
||||||
if !key_slice.is_ascii() {
|
if !key_slice.is_ascii() {
|
||||||
error!("invalid key");
|
error!("invalid key");
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: false })
|
||||||
} else {
|
} else {
|
||||||
let key = core::str::from_utf8(key_slice).unwrap();
|
let key = core::str::from_utf8(key_slice).unwrap();
|
||||||
if core_manager.remove_config(key).is_ok() {
|
let succeeded = core_manager.remove_config(key).is_ok();
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded })
|
||||||
} else {
|
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtNack)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drtioaux::Packet::CoreMgmtConfigEraseRequest {
|
drtioaux::Packet::CoreMgmtConfigEraseRequest {
|
||||||
|
@ -1267,7 +1278,7 @@ fn process_aux_packet(
|
||||||
timer
|
timer
|
||||||
);
|
);
|
||||||
|
|
||||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck)?;
|
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: true })?;
|
||||||
info!("reboot imminent");
|
info!("reboot imminent");
|
||||||
slcr::reboot();
|
slcr::reboot();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
use io::{Cursor, ProtoRead, ProtoWrite};
|
use io::{Cursor, ProtoRead, ProtoWrite};
|
||||||
use libboard_artiq::{drtioaux_proto::SAT_PAYLOAD_MAX_SIZE,
|
use libboard_artiq::{drtioaux_proto::CORE_MGMT_PAYLOAD_MAX_SIZE,
|
||||||
logger::{BufferLogger, LogBufferRef}};
|
logger::{BufferLogger, LogBufferRef}};
|
||||||
use libconfig::Config;
|
use libconfig::Config;
|
||||||
use log::{self, debug, error, info, warn, LevelFilter};
|
use log::{self, debug, error, info, warn, LevelFilter};
|
||||||
|
@ -60,13 +60,13 @@ impl<'a> Manager<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_get_slice(&mut self, data_slice: &mut [u8; SAT_PAYLOAD_MAX_SIZE]) -> SliceMeta {
|
pub fn log_get_slice(&mut self, data_slice: &mut [u8; CORE_MGMT_PAYLOAD_MAX_SIZE]) -> SliceMeta {
|
||||||
// Populate buffer if depleted
|
// Populate buffer if depleted
|
||||||
if self.last_log.at_end() {
|
if self.last_log.at_end() {
|
||||||
self.last_log.extend(get_logger_buffer().extract().as_bytes());
|
self.last_log.extend(get_logger_buffer().extract().as_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
self.last_log.get_slice_satellite(data_slice)
|
self.last_log.get_slice_core_mgmt(data_slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fetch_config_value(&mut self, key: &str) -> Result<()> {
|
pub fn fetch_config_value(&mut self, key: &str) -> Result<()> {
|
||||||
|
@ -79,8 +79,8 @@ impl<'a> Manager<'_> {
|
||||||
.map_err(|_| warn!("read error: no such key"))
|
.map_err(|_| warn!("read error: no such key"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_config_value_slice(&mut self, data_slice: &mut [u8; SAT_PAYLOAD_MAX_SIZE]) -> SliceMeta {
|
pub fn get_config_value_slice(&mut self, data_slice: &mut [u8; CORE_MGMT_PAYLOAD_MAX_SIZE]) -> SliceMeta {
|
||||||
self.last_value.get_slice_satellite(data_slice)
|
self.last_value.get_slice_core_mgmt(data_slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_data(&mut self, data: &[u8], data_len: usize) {
|
pub fn add_data(&mut self, data: &[u8], data_len: usize) {
|
||||||
|
@ -97,7 +97,6 @@ impl<'a> Manager<'_> {
|
||||||
.current_payload
|
.current_payload
|
||||||
.read_string()
|
.read_string()
|
||||||
.map_err(|_err| error!("error on reading key"))?;
|
.map_err(|_err| error!("error on reading key"))?;
|
||||||
debug!("write key: {}", key);
|
|
||||||
let value = self.current_payload.read_bytes().unwrap();
|
let value = self.current_payload.read_bytes().unwrap();
|
||||||
|
|
||||||
self.cfg
|
self.cfg
|
||||||
|
|
|
@ -4,7 +4,7 @@ use core::cmp::min;
|
||||||
#[cfg(has_drtio_routing)]
|
#[cfg(has_drtio_routing)]
|
||||||
use libboard_artiq::pl::csr;
|
use libboard_artiq::pl::csr;
|
||||||
use libboard_artiq::{drtio_routing, drtioaux,
|
use libboard_artiq::{drtio_routing, drtioaux,
|
||||||
drtioaux_proto::{PayloadStatus, MASTER_PAYLOAD_MAX_SIZE, SAT_PAYLOAD_MAX_SIZE}};
|
drtioaux_proto::{PayloadStatus, CORE_MGMT_PAYLOAD_MAX_SIZE, MASTER_PAYLOAD_MAX_SIZE}};
|
||||||
|
|
||||||
pub struct SliceMeta {
|
pub struct SliceMeta {
|
||||||
pub destination: u8,
|
pub destination: u8,
|
||||||
|
@ -58,7 +58,7 @@ impl Sliceable {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_slice_fn!(get_slice_master, MASTER_PAYLOAD_MAX_SIZE);
|
get_slice_fn!(get_slice_master, MASTER_PAYLOAD_MAX_SIZE);
|
||||||
get_slice_fn!(get_slice_satellite, SAT_PAYLOAD_MAX_SIZE);
|
get_slice_fn!(get_slice_core_mgmt, CORE_MGMT_PAYLOAD_MAX_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packets from downstream (further satellites) are received and routed appropriately.
|
// Packets from downstream (further satellites) are received and routed appropriately.
|
||||||
|
|
Loading…
Reference in New Issue