diff --git a/flake.lock b/flake.lock index f52fff5..8dd1064 100644 --- a/flake.lock +++ b/flake.lock @@ -11,11 +11,11 @@ "src-pythonparser": "src-pythonparser" }, "locked": { - "lastModified": 1728269744, - "narHash": "sha256-GpVK5qyEnqcVDApRwD5wP3TlLVYj37XRJpN3KGb4mjU=", + "lastModified": 1729249162, + "narHash": "sha256-o3UROeulca0x5LQ6PlVILKEnZfhLElUA6qnNJ4Uwjmk=", "ref": "refs/heads/master", - "rev": "049ef9022016f05119454335972d328b9e3ca539", - "revCount": 9022, + "rev": "02235b2d80780de2ce0bb3cea09fe05be191fa5b", + "revCount": 9039, "type": "git", "url": "https://github.com/m-labs/artiq.git" }, @@ -102,11 +102,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1727348695, - "narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=", + "lastModified": 1728492678, + "narHash": "sha256-9UTxR8eukdg+XZeHgxW5hQA9fIKHsKCdOIUycTryeVw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784", + "rev": "5633bcff0c6162b9e4b5f1264264611e950c8ec7", "type": "github" }, "original": { @@ -153,11 +153,11 @@ ] }, "locked": { - "lastModified": 1724921939, - "narHash": "sha256-/S5iip1LHLiCP2VY7PwClDteP9ZMRZvzzKR1LZuV3fs=", + "lastModified": 1728371104, + "narHash": "sha256-PPnAyDedUQ7Og/Cby9x5OT9wMkNGTP8GS53V6N/dk4w=", "owner": "m-labs", "repo": "sipyco", - "rev": "32ddd78ff3641b75054793ea0d5681c951766754", + "rev": "094a6cd63ffa980ef63698920170e50dc9ba77fd", "type": "github" }, "original": { @@ -185,11 +185,11 @@ "src-misoc": { "flake": false, "locked": { - "lastModified": 1715647536, - "narHash": "sha256-q+USDcaKHABwW56Jzq8u94iGPWlyLXMyVt0j/Gyg+IE=", + "lastModified": 1728978817, + "narHash": "sha256-b4633jrhh4i+KunZq4kNlyhdm9BCsEJwKs+6KINKV2o=", "ref": "refs/heads/master", - "rev": "fea9de558c730bc394a5936094ae95bb9d6fa726", - "revCount": 2455, + "rev": "386b544776b66cea148da67d06a4b3a4151179f9", + "revCount": 2459, "submodules": true, "type": "git", "url": "https://github.com/m-labs/misoc.git" diff --git a/flake.nix b/flake.nix index 100f90d..9031818 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,6 @@ pkgs = import artiq.inputs.nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; }; zynqpkgs = zynq-rs.packages.x86_64-linux; artiqpkgs = artiq.packages.x86_64-linux; - llvmPackages_11 = zynq-rs.llvmPackages_11; rust = zynq-rs.rust; rustPlatform = zynq-rs.rustPlatform; @@ -126,7 +125,7 @@ lockFile = src/Cargo.lock; outputHashes = { "tar-no-std-0.1.8" = "sha256-xm17108v4smXOqxdLvHl9CxTCJslmeogjm4Y87IXFuM="; - "nalgebra-0.32.6" = "sha256-L/YudkVOtfGYoNQKBD7LMk/sMYgRDzPDdpGL5rO7G2I="; + "fatfs-0.4.0" = "sha256-P7IgvhwTPXtNhcyv8cFqwO2UdaEcCGJY7UBG6+yBFSg="; }; }; @@ -134,12 +133,12 @@ pkgs.gnumake (pkgs.python3.withPackages(ps: [ ps.jsonschema artiqpkgs.migen migen-axi artiqpkgs.misoc artiqpkgs.artiq ])) zynqpkgs.cargo-xbuild - llvmPackages_11.llvm - llvmPackages_11.clang-unwrapped + pkgs.llvmPackages_18.llvm + pkgs.llvmPackages_18.clang-unwrapped ]; buildPhase = '' export XARGO_RUST_SRC="${rust}/lib/rustlib/src/rust/library" - export CLANG_EXTRA_INCLUDE_DIR="${llvmPackages_11.clang-unwrapped.lib}/lib/clang/11.1.0/include" + export CLANG_EXTRA_INCLUDE_DIR="${pkgs.llvmPackages_18.clang-unwrapped.lib}/lib/clang/18/include" export CARGO_HOME=$(mktemp -d cargo-home.XXX) export ZYNQ_RS=${zynq-rs} make TARGET=${target} GWARGS="${if json == null then "-V ${variant}" else json}" ${fwtype} @@ -373,8 +372,8 @@ name = "artiq-zynq-dev-shell"; buildInputs = with pkgs; [ rust - llvmPackages_11.llvm - llvmPackages_11.clang-unwrapped + llvmPackages_18.llvm + llvmPackages_18.clang-unwrapped gnumake cacert zynqpkgs.cargo-xbuild @@ -388,7 +387,7 @@ pre-commit ]; XARGO_RUST_SRC = "${rust}/lib/rustlib/src/rust/library"; - CLANG_EXTRA_INCLUDE_DIR = "${llvmPackages_11.clang-unwrapped.lib}/lib/clang/11.1.0/include"; + CLANG_EXTRA_INCLUDE_DIR = "${pkgs.llvmPackages_18.clang-unwrapped.lib}/lib/clang/18/include"; ZYNQ_RS = "${zynq-rs}"; OPENOCD_ZYNQ = "${zynq-rs}/openocd"; SZL = "${zynqpkgs.szl}"; diff --git a/src/Cargo.lock b/src/Cargo.lock index 835eca0..6347f22 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -46,6 +46,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "build_const" version = "0.2.2" @@ -82,18 +88,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "compiler_builtins" -version = "0.1.39" +version = "0.1.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3748f82c7d366a0b4950257d19db685d4958d2fa27c6d164a3f069fec42b748b" - -[[package]] -name = "core_io" -version = "0.1.20210325" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97f8932064288cc79feb4d343a399d353a6f6f001e586ece47fe518a9e8507df" -dependencies = [ - "rustc_version", -] +checksum = "f11973008a8cf741fe6d22f339eba21fd0ca81e2760a769ba8243ed6c21edd7e" [[package]] name = "crc" @@ -141,13 +138,10 @@ dependencies = [ [[package]] name = "fatfs" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e18f80a87439240dac45d927fd8f8081b6f1e34c03e97271189fa8a8c2e96c8f" +version = "0.4.0" +source = "git+https://github.com/rafalh/rust-fatfs?rev=85f06e0#85f06e08edbd3368e1b0562f2fc1b6d178bf7b8a" dependencies = [ - "bitflags", - "byteorder", - "core_io", + "bitflags 2.6.0", "log", ] @@ -319,7 +313,6 @@ dependencies = [ name = "libconfig" version = "0.1.0" dependencies = [ - "core_io", "fatfs", "libboard_zynq", "log", @@ -391,8 +384,9 @@ checksum = "c75de51135344a4f8ed3cfe2720dc27736f7711989703a0b43aadf3753c55577" [[package]] name = "nalgebra" -version = "0.32.6" -source = "git+https://git.m-labs.hk/M-Labs/nalgebra.git?rev=dd00f9b#dd00f9b46046e0b931d1b470166db02fd29591be" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c4b5f057b303842cf3262c27e465f4c303572e7f6b0648f60e16248ac3397f4" dependencies = [ "approx", "num-complex", @@ -541,15 +535,6 @@ dependencies = [ "void", ] -[[package]] -name = "rustc_version" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" -dependencies = [ - "semver", -] - [[package]] name = "satman" version = "0.0.0" @@ -571,17 +556,11 @@ dependencies = [ "unwind", ] -[[package]] -name = "semver" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" - [[package]] name = "simba" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" +checksum = "b3a386a501cd104797982c15ae17aafe8b9261315b5d07e3ec803f2ea26be0fa" dependencies = [ "approx", "num-complex", @@ -595,7 +574,7 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e4a069bef843d170df47e7c0a8bf8d037f217d9f5b325865acc3e466ffe40d3" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "managed", ] @@ -617,7 +596,7 @@ version = "0.1.8" source = "git+https://git.m-labs.hk/M-Labs/tar-no-std?rev=2ab6dc5#2ab6dc58e5249c59c4eb03eaf3a119bcdd678d32" dependencies = [ "arrayvec", - "bitflags", + "bitflags 1.3.2", "log", ] diff --git a/src/libboard_artiq/src/drtioaux.rs b/src/libboard_artiq/src/drtioaux.rs index 4bb12cc..dce496b 100644 --- a/src/libboard_artiq/src/drtioaux.rs +++ b/src/libboard_artiq/src/drtioaux.rs @@ -9,7 +9,7 @@ pub use crate::drtioaux_proto::Packet; use crate::{drtioaux_proto::Error as ProtocolError, mem::mem::DRTIOAUX_MEM, pl::csr::DRTIOAUX}; #[derive(Debug)] -pub enum Error { +pub enum Error { GatewareError, CorruptedPacket, @@ -19,17 +19,17 @@ pub enum Error { RoutingError, - Protocol(ProtocolError), + Protocol(ProtocolError), } -impl From for Error { - fn from(value: ProtocolError) -> Error { +impl From> for Error { + fn from(value: ProtocolError) -> Error { Error::Protocol(value) } } -impl From for Error { - fn from(value: IoError) -> Error { +impl From> for Error { + fn from(value: IoError) -> Error { Error::Protocol(ProtocolError::Io(value)) } } @@ -56,8 +56,8 @@ pub fn has_rx_error(linkno: u8) -> bool { } } -fn receive(linkno: u8, f: F) -> Result, Error> -where F: FnOnce(&[u8]) -> Result { +fn receive(linkno: u8, f: F) -> Result, Error> +where F: FnOnce(&[u8]) -> Result> { let linkidx = linkno as usize; unsafe { if (DRTIOAUX[linkidx].aux_rx_present_read)() == 1 { @@ -72,14 +72,14 @@ where F: FnOnce(&[u8]) -> Result { } } -pub fn recv(linkno: u8) -> Result, Error> { +pub fn recv(linkno: u8) -> Result, Error> { if has_rx_error(linkno) { return Err(Error::GatewareError); } receive(linkno, |buffer| { if buffer.len() < 8 { - return Err(IoError::UnexpectedEnd).into()); + return Err(IoError::UnexpectedEnd.into()); } let mut reader = Cursor::new(buffer); @@ -96,7 +96,7 @@ pub fn recv(linkno: u8) -> Result, Error> { }) } -pub fn recv_timeout(linkno: u8, timeout_ms: Option, timer: GlobalTimer) -> Result { +pub fn recv_timeout(linkno: u8, timeout_ms: Option, timer: GlobalTimer) -> Result> { let timeout_ms = Milliseconds(timeout_ms.unwrap_or(10)); let limit = timer.get_time() + timeout_ms; while timer.get_time() < limit { @@ -108,8 +108,8 @@ pub fn recv_timeout(linkno: u8, timeout_ms: Option, timer: GlobalTimer) -> Err(Error::TimedOut) } -fn transmit(linkno: u8, f: F) -> Result<(), Error> -where F: FnOnce(&mut [u8]) -> Result { +fn transmit(linkno: u8, f: F) -> Result<(), Error> +where F: FnOnce(&mut [u8]) -> Result> { let linkno = linkno as usize; unsafe { while (DRTIOAUX[linkno].aux_tx_read)() != 0 {} @@ -121,7 +121,7 @@ where F: FnOnce(&mut [u8]) -> Result { } } -pub fn send(linkno: u8, packet: &Packet) -> Result<(), Error> { +pub fn send(linkno: u8, packet: &Packet) -> Result<(), Error> { transmit(linkno, |buffer| { let mut writer = Cursor::new(buffer); diff --git a/src/libboard_artiq/src/drtioaux_async.rs b/src/libboard_artiq/src/drtioaux_async.rs index 3244432..e86b5fb 100644 --- a/src/libboard_artiq/src/drtioaux_async.rs +++ b/src/libboard_artiq/src/drtioaux_async.rs @@ -34,8 +34,8 @@ fn tx_ready(linkno: usize) -> nb::Result<(), Void> { } } -async fn receive(linkno: u8, f: F) -> Result, Error> -where F: FnOnce(&[u8]) -> Result { +async fn receive(linkno: u8, f: F) -> Result, Error> +where F: FnOnce(&[u8]) -> Result> { let linkidx = linkno as usize; unsafe { if (DRTIOAUX[linkidx].aux_rx_present_read)() == 1 { @@ -50,14 +50,14 @@ where F: FnOnce(&[u8]) -> Result { } } -pub async fn recv(linkno: u8) -> Result, Error> { +pub async fn recv(linkno: u8) -> Result, Error> { if has_rx_error(linkno) { return Err(Error::GatewareError); } receive(linkno, |buffer| { if buffer.len() < 8 { - return Err(IoError::UnexpectedEnd).into()); + return Err(IoError::UnexpectedEnd.into()); } let mut reader = Cursor::new(buffer); @@ -75,7 +75,7 @@ pub async fn recv(linkno: u8) -> Result, Error> { .await } -pub async fn recv_timeout(linkno: u8, timeout_ms: Option, timer: GlobalTimer) -> Result { +pub async fn recv_timeout(linkno: u8, timeout_ms: Option, timer: GlobalTimer) -> Result> { let timeout_ms = Milliseconds(timeout_ms.unwrap_or(10)); let limit = timer.get_time() + timeout_ms; let mut would_block = false; @@ -95,8 +95,8 @@ pub async fn recv_timeout(linkno: u8, timeout_ms: Option, timer: GlobalTime Err(Error::TimedOut) } -async fn transmit(linkno: u8, f: F) -> Result<(), Error> -where F: FnOnce(&mut [u8]) -> Result { +async fn transmit(linkno: u8, f: F) -> Result<(), Error> +where F: FnOnce(&mut [u8]) -> Result> { let linkno = linkno as usize; unsafe { let _ = block_async!(tx_ready(linkno)).await; @@ -108,7 +108,7 @@ where F: FnOnce(&mut [u8]) -> Result { } } -pub async fn send(linkno: u8, packet: &Packet) -> Result<(), Error> { +pub async fn send(linkno: u8, packet: &Packet) -> Result<(), Error> { transmit(linkno, |buffer| { let mut writer = Cursor::new(buffer); diff --git a/src/libboard_artiq/src/fiq.rs b/src/libboard_artiq/src/fiq.rs index dc9c013..1c85b06 100644 --- a/src/libboard_artiq/src/fiq.rs +++ b/src/libboard_artiq/src/fiq.rs @@ -1,5 +1,6 @@ use libboard_zynq::{println, stdio}; use libcortex_a9::{interrupt_handler, regs::MPIDR}; +use core::arch::asm; use libregister::RegisterR; #[cfg(has_si549)] diff --git a/src/libboard_artiq/src/lib.rs b/src/libboard_artiq/src/lib.rs index b70ec4d..aeca82d 100644 --- a/src/libboard_artiq/src/lib.rs +++ b/src/libboard_artiq/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] #![feature(never_type)] #![feature(naked_functions)] -#![feature(asm)] +#![allow(unexpected_cfgs)] extern crate crc; extern crate embedded_hal; diff --git a/src/libbuild_zynq/lib.rs b/src/libbuild_zynq/lib.rs index ab31b06..afebb67 100644 --- a/src/libbuild_zynq/lib.rs +++ b/src/libbuild_zynq/lib.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] + use std::{env, fs::File, io::{BufRead, BufReader, Write}, diff --git a/src/libio/lib.rs b/src/libio/lib.rs index ed115ac..f0c9fcb 100644 --- a/src/libio/lib.rs +++ b/src/libio/lib.rs @@ -1,5 +1,6 @@ #![no_std] #![feature(never_type)] +#![allow(unexpected_cfgs)] #[cfg(feature = "alloc")] extern crate alloc; diff --git a/src/libksupport/Cargo.toml.tpl b/src/libksupport/Cargo.toml.tpl index e06c1c9..0738154 100644 --- a/src/libksupport/Cargo.toml.tpl +++ b/src/libksupport/Cargo.toml.tpl @@ -17,6 +17,7 @@ void = { version = "1", default-features = false } log_buffer = { version = "1.2" } libm = { version = "0.2", features = ["unstable"] } vcell = "0.1" +nalgebra = { version = "0.33.0", default-features = false, features = ["libm", "alloc"]} libboard_zynq = { path = "@@ZYNQ_RS@@/libboard_zynq", features = ["ipv6"]} libsupport_zynq = { path = "@@ZYNQ_RS@@/libsupport_zynq", default-features = false, features = ["alloc_core"] } @@ -31,9 +32,3 @@ unwind = { path = "../libunwind" } libc = { path = "../libc" } io = { path = "../libio" } libboard_artiq = { path = "../libboard_artiq" } - -[dependencies.nalgebra] -git = "https://git.m-labs.hk/M-Labs/nalgebra.git" -rev = "dd00f9b" -default-features = false -features = ["libm", "alloc"] diff --git a/src/libksupport/src/eh_artiq.rs b/src/libksupport/src/eh_artiq.rs index 4741c5e..c06f56e 100644 --- a/src/libksupport/src/eh_artiq.rs +++ b/src/libksupport/src/eh_artiq.rs @@ -95,30 +95,30 @@ struct ExceptionBuffer { } static mut EXCEPTION_BUFFER: ExceptionBuffer = ExceptionBuffer { - uw_exceptions: [uw::_Unwind_Exception { + uw_exceptions: [ const { uw::_Unwind_Exception { exception_class: EXCEPTION_CLASS, exception_cleanup: cleanup, private: [0; uw::unwinder_private_data_size], - }; MAX_INFLIGHT_EXCEPTIONS], + } }; 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: [StackPointerBacktrace { + stack_pointers: [ const { StackPointerBacktrace { stack_pointer: 0, initial_backtrace_size: 0, current_backtrace_size: 0, - }; MAX_INFLIGHT_EXCEPTIONS + 1], + } }; MAX_INFLIGHT_EXCEPTIONS + 1], exception_count: 0, }; pub unsafe extern "C" fn reset_exception_buffer() { trace!("reset exception buffer"); - EXCEPTION_BUFFER.uw_exceptions = [uw::_Unwind_Exception { + 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]; + } }; 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/irq.rs b/src/libksupport/src/irq.rs index a18feb9..b21afef 100644 --- a/src/libksupport/src/irq.rs +++ b/src/libksupport/src/irq.rs @@ -1,5 +1,5 @@ use core::sync::atomic::{AtomicBool, Ordering}; - +use core::arch::asm; use libboard_zynq::{gic, mpcore, println, stdio}; use libcortex_a9::{asm, interrupt_handler, notify_spin_lock, regs::MPIDR, spin_lock_yield}; use libregister::RegisterR; diff --git a/src/libksupport/src/rpc.rs b/src/libksupport/src/rpc.rs index 4bfa425..45c8dc2 100644 --- a/src/libksupport/src/rpc.rs +++ b/src/libksupport/src/rpc.rs @@ -44,7 +44,7 @@ unsafe fn recv_elements( alloc: &mut F, ) -> Result<(), E> where - F: FnMut(usize) -> *mut (), + F: FnMut(usize) -> Result<*mut (), E>, R: Read + ?Sized, E: From>, { @@ -57,7 +57,6 @@ where let ptr = storage as *mut u32; let dest = core::slice::from_raw_parts_mut(ptr as *mut u8, length * 4); reader.read_exact(dest)?; - drop(dest); let dest = core::slice::from_raw_parts_mut(ptr, length); NativeEndian::from_slice_u32(dest); } @@ -65,7 +64,6 @@ where let ptr = storage as *mut u64; let dest = core::slice::from_raw_parts_mut(ptr as *mut u8, length * 8); reader.read_exact(dest)?; - drop(dest); let dest = core::slice::from_raw_parts_mut(ptr, length); NativeEndian::from_slice_u64(dest); } @@ -81,7 +79,7 @@ where unsafe fn recv_value(reader: &mut R, tag: Tag, data: &mut *mut (), alloc: &mut F) -> Result<(), E> where - F: FnMut(usize) -> *mut (), + F: FnMut(usize) -> Result<*mut (), E>, R: Read + ?Sized, E: From>, { @@ -110,7 +108,7 @@ where Tag::String | Tag::Bytes | Tag::ByteArray => { consume_value!(CMutSlice, |ptr| { let length = reader.read_u32()? as usize; - *ptr = CMutSlice::new(alloc(length) as *mut u8, length); + *ptr = CMutSlice::new(alloc(length)? as *mut u8, length); reader.read_exact((*ptr).as_mut())?; Ok(()) }) @@ -140,7 +138,7 @@ where let storage_offset = round_up(list_size, tag.alignment()); let storage_size = tag.size() * length; - let allocation = alloc(storage_offset + storage_size) as *mut u8; + let allocation = alloc(storage_offset + storage_size)? as *mut u8; *ptr_to_list = allocation as *mut List; let storage = allocation.offset(storage_offset as isize) as *mut (); @@ -159,7 +157,7 @@ where } let elt_tag = it.clone().next().expect("truncated tag"); - *buffer = alloc(elt_tag.size() * total_len); + *buffer = alloc(elt_tag.size() * total_len)?; recv_elements(reader, elt_tag, total_len, *buffer, alloc) }) } @@ -183,7 +181,7 @@ pub fn recv_return<'a, F, R, E>( alloc: &mut F, ) -> Result<&'a [u8], E> where - F: FnMut(usize) -> *mut (), + F: FnMut(usize) -> Result<*mut (), E>, R: Read + ?Sized, E: From>, { diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs index 34ae38d..80ec618 100644 --- a/src/libunwind/lib.rs +++ b/src/libunwind/lib.rs @@ -1,8 +1,5 @@ #![no_std] #![feature(link_cfg)] -#![feature(nll)] -#![feature(unwind_attributes)] -#![feature(static_nobundle)] #![cfg_attr(not(target_env = "msvc"), feature(libc))] cfg_if::cfg_if! { @@ -17,17 +14,3 @@ cfg_if::cfg_if! { pub use backtrace::backtrace; } } - -#[cfg(target_env = "musl")] -#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))] -#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] -extern "C" {} - -#[cfg(target_os = "redox")] -#[link(name = "gcc_eh", kind = "static-nobundle", cfg(target_feature = "crt-static"))] -#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] -extern "C" {} - -#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] -#[link(name = "unwind", kind = "static-nobundle")] -extern "C" {} diff --git a/src/libunwind/libunwind.rs b/src/libunwind/libunwind.rs index 0f0e457..4ec0626 100644 --- a/src/libunwind/libunwind.rs +++ b/src/libunwind/libunwind.rs @@ -77,8 +77,7 @@ pub type _Unwind_Exception_Cleanup_Fn = all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static") )] -extern "C" { - #[unwind(allowed)] +extern "C-unwind" { pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !; pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception); pub fn _Unwind_GetLanguageSpecificData(ctx: *mut _Unwind_Context) -> *mut c_void; @@ -226,8 +225,7 @@ if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { #[cfg_attr(all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] - extern "C" { - #[unwind(allowed)] + extern "C-unwind" { pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code; pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn, trace_argument: *mut c_void) @@ -238,8 +236,7 @@ if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] { #[cfg_attr(all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")), link(name = "unwind", kind = "static"))] - extern "C" { - #[unwind(allowed)] + extern "C-unwind" { pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code; } diff --git a/src/runtime/build.rs b/src/runtime/build.rs index aee092b..557db0a 100644 --- a/src/runtime/build.rs +++ b/src/runtime/build.rs @@ -1,3 +1,4 @@ +#![allow(unexpected_cfgs)] extern crate build_zynq; fn main() { diff --git a/src/runtime/src/main.rs b/src/runtime/src/main.rs index dd24e25..3c19273 100644 --- a/src/runtime/src/main.rs +++ b/src/runtime/src/main.rs @@ -1,9 +1,9 @@ #![no_std] #![no_main] #![recursion_limit = "1024"] // for futures_util::select! +#![allow(unexpected_cfgs)] #![feature(alloc_error_handler)] -#![feature(const_btree_new)] -#![feature(panic_info_message)] +#![feature(const_btree_len)] #[macro_use] extern crate alloc; diff --git a/src/runtime/src/panic.rs b/src/runtime/src/panic.rs index 7ec2a21..c0bf1ad 100644 --- a/src/runtime/src/panic.rs +++ b/src/runtime/src/panic.rs @@ -22,7 +22,7 @@ fn panic(info: &core::panic::PanicInfo) -> ! { } else { print!("unknown location"); } - if let Some(message) = info.message() { + if let Some(message) = info.message().as_str() { println!(": {}", message); } else { println!(""); @@ -61,7 +61,7 @@ fn soft_panic(info: &core::panic::PanicInfo) -> ! { } else { error!("panic at unknown location"); } - if let Some(message) = info.message() { + if let Some(message) = info.message().as_str() { error!("panic message: {}", message); } let timer = GlobalTimer::start(); diff --git a/src/runtime/src/rpc_async.rs b/src/runtime/src/rpc_async.rs index 303c630..25d17cd 100644 --- a/src/runtime/src/rpc_async.rs +++ b/src/runtime/src/rpc_async.rs @@ -38,7 +38,6 @@ where let ptr = storage as *mut u32; let dest = core::slice::from_raw_parts_mut(ptr as *mut u8, length * 4); proto_async::read_chunk(stream, dest).await?; - drop(dest); let dest = core::slice::from_raw_parts_mut(ptr, length); NativeEndian::from_slice_u32(dest); } @@ -46,7 +45,6 @@ where let ptr = storage as *mut u64; let dest = core::slice::from_raw_parts_mut(ptr as *mut u8, length * 8); proto_async::read_chunk(stream, dest).await?; - drop(dest); let dest = core::slice::from_raw_parts_mut(ptr, length); NativeEndian::from_slice_u64(dest); } diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index d77cff1..d97ce72 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -1,6 +1,7 @@ #![no_std] #![no_main] -#![feature(alloc_error_handler, try_trait, never_type, panic_info_message)] +#![feature(alloc_error_handler, never_type)] +#![allow(unexpected_cfgs)] #[macro_use] extern crate log; @@ -149,7 +150,7 @@ fn process_aux_packet( analyzer: &mut Analyzer, kernel_manager: &mut KernelManager, router: &mut Router, -) -> Result<(), drtioaux::Error> { +) -> Result<(), drtioaux::Error> { // In the code below, *_chan_sel_write takes an u8 if there are fewer than 256 channels, // and u16 otherwise; hence the `as _` conversion. match packet { @@ -1457,7 +1458,7 @@ pub fn panic_fmt(info: &core::panic::PanicInfo) -> ! { } else { print!("unknown location"); } - if let Some(message) = info.message() { + if let Some(message) = info.message().as_str() { println!(": {}", message); } else { println!(""); diff --git a/src/satman/src/repeater.rs b/src/satman/src/repeater.rs index 7834007..8481aa3 100644 --- a/src/satman/src/repeater.rs +++ b/src/satman/src/repeater.rs @@ -191,7 +191,7 @@ impl Repeater { } } - fn recv_aux_timeout(&self, timeout: u32, timer: &mut GlobalTimer) -> Result { + fn recv_aux_timeout(&self, timeout: u32, timer: &mut GlobalTimer) -> Result> { let max_time = timer.get_time() + Milliseconds(timeout.into()); loop { if !rep_link_rx_up(self.repno) { @@ -216,7 +216,7 @@ impl Repeater { rank: u8, self_destination: u8, timer: &mut GlobalTimer, - ) -> Result<(), drtioaux::Error> { + ) -> Result<(), drtioaux::Error> { self.aux_send(request)?; loop { let reply = self.recv_aux_timeout(200, timer)?; @@ -242,14 +242,14 @@ impl Repeater { Ok(()) } - pub fn aux_send(&self, request: &drtioaux::Packet) -> Result<(), drtioaux::Error> { + pub fn aux_send(&self, request: &drtioaux::Packet) -> Result<(), drtioaux::Error> { if self.state != RepeaterState::Up { return Err(drtioaux::Error::LinkDown); } drtioaux::send(self.auxno, request) } - pub fn sync_tsc(&self, timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { + pub fn sync_tsc(&self, timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { if self.state != RepeaterState::Up { return Ok(()); } @@ -275,7 +275,7 @@ impl Repeater { destination: u8, hops: &[u8; drtio_routing::MAX_HOPS], timer: &mut GlobalTimer, - ) -> Result<(), drtioaux::Error> { + ) -> Result<(), drtioaux::Error> { if self.state != RepeaterState::Up { return Ok(()); } @@ -299,14 +299,14 @@ impl Repeater { &self, routing_table: &drtio_routing::RoutingTable, timer: &mut GlobalTimer, - ) -> Result<(), drtioaux::Error> { + ) -> Result<(), drtioaux::Error> { for i in 0..drtio_routing::DEST_COUNT { self.set_path(i as u8, &routing_table.0[i], timer)?; } Ok(()) } - pub fn set_rank(&self, rank: u8, timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { + pub fn set_rank(&self, rank: u8, timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { if self.state != RepeaterState::Up { return Ok(()); } @@ -318,7 +318,7 @@ impl Repeater { Ok(()) } - pub fn rtio_reset(&self, timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { + pub fn rtio_reset(&self, timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { let repno = self.repno as usize; unsafe { (csr::DRTIOREP[repno].reset_write)(1); @@ -361,11 +361,11 @@ impl Repeater { ) { } - pub fn sync_tsc(&self, _timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { + pub fn sync_tsc(&self, _timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { Ok(()) } - pub fn rtio_reset(&self, _timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { + pub fn rtio_reset(&self, _timer: &mut GlobalTimer) -> Result<(), drtioaux::Error> { Ok(()) } } diff --git a/src/satman/src/routing.rs b/src/satman/src/routing.rs index 87d5f09..de2ad32 100644 --- a/src/satman/src/routing.rs +++ b/src/satman/src/routing.rs @@ -129,7 +129,7 @@ impl Router { _routing_table: &drtio_routing::RoutingTable, _rank: u8, _destination: u8, - ) -> Result<(), drtioaux::Error> { + ) -> Result<(), drtioaux::Error> { #[cfg(has_drtio_routing)] { let destination = packet.routable_destination(); diff --git a/src/satman/src/subkernel.rs b/src/satman/src/subkernel.rs index b418363..9b836e0 100644 --- a/src/satman/src/subkernel.rs +++ b/src/satman/src/subkernel.rs @@ -1,17 +1,21 @@ -use alloc::{collections::BTreeMap, - format, - string::{String, ToString}, - vec::Vec}; -use core::{option::NoneError, slice, str}; +use alloc::{ + collections::BTreeMap, + format, + string::{String, ToString}, + vec::Vec, +}; +use core::{slice, str}; use cslice::AsCSlice; use dma::{Error as DmaError, Manager as DmaManager}; use io::{Cursor, Error as IoError, ProtoWrite, Write}; use ksupport::{eh_artiq, kernel, rpc}; -use libboard_artiq::{drtio_routing::RoutingTable, - drtioaux, - drtioaux_proto::{PayloadStatus, MASTER_PAYLOAD_MAX_SIZE}, - pl::csr}; +use libboard_artiq::{ + drtio_routing::RoutingTable, + drtioaux, + drtioaux_proto::{PayloadStatus, MASTER_PAYLOAD_MAX_SIZE}, + pl::csr, +}; use libboard_zynq::{time::Milliseconds, timer::GlobalTimer}; use libcortex_a9::sync_channel::Receiver; use log::warn; @@ -51,6 +55,7 @@ enum KernelState { }, } +#[allow(dead_code)] #[derive(Debug)] pub enum Error { Load(String), @@ -64,14 +69,8 @@ pub enum Error { DmaError(DmaError), } -impl From for Error { - fn from(_: NoneError) -> Error { - Error::KernelNotFound - } -} - -impl From for Error { - fn from(_value: IoError) -> Error { +impl From> for Error { + fn from(_value: IoError) -> Error { Error::SubkernelIoError } } @@ -88,8 +87,8 @@ impl From<()> for Error { } } -impl From for Error { - fn from(_value: drtioaux::Error) -> Error { +impl From> for Error { + fn from(_value: drtioaux::Error) -> Error { Error::DrtioError } } @@ -125,7 +124,7 @@ struct MessageManager { struct Session { id: u32, kernel_state: KernelState, - last_exception: Option, // exceptions raised locally + last_exception: Option, // exceptions raised locally external_exception: Option>, // exceptions from sub-subkernels messages: MessageManager, source: u8, // which destination requested running the kernel @@ -221,7 +220,10 @@ impl MessageManager { } } - pub fn get_outgoing_slice(&mut self, data_slice: &mut [u8; MASTER_PAYLOAD_MAX_SIZE]) -> Option { + pub fn get_outgoing_slice( + &mut self, + data_slice: &mut [u8; MASTER_PAYLOAD_MAX_SIZE], + ) -> Option { if self.out_state != OutMessageState::MessageBeingSent { return None; } @@ -302,7 +304,13 @@ impl<'a> Manager<'_> { } } - pub fn add(&mut self, id: u32, status: PayloadStatus, data: &[u8], data_len: usize) -> Result<(), Error> { + pub fn add( + &mut self, + id: u32, + status: PayloadStatus, + data: &[u8], + data_len: usize, + ) -> Result<(), Error> { let kernel = match self.kernels.get_mut(&id) { Some(kernel) => { if kernel.complete || status.is_first() { @@ -315,7 +323,7 @@ impl<'a> Manager<'_> { complete: false, }, ); - self.kernels.get_mut(&id)? + self.kernels.get_mut(&id).ok_or(Error::KernelNotFound)? } else { kernel } @@ -328,7 +336,7 @@ impl<'a> Manager<'_> { complete: false, }, ); - self.kernels.get_mut(&id)? + self.kernels.get_mut(&id).ok_or(Error::KernelNotFound)? } }; kernel.library.extend(&data[0..data_len]); @@ -372,10 +380,15 @@ impl<'a> Manager<'_> { if !self.running() { return; } - self.session.messages.handle_incoming(status, id, length, slice); + self.session + .messages + .handle_incoming(status, id, length, slice); } - pub fn message_get_slice(&mut self, slice: &mut [u8; MASTER_PAYLOAD_MAX_SIZE]) -> Option { + pub fn message_get_slice( + &mut self, + slice: &mut [u8; MASTER_PAYLOAD_MAX_SIZE], + ) -> Option { if !self.running() { return None; } @@ -394,15 +407,19 @@ impl<'a> Manager<'_> { if self.session.id == id && self.session.kernel_state == KernelState::Loaded { return Ok(()); } - if !self.kernels.get(&id)?.complete { + if !self.kernels.get(&id).ok_or(Error::KernelNotFound)?.complete { return Err(Error::KernelNotFound); } self.session = Session::new(id); self.control.restart(); - self.control - .tx - .send(kernel::Message::LoadRequest(self.kernels.get(&id)?.library.clone())); + self.control.tx.send(kernel::Message::LoadRequest( + self.kernels + .get(&id) + .ok_or(Error::KernelNotFound)? + .library + .clone(), + )); let reply = self.control.rx.recv(); match reply { kernel::Message::LoadCompleted => Ok(()), @@ -414,7 +431,10 @@ impl<'a> Manager<'_> { } } - pub fn exception_get_slice(&mut self, data_slice: &mut [u8; MASTER_PAYLOAD_MAX_SIZE]) -> SliceMeta { + pub fn exception_get_slice( + &mut self, + data_slice: &mut [u8; MASTER_PAYLOAD_MAX_SIZE], + ) -> SliceMeta { match self.session.last_exception.as_mut() { Some(exception) => exception.get_slice_master(data_slice), None => SliceMeta { @@ -568,7 +588,14 @@ impl<'a> Manager<'_> { } } - match self.process_kern_message(router, routing_table, rank, destination, dma_manager, timer) { + match self.process_kern_message( + router, + routing_table, + rank, + destination, + dma_manager, + timer, + ) { Ok(true) => { self.last_finished = Some(SubkernelFinished { id: self.session.id, @@ -611,7 +638,9 @@ impl<'a> Manager<'_> { for (i, (status, exception_source)) in self.session.subkernels_finished.iter().enumerate() { if *status == id { if exception_source.is_none() { - self.control.tx.send(kernel::Message::SubkernelAwaitFinishReply); + self.control + .tx + .send(kernel::Message::SubkernelAwaitFinishReply); self.session.kernel_state = KernelState::Running; self.session.subkernels_finished.swap_remove(i); } else { @@ -639,15 +668,26 @@ impl<'a> Manager<'_> { if self.session.kernel_state == KernelState::SubkernelAwaitLoad { self.control .tx - .send(kernel::Message::SubkernelLoadRunReply { succeeded: succeeded }); + .send(kernel::Message::SubkernelLoadRunReply { + succeeded: succeeded, + }); self.session.kernel_state = KernelState::Running; } else { warn!("received unsolicited SubkernelLoadRunReply"); } } - pub fn remote_subkernel_finished(&mut self, id: u32, with_exception: bool, exception_source: u8) { - let exception_src = if with_exception { Some(exception_source) } else { None }; + pub fn remote_subkernel_finished( + &mut self, + id: u32, + with_exception: bool, + exception_source: u8, + ) { + let exception_src = if with_exception { + Some(exception_source) + } else { + None + }; self.session.subkernels_finished.push((id, exception_src)); } @@ -660,18 +700,19 @@ impl<'a> Manager<'_> { rank: u8, self_destination: u8, ) { - if let KernelState::SubkernelRetrievingException { destination } = self.session.kernel_state { + if let KernelState::SubkernelRetrievingException { destination } = self.session.kernel_state + { self.session .external_exception .as_mut() .unwrap() .extend_from_slice(exception_data); if last { - self.control - .tx - .send(kernel::Message::SubkernelError(kernel::SubkernelStatus::Exception( + self.control.tx.send(kernel::Message::SubkernelError( + kernel::SubkernelStatus::Exception( self.session.external_exception.take().unwrap(), - ))); + ), + )); self.session.kernel_state = KernelState::Running; } else { /* fetch another slice */ @@ -706,7 +747,12 @@ impl<'a> Manager<'_> { dma_manager.cleanup(router, rank, self_destination, routing_table); return Ok(true); } - kernel::Message::KernelException(exceptions, stack_pointers, backtrace, async_errors) => { + kernel::Message::KernelException( + exceptions, + stack_pointers, + backtrace, + async_errors, + ) => { error!("exception in kernel"); for exception in exceptions { error!("{:?}", exception.unwrap()); @@ -715,12 +761,21 @@ impl<'a> Manager<'_> { error!("backtrace: {:?}", backtrace); let buf: Vec = Vec::new(); let mut writer = Cursor::new(buf); - match write_exception(&mut writer, exceptions, stack_pointers, backtrace, async_errors) { + match write_exception( + &mut writer, + exceptions, + stack_pointers, + backtrace, + async_errors, + ) { Ok(()) => (), Err(_) => error!("Error writing exception data"), } self.kernel_stop(); - return Err(Error::KernelException(Sliceable::new(0, writer.into_inner()))); + return Err(Error::KernelException(Sliceable::new( + 0, + writer.into_inner(), + ))); } kernel::Message::CachePutRequest(key, value) => { self.cache.insert(key, value); @@ -768,11 +823,13 @@ impl<'a> Manager<'_> { let max_time = timer.get_time() + Milliseconds(10000); self.session.kernel_state = match self.session.kernel_state { // if we are still waiting for the traces to be uploaded, extend the state by timeout - KernelState::DmaPendingPlayback { id, timestamp } => KernelState::DmaPendingAwait { - id: id, - timestamp: timestamp, - max_time: max_time, - }, + KernelState::DmaPendingPlayback { id, timestamp } => { + KernelState::DmaPendingAwait { + id: id, + timestamp: timestamp, + max_time: max_time, + } + } _ => KernelState::DmaAwait { max_time: max_time }, }; } @@ -843,7 +900,10 @@ impl<'a> Manager<'_> { )); } _ => { - unexpected!("unexpected message from core1 while kernel was running: {:?}", reply); + unexpected!( + "unexpected message from core1 while kernel was running: {:?}", + reply + ); } } Ok(false) @@ -861,9 +921,9 @@ impl<'a> Manager<'_> { KernelState::MsgAwait { max_time, id, tags } => { if let Some(max_time) = *max_time { if timer.get_time() > max_time { - self.control - .tx - .send(kernel::Message::SubkernelError(kernel::SubkernelStatus::Timeout)); + self.control.tx.send(kernel::Message::SubkernelError( + kernel::SubkernelStatus::Timeout, + )); self.session.kernel_state = KernelState::Running; return Ok(()); } @@ -871,7 +931,9 @@ impl<'a> Manager<'_> { if let Some(message) = self.session.messages.get_incoming(*id) { self.control .tx - .send(kernel::Message::SubkernelMsgRecvReply { count: message.count }); + .send(kernel::Message::SubkernelMsgRecvReply { + count: message.count, + }); let tags = tags.clone(); self.session.kernel_state = KernelState::Running; self.pass_message_to_kernel(&message, tags, timer) @@ -893,9 +955,9 @@ impl<'a> Manager<'_> { KernelState::SubkernelAwaitFinish { max_time, id } => { if let Some(max_time) = *max_time { if timer.get_time() > max_time { - self.control - .tx - .send(kernel::Message::SubkernelError(kernel::SubkernelStatus::Timeout)); + self.control.tx.send(kernel::Message::SubkernelError( + kernel::SubkernelStatus::Timeout, + )); self.session.kernel_state = KernelState::Running; return Ok(()); } @@ -921,7 +983,12 @@ impl<'a> Manager<'_> { } } - fn pass_message_to_kernel(&mut self, message: &Message, tags: Vec, timer: &GlobalTimer) -> Result<(), Error> { + fn pass_message_to_kernel( + &mut self, + message: &Message, + tags: Vec, + timer: &GlobalTimer, + ) -> Result<(), Error> { let mut reader = Cursor::new(&message.data); let mut current_tags: &[u8] = &tags; let mut i = message.count; @@ -932,33 +999,54 @@ impl<'a> Manager<'_> { }; let mut exception: Option = None; let mut unexpected: Option = None; - let remaining_tags = rpc::recv_return(&mut reader, current_tags, slot, &mut |size| { - if size == 0 { - 0 as *mut () - } else { - self.control.tx.send(kernel::Message::RpcRecvReply(Ok(size))); - match recv_w_timeout(&mut self.control.rx, timer, 100) { - Ok(kernel::Message::RpcRecvRequest(slot)) => slot, - Ok(kernel::Message::KernelException(exceptions, stack_pointers, backtrace, async_errors)) => { - let buf: Vec = Vec::new(); - let mut writer = Cursor::new(buf); - match write_exception(&mut writer, exceptions, stack_pointers, backtrace, async_errors) { - Ok(()) => { - exception = Some(Sliceable::new(0, writer.into_inner())); - } - Err(_) => { - unexpected = Some("Error writing exception data".to_string()); - } - }; - 0 as *mut () - } - other => { - unexpected = Some(format!("expected nested value slot from kernel CPU, not {:?}", other)); - 0 as *mut () + let remaining_tags = + rpc::recv_return(&mut reader, current_tags, slot, &mut |size| -> Result< + _, + Error, + > { + if size == 0 { + Ok(0 as *mut ()) + } else { + self.control + .tx + .send(kernel::Message::RpcRecvReply(Ok(size))); + match recv_w_timeout(&mut self.control.rx, timer, 100) { + Ok(kernel::Message::RpcRecvRequest(slot)) => Ok(slot), + Ok(kernel::Message::KernelException( + exceptions, + stack_pointers, + backtrace, + async_errors, + )) => { + let buf: Vec = Vec::new(); + let mut writer = Cursor::new(buf); + match write_exception( + &mut writer, + exceptions, + stack_pointers, + backtrace, + async_errors, + ) { + Ok(()) => { + exception = Some(Sliceable::new(0, writer.into_inner())); + } + Err(_) => { + unexpected = + Some("Error writing exception data".to_string()); + } + }; + Ok(0 as *mut ()) + } + other => { + unexpected = Some(format!( + "expected nested value slot from kernel CPU, not {:?}", + other + )); + Ok(0 as *mut ()) + } } } - } - })?; + })?; if let Some(exception) = exception { self.kernel_stop(); return Err(Error::KernelException(exception)); @@ -1000,17 +1088,18 @@ where writer.write_u32(u32::MAX)?; writer.write_u32(exception.message.as_ptr() as u32)?; } else { - let msg = - str::from_utf8(unsafe { slice::from_raw_parts(exception.message.as_ptr(), exception.message.len()) }) - .unwrap() - .replace( - "{rtio_channel_info:0}", - &format!( - "0x{:04x}:{}", - exception.param[0], - ksupport::resolve_channel_name(exception.param[0] as u32) - ), - ); + let msg = str::from_utf8(unsafe { + slice::from_raw_parts(exception.message.as_ptr(), exception.message.len()) + }) + .unwrap() + .replace( + "{rtio_channel_info:0}", + &format!( + "0x{:04x}:{}", + exception.param[0], + ksupport::resolve_channel_name(exception.param[0] as u32) + ), + ); writer.write_string(&msg)?; } writer.write_u64(exception.param[0] as u64)?;