Skip to content

Commit

Permalink
Merge #372
Browse files Browse the repository at this point in the history
372: asm/inline: explicitly use asm macro r=adamgreig a=jordens

`asm!()` removed from prelude in current nightly
rust-lang/rust#91728

close #371

This is also a good candidate for the cortex-m v0.7 series.

Co-authored-by: Robert Jördens <[email protected]>
  • Loading branch information
bors[bot] and jordens authored Dec 17, 2021
2 parents ae1d2a6 + 46a3320 commit eacad52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions asm/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! All of these functions should be blanket-`unsafe`. `cortex-m` provides safe wrappers where
//! applicable.
use core::arch::asm;
use core::sync::atomic::{compiler_fence, Ordering};

#[inline(always)]
Expand Down Expand Up @@ -214,6 +215,7 @@ pub unsafe fn __bootstrap(msp: u32, rv: u32) -> ! {
pub use self::v7m::*;
#[cfg(any(armv7m, armv8m_main))]
mod v7m {
use core::arch::asm;
use core::sync::atomic::{compiler_fence, Ordering};

#[inline(always)]
Expand Down Expand Up @@ -283,6 +285,8 @@ mod v7m {
pub use self::v7em::*;
#[cfg(armv7em)]
mod v7em {
use core::arch::asm;

#[inline(always)]
pub unsafe fn __basepri_max_cm7_r0p1(val: u8) {
asm!(
Expand Down Expand Up @@ -319,6 +323,8 @@ pub use self::v8m::*;
/// Baseline and Mainline.
#[cfg(armv8m)]
mod v8m {
use core::arch::asm;

#[inline(always)]
pub unsafe fn __tt(mut target: u32) -> u32 {
asm!("tt {target}, {target}", target = inout(reg) target);
Expand Down Expand Up @@ -366,6 +372,8 @@ pub use self::v8m_main::*;
/// Mainline only.
#[cfg(armv8m_main)]
mod v8m_main {
use core::arch::asm;

#[inline(always)]
pub unsafe fn __msplim_r() -> u32 {
let r;
Expand Down Expand Up @@ -396,6 +404,8 @@ pub use self::fpu::*;
/// All targets with FPU.
#[cfg(has_fpu)]
mod fpu {
use core::arch::asm;

#[inline(always)]
pub unsafe fn __fpscr_r() -> u32 {
let r;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
// - A generated #[derive(Debug)] function (in which case the attribute needs
// to be applied to the struct).
#![deny(clippy::missing_inline_in_public_items)]
// Don't warn about feature(asm) being stable on Rust >= 1.59.0
#![allow(stable_features)]

extern crate bare_metal;
extern crate volatile_register;
Expand Down

0 comments on commit eacad52

Please sign in to comment.