Skip to content

Commit

Permalink
Merge pull request tock#4193 from tock/update-nightly-oct-2024
Browse files Browse the repository at this point in the history
Update Rust Nightly to November 16 2024
  • Loading branch information
ppannuto authored Nov 21, 2024
2 parents 15c3240 + f8ca36c commit 50f36b3
Show file tree
Hide file tree
Showing 251 changed files with 921 additions and 772 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true,
"rust-analyzer.server.extraEnv": {
"RUSTUP_TOOLCHAIN": "nightly-2024-07-08"
"RUSTUP_TOOLCHAIN": "nightly-2024-11-16"
},
"rust-analyzer.check.allTargets": false,
}
7 changes: 3 additions & 4 deletions arch/cortex-m/src/mpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ pub struct CortexMRegion {

impl PartialEq<mpu::Region> for CortexMRegion {
fn eq(&self, other: &mpu::Region) -> bool {
self.location.map_or(false, |(addr, size)| {
addr == other.start_address() && size == other.size()
})
self.location
.is_some_and(|(addr, size)| addr == other.start_address() && size == other.size())
}
}

Expand Down Expand Up @@ -738,7 +737,7 @@ impl<const NUM_REGIONS: usize, const MIN_REGION_SIZE: usize> mpu::MPU

// Determine the number of subregions to enable.
// Want `round_up(app_memory_size / subregion_size)`.
let num_enabled_subregions = (app_memory_size + subregion_size - 1) / subregion_size;
let num_enabled_subregions = app_memory_size.div_ceil(subregion_size);

let subregions_enabled_end = region_start + subregion_size * num_enabled_subregions;

Expand Down
8 changes: 5 additions & 3 deletions arch/cortex-m/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ pub static mut SYSCALL_FIRED: usize = 0;
#[used]
pub static mut APP_HARD_FAULT: usize = 0;

/// This is used in the hardfault handler. When an app faults, the hardfault
/// handler stores the value of the SCB registers in this static array. This
/// makes them available to be displayed in a diagnostic fault message.
/// This is used in the hardfault handler.
///
/// When an app faults, the hardfault handler stores the value of the
/// SCB registers in this static array. This makes them available to
/// be displayed in a diagnostic fault message.
#[no_mangle]
#[used]
pub static mut SCB_REGISTERS: [u32; 5] = [0; 5];
Expand Down
8 changes: 5 additions & 3 deletions arch/rv32i/src/pmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,9 +1719,11 @@ pub mod kernel_protection_mml_epmp {
#[derive(Copy, Clone, Debug)]
pub struct KernelTextRegion(pub TORRegionSpec);

/// A RISC-V ePMP implementation which supports machine-mode (kernel) memory
/// protection by using the machine-mode lockdown mode (MML), with a fixed
/// number of "kernel regions" (such as `.text`, flash, RAM and MMIO).
/// A RISC-V ePMP implementation.
///
/// Supports machine-mode (kernel) memory protection by using the
/// machine-mode lockdown mode (MML), with a fixed number of
/// "kernel regions" (such as `.text`, flash, RAM and MMIO).
///
/// This implementation will configure the ePMP in the following way:
///
Expand Down
4 changes: 2 additions & 2 deletions boards/clue_nrf52840/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ impl IoWrite for Writer {
n.clear_pending();
n.enable();
}
if DUMMY.fired.get() {
if (*addr_of!(DUMMY)).fired.get() {
// buffer finished transmitting, return so we can output additional
// messages when requested by the panic handler.
break;
}
}
DUMMY.fired.set(false);
(*addr_of!(DUMMY)).fired.set(false);
});
}
buf.len()
Expand Down
4 changes: 2 additions & 2 deletions boards/clue_nrf52840/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ unsafe fn start() -> (
// DEVICEADDR register on the nRF52 to set the serial number.
let serial_number_buf = static_init!([u8; 17], [0; 17]);
let serial_number_string: &'static str =
nrf52::ficr::FICR_INSTANCE.address_str(serial_number_buf);
(*addr_of!(nrf52::ficr::FICR_INSTANCE)).address_str(serial_number_buf);
let strings = static_init!(
[&str; 3],
[
Expand Down Expand Up @@ -716,7 +716,7 @@ unsafe fn start() -> (
kernel::deferred_call::DeferredCallClient::register(aes_mux);
base_peripherals.ecb.set_client(aes_mux);

let device_id = nrf52840::ficr::FICR_INSTANCE.id();
let device_id = (*addr_of!(nrf52840::ficr::FICR_INSTANCE)).id();

let device_id_bottom_16 = u16::from_le_bytes([device_id[0], device_id[1]]);

Expand Down
22 changes: 12 additions & 10 deletions boards/components/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.

//! Components for Console and ConsoleOrdered. These are two
//! alternative implementations of the serial console system call
//! interface. Console allows prints of arbitrary length but does not
//! have ordering or atomicity guarantees. ConsoleOrdered, in
//! contrast, has limits on the maximum lengths of prints but provides
//! a temporal ordering and ensures a print is atomic at least up to
//! particular length (typically 200 bytes). Console is useful when
//! userspace is printing large messages. ConsoleOrdered is useful
//! when you are debugging and there are inter-related messages from
//! the kernel and userspace, whose ordering is important to maintain.
//! Components for Console and ConsoleOrdered.
//!
//! These are two alternative implementations of the serial console
//! system call interface. Console allows prints of arbitrary length
//! but does not have ordering or atomicity
//! guarantees. ConsoleOrdered, in contrast, has limits on the maximum
//! lengths of prints but provides a temporal ordering and ensures a
//! print is atomic at least up to particular length (typically 200
//! bytes). Console is useful when userspace is printing large
//! messages. ConsoleOrdered is useful when you are debugging and
//! there are inter-related messages from the kernel and userspace,
//! whose ordering is important to maintain.
//!
//!
//! This provides three Components, `ConsoleComponent` and
Expand Down
12 changes: 8 additions & 4 deletions boards/components/src/debug_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ pub const DEFAULT_DEBUG_BUFFER_KBYTE: usize = 2;
const DEBUG_BUFFER_SPLIT: usize = 64;

/// The optional argument to this macro allows boards to specify the size of the in-RAM
/// buffer used for storing debug messages. Increase this value to be able to send more debug
/// messages in quick succession.
/// buffer used for storing debug messages.
///
/// Increase this value to be able to send more debug messages in
/// quick succession.
#[macro_export]
macro_rules! debug_writer_component_static {
($BUF_SIZE_KB:expr) => {{
Expand All @@ -61,8 +63,10 @@ macro_rules! debug_writer_component_static {
}

/// The optional argument to this macro allows boards to specify the size of the in-RAM
/// buffer used for storing debug messages. Increase this value to be able to send more debug
/// messages in quick succession.
/// buffer used for storing debug messages.
///
/// Increase this value to be able to send more debug messages in
/// quick succession.
#[macro_export]
macro_rules! debug_writer_no_mux_component_static {
($BUF_SIZE_KB:expr) => {{
Expand Down
24 changes: 10 additions & 14 deletions boards/components/src/process_console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,16 @@ impl<const COMMAND_HISTORY_LEN: usize, A: 'static + Alarm<'static>> Component

// Get addresses of where the kernel is placed to enable additional
// debugging in process console.
// SAFETY: These statics are defined by the linker script, and we are merely creating
// pointers to them.
let kernel_addresses = unsafe {
process_console::KernelAddresses {
stack_start: core::ptr::addr_of!(_sstack),
stack_end: core::ptr::addr_of!(_estack),
text_start: core::ptr::addr_of!(_stext),
text_end: core::ptr::addr_of!(_etext),
read_only_data_start: core::ptr::addr_of!(_srodata),
relocations_start: core::ptr::addr_of!(_srelocate),
relocations_end: core::ptr::addr_of!(_erelocate),
bss_start: core::ptr::addr_of!(_szero),
bss_end: core::ptr::addr_of!(_ezero),
}
let kernel_addresses = process_console::KernelAddresses {
stack_start: core::ptr::addr_of!(_sstack),
stack_end: core::ptr::addr_of!(_estack),
text_start: core::ptr::addr_of!(_stext),
text_end: core::ptr::addr_of!(_etext),
read_only_data_start: core::ptr::addr_of!(_srodata),
relocations_start: core::ptr::addr_of!(_srelocate),
relocations_end: core::ptr::addr_of!(_erelocate),
bss_start: core::ptr::addr_of!(_szero),
bss_end: core::ptr::addr_of!(_ezero),
};

let console_alarm = static_buffer.0.write(VirtualMuxAlarm::new(self.alarm_mux));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct Platform {
alarm: &'static AlarmDriver,
scheduler: &'static RoundRobinSched<'static>,
systick: cortexm4::systick::SysTick,
processes: &'static [Option<&'static dyn kernel::process::Process>],
}

impl SyscallDriverLookup for Platform {
Expand Down Expand Up @@ -148,13 +149,11 @@ impl kernel::process::ProcessLoadingAsyncClient for Platform {
fn process_loading_finished(&self) {
kernel::debug!("Processes Loaded:");

unsafe {
for (i, proc) in PROCESSES.iter().enumerate() {
proc.map(|p| {
kernel::debug!("[{}] {}", i, p.get_process_name());
kernel::debug!(" ShortId: {}", p.short_app_id());
});
}
for (i, proc) in self.processes.iter().enumerate() {
proc.map(|p| {
kernel::debug!("[{}] {}", i, p.get_process_name());
kernel::debug!(" ShortId: {}", p.short_app_id());
});
}
}
}
Expand All @@ -177,13 +176,15 @@ pub unsafe fn main() {
nrf52840_peripherals.init();
let base_peripherals = &nrf52840_peripherals.nrf52;

let processes = &*addr_of!(PROCESSES);

// Choose the channel for serial output. This board can be configured to use
// either the Segger RTT channel or via UART with traditional TX/RX GPIO
// pins.
let uart_channel = UartChannel::Pins(UartPins::new(UART_RTS, UART_TXD, UART_CTS, UART_RXD));

// Setup space to store the core kernel data structure.
let board_kernel = static_init!(kernel::Kernel, kernel::Kernel::new(&*addr_of!(PROCESSES)));
let board_kernel = static_init!(kernel::Kernel, kernel::Kernel::new(processes));

// Create (and save for panic debugging) a chip object to setup low-level
// resources (e.g. MPU, systick).
Expand Down Expand Up @@ -342,7 +343,7 @@ pub unsafe fn main() {
// PLATFORM SETUP, SCHEDULER, AND START KERNEL LOOP
//--------------------------------------------------------------------------

let scheduler = components::sched::round_robin::RoundRobinComponent::new(&*addr_of!(PROCESSES))
let scheduler = components::sched::round_robin::RoundRobinComponent::new(processes)
.finalize(components::round_robin_component_static!(NUM_PROCS));

let platform = static_init!(
Expand All @@ -353,6 +354,7 @@ pub unsafe fn main() {
alarm,
scheduler,
systick: cortexm4::systick::SysTick::new_with_calibration(64000000),
processes,
}
);
loader.set_client(platform);
Expand Down
2 changes: 1 addition & 1 deletion boards/imix/src/power.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct Submodule<'a> {
detachable_pins: &'a [DetachablePin],
}

impl<'a> Submodule<'a> {
impl Submodule<'_> {
fn power(&self, state: bool) {
self.gate_pin.enable_output();
match state {
Expand Down
26 changes: 12 additions & 14 deletions boards/imix/src/test/ipv6_lowpan_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use capsules_extra::net::sixlowpan::sixlowpan_state::{
use capsules_extra::net::udp::UDPHeader;
use core::cell::Cell;
use core::ptr::addr_of_mut;
use core::sync::atomic::{AtomicUsize, Ordering};
use kernel::debug;
use kernel::hil::radio;
use kernel::hil::time::{self, Alarm, ConvertTicks};
Expand Down Expand Up @@ -110,7 +111,7 @@ enum DAC {

pub const TEST_DELAY_MS: u32 = 10000;
pub const TEST_LOOP: bool = false;
static mut SUCCESS_COUNT: usize = 0;
static SUCCESS_COUNT: AtomicUsize = AtomicUsize::new(0);
// Below was IP6_DGRAM before change to typed buffers
//static mut IP6_DGRAM: [u8; IP6_HDR_SIZE + PAYLOAD_LEN] = [0; IP6_HDR_SIZE + PAYLOAD_LEN];
static mut UDP_DGRAM: [u8; PAYLOAD_LEN - UDP_HDR_SIZE] = [0; PAYLOAD_LEN - UDP_HDR_SIZE]; //Becomes payload of UDP
Expand Down Expand Up @@ -396,21 +397,18 @@ impl<'a, A: time::Alarm<'a>> LowpanTest<'a, A> {
}
};
if success {
unsafe {
SUCCESS_COUNT += 1;
}
SUCCESS_COUNT.fetch_add(1, Ordering::SeqCst);
}
if test_id == self.num_tests() - 1 {
unsafe {
if SUCCESS_COUNT == self.num_tests() {
debug!("All Tests completed successfully!");
} else {
debug!(
"Successfully completed {:?}/{:?} tests",
SUCCESS_COUNT,
self.num_tests()
);
}
let success_count = SUCCESS_COUNT.load(Ordering::SeqCst);
if success_count == self.num_tests() {
debug!("All Tests completed successfully!");
} else {
debug!(
"Successfully completed {:?}/{:?} tests",
success_count,
self.num_tests()
);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions boards/imix/src/test/log_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,9 @@ impl<A: 'static + Alarm<'static>> LogTest<A> {

// Ensure failure if entry is too large to fit within a single flash page.
unsafe {
match self
.log
.append(&mut *addr_of_mut!(DUMMY_BUFFER), DUMMY_BUFFER.len())
{
let dummy_buffer = &mut *addr_of_mut!(DUMMY_BUFFER);
let len = dummy_buffer.len();
match self.log.append(dummy_buffer, len) {
Ok(()) => panic!("Appending with too-small buffer succeeded unexpectedly!"),
Err((ecode, _original_buffer)) => assert_eq!(ecode, ErrorCode::SIZE),
}
Expand Down
5 changes: 3 additions & 2 deletions boards/imix/src/test/spi_dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ pub unsafe fn spi_dummy_test(spi: &'static sam4l::spi::SpiHw<'static>) {
spi.init().unwrap();
spi.set_baud_rate(200000);

let len = BUF2.len();
let buf2 = &mut *addr_of_mut!(BUF2);
let len = buf2.len();
if spi.read_write_bytes(
(&mut *addr_of_mut!(BUF2) as &mut [u8]).into(),
(buf2 as &mut [u8]).into(),
Some((&mut *addr_of_mut!(BUF1) as &mut [u8]).into()),
) != Ok(())
{
Expand Down
15 changes: 9 additions & 6 deletions boards/imix/src/test/spi_loopback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ pub unsafe fn spi_loopback_test(
spi.set_rate(speed)
.expect("Failed to set SPI speed in SPI loopback test.");

let len = WBUF.len();
let wbuf = &mut *addr_of_mut!(WBUF);
let len = wbuf.len();
if let Err((e, _, _)) = spi.read_write_bytes(
(&mut *addr_of_mut!(WBUF) as &mut [u8]).into(),
(wbuf as &mut [u8]).into(),
Some((&mut *addr_of_mut!(RBUF) as &mut [u8]).into()),
) {
panic!(
Expand Down Expand Up @@ -127,9 +128,10 @@ pub unsafe fn spi_two_loopback_test(mux: &'static MuxSpiMaster<'static, sam4l::s
spi_fast.set_client(spicb_fast);
spi_slow.set_client(spicb_slow);

let len = WBUF.len();
let wbuf = &mut *addr_of_mut!(WBUF);
let len = wbuf.len();
if let Err((e, _, _)) = spi_fast.read_write_bytes(
(&mut *addr_of_mut!(WBUF) as &mut [u8]).into(),
(wbuf as &mut [u8]).into(),
Some((&mut *addr_of_mut!(RBUF) as &mut [u8]).into()),
) {
panic!(
Expand All @@ -138,9 +140,10 @@ pub unsafe fn spi_two_loopback_test(mux: &'static MuxSpiMaster<'static, sam4l::s
);
}

let len = WBUF2.len();
let wbuf = &mut *addr_of_mut!(WBUF);
let len = wbuf.len();
if let Err((e, _, _)) = spi_slow.read_write_bytes(
(&mut *addr_of_mut!(WBUF2) as &mut [u8]).into(),
(wbuf as &mut [u8]).into(),
Some((&mut *addr_of_mut!(RBUF2) as &mut [u8]).into()),
) {
panic!(
Expand Down
2 changes: 1 addition & 1 deletion boards/imxrt1050-evkb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ unsafe fn start() -> (

let lpuart_mux = components::console::UartMuxComponent::new(&peripherals.lpuart1, 115200)
.finalize(components::uart_mux_component_static!());
io::WRITER.set_initialized();
(*addr_of_mut!(io::WRITER)).set_initialized();

// Create capabilities that the board needs to call certain protected kernel
// functions.
Expand Down
4 changes: 2 additions & 2 deletions boards/makepython-nrf52840/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ impl IoWrite for Writer {
n.clear_pending();
n.enable();
}
if DUMMY.fired.get() {
if (*addr_of!(DUMMY)).fired.get() {
// buffer finished transmitting, return so we can output additional
// messages when requested by the panic handler.
break;
}
}
DUMMY.fired.set(false);
(*addr_of!(DUMMY)).fired.set(false);
});
}
buf.len()
Expand Down
Loading

0 comments on commit 50f36b3

Please sign in to comment.