Skip to content

Commit af4c24f

Browse files
bors[bot]bradjc
andauthored
Merge #2959
2959: Update Nightly to Feb 2022 r=hudson-ayers a=bradjc ### Pull Request Overview The headline here being: `asm!()` is stabilized! (As of rust-lang/rust#91728.) Most changes are to remove the asm feature and add `use core::arch:asm`. ### Testing Strategy travis ### TODO or Help Wanted Resolved: ~~Can someone look at https://github.com/tock/tock/compare/update-nightly-feb-2022?expand=1#diff-494cb9c3b94f58f1ab43cca69f63906088f87a97726d9260665f8529f605f2c9L259? I had to remove some clobbers to remove an error. I think that is ok (https://stackoverflow.com/questions/41380345/how-to-use-hir8-r12-register-in-cortex-m0) but I'm not sure.~~ ### Documentation Updated - [x] Updated the relevant files in `/docs`, or no updates are required. ### Formatting - [x] Ran `make prepush`. Co-authored-by: Brad Campbell <[email protected]>
2 parents aeb62a5 + dab6ffa commit af4c24f

File tree

32 files changed

+65
-22
lines changed

32 files changed

+65
-22
lines changed

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"editor.formatOnSave": true,
3-
"rust-client.channel": "nightly-2021-12-04",
3+
"rust-client.channel": "nightly-2022-02-23",
44
}

arch/cortex-m/src/lib.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![crate_name = "cortexm"]
44
#![crate_type = "rlib"]
5-
#![feature(asm, asm_sym)]
5+
#![feature(asm_sym)]
66
#![feature(naked_functions)]
77
#![no_std]
88

