forked from M-Labs/artiq
Compare commits
No commits in common. "dd7ac81b284668ba0b6983d38ab2f53d0485ff98" and "e2382c2cd5023bb8f6a402c3eff6459b5937ca0e" have entirely different histories.
dd7ac81b28
...
e2382c2cd5
@ -1,6 +1,6 @@
|
||||
use core::cell::RefCell;
|
||||
|
||||
use board_artiq::drtio_routing::RoutingTable;
|
||||
use board_artiq::drtio_routing;
|
||||
use io::{ProtoRead, Write, Error as IoError};
|
||||
use mgmt_proto::*;
|
||||
use sched::{Io, Mutex, TcpListener, TcpStream, Error as SchedError};
|
||||
@ -19,10 +19,10 @@ mod local_coremgmt {
|
||||
use log::LevelFilter;
|
||||
|
||||
use board_misoc::{config, mem, spiflash};
|
||||
use io::ProtoWrite;
|
||||
use io::{Write, ProtoWrite, Error as IoError};
|
||||
use logger_artiq::BufferLogger;
|
||||
|
||||
use super::*;
|
||||
use mgmt_proto::{Error, Reply};
|
||||
use sched::{Io, TcpStream, Error as SchedError};
|
||||
|
||||
|
||||
pub fn get_log(io: &Io, stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
@ -177,12 +177,13 @@ mod remote_coremgmt {
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use log::LevelFilter;
|
||||
|
||||
use board_artiq::{drtioaux, drtioaux::Packet};
|
||||
use io::ProtoWrite;
|
||||
use board_artiq::{drtioaux, drtioaux::Packet, drtio_routing};
|
||||
use io::{Cursor, ProtoWrite};
|
||||
use mgmt_proto::{Error, Reply};
|
||||
use rtio_mgt::drtio;
|
||||
use sched::{Io, Mutex, TcpStream, Error as SchedError};
|
||||
use proto_artiq::drtioaux_proto::MASTER_PAYLOAD_MAX_SIZE;
|
||||
|
||||
use super::*;
|
||||
|
||||
impl From<drtio::Error> for Error<SchedError> {
|
||||
fn from(_value: drtio::Error) -> Error<SchedError> {
|
||||
@ -192,7 +193,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn get_log(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
let mut buffer = String::new();
|
||||
loop {
|
||||
@ -225,7 +226,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn clear_log(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
let reply = drtio::aux_transact(io, aux_mutex, ddma_mutex, subkernel_mutex, routing_table, linkno,
|
||||
&Packet::CoreMgmtClearLogRequest { destination }
|
||||
@ -251,7 +252,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn pull_log(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
loop {
|
||||
let reply = drtio::aux_transact(io, aux_mutex, ddma_mutex, subkernel_mutex, routing_table, linkno,
|
||||
@ -276,7 +277,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn set_log_filter(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream, level: LevelFilter) -> Result<(), Error<SchedError>> {
|
||||
let reply = drtio::aux_transact(io, aux_mutex, ddma_mutex, subkernel_mutex, routing_table, linkno,
|
||||
&Packet::CoreMgmtSetLogLevelRequest { destination, log_level: level as u8 }
|
||||
@ -302,7 +303,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn set_uart_log_filter(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream, level: LevelFilter) -> Result<(), Error<SchedError>> {
|
||||
let reply = drtio::aux_transact(io, aux_mutex, ddma_mutex, subkernel_mutex, routing_table, linkno,
|
||||
&Packet::CoreMgmtSetUartLogLevelRequest { destination, log_level: level as u8 }
|
||||
@ -328,7 +329,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn config_read(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream, key: &String) -> Result<(), Error<SchedError>> {
|
||||
let mut config_key: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
||||
let len = key.len();
|
||||
@ -375,13 +376,13 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn config_write(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream, key: &String, value: &Vec<u8>) -> Result<(), Error<SchedError>> {
|
||||
let mut message = Vec::with_capacity(key.len() + value.len() + 4 * 2);
|
||||
let mut message = Cursor::new(Vec::with_capacity(key.len() + value.len() + 4 * 2));
|
||||
message.write_string(key).unwrap();
|
||||
message.write_bytes(value).unwrap();
|
||||
|
||||
match drtio::partition_data(&message, |slice, status, len: usize| {
|
||||
match drtio::partition_data(message.get_ref(), |slice, status, len: usize| {
|
||||
let reply = drtio::aux_transact(io, aux_mutex, ddma_mutex, subkernel_mutex, routing_table, linkno,
|
||||
&Packet::CoreMgmtConfigWriteRequest {
|
||||
destination: destination, length: len as u16, last: status.is_last(), data: *slice});
|
||||
@ -410,7 +411,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn config_remove(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream, key: &String) -> Result<(), Error<SchedError>> {
|
||||
let mut config_key: [u8; MASTER_PAYLOAD_MAX_SIZE] = [0; MASTER_PAYLOAD_MAX_SIZE];
|
||||
let len = key.len();
|
||||
@ -443,7 +444,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn config_erase(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
let reply = drtio::aux_transact(io, aux_mutex, ddma_mutex, subkernel_mutex, routing_table, linkno,
|
||||
&Packet::CoreMgmtConfigEraseRequest {
|
||||
@ -470,7 +471,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn reboot(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
let reply = drtio::aux_transact(io, aux_mutex, ddma_mutex, subkernel_mutex, routing_table, linkno,
|
||||
&Packet::CoreMgmtRebootRequest {
|
||||
@ -497,7 +498,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn debug_allocator(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, _stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
let reply = drtio::aux_transact(io, aux_mutex, ddma_mutex, subkernel_mutex, routing_table, linkno,
|
||||
&Packet::CoreMgmtAllocatorDebugRequest {
|
||||
@ -519,7 +520,7 @@ mod remote_coremgmt {
|
||||
|
||||
pub fn flash(io: &Io, aux_mutex: &Mutex,
|
||||
ddma_mutex: &Mutex, subkernel_mutex: &Mutex,
|
||||
routing_table: &RoutingTable, linkno: u8,
|
||||
routing_table: &drtio_routing::RoutingTable, linkno: u8,
|
||||
destination: u8, stream: &mut TcpStream, image: &[u8]) -> Result<(), Error<SchedError>> {
|
||||
|
||||
match drtio::partition_data(&image, |slice, status, len: usize| {
|
||||
@ -581,7 +582,7 @@ macro_rules! process {
|
||||
}
|
||||
|
||||
fn worker(io: &Io, _aux_mutex: &Mutex, _ddma_mutex: &Mutex, _subkernel_mutex: &Mutex,
|
||||
_routing_table: &RoutingTable, stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
_routing_table: &drtio_routing::RoutingTable, stream: &mut TcpStream) -> Result<(), Error<SchedError>> {
|
||||
read_magic(stream)?;
|
||||
let _destination = stream.read_u8()?;
|
||||
Write::write_all(stream, "e".as_bytes())?;
|
||||
@ -605,7 +606,7 @@ fn worker(io: &Io, _aux_mutex: &Mutex, _ddma_mutex: &Mutex, _subkernel_mutex: &M
|
||||
}
|
||||
}
|
||||
|
||||
pub fn thread(io: Io, aux_mutex: &Mutex, ddma_mutex: &Mutex, subkernel_mutex: &Mutex, routing_table: &Urc<RefCell<RoutingTable>>) {
|
||||
pub fn thread(io: Io, aux_mutex: &Mutex, ddma_mutex: &Mutex, subkernel_mutex: &Mutex, routing_table: &Urc<RefCell<drtio_routing::RoutingTable>>) {
|
||||
let listener = TcpListener::new(&io, 8192);
|
||||
listener.listen(1380).expect("mgmt: cannot listen");
|
||||
info!("management interface active");
|
||||
|
@ -574,15 +574,6 @@ fn process_aux_packet(dmamgr: &mut DmaManager, analyzer: &mut Analyzer, kernelmg
|
||||
|
||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })
|
||||
}
|
||||
drtioaux::Packet::CoreMgmtConfigEraseRequest { destination: _destination } => {
|
||||
forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet);
|
||||
|
||||
let succeeded = config::erase()
|
||||
.map_err(|err| warn!("error on erasing config: {:?}", err))
|
||||
.is_ok();
|
||||
|
||||
drtioaux::send(0, &drtioaux::Packet::CoreMgmtReply { succeeded })
|
||||
}
|
||||
drtioaux::Packet::CoreMgmtRebootRequest { destination: _destination } => {
|
||||
forward!(router, _routing_table, _destination, *rank, *self_destination, _repeaters, &packet);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user