From 771c45da2d2afc4f83df033dd4bdf3f976d14a74 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 13 Oct 2023 20:24:27 +0900 Subject: [PATCH] interrupt/armv4t: Optimize disable-fiq --- src/imp/interrupt/armv4t.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/imp/interrupt/armv4t.rs b/src/imp/interrupt/armv4t.rs index 3f1f038f..20f7089c 100644 --- a/src/imp/interrupt/armv4t.rs +++ b/src/imp/interrupt/armv4t.rs @@ -3,21 +3,24 @@ // Refs: https://developer.arm.com/documentation/ddi0406/cb/System-Level-Architecture/The-System-Level-Programmers--Model/ARM-processor-modes-and-ARM-core-registers/Program-Status-Registers--PSRs-?lang=en // // Generated asm: -// - armv5te https://godbolt.org/z/Y48cEWvWc +// - armv5te https://godbolt.org/z/Teh7WajMs #[cfg(not(portable_atomic_no_asm))] use core::arch::asm; +// - 0x80 - I (IRQ mask) bit (1 << 7) +// - 0x40 - F (FIQ mask) bit (1 << 6) +// We disable only IRQs by default. See also https://github.com/taiki-e/portable-atomic/pull/28#issuecomment-1214146912. #[cfg(not(portable_atomic_disable_fiq))] -macro_rules! if_disable_fiq { - ($tt:tt) => { - "" +macro_rules! mask { + () => { + "0x80" }; } #[cfg(portable_atomic_disable_fiq)] -macro_rules! if_disable_fiq { - ($tt:tt) => { - $tt +macro_rules! mask { + () => { + "0xC0" // 0x80 | 0x40 }; } @@ -33,9 +36,7 @@ pub(super) fn disable() -> State { unsafe { asm!( "mrs {prev}, cpsr", - "orr {new}, {prev}, 0x80", // I (IRQ mask) bit (1 << 7) - // We disable only IRQs by default. See also https://github.com/taiki-e/portable-atomic/pull/28#issuecomment-1214146912. - if_disable_fiq!("orr {new}, {new}, 0x40"), // F (FIQ mask) bit (1 << 6) + concat!("orr {new}, {prev}, ", mask!()), "msr cpsr_c, {new}", prev = out(reg) cpsr, new = out(reg) _,