@@ -40,6 +40,7 @@ extern "C" {
4040
))]
4141
#[naked]
4242
pub unsafe extern "C" fn systick_handler_arm_v7m() {
43+
use core::arch::asm;
4344
asm!(
4445
"
4546
// Set thread mode to privileged to switch back to kernel mode.
@@ -70,6 +71,7 @@ pub unsafe extern "C" fn systick_handler_arm_v7m() {
7071
))]
7172
#[naked]
7273
pub unsafe extern "C" fn svc_handler_arm_v7m() {
74+
use core::arch::asm;
7375
asm!(
7476
"
7577
// First check to see which direction we are going in. If the link register
@@ -132,6 +134,7 @@ pub unsafe extern "C" fn svc_handler_arm_v7m() {
132134
))]
133135
#[naked]
134136
pub unsafe extern "C" fn generic_isr_arm_v7m() {
137+
use core::arch::asm;
135138
asm!(
136139
"
137140
// Set thread mode to privileged to ensure we are executing as the kernel.
@@ -209,6 +212,7 @@ pub unsafe extern "C" fn generic_isr_arm_v7m() {
209212

210213
#[cfg(all(target_arch = "arm", target_os = "none"))]
211214
pub unsafe extern "C" fn unhandled_interrupt() {
215+
use core::arch::asm;
212216
let mut interrupt_number: u32;
213217

214218
// IPSR[8:0] holds the currently active interrupt
@@ -232,6 +236,7 @@ pub unsafe extern "C" fn unhandled_interrupt() {
232236
#[cfg(all(target_arch = "arm", target_os = "none"))]
233237
#[naked]
234238
pub unsafe extern "C" fn initialize_ram_jump_to_main() {
239+
use core::arch::asm;
235240
asm!(
236241
"
237242
// Start by initializing .bss memory. The Tock linker script defines
@@ -298,6 +303,7 @@ pub unsafe extern "C" fn switch_to_user_arm_v7m(
298303
mut user_stack: *const usize,
299304
process_regs: &mut [usize; 8],
300305
) -> *const usize {
306+
use core::arch::asm;
301307
asm!(
302308
"
303309
// Rust `asm!()` macro (as of May 2021) will not let us mark r6, r7 and r9
@@ -514,6 +520,7 @@ unsafe extern "C" fn hard_fault_handler_arm_v7m_continued(
514520
kernel_stack: u32,
515521
stack_overflow: u32,
516522
) {
523+
use core::arch::asm;
517524
if kernel_stack != 0 {
518525
if stack_overflow != 0 {
519526
// Panic to show the correct error.
@@ -570,6 +577,7 @@ unsafe extern "C" fn hard_fault_handler_arm_v7m_continued(
570577
))]
571578
#[naked]
572579
pub unsafe extern "C" fn hard_fault_handler_arm_v7m() {
580+
use core::arch::asm;
573581
// First need to determine if this a kernel fault or a userspace fault, and store
574582
// the unmodified stack pointer. Place these values in registers, then call
575583
// a non-naked function, to allow for use of rust code alongside inline asm.

arch/cortex-m/src/scb.rs

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ pub unsafe fn set_vector_table_offset(offset: *const ()) {
298298
/// Disable the FPU
299299
#[cfg(all(target_arch = "arm", target_os = "none"))]
300300
pub unsafe fn disable_fpca() {
301+
use core::arch::asm;
301302
SCB.cpacr
302303
.modify(CoprocessorAccessControl::CP10::CLEAR + CoprocessorAccessControl::CP11::CLEAR);
303304

arch/cortex-m/src/support.rs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use core::ops::FnOnce;
44
#[inline(always)]
55
/// NOP instruction
66
pub fn nop() {
7+
use core::arch::asm;
78
unsafe {
89
asm!("nop", options(nomem, nostack, preserves_flags));
910
}
@@ -13,6 +14,7 @@ pub fn nop() {
1314
#[inline(always)]
1415
/// WFI instruction
1516
pub unsafe fn wfi() {
17+
use core::arch::asm;
1618
asm!("wfi", options(nomem, preserves_flags));
1719
}
1820

@@ -21,6 +23,7 @@ pub unsafe fn atomic<F, R>(f: F) -> R
2123
where
2224
F: FnOnce() -> R,
2325
{
26+
use core::arch::asm;
2427
// Set PRIMASK
2528
asm!("cpsid i", options(nomem, nostack));
2629

arch/cortex-m0/src/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![crate_name = "cortexm0"]
44
#![crate_type = "rlib"]
5-
#![feature(asm, asm_sym, naked_functions)]
5+
#![feature(asm_sym, naked_functions)]
66
#![no_std]
77

88
// Re-export the base generic cortex-m functions here as they are
@@ -35,6 +35,7 @@ pub unsafe extern "C" fn generic_isr() {
3535
#[naked]
3636
/// All ISRs are caught by this handler which disables the NVIC and switches to the kernel.
3737
pub unsafe extern "C" fn generic_isr() {
38+
use core::arch::asm;
3839
asm!(
3940
"
4041
/* Skip saving process state if not coming from user-space */
@@ -130,6 +131,7 @@ pub unsafe extern "C" fn systick_handler() {
130131
#[cfg(all(target_arch = "arm", target_os = "none"))]
131132
#[naked]
132133
pub unsafe extern "C" fn systick_handler() {
134+
use core::arch::asm;
133135
asm!(
134136
"
135137
// Set thread mode to privileged to switch back to kernel mode.
@@ -161,6 +163,7 @@ pub unsafe extern "C" fn svc_handler() {
161163
#[cfg(all(target_arch = "arm", target_os = "none"))]
162164
#[naked]
163165
pub unsafe extern "C" fn svc_handler() {
166+
use core::arch::asm;
164167
asm!(
165168
"
166169
ldr r0, 200f // EXC_RETURN_MSP
@@ -201,6 +204,7 @@ pub unsafe extern "C" fn switch_to_user(
201204
mut user_stack: *const u8,
202205
process_regs: &mut [usize; 8],
203206
) -> *mut u8 {
207+
use core::arch::asm;
204208
asm!("
205209
// Rust `asm!()` macro (as of May 2021) will not let us mark r6, r7 and r9
206210
// as clobbers. r6 and r9 is used internally by LLVM, and r7 is used for
@@ -323,6 +327,7 @@ pub unsafe extern "C" fn hard_fault_handler() {
323327
/// can mix `asm!()` and Rust. We separate this logic to not have to write the
324328
/// entire fault handler entirely in assembly.
325329
unsafe extern "C" fn hard_fault_handler_continued(faulting_stack: *mut u32, kernel_stack: u32) {
330+
use core::arch::asm;
326331
if kernel_stack != 0 {
327332
kernel_hardfault(faulting_stack);
328333
} else {
@@ -385,6 +390,7 @@ unsafe extern "C" fn hard_fault_handler_continued(faulting_stack: *mut u32, kern
385390
#[cfg(all(target_arch = "arm", target_os = "none"))]
386391
#[naked]
387392
pub unsafe extern "C" fn hard_fault_handler() {
393+
use core::arch::asm;
388394
// If `kernel_stack` is non-zero, then hard-fault occurred in
389395
// kernel, otherwise the hard-fault occurred in user.
390396
asm!("

arch/cortex-m0p/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
#![crate_name = "cortexm0p"]
44
#![crate_type = "rlib"]
5-
#![feature(asm)]
65
#![feature(naked_functions)]
76
#![no_std]
87

@@ -44,6 +43,7 @@ pub unsafe extern "C" fn svc_handler() {
4443
#[cfg(all(target_arch = "arm", target_os = "none"))]
4544
#[naked]
4645
pub unsafe extern "C" fn svc_handler() {
46+
use core::arch::asm;
4747
asm!(
4848
"
4949
ldr r0, 100f // EXC_RETURN_MSP

arch/rv32i/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![crate_name = "rv32i"]
44
#![crate_type = "rlib"]
5-
#![feature(asm, asm_sym, const_fn_trait_bound, naked_functions)]
5+
#![feature(asm_sym, const_fn_trait_bound, naked_functions)]
66
#![no_std]
77

88
use core::fmt::Write;
@@ -55,6 +55,7 @@ extern "C" {
5555
#[export_name = "_start"]
5656
#[naked]
5757
pub extern "C" fn _start() {
58+
use core::arch::asm;
5859
unsafe {
5960
asm! ("
6061
// Set the global pointer register using the variable defined in the
@@ -191,6 +192,7 @@ pub extern "C" fn _start_trap() {
191192
#[export_name = "_start_trap"]
192193
#[naked]
193194
pub extern "C" fn _start_trap() {
195+
use core::arch::asm;
194196
unsafe {
195197
asm!(
196198
"
@@ -438,6 +440,7 @@ pub extern "C" fn _start_trap() {
438440
/// https://groups.google.com/a/groups.riscv.org/g/isa-dev/c/XKkYacERM04/m/CdpOcqtRAgAJ
439441
#[cfg(all(target_arch = "riscv32", target_os = "none"))]
440442
pub unsafe fn semihost_command(command: usize, arg0: usize, arg1: usize) -> usize {
443+
use core::arch::asm;
441444
let res;
442445
asm!(
443446
"

arch/rv32i/src/support.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use core::ops::FnOnce;
77
#[inline(always)]
88
/// NOP instruction
99
pub fn nop() {
10+
use core::arch::asm;
1011
unsafe {
1112
asm!("nop", options(nomem, nostack, preserves_flags));
1213
}
@@ -16,6 +17,7 @@ pub fn nop() {
1617
#[inline(always)]
1718
/// WFI instruction
1819
pub unsafe fn wfi() {
20+
use core::arch::asm;
1921
asm!("wfi", options(nomem, nostack));
2022
}
2123

arch/rv32i/src/syscall.rs

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ impl kernel::syscall::UserspaceKernelBoundary for SysCall {
230230
_app_brk: *const u8,
231231
state: &mut Riscv32iStoredState,
232232
) -> (ContextSwitchReason, Option<*const u8>) {
233+
use core::arch::asm;
233234
// We need to ensure that the compiler does not reorder
234235
// kernel memory writes to after the userspace context switch
235236
// to ensure we provide a consistent memory view of

boards/nano_rp2040_connect/src/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
// https://github.com/rust-lang/rust/issues/62184.
88
#![cfg_attr(not(doc), no_main)]
99
#![deny(missing_docs)]
10-
#![feature(asm, naked_functions)]
10+
#![feature(naked_functions)]
11+
12+
use core::arch::asm;
1113

1214
use capsules::virtual_alarm::VirtualMuxAlarm;
1315
use components::gpio::GpioComponent;

boards/pico_explorer_base/src/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
// https://github.com/rust-lang/rust/issues/62184.
88
#![cfg_attr(not(doc), no_main)]
99
#![deny(missing_docs)]
10-
#![feature(asm, naked_functions)]
10+
#![feature(naked_functions)]
11+
12+
use core::arch::asm;
1113

1214
use kernel::dynamic_deferred_call::{DynamicDeferredCall, DynamicDeferredCallClientState};
1315

boards/raspberry_pi_pico/src/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
// https://github.com/rust-lang/rust/issues/62184.
88
#![cfg_attr(not(doc), no_main)]
99
#![deny(missing_docs)]
10-
#![feature(asm, naked_functions)]
10+
#![feature(naked_functions)]
11+
12+
use core::arch::asm;
1113

1214
use capsules::i2c_master::I2CMasterDriver;
1315
use capsules::virtual_alarm::VirtualMuxAlarm;

chips/apollo3/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![crate_name = "apollo3"]
44
#![crate_type = "rlib"]
5-
#![feature(asm, const_fn_trait_bound)]
5+
#![feature(const_fn_trait_bound)]
66
#![no_std]
77

88
// Peripherals
@@ -76,6 +76,7 @@ pub static PATCH: [unsafe extern "C" fn(); 16] = [unhandled_interrupt; 16];
7676

7777
#[cfg(all(target_arch = "arm", target_os = "none"))]
7878
pub unsafe fn init() {
79+
use core::arch::asm;
7980
let cache_ctrl = crate::cachectrl::CacheCtrl::new();
8081
cache_ctrl.enable_cache();
8182

chips/arty_e21_chip/src/chip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ impl<'a, I: InterruptService<()> + 'a> ArtyExx<'a, I> {
109109
/// valid for platforms with a CLIC.
110110
#[cfg(all(target_arch = "riscv32", target_os = "none"))]
111111
pub unsafe fn configure_trap_handler(&self) {
112+
use core::arch::asm;
112113
asm!(
113114
"
114115
// The csrw instruction writes a Control and Status Register (CSR)

chips/arty_e21_chip/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Drivers and chip support for the E21 soft core.
22
3-
#![feature(asm)]
43
#![no_std]
54
#![crate_name = "arty_e21_chip"]
65
#![crate_type = "rlib"]

chips/earlgrey/src/chip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ pub extern "C" fn _start_trap_vectored() {
401401
#[export_name = "_start_trap_vectored"]
402402
#[naked]
403403
pub extern "C" fn _start_trap_vectored() -> ! {
404+
use core::arch::asm;
404405
unsafe {
405406
// According to the Ibex user manual:
406407
// [NMI] has interrupt ID 31, i.e., it has the highest priority of all

chips/earlgrey/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Drivers and chip support for EarlGrey.
22
3-
#![feature(asm, const_fn_trait_bound, naked_functions)]
3+
#![feature(const_fn_trait_bound, naked_functions)]
44
#![no_std]
55
#![crate_name = "earlgrey"]
66
#![crate_type = "rlib"]

chips/esp32-c3/src/chip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ pub extern "C" fn _start_trap_vectored() {
299299
#[export_name = "_start_trap_vectored"]
300300
#[naked]
301301
pub extern "C" fn _start_trap_vectored() -> ! {
302+
use core::arch::asm;
302303
unsafe {
303304
// Below are 32 (non-compressed) jumps to cover the entire possible
304305
// range of vectored traps.

chips/esp32-c3/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Drivers and chip support for ESP32-C3.
22
3-
#![feature(const_fn_trait_bound, naked_functions, asm)]
3+
#![feature(const_fn_trait_bound, naked_functions)]
44
#![no_std]
55
#![crate_name = "esp32_c3"]
66
#![crate_type = "rlib"]

chips/litex_vexriscv/src/interrupt_controller.rs

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ mod vexriscv_irq_raw {
107107
#[cfg(all(target_arch = "riscv32", target_os = "none"))]
108108
pub unsafe fn irq_getmask() -> usize {
109109
let mask: usize;
110+
use core::arch::asm;
110111
asm!("csrr {mask}, {csr}", mask = out(reg) mask, csr = const CSR_IRQ_MASK);
111112
mask
112113
}
@@ -116,6 +117,7 @@ mod vexriscv_irq_raw {
116117

117118
#[cfg(all(target_arch = "riscv32", target_os = "none"))]
118119
pub unsafe fn irq_setmask(mask: usize) {
120+
use core::arch::asm;
119121
asm!("csrw {csr}, {mask}", csr = const CSR_IRQ_MASK, mask = in(reg) mask);
120122
}
121123

@@ -127,6 +129,7 @@ mod vexriscv_irq_raw {
127129
#[cfg(all(target_arch = "riscv32", target_os = "none"))]
128130
pub unsafe fn irq_pending() -> usize {
129131
let pending: usize;
132+
use core::arch::asm;
130133
asm!("csrr {pending}, {csr}", pending = out(reg) pending, csr = const CSR_IRQ_PENDING);
131134
pending
132135
}

chips/litex_vexriscv/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! LiteX SoCs based around a VexRiscv CPU
22
3-
#![feature(asm, asm_const, const_fn_trait_bound)]
3+
#![feature(asm_const, const_fn_trait_bound)]
44
#![no_std]
55
#![crate_name = "litex_vexriscv"]
66
#![crate_type = "rlib"]

chips/msp432/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![crate_name = "msp432"]
22
#![crate_type = "rlib"]
3-
#![feature(asm, const_fn_trait_bound)]
3+
#![feature(const_fn_trait_bound)]
44
#![no_std]
55

66
use cortexm4::{

chips/rp2040/src/clocks.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ impl Clocks {
10441044
let _delay_cyc: u32 = self.get_frequency(Clock::System) / self.get_frequency(clock) + 1;
10451045
#[cfg(target_arch = "arm")]
10461046
unsafe {
1047+
use core::arch::asm;
10471048
asm! (
10481049
"1:",
10491050
"subs {0}, #1",

chips/rp2040/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(const_fn_trait_bound, asm)]
1+
#![feature(const_fn_trait_bound)]
22
#![no_std]
33

44
pub mod adc;

0 commit comments

Comments
 (0)