diff --git a/.vscode/launch.json b/.vscode/launch.json index f74e5c17e20f7853909494a33a6ecc946a4688d8..9b0e94793b69884354de1ba53e5cf96bcc9994d6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -38,6 +38,23 @@ ], "cwd": "${workspaceRoot}" }, + { + "type": "gdb", + "request": "attach", + "name": "Release nested", + "gdbpath": "/usr/bin/arm-none-eabi-gdb", + "executable": "./target/thumbv7em-none-eabihf/release/examples/nested", + "target": ":3333", + "remote": true, + "autorun": [ + "monitor reset init", + "monitor arm semihosting enable", + "monitor tpiu config internal /tmp/itm.log uart off 16000000", + "monitor itm port 0 on", + "load" + ], + "cwd": "${workspaceRoot}" + }, { "type": "gdb", "request": "attach", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 846c88a066025b9e3c9e44f8ec2a9c396e05c4dd..4250bdde9019b4f73b6dff0107eccaf44a24a2f8 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -27,6 +27,30 @@ "$rustc" ] }, + { + "label": "xargo build --example nested --features wcet_bkpt", + "type": "shell", + "command": "xargo build --features \"wcet_bkpt\" --example nested ", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$rustc" + ] + }, + { + "label": "xargo build --release --example nested --features wcet_bkpt", + "type": "shell", + "command": "xargo build --release --features \"wcet_bkpt\" --example nested", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$rustc" + ] + }, { "label": "xargo build --example preemption", "type": "shell", diff --git a/Cargo.toml b/Cargo.toml index b71aaa61ca04e6125d0fa68d6fba59fb16302ada..0184c0eb5da833e9198caa3831835c37c9f4415c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,5 +30,9 @@ git = "https://gitlab.henriktjader.com/pln/STM32F40x" features = ["rt"] version = "0.1.0" +[features] +wcet_bkpt = [] + [profile.release] lto = true +debug = true diff --git a/examples/nested.rs b/examples/nested.rs index 86034961b2e281e602111cd053863eacf29bdf9e..6aa9ba80eac05eeb28a850657d458079cf656ceb 100644 --- a/examples/nested.rs +++ b/examples/nested.rs @@ -43,6 +43,7 @@ app! { fn init(_p: init::Peripherals, _r: init::Resources) {} +#[inline(never)] fn idle() -> ! { // A rtfm::bkpt(); @@ -59,6 +60,7 @@ fn idle() -> ! { } #[allow(non_snake_case)] +#[inline(never)] fn exti0( t: &mut Threshold, EXTI0::Resources { mut LOW, mut HIGH }: EXTI0::Resources, @@ -116,13 +118,18 @@ fn exti0( // Once again the preemption threshold drops but this time to 1. Now the // pending `exti1` task can preempt this task // ~> exti1 + + // K + rtfm::bkpt(); } +#[inline(never)] fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) { - // C, I + // C, J rtfm::bkpt(); } +#[inline(never)] fn exti2(_t: &mut Threshold, _r: EXTI2::Resources) { // E, H rtfm::bkpt(); diff --git a/src/lib.rs b/src/lib.rs index 4ab8ec58d927accfcea548553ac223c673b50359..b62bac37b21c77df15804aedcd6d714bd042779f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,7 +85,7 @@ extern crate untagged_option; use core::u8; pub use rtfm_core::{Resource, Static, Threshold}; -pub use cortex_m::asm::{bkpt, wfi}; +pub use cortex_m::asm::{bkpt, nop, wfi}; pub use cortex_m_rtfm_macros::app; #[doc(hidden)] pub use untagged_option::UntaggedOption; @@ -140,7 +140,11 @@ where let old = basepri::read(); let hw = (max_priority - ceiling) << (8 - _nvic_prio_bits); basepri::write(hw); + if cfg!(feature = "wcet_bkpt") {bkpt();} else {nop();} + + let ret = f(data, &mut Threshold::new(ceiling)); + if cfg!(feature = "wcet_bkpt") {bkpt();} else {nop();} basepri::write(old); ret }