Skip to content

Commit 61eb4ce

Browse files
committed
Format kern's cfg-if'd modules
The conditionally-included modules are not being automatically formatted due to: rust-lang/rustfmt#4656
1 parent 02c5538 commit 61eb4ce

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

kern/src/arch/arm_m.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//!
1616
//! For performance and (believe it or not) simplicity, this implementation uses
1717
//! several different interrupt service routines:
18-
//!
18+
//!
1919
//! - `SVCall` implements the `SVC` instruction used to make syscalls.
2020
//! - `SysTick` handles interrupts from the System Tick Timer, used to maintain
2121
//! the kernel timestamp.
@@ -72,11 +72,11 @@ use core::ptr::NonNull;
7272

7373
use zerocopy::FromBytes;
7474

75-
use abi::{FaultSource, FaultInfo};
7675
use crate::app;
7776
use crate::task;
7877
use crate::time::Timestamp;
7978
use crate::umem::USlice;
79+
use abi::{FaultInfo, FaultSource};
8080

8181
/// Log things from kernel context. This macro is made visible to the rest of
8282
/// the kernel by a chain of `#[macro_use]` attributes, but its implementation
@@ -96,8 +96,8 @@ use crate::umem::USlice;
9696
///
9797
#[cfg(not(any(feature = "klog-semihosting", feature = "klog-itm")))]
9898
macro_rules! klog {
99-
($s:expr) => { };
100-
($s:expr, $($tt:tt)*) => { };
99+
($s:expr) => {};
100+
($s:expr, $($tt:tt)*) => {};
101101
}
102102

103103
#[cfg(feature = "klog-itm")]
@@ -126,18 +126,18 @@ macro_rules! klog {
126126

127127
macro_rules! uassert {
128128
($cond : expr) => {
129-
if ! $cond {
129+
if !$cond {
130130
panic!("Assertion failed!");
131131
}
132-
}
132+
};
133133
}
134134

135135
macro_rules! uassert_eq {
136136
($cond1 : expr, $cond2 : expr) => {
137-
if ! ($cond1 == $cond2) {
137+
if !($cond1 == $cond2) {
138138
panic!("Assertion failed!");
139139
}
140-
}
140+
};
141141
}
142142

143143
/// On ARMvx-M we use a global to record the task table position and extent.
@@ -448,8 +448,8 @@ pub fn apply_memory_protection(task: &task::Task) {
448448
// Outer/inner non-cacheable, outer shared.
449449
(0b01000100, 0b10)
450450
} else {
451-
let rw =
452-
u32::from(ratts.contains(app::RegionAttributes::READ)) << 1
451+
let rw = u32::from(ratts.contains(app::RegionAttributes::READ))
452+
<< 1
453453
| u32::from(ratts.contains(app::RegionAttributes::WRITE));
454454
// write-back transient, not shared
455455
(0b0100_0100 | rw | rw << 4, 0b00)
@@ -680,7 +680,9 @@ pub unsafe extern "C" fn SVCall() {
680680
///
681681
/// You can use this safely at kernel entry points, exactly once, to create a
682682
/// reference to the task table.
683-
pub unsafe fn with_task_table<R>(body: impl FnOnce(&mut [task::Task]) -> R) -> R{
683+
pub unsafe fn with_task_table<R>(
684+
body: impl FnOnce(&mut [task::Task]) -> R,
685+
) -> R {
684686
let tasks = core::slice::from_raw_parts_mut(
685687
TASK_TABLE_BASE.expect("kernel not started").as_mut(),
686688
TASK_TABLE_SIZE,
@@ -694,7 +696,7 @@ pub unsafe fn with_task_table<R>(body: impl FnOnce(&mut [task::Task]) -> R) -> R
694696
///
695697
/// Because the lifetime of the reference passed into `body` is anonymous, the
696698
/// reference can't easily be stored, which is deliberate.
697-
pub fn with_irq_table<R>(body: impl FnOnce(&[abi::Interrupt]) -> R) -> R{
699+
pub fn with_irq_table<R>(body: impl FnOnce(&[abi::Interrupt]) -> R) -> R {
698700
// Safety: as long as a legit pointer was stored in IRQ_TABLE_BASE, or no
699701
// pointer has been stored, we can do this safely.
700702
let table = unsafe {
@@ -770,7 +772,8 @@ fn pend_context_switch_from_isr() {
770772
#[naked]
771773
#[no_mangle]
772774
pub unsafe extern "C" fn PendSV() {
773-
asm!("
775+
asm!(
776+
"
774777
@ store volatile state.
775778
@ first, get a pointer to the current task.
776779
movw r0, #:lower16:CURRENT_TASK_PTR
@@ -847,7 +850,6 @@ pub unsafe extern "C" fn DefaultHandler() {
847850
// 13 is currently reserved
848851
// 14=PendSV is handled above by its own handler
849852
// 15=SysTick is handled above by its own handler
850-
851853
x if x > 16 => {
852854
// Hardware interrupt
853855
let irq_num = exception_num - 16;

0 commit comments

Comments
 (0)