15
15
//!
16
16
//! For performance and (believe it or not) simplicity, this implementation uses
17
17
//! several different interrupt service routines:
18
- //!
18
+ //!
19
19
//! - `SVCall` implements the `SVC` instruction used to make syscalls.
20
20
//! - `SysTick` handles interrupts from the System Tick Timer, used to maintain
21
21
//! the kernel timestamp.
@@ -72,11 +72,11 @@ use core::ptr::NonNull;
72
72
73
73
use zerocopy:: FromBytes ;
74
74
75
- use abi:: { FaultSource , FaultInfo } ;
76
75
use crate :: app;
77
76
use crate :: task;
78
77
use crate :: time:: Timestamp ;
79
78
use crate :: umem:: USlice ;
79
+ use abi:: { FaultInfo , FaultSource } ;
80
80
81
81
/// Log things from kernel context. This macro is made visible to the rest of
82
82
/// the kernel by a chain of `#[macro_use]` attributes, but its implementation
@@ -96,8 +96,8 @@ use crate::umem::USlice;
96
96
///
97
97
#[ cfg( not( any( feature = "klog-semihosting" , feature = "klog-itm" ) ) ) ]
98
98
macro_rules! klog {
99
- ( $s: expr) => { } ;
100
- ( $s: expr, $( $tt: tt) * ) => { } ;
99
+ ( $s: expr) => { } ;
100
+ ( $s: expr, $( $tt: tt) * ) => { } ;
101
101
}
102
102
103
103
#[ cfg( feature = "klog-itm" ) ]
@@ -126,18 +126,18 @@ macro_rules! klog {
126
126
127
127
macro_rules! uassert {
128
128
( $cond : expr) => {
129
- if ! $cond {
129
+ if !$cond {
130
130
panic!( "Assertion failed!" ) ;
131
131
}
132
- }
132
+ } ;
133
133
}
134
134
135
135
macro_rules! uassert_eq {
136
136
( $cond1 : expr, $cond2 : expr) => {
137
- if ! ( $cond1 == $cond2) {
137
+ if !( $cond1 == $cond2) {
138
138
panic!( "Assertion failed!" ) ;
139
139
}
140
- }
140
+ } ;
141
141
}
142
142
143
143
/// 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) {
448
448
// Outer/inner non-cacheable, outer shared.
449
449
( 0b01000100 , 0b10 )
450
450
} 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
453
453
| u32:: from ( ratts. contains ( app:: RegionAttributes :: WRITE ) ) ;
454
454
// write-back transient, not shared
455
455
( 0b0100_0100 | rw | rw << 4 , 0b00 )
@@ -680,7 +680,9 @@ pub unsafe extern "C" fn SVCall() {
680
680
///
681
681
/// You can use this safely at kernel entry points, exactly once, to create a
682
682
/// 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 {
684
686
let tasks = core:: slice:: from_raw_parts_mut (
685
687
TASK_TABLE_BASE . expect ( "kernel not started" ) . as_mut ( ) ,
686
688
TASK_TABLE_SIZE ,
@@ -694,7 +696,7 @@ pub unsafe fn with_task_table<R>(body: impl FnOnce(&mut [task::Task]) -> R) -> R
694
696
///
695
697
/// Because the lifetime of the reference passed into `body` is anonymous, the
696
698
/// 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 {
698
700
// Safety: as long as a legit pointer was stored in IRQ_TABLE_BASE, or no
699
701
// pointer has been stored, we can do this safely.
700
702
let table = unsafe {
@@ -770,7 +772,8 @@ fn pend_context_switch_from_isr() {
770
772
#[ naked]
771
773
#[ no_mangle]
772
774
pub unsafe extern "C" fn PendSV ( ) {
773
- asm ! ( "
775
+ asm ! (
776
+ "
774
777
@ store volatile state.
775
778
@ first, get a pointer to the current task.
776
779
movw r0, #:lower16:CURRENT_TASK_PTR
@@ -847,7 +850,6 @@ pub unsafe extern "C" fn DefaultHandler() {
847
850
// 13 is currently reserved
848
851
// 14=PendSV is handled above by its own handler
849
852
// 15=SysTick is handled above by its own handler
850
-
851
853
x if x > 16 => {
852
854
// Hardware interrupt
853
855
let irq_num = exception_num - 16 ;
0 commit comments