diff --git a/tests/cpass/binds.rs b/tests/cpass/binds.rs index 7cb91741fd..897e083abc 100644 --- a/tests/cpass/binds.rs +++ b/tests/cpass/binds.rs @@ -1,4 +1,6 @@ //! Check that `binds` works as advertised +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -6,18 +8,20 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init] - fn init() {} + fn init(_: init::Context) {} #[exception(binds = SVCall)] - fn foo() {} + fn foo(c: foo::Context) { + foo_trampoline(c) + } #[interrupt(binds = UART0)] - fn bar() {} + fn bar(c: bar::Context) { + bar_trampoline(c) + } }; #[allow(dead_code)] diff --git a/tests/cpass/cfg.rs b/tests/cpass/cfg.rs index c91ab60465..a0b6a870d0 100644 --- a/tests/cpass/cfg.rs +++ b/tests/cpass/cfg.rs @@ -6,24 +6,22 @@ #![no_std] extern crate lm3s6965; -extern crate panic_semihosting; +extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[cfg(never)] static mut FOO: u32 = 0; #[init] - fn init() { + fn init(_: init::Context) { #[cfg(never)] static mut BAR: u32 = 0; } #[idle] - fn idle() -> ! { + fn idle(_: idle::Context) -> ! { #[cfg(never)] static mut BAR: u32 = 0; @@ -31,20 +29,20 @@ const APP: () = { } #[task(resources = [FOO], schedule = [quux], spawn = [quux])] - fn foo() { + fn foo(_: foo::Context) { #[cfg(never)] static mut BAR: u32 = 0; } #[task(priority = 3, resources = [FOO], schedule = [quux], spawn = [quux])] - fn bar() { + fn bar(_: bar::Context) { #[cfg(never)] static mut BAR: u32 = 0; } #[cfg(never)] #[task] - fn quux() {} + fn quux(_: quux::Context) {} extern "C" { fn UART0(); diff --git a/tests/cpass/late-not-send.rs b/tests/cpass/late-not-send.rs index 5b278ab5c3..0f69096748 100644 --- a/tests/cpass/late-not-send.rs +++ b/tests/cpass/late-not-send.rs @@ -1,3 +1,5 @@ +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -7,20 +9,18 @@ extern crate rtfm; use core::marker::PhantomData; -use rtfm::app; - pub struct NotSend { _0: PhantomData<*const ()>, } -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { static mut X: NotSend = (); static mut Y: Option = None; #[init(resources = [Y])] - fn init() -> init::LateResources { - *resources.Y = Some(NotSend { _0: PhantomData }); + fn init(c: init::Context) -> init::LateResources { + *c.resources.Y = Some(NotSend { _0: PhantomData }); init::LateResources { X: NotSend { _0: PhantomData }, @@ -28,7 +28,7 @@ const APP: () = { } #[idle(resources = [X, Y])] - fn idle() -> ! { + fn idle(_: idle::Context) -> ! { loop {} } }; diff --git a/tests/cpass/late-resource.rs b/tests/cpass/late-resource.rs index 0dec4cbee0..37dcf33163 100644 --- a/tests/cpass/late-resource.rs +++ b/tests/cpass/late-resource.rs @@ -1,4 +1,6 @@ //! Runtime initialized resources +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -6,15 +8,13 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { static mut X: u32 = (); static Y: u32 = (); #[init] - fn init() -> init::LateResources { + fn init(_: init::Context) -> init::LateResources { init::LateResources { X: 0, Y: 1 } } }; diff --git a/tests/cpass/peripheral.rs b/tests/cpass/peripheral.rs index 509a6be162..34352b845c 100644 --- a/tests/cpass/peripheral.rs +++ b/tests/cpass/peripheral.rs @@ -1,4 +1,6 @@ //! Core and device peripherals +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -6,13 +8,11 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init] - fn init() { - let _: rtfm::Peripherals = core; - let _: lm3s6965::Peripherals = device; + fn init(c: init::Context) { + let _: rtfm::Peripherals = c.core; + let _: lm3s6965::Peripherals = c.device; } }; diff --git a/tests/cpass/resource.rs b/tests/cpass/resource.rs index bb8373939f..4e92a0320b 100644 --- a/tests/cpass/resource.rs +++ b/tests/cpass/resource.rs @@ -1,5 +1,7 @@ //! Check code generation of resources +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -7,9 +9,9 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::{app, Exclusive}; +use rtfm::Exclusive; -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { static mut O1: u32 = 0; // init static mut O2: u32 = 0; // idle @@ -23,57 +25,57 @@ const APP: () = { static S3: u32 = 0; #[init(resources = [O1, O4, O5, O6, S3])] - fn init() { + fn init(c: init::Context) { // owned by `init` == `&'static mut` - let _: &'static mut u32 = resources.O1; + let _: &'static mut u32 = c.resources.O1; // owned by `init` == `&'static` if read-only - let _: &'static u32 = resources.O6; + let _: &'static u32 = c.resources.O6; // `init` has exclusive access to all resources - let _: &mut u32 = resources.O4; - let _: &mut u32 = resources.O5; - let _: &mut u32 = resources.S3; + let _: &mut u32 = c.resources.O4; + let _: &mut u32 = c.resources.O5; + let _: &mut u32 = c.resources.S3; } #[idle(resources = [O2, O4, S1, S3])] - fn idle() -> ! { + fn idle(mut c: idle::Context) -> ! { // owned by `idle` == `&'static mut` - let _: &'static mut u32 = resources.O2; + let _: &'static mut u32 = c.resources.O2; // owned by `idle` == `&'static` if read-only - let _: &'static u32 = resources.O4; + let _: &'static u32 = c.resources.O4; // shared with `idle` == `Mutex` - resources.S1.lock(|_| {}); + c.resources.S1.lock(|_| {}); // `&` if read-only - let _: &u32 = resources.S3; + let _: &u32 = c.resources.S3; loop {} } #[interrupt(resources = [O3, S1, S2, S3])] - fn UART0() { + fn UART0(c: UART0::Context) { // owned by interrupt == `&mut` - let _: &mut u32 = resources.O3; + let _: &mut u32 = c.resources.O3; // no `Mutex` proxy when access from highest priority task - let _: Exclusive = resources.S1; + let _: Exclusive = c.resources.S1; // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: Exclusive = resources.S2; + let _: Exclusive = c.resources.S2; // `&` if read-only - let _: &u32 = resources.S3; + let _: &u32 = c.resources.S3; } #[interrupt(resources = [S2, O5])] - fn UART1() { + fn UART1(c: UART1::Context) { // owned by interrupt == `&` if read-only - let _: &u32 = resources.O5; + let _: &u32 = c.resources.O5; // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: Exclusive = resources.S2; + let _: Exclusive = c.resources.S2; } }; diff --git a/tests/cpass/schedule.rs b/tests/cpass/schedule.rs index 0728d8b322..346f9124a6 100644 --- a/tests/cpass/schedule.rs +++ b/tests/cpass/schedule.rs @@ -1,3 +1,5 @@ +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -5,52 +7,52 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::{app, Instant}; +use rtfm::Instant; -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init(schedule = [foo, bar, baz])] - fn init() { - let _: Result<(), ()> = schedule.foo(start + 10.cycles()); - let _: Result<(), u32> = schedule.bar(start + 20.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(start + 30.cycles(), 0, 1); + fn init(c: init::Context) { + let _: Result<(), ()> = c.schedule.foo(c.start + 10.cycles()); + let _: Result<(), u32> = c.schedule.bar(c.start + 20.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 30.cycles(), 0, 1); } #[idle(schedule = [foo, bar, baz])] - fn idle() -> ! { - let _: Result<(), ()> = schedule.foo(Instant::now() + 40.cycles()); - let _: Result<(), u32> = schedule.bar(Instant::now() + 50.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(Instant::now() + 60.cycles(), 0, 1); + fn idle(c: idle::Context) -> ! { + let _: Result<(), ()> = c.schedule.foo(Instant::now() + 40.cycles()); + let _: Result<(), u32> = c.schedule.bar(Instant::now() + 50.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(Instant::now() + 60.cycles(), 0, 1); loop {} } #[exception(schedule = [foo, bar, baz])] - fn SVCall() { - let _: Result<(), ()> = schedule.foo(start + 70.cycles()); - let _: Result<(), u32> = schedule.bar(start + 80.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(start + 90.cycles(), 0, 1); + fn SVCall(c: SVCall::Context) { + let _: Result<(), ()> = c.schedule.foo(c.start + 70.cycles()); + let _: Result<(), u32> = c.schedule.bar(c.start + 80.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 90.cycles(), 0, 1); } #[interrupt(schedule = [foo, bar, baz])] - fn UART0() { - let _: Result<(), ()> = schedule.foo(start + 100.cycles()); - let _: Result<(), u32> = schedule.bar(start + 110.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(start + 120.cycles(), 0, 1); + fn UART0(c: UART0::Context) { + let _: Result<(), ()> = c.schedule.foo(c.start + 100.cycles()); + let _: Result<(), u32> = c.schedule.bar(c.start + 110.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(c.start + 120.cycles(), 0, 1); } #[task(schedule = [foo, bar, baz])] - fn foo() { - let _: Result<(), ()> = schedule.foo(scheduled + 130.cycles()); - let _: Result<(), u32> = schedule.bar(scheduled + 140.cycles(), 0); - let _: Result<(), (u32, u32)> = schedule.baz(scheduled + 150.cycles(), 0, 1); + fn foo(c: foo::Context) { + let _: Result<(), ()> = c.schedule.foo(c.scheduled + 130.cycles()); + let _: Result<(), u32> = c.schedule.bar(c.scheduled + 140.cycles(), 0); + let _: Result<(), (u32, u32)> = c.schedule.baz(c.scheduled + 150.cycles(), 0, 1); } #[task] - fn bar(_x: u32) {} + fn bar(_: bar::Context, _x: u32) {} #[task] - fn baz(_x: u32, _y: u32) {} + fn baz(_: baz::Context, _x: u32, _y: u32) {} extern "C" { fn UART1(); diff --git a/tests/cpass/singleton.rs b/tests/cpass/singleton.rs deleted file mode 100644 index d50f8523ee..0000000000 --- a/tests/cpass/singleton.rs +++ /dev/null @@ -1,66 +0,0 @@ -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate owned_singleton; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::{app, Exclusive}; - -#[app(device = lm3s6965)] -const APP: () = { - #[Singleton] - static mut O1: u32 = 0; - #[Singleton] - static mut O2: u32 = 0; - #[Singleton] - static mut O3: u32 = 0; - #[Singleton] - static O4: u32 = 0; - #[Singleton] - static O5: u32 = 0; - #[Singleton] - static O6: u32 = 0; - - #[Singleton] - static mut S1: u32 = 0; - #[Singleton] - static S2: u32 = 0; - - #[init(resources = [O1, O2, O3, O4, O5, O6, S1, S2])] - fn init() { - let _: O1 = resources.O1; - let _: &mut O2 = resources.O2; - let _: &mut O3 = resources.O3; - let _: O4 = resources.O4; - let _: &mut O5 = resources.O5; - let _: &mut O6 = resources.O6; - - let _: &mut S1 = resources.S1; - let _: &mut S2 = resources.S2; - } - - #[idle(resources = [O2, O5])] - fn idle() -> ! { - let _: O2 = resources.O2; - let _: O5 = resources.O5; - - loop {} - } - - #[interrupt(resources = [O3, O6, S1, S2])] - fn UART0() { - let _: &mut O3 = resources.O3; - let _: &O6 = resources.O6; - - let _: Exclusive = resources.S1; - let _: &S2 = resources.S2; - } - - #[interrupt(resources = [S1, S2])] - fn UART1() { - let _: Exclusive = resources.S1; - let _: &S2 = resources.S2; - } -}; diff --git a/tests/cpass/spawn.rs b/tests/cpass/spawn.rs index 3df606a4a0..0a27c4f6bc 100644 --- a/tests/cpass/spawn.rs +++ b/tests/cpass/spawn.rs @@ -1,4 +1,6 @@ //! Check code generation of `spawn` +#![deny(unsafe_code)] +#![deny(warnings)] #![no_main] #![no_std] @@ -6,52 +8,50 @@ extern crate lm3s6965; extern crate panic_halt; extern crate rtfm; -use rtfm::app; - -#[app(device = lm3s6965)] +#[rtfm::app(device = lm3s6965)] const APP: () = { #[init(spawn = [foo, bar, baz])] - fn init() { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn init(c: init::Context) { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); } #[idle(spawn = [foo, bar, baz])] - fn idle() -> ! { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn idle(c: idle::Context) -> ! { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); loop {} } #[exception(spawn = [foo, bar, baz])] - fn SVCall() { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn SVCall(c: SVCall::Context) { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); } #[interrupt(spawn = [foo, bar, baz])] - fn UART0() { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn UART0(c: UART0::Context) { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); } #[task(spawn = [foo, bar, baz])] - fn foo() { - let _: Result<(), ()> = spawn.foo(); - let _: Result<(), u32> = spawn.bar(0); - let _: Result<(), (u32, u32)> = spawn.baz(0, 1); + fn foo(c: foo::Context) { + let _: Result<(), ()> = c.spawn.foo(); + let _: Result<(), u32> = c.spawn.bar(0); + let _: Result<(), (u32, u32)> = c.spawn.baz(0, 1); } #[task] - fn bar(_x: u32) {} + fn bar(_: bar::Context, _x: u32) {} #[task] - fn baz(_x: u32, _y: u32) {} + fn baz(_: baz::Context, _x: u32, _y: u32) {} extern "C" { fn UART1(); diff --git a/tests/cpass/unsafe.rs b/tests/cpass/unsafe.rs deleted file mode 100644 index b6996ad115..0000000000 --- a/tests/cpass/unsafe.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! Check code generation of `unsafe` `init` / `idle` / `exception` / `interrupt` / `task` -#![no_main] -#![no_std] - -extern crate lm3s6965; -extern crate panic_halt; -extern crate rtfm; - -use rtfm::app; - -unsafe fn foo() {} - -#[app(device = lm3s6965)] -const APP: () = { - #[init] - unsafe fn init() { - foo(); - } - - #[idle] - unsafe fn idle() -> ! { - foo(); - - loop {} - } - - #[exception] - unsafe fn SVCall() { - foo(); - } - - #[interrupt] - unsafe fn UART0() { - foo(); - } - - #[task] - unsafe fn bar() { - foo(); - } - - extern "C" { - fn UART1(); - } -};