From a0281e498927d5c8467dd18f28aa497cb75150fd Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Mon, 23 Dec 2024 12:51:10 +0800 Subject: [PATCH] cargo fmt --- src/libboard_artiq/src/drtioaux_proto.rs | 3 +- src/libio/cursor.rs | 10 +++++-- src/libksupport/src/eh_artiq.rs | 36 ++++++++++++++---------- src/libksupport/src/kernel/dma.rs | 2 +- src/satman/src/subkernel.rs | 10 +++++-- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/libboard_artiq/src/drtioaux_proto.rs b/src/libboard_artiq/src/drtioaux_proto.rs index 173aa9c..a24dde6 100644 --- a/src/libboard_artiq/src/drtioaux_proto.rs +++ b/src/libboard_artiq/src/drtioaux_proto.rs @@ -5,7 +5,8 @@ pub const MAX_PACKET: usize = 1024; // maximum size of arbitrary payloads // used by satellite -> master analyzer, subkernel exceptions -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) pub const MASTER_PAYLOAD_MAX_SIZE: usize = SAT_PAYLOAD_MAX_SIZE - /*source*/1 - /*destination*/1 - /*ID*/4; diff --git a/src/libio/cursor.rs b/src/libio/cursor.rs index 46ff6d6..4ee0816 100644 --- a/src/libio/cursor.rs +++ b/src/libio/cursor.rs @@ -1,8 +1,8 @@ #[cfg(feature = "alloc")] use alloc::vec::Vec; +use core::arch::asm; use core_io::{Error as IoError, Read, Write}; -use core::arch::asm; #[derive(Debug, Clone)] pub struct Cursor { @@ -48,7 +48,9 @@ impl> Read for Cursor { let len = buf.len().min(data.len()); // ``copy_from_slice`` generates AXI bursts, use a regular loop instead for i in 0..len { - unsafe { asm!("", options(preserves_flags, nostack, readonly)); } + unsafe { + asm!("", options(preserves_flags, nostack, readonly)); + } buf[i] = data[i]; } self.pos += len; @@ -61,7 +63,9 @@ impl Write for Cursor<&mut [u8]> { let data = &mut self.inner[self.pos..]; let len = buf.len().min(data.len()); for i in 0..len { - unsafe { asm!("", options(preserves_flags, nostack, readonly)); } + unsafe { + asm!("", options(preserves_flags, nostack, readonly)); + } data[i] = buf[i]; } self.pos += len; diff --git a/src/libksupport/src/eh_artiq.rs b/src/libksupport/src/eh_artiq.rs index 5b225e1..53d7d6e 100644 --- a/src/libksupport/src/eh_artiq.rs +++ b/src/libksupport/src/eh_artiq.rs @@ -96,30 +96,36 @@ struct ExceptionBuffer { } static mut EXCEPTION_BUFFER: ExceptionBuffer = ExceptionBuffer { - uw_exceptions: [const { uw::_Unwind_Exception { - exception_class: EXCEPTION_CLASS, - exception_cleanup: cleanup, - private: [0; uw::unwinder_private_data_size], - }}; MAX_INFLIGHT_EXCEPTIONS], + uw_exceptions: [const { + uw::_Unwind_Exception { + exception_class: EXCEPTION_CLASS, + exception_cleanup: cleanup, + private: [0; uw::unwinder_private_data_size], + } + }; MAX_INFLIGHT_EXCEPTIONS], exceptions: [None; MAX_INFLIGHT_EXCEPTIONS + 1], exception_stack: [-1; MAX_INFLIGHT_EXCEPTIONS + 1], backtrace: [(0, 0); MAX_BACKTRACE_SIZE], backtrace_size: 0, - stack_pointers: [const { StackPointerBacktrace { - stack_pointer: 0, - initial_backtrace_size: 0, - current_backtrace_size: 0, - }}; MAX_INFLIGHT_EXCEPTIONS + 1], + stack_pointers: [const { + StackPointerBacktrace { + stack_pointer: 0, + initial_backtrace_size: 0, + current_backtrace_size: 0, + } + }; MAX_INFLIGHT_EXCEPTIONS + 1], exception_count: 0, }; pub unsafe extern "C" fn reset_exception_buffer() { trace!("reset exception buffer"); - EXCEPTION_BUFFER.uw_exceptions = [const { uw::_Unwind_Exception { - exception_class: EXCEPTION_CLASS, - exception_cleanup: cleanup, - private: [0; uw::unwinder_private_data_size], - }}; MAX_INFLIGHT_EXCEPTIONS]; + EXCEPTION_BUFFER.uw_exceptions = [const { + uw::_Unwind_Exception { + exception_class: EXCEPTION_CLASS, + exception_cleanup: cleanup, + private: [0; uw::unwinder_private_data_size], + } + }; MAX_INFLIGHT_EXCEPTIONS]; EXCEPTION_BUFFER.exceptions = [None; MAX_INFLIGHT_EXCEPTIONS + 1]; EXCEPTION_BUFFER.exception_stack = [-1; MAX_INFLIGHT_EXCEPTIONS + 1]; EXCEPTION_BUFFER.backtrace_size = 0; diff --git a/src/libksupport/src/kernel/dma.rs b/src/libksupport/src/kernel/dma.rs index 961e862..f8a5153 100644 --- a/src/libksupport/src/kernel/dma.rs +++ b/src/libksupport/src/kernel/dma.rs @@ -82,7 +82,7 @@ pub extern "C" fn dma_record_stop(duration: i64, enable_ddma: bool) { #[inline(always)] unsafe fn dma_record_output_prepare(timestamp: i64, target: i32, words: usize) { // See gateware/rtio/dma.py. - const HEADER_LENGTH: usize = /*length*/1 + /*channel*/3 + /*timestamp*/8 + /*address*/1; + const HEADER_LENGTH: usize = /*length*/ 1 + /*channel*/3 + /*timestamp*/8 + /*address*/1; let length = HEADER_LENGTH + /*data*/words * 4; let buffer = &mut RECORDER.as_mut().unwrap().buffer; diff --git a/src/satman/src/subkernel.rs b/src/satman/src/subkernel.rs index a02fe7d..0e53f5e 100644 --- a/src/satman/src/subkernel.rs +++ b/src/satman/src/subkernel.rs @@ -396,9 +396,13 @@ impl<'a> Manager<'_> { self.session = Session::new(id); self.control.restart(); - self.control - .tx - .send(kernel::Message::LoadRequest(self.kernels.get(&id).ok_or_else(|| Error::KernelNotFound)?.library.clone())); + self.control.tx.send(kernel::Message::LoadRequest( + self.kernels + .get(&id) + .ok_or_else(|| Error::KernelNotFound)? + .library + .clone(), + )); let reply = self.control.rx.recv(); match reply { kernel::Message::LoadCompleted => Ok(()),