From 7da5061f7e93eddfb75e15ce5a0dd0713bea8931 Mon Sep 17 00:00:00 2001 From: occheung Date: Thu, 5 Sep 2024 12:16:57 +0800 Subject: [PATCH] coremgmt: fix import/uses --- src/runtime/src/mgmt.rs | 58 +++++++++++++++++++---------------------- src/satman/src/mgmt.rs | 19 +++++++------- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/runtime/src/mgmt.rs b/src/runtime/src/mgmt.rs index b2e5a88..efec891 100644 --- a/src/runtime/src/mgmt.rs +++ b/src/runtime/src/mgmt.rs @@ -3,19 +3,18 @@ use core::{cell::RefCell, ops::Deref}; use futures::{future::poll_fn, task::Poll}; use libasync::{smoltcp::TcpStream, task}; -use libboard_artiq::{drtio_routing, - drtio_routing::RoutingTable, +use libboard_artiq::{drtio_routing::RoutingTable, logger::{BufferLogger, LogBufferRef}}; -use libboard_zynq::{slcr, smoltcp, timer::GlobalTimer}; +use libboard_zynq::{smoltcp, timer::GlobalTimer}; use libconfig::Config; -use libcortex_a9::{mutex::Mute, semaphore::Semaphore}; -use log::{self, debug, error, info, warn, LevelFilter}; +use libcortex_a9::{mutex::Mutex, semaphore::Semaphore}; +use log::{self, debug, error, info, warn}; use num_derive::FromPrimitive; use num_traits::FromPrimitive; use crate::proto_async::*; #[cfg(has_drtio)] -use crate::rtio_mgt::*; +use crate::rtio_mgt::drtio; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Error { @@ -140,12 +139,11 @@ mod remote_coremgmt { drtioaux_proto::{Packet, MASTER_PAYLOAD_MAX_SIZE}}; use super::*; - use crate::rtio_mgt::drtio; pub async fn get_log( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -190,7 +188,7 @@ mod remote_coremgmt { pub async fn clear_log( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -225,7 +223,7 @@ mod remote_coremgmt { pub async fn pull_log( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -276,11 +274,11 @@ mod remote_coremgmt { pub async fn set_log_filter( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, - level: LevelFilter, + level: log::LevelFilter, ) -> Result<()> { let reply = drtio::aux_transact( aux_mutex, @@ -315,11 +313,11 @@ mod remote_coremgmt { pub async fn set_uart_log_filter( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, - level: LevelFilter, + level: log::LevelFilter, ) -> Result<()> { let reply = drtio::aux_transact( aux_mutex, @@ -354,7 +352,7 @@ mod remote_coremgmt { pub async fn config_read( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -418,7 +416,7 @@ mod remote_coremgmt { pub async fn config_write( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -468,7 +466,7 @@ mod remote_coremgmt { pub async fn config_remove( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -514,7 +512,7 @@ mod remote_coremgmt { pub async fn config_erase( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -551,7 +549,7 @@ mod remote_coremgmt { pub async fn reboot( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -589,7 +587,7 @@ mod remote_coremgmt { pub async fn debug_allocator( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -624,7 +622,7 @@ mod remote_coremgmt { pub async fn image_write( stream: &mut TcpStream, aux_mutex: &Rc>, - routing_table: &drtio_routing::RoutingTable, + routing_table: &RoutingTable, timer: GlobalTimer, linkno: u8, destination: u8, @@ -681,6 +679,8 @@ mod remote_coremgmt { } mod local_coremgmt { + use libboard_zynq::slcr; + use super::*; pub async fn get_log(stream: &mut TcpStream) -> Result<()> { @@ -714,25 +714,25 @@ mod local_coremgmt { buffer.clear(); core::mem::drop(buffer); write_chunk(stream, &bytes).await?; - if log::max_level() == LevelFilter::Trace { + if log::max_level() == log::LevelFilter::Trace { // temporarily discard all trace level log let logger = unsafe { BufferLogger::get_logger().as_mut().unwrap() }; - logger.set_buffer_log_level(LevelFilter::Debug); + logger.set_buffer_log_level(log::LevelFilter::Debug); stream.flush().await?; - logger.set_buffer_log_level(LevelFilter::Trace); + logger.set_buffer_log_level(log::LevelFilter::Trace); } } Ok(()) } - pub async fn set_log_filter(stream: &mut TcpStream, lvl: LevelFilter) -> Result<()> { + pub async fn set_log_filter(stream: &mut TcpStream, lvl: log::LevelFilter) -> Result<()> { info!("Changing log level to {}", lvl); log::set_max_level(lvl); write_i8(stream, Reply::Success as i8).await?; Ok(()) } - pub async fn set_uart_log_filter(stream: &mut TcpStream, lvl: LevelFilter) -> Result<()> { + pub async fn set_uart_log_filter(stream: &mut TcpStream, lvl: log::LevelFilter) -> Result<()> { info!("Changing UART log level to {}", lvl); unsafe { BufferLogger::get_logger().as_ref().unwrap().set_uart_log_level(lvl); @@ -920,11 +920,7 @@ async fn handle_connection( } } -pub fn start( - cfg: Rc, - restart_idle: Rc, - drtio_tuple: Option<(&Rc>, &Rc>, GlobalTimer)>, -) { +pub fn start(cfg: Config, restart_idle: Rc, drtio_tuple: Option<(&Rc>, &Rc>, GlobalTimer)>) { let drtio_tuple = drtio_tuple.map(|(aux_mutex, routing_table, timer)| (aux_mutex.clone(), routing_table.clone(), timer)); task::spawn(async move { diff --git a/src/satman/src/mgmt.rs b/src/satman/src/mgmt.rs index 9866999..2e7a568 100644 --- a/src/satman/src/mgmt.rs +++ b/src/satman/src/mgmt.rs @@ -2,24 +2,24 @@ use alloc::vec::Vec; use byteorder::{ByteOrder, NativeEndian}; use crc::crc32; -use io::{Cursor, ProtoRead, ProtoWrite}; +use io::{ProtoRead, ProtoWrite}; use libboard_artiq::{drtioaux_proto::SAT_PAYLOAD_MAX_SIZE, logger::{BufferLogger, LogBufferRef}}; use libconfig::Config; -use log::{self, debug, error, info, warn, LevelFilter}; +use log::{debug, error, info, warn, LevelFilter}; use crate::routing::{SliceMeta, Sliceable}; type Result = core::result::Result; -pub fn byte_to_level_filter(level_byte: u8) -> Result { +pub fn byte_to_level_filter(level_byte: u8) -> Result { Ok(match level_byte { - 0 => log::LevelFilter::Off, - 1 => log::LevelFilter::Error, - 2 => log::LevelFilter::Warn, - 3 => log::LevelFilter::Info, - 4 => log::LevelFilter::Debug, - 5 => log::LevelFilter::Trace, + 0 => LevelFilter::Off, + 1 => LevelFilter::Error, + 2 => LevelFilter::Warn, + 3 => LevelFilter::Info, + 4 => LevelFilter::Debug, + 5 => LevelFilter::Trace, lv => { error!("unknown log level: {}", lv); return Err(()); @@ -132,6 +132,7 @@ impl<'a> Manager<'_> { let actual_crc = crc32::checksum_ieee(image_ref); if actual_crc == expected_crc { + info!("CRC passed. Writing boot image to SD card..."); image.truncate(bin_len); self.cfg.write("boot", image).expect("failed to write boot image"); } else {