Skip to content
This repository was archived by the owner on Jan 23, 2021. It is now read-only.

Commit 598b3e9

Browse files
style: update tree with new rustfmt
This commit contains only auto-generated changes from the most recent rustfmt.
1 parent 047af5d commit 598b3e9

File tree

14 files changed

+411
-335
lines changed

14 files changed

+411
-335
lines changed

arch/cortex-m3/src/lib.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(asm,const_fn,naked_functions)]
1+
#![feature(asm, const_fn, naked_functions)]
22
#![no_std]
33

44
extern crate kernel;
@@ -8,7 +8,8 @@ pub mod systick;
88
#[no_mangle]
99
#[naked]
1010
pub unsafe extern "C" fn systick_handler() {
11-
asm!("
11+
asm!(
12+
"
1213
/* Skip saving process state if not coming from user-space */
1314
cmp lr, #0xfffffffd
1415
bne _systick_handler_no_stacking
@@ -30,15 +31,17 @@ pub unsafe extern "C" fn systick_handler() {
3031
3132
movw LR, #0xFFF9
3233
movt LR, #0xFFFF
33-
");
34+
"
35+
);
3436
}
3537

3638
#[no_mangle]
3739
#[naked]
3840
/// All ISRs are caught by this handler which indirects to a custom handler by
3941
/// indexing into `INTERRUPT_TABLE` based on the ISR number.
4042
pub unsafe extern "C" fn generic_isr() {
41-
asm!("
43+
asm!(
44+
"
4245
/* Skip saving process state if not coming from user-space */
4346
cmp lr, #0xfffffffd
4447
bne _ggeneric_isr_no_stacking
@@ -72,14 +75,16 @@ _ggeneric_isr_no_stacking:
7275
msr CONTROL, r0
7376
7477
movw LR, #0xFFF9
75-
movt LR, #0xFFFF");
78+
movt LR, #0xFFFF"
79+
);
7680
}
7781

7882
#[no_mangle]
7983
#[naked]
8084
#[allow(non_snake_case)]
8185
pub unsafe extern "C" fn SVC_Handler() {
82-
asm!("
86+
asm!(
87+
"
8388
ldr r0, EXC_RETURN_MSP
8489
cmp lr, r0
8590
bne to_kernel
@@ -97,13 +102,15 @@ EXC_RETURN_MSP:
97102
.word 0xFFFFFFF9
98103
EXC_RETURN_PSP:
99104
.word 0xFFFFFFFD
100-
");
105+
"
106+
);
101107
}
102108

103109
#[no_mangle]
104-
pub unsafe extern "C" fn switch_to_user(mut user_stack: *const u8,
105-
process_regs: &mut [usize; 8])
106-
-> *mut u8 {
110+
pub unsafe extern "C" fn switch_to_user(
111+
mut user_stack: *const u8,
112+
process_regs: &mut [usize; 8],
113+
) -> *mut u8 {
107114
asm!("
108115
/* Load non-hardware-stacked registers from Process stack */
109116
ldmia $2!, {r4-r7}

boards/nucleo_f103/src/io.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ impl Write for Writer {
3636
}
3737
}
3838

39-
4039
#[cfg(not(test))]
4140
#[no_mangle]
42-
#[lang="panic_fmt"]
41+
#[lang = "panic_fmt"]
4342
pub unsafe extern "C" fn panic_fmt(args: Arguments, file: &'static str, line: u32) -> ! {
4443
// XXX Replace with something like kernel::begin_panic()
4544
// XXX Maybe place that call at panic_fmt, as it's called first
@@ -54,24 +53,34 @@ pub unsafe extern "C" fn panic_fmt(args: Arguments, file: &'static str, line: u3
5453
asm!("nop");
5554

5655
let writer = &mut WRITER;
57-
let _ = writer.write_fmt(format_args!("\r\n\nKernel panic at {}:{}:\r\n\t\"", file, line));
56+
let _ = writer.write_fmt(format_args!(
57+
"\r\n\nKernel panic at {}:{}:\r\n\t\"",
58+
file, line
59+
));
5860
let _ = write(writer, args);
5961
let _ = writer.write_str("\"\r\n");
6062

6163
// Print version of the kernel
62-
let _ = writer.write_fmt(format_args!("\tKernel version {}\r\n", env!("TOCK_KERNEL_VERSION")));
64+
let _ = writer.write_fmt(format_args!(
65+
"\tKernel version {}\r\n",
66+
env!("TOCK_KERNEL_VERSION")
67+
));
6368

6469
// Print fault status once
6570
let procs = &mut process::PROCS;
6671
if procs.len() > 0 {
67-
procs[0].as_mut().map(|process| { process.fault_str(writer); });
72+
procs[0].as_mut().map(|process| {
73+
process.fault_str(writer);
74+
});
6875
}
6976

7077
// print data about each process
7178
let _ = writer.write_fmt(format_args!("\r\n---| App Status |---\r\n"));
7279
let procs = &mut process::PROCS;
7380
for idx in 0..procs.len() {
74-
procs[idx].as_mut().map(|process| { process.statistics_str(writer); });
81+
procs[idx].as_mut().map(|process| {
82+
process.statistics_str(writer);
83+
});
7584
}
7685

7786
// blink the panic signal
@@ -93,7 +102,6 @@ pub unsafe extern "C" fn panic_fmt(args: Arguments, file: &'static str, line: u3
93102
}
94103
}
95104

96-
97105
#[macro_export]
98106
macro_rules! print {
99107
($($arg:tt)*) => (

boards/nucleo_f103/src/main.rs

Lines changed: 75 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#![no_std]
22
#![no_main]
3-
#![feature(asm,const_fn,lang_items,compiler_builtins_lib)]
3+
#![feature(asm, const_fn, lang_items, compiler_builtins_lib)]
44

5-
extern crate cortexm3;
65
extern crate capsules;
76
extern crate compiler_builtins;
7+
extern crate cortexm3;
88
#[allow(unused_imports)]
9-
#[macro_use(debug,static_init)]
9+
#[macro_use(debug, static_init)]
1010
extern crate kernel;
1111
extern crate stm32;
1212
extern crate stm32f1;
@@ -32,27 +32,26 @@ static mut APP_MEMORY: [u8; 10240] = [0; 10240];
3232
// Actual memory for holding the active process structures.
3333
static mut PROCESSES: [Option<kernel::Process<'static>>; NUM_PROCS] = [None, None, None, None];
3434

35-
3635
/// A structure representing this platform that holds references to all
3736
/// capsules for this platform.
3837
struct NucleoF103 {
3938
console: &'static capsules::console::Console<'static, stm32::usart::USART>,
40-
alarm: &'static capsules::alarm::AlarmDriver<'static,
41-
VirtualMuxAlarm<'static,
42-
stm32::timer::AlarmTimer>>,
39+
alarm: &'static capsules::alarm::AlarmDriver<
40+
'static,
41+
VirtualMuxAlarm<'static, stm32::timer::AlarmTimer>,
42+
>,
4343
button: &'static capsules::button::Button<'static, stm32::gpio::GPIOPin>,
4444
gpio: &'static capsules::gpio::GPIO<'static, stm32::gpio::GPIOPin>,
4545
led: &'static capsules::led::LED<'static, stm32::gpio::GPIOPin>,
4646
ipc: kernel::ipc::IPC,
4747
}
4848

49-
5049
/// Mapping of integer syscalls to objects that implement syscalls.
5150
impl Platform for NucleoF103 {
5251
fn with_driver<F, R>(&self, driver_num: usize, f: F) -> R
53-
where F: FnOnce(Option<&kernel::Driver>) -> R
52+
where
53+
F: FnOnce(Option<&kernel::Driver>) -> R,
5454
{
55-
5655
match driver_num {
5756
capsules::console::DRIVER_NUM => f(Some(self.console)),
5857
capsules::alarm::DRIVER_NUM => f(Some(self.alarm)),
@@ -81,75 +80,98 @@ pub unsafe fn reset_handler() {
8180

8281
let console = static_init!(
8382
capsules::console::Console<stm32::usart::USART>,
84-
capsules::console::Console::new(&stm32::usart::USART2,
85-
115200,
86-
&mut capsules::console::WRITE_BUF,
87-
kernel::Grant::create()));
83+
capsules::console::Console::new(
84+
&stm32::usart::USART2,
85+
115200,
86+
&mut capsules::console::WRITE_BUF,
87+
kernel::Grant::create()
88+
)
89+
);
8890
hil::uart::UART::set_client(&stm32::usart::USART2, console);
8991
stm32::usart::USART2.specify_pins(&stm32::gpio::PA[3], &stm32::gpio::PA[2]);
9092

9193
// Alarm
9294
let alarm_timer = &stm32::timer::TIMER2;
9395
let mux_alarm = static_init!(
9496
MuxAlarm<'static, stm32::timer::AlarmTimer>,
95-
MuxAlarm::new(alarm_timer));
97+
MuxAlarm::new(alarm_timer)
98+
);
9699
alarm_timer.configure(mux_alarm);
97100
let virtual_alarm1 = static_init!(
98101
VirtualMuxAlarm<'static, stm32::timer::AlarmTimer>,
99-
VirtualMuxAlarm::new(mux_alarm));
102+
VirtualMuxAlarm::new(mux_alarm)
103+
);
100104
let alarm = static_init!(
101105
capsules::alarm::AlarmDriver<'static, VirtualMuxAlarm<'static, stm32::timer::AlarmTimer>>,
102-
capsules::alarm::AlarmDriver::new(virtual_alarm1, kernel::Grant::create()));
106+
capsules::alarm::AlarmDriver::new(virtual_alarm1, kernel::Grant::create())
107+
);
103108
virtual_alarm1.set_client(alarm);
104109

105110
// LEDs
106111
let led_pins = static_init!(
107112
[(&'static stm32::gpio::GPIOPin, capsules::led::ActivationMode); 1],
108-
[(&stm32::gpio::PA[5], capsules::led::ActivationMode::ActiveHigh)]);
113+
[
114+
(
115+
&stm32::gpio::PA[5],
116+
capsules::led::ActivationMode::ActiveHigh
117+
)
118+
]
119+
);
109120
let led = static_init!(
110121
capsules::led::LED<'static, stm32::gpio::GPIOPin>,
111-
capsules::led::LED::new(led_pins));
122+
capsules::led::LED::new(led_pins)
123+
);
112124

113125
// Buttons
114126
let button_pins = static_init!(
115127
[(&'static stm32::gpio::GPIOPin, capsules::button::GpioMode); 1],
116-
[(&stm32::gpio::PC[13], capsules::button::GpioMode::LowWhenPressed)]);
128+
[
129+
(
130+
&stm32::gpio::PC[13],
131+
capsules::button::GpioMode::LowWhenPressed
132+
)
133+
]
134+
);
117135
let button = static_init!(
118136
capsules::button::Button<'static, stm32::gpio::GPIOPin>,
119-
capsules::button::Button::new(button_pins, kernel::Grant::create()));
137+
capsules::button::Button::new(button_pins, kernel::Grant::create())
138+
);
120139
for &(btn, _) in button_pins.iter() {
121140
btn.set_client(button);
122141
}
123142

124143
// set GPIO driver controlling remaining GPIO pins
125144
let gpio_pins = static_init!(
126-
[&'static stm32::gpio::GPIOPin; 19],[
127-
// &stm32::gpio::PA[3], // D0 (RX)
128-
// &stm32::gpio::PA[2], // D1 (TX)
129-
&stm32::gpio::PA[10], // D2
130-
&stm32::gpio::PB[3], // D3
131-
&stm32::gpio::PB[5], // D4
132-
&stm32::gpio::PB[4], // D5
133-
&stm32::gpio::PB[10], // D6
134-
&stm32::gpio::PA[8], // D7
135-
&stm32::gpio::PA[9], // D8
136-
&stm32::gpio::PC[7], // D9
137-
&stm32::gpio::PB[6], // D10
138-
&stm32::gpio::PA[7], // D11
139-
&stm32::gpio::PA[6], // D12
140-
// &stm32::gpio::PA[5], // D13 (LED)
141-
&stm32::gpio::PB[9], // D14
142-
&stm32::gpio::PB[8], // D15
143-
&stm32::gpio::PA[0], // A0
144-
&stm32::gpio::PA[1], // A1
145-
&stm32::gpio::PA[4], // A2
146-
&stm32::gpio::PB[0], // A3
147-
&stm32::gpio::PC[1], // A4
148-
&stm32::gpio::PC[0], // A5
149-
]);
145+
[&'static stm32::gpio::GPIOPin; 19],
146+
[
147+
// &stm32::gpio::PA[3], // D0 (RX)
148+
// &stm32::gpio::PA[2], // D1 (TX)
149+
&stm32::gpio::PA[10], // D2
150+
&stm32::gpio::PB[3], // D3
151+
&stm32::gpio::PB[5], // D4
152+
&stm32::gpio::PB[4], // D5
153+
&stm32::gpio::PB[10], // D6
154+
&stm32::gpio::PA[8], // D7
155+
&stm32::gpio::PA[9], // D8
156+
&stm32::gpio::PC[7], // D9
157+
&stm32::gpio::PB[6], // D10
158+
&stm32::gpio::PA[7], // D11
159+
&stm32::gpio::PA[6], // D12
160+
// &stm32::gpio::PA[5], // D13 (LED)
161+
&stm32::gpio::PB[9], // D14
162+
&stm32::gpio::PB[8], // D15
163+
&stm32::gpio::PA[0], // A0
164+
&stm32::gpio::PA[1], // A1
165+
&stm32::gpio::PA[4], // A2
166+
&stm32::gpio::PB[0], // A3
167+
&stm32::gpio::PC[1], // A4
168+
&stm32::gpio::PC[0] // A5
169+
]
170+
);
150171
let gpio = static_init!(
151172
capsules::gpio::GPIO<'static, stm32::gpio::GPIOPin>,
152-
capsules::gpio::GPIO::new(gpio_pins));
173+
capsules::gpio::GPIO::new(gpio_pins)
174+
);
153175
for pin in gpio_pins.iter() {
154176
pin.set_client(gpio);
155177
}
@@ -165,9 +187,7 @@ pub unsafe fn reset_handler() {
165187

166188
nucleo.console.initialize();
167189
// Attach the kernel debug interface to this console
168-
let kc = static_init!(
169-
capsules::console::App,
170-
capsules::console::App::default());
190+
let kc = static_init!(capsules::console::App, capsules::console::App::default());
171191
kernel::debug::assign_console_driver(Some(nucleo.console), kc);
172192

173193
debug!("Initialization complete. Entering main loop ...");
@@ -178,9 +198,11 @@ pub unsafe fn reset_handler() {
178198
/// This symbol is defined in the linker script.
179199
static _sapps: u8;
180200
}
181-
kernel::process::load_processes(&_sapps as *const u8,
182-
&mut APP_MEMORY,
183-
&mut PROCESSES,
184-
FAULT_RESPONSE);
201+
kernel::process::load_processes(
202+
&_sapps as *const u8,
203+
&mut APP_MEMORY,
204+
&mut PROCESSES,
205+
FAULT_RESPONSE,
206+
);
185207
kernel::main(&nucleo, &mut chip, &mut PROCESSES, &nucleo.ipc);
186208
}

chips/stm32/src/chip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use kernel::common::{RingBuffer, Queue};
1+
use kernel::common::{Queue, RingBuffer};
22
use nvic::NvicIdx;
33

44
const IQ_SIZE: usize = 100;

chips/stm32/src/flash.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ pub struct FlashController {
3232

3333
impl FlashController {
3434
const fn new(base_addr: usize) -> FlashController {
35-
FlashController { registers: base_addr as *mut Registers }
35+
FlashController {
36+
registers: base_addr as *mut Registers,
37+
}
3638
}
3739

3840
pub fn set_latency(&self, latency: Latency) {

0 commit comments

Comments
 (0)