Skip to content
Snippets Groups Projects
Commit 56477acc authored by Per Lindgren's avatar Per Lindgren
Browse files

to marcus

parent 6d238c9c
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,11 @@ version = "0.2.0" ...@@ -33,6 +33,11 @@ version = "0.2.0"
[features] [features]
wcet_bkpt = [] wcet_bkpt = []
wcet_nop = [] wcet_nop = []
klee = []
[profile.dev]
codegen-units = 1
incremental = false
[profile.release] [profile.release]
lto = true lto = true
......
...@@ -6,6 +6,7 @@ use syntax::{self, Resources, Statics}; ...@@ -6,6 +6,7 @@ use syntax::{self, Resources, Statics};
use syntax::error::*; use syntax::error::*;
#[derive(Debug)]
pub struct App { pub struct App {
pub device: Path, pub device: Path,
pub idle: Idle, pub idle: Idle,
...@@ -17,6 +18,7 @@ pub struct App { ...@@ -17,6 +18,7 @@ pub struct App {
pub type Tasks = HashMap<Ident, Task>; pub type Tasks = HashMap<Ident, Task>;
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Debug)]
pub enum Exception { pub enum Exception {
PENDSV, PENDSV,
SVCALL, SVCALL,
...@@ -42,11 +44,13 @@ impl Exception { ...@@ -42,11 +44,13 @@ impl Exception {
} }
} }
#[derive(Debug)]
pub enum Kind { pub enum Kind {
Exception(Exception), Exception(Exception),
Interrupt { enabled: bool }, Interrupt { enabled: bool },
} }
#[derive(Debug)]
pub struct Task { pub struct Task {
pub kind: Kind, pub kind: Kind,
pub path: Path, pub path: Path,
...@@ -63,16 +67,15 @@ pub fn app(app: check::App) -> Result<App> { ...@@ -63,16 +67,15 @@ pub fn app(app: check::App) -> Result<App> {
tasks: app.tasks tasks: app.tasks
.into_iter() .into_iter()
.map(|(k, v)| { .map(|(k, v)| {
let v = ::check::task(k.as_ref(), v) let v =
.chain_err(|| format!("checking task `{}`", k))?; ::check::task(k.as_ref(), v).chain_err(|| format!("checking task `{}`", k))?;
Ok((k, v)) Ok((k, v))
}) })
.collect::<Result<_>>()?, .collect::<Result<_>>()?,
}; };
::check::resources(&app) ::check::resources(&app).chain_err(|| "checking `resources`")?;
.chain_err(|| "checking `resources`")?;
Ok(app) Ok(app)
} }
......
...@@ -181,6 +181,9 @@ fn run(ts: TokenStream) -> Result<TokenStream> { ...@@ -181,6 +181,9 @@ fn run(ts: TokenStream) -> Result<TokenStream> {
let ownerships = analyze::app(&app); let ownerships = analyze::app(&app);
let tokens = trans::app(&app, &ownerships); let tokens = trans::app(&app, &ownerships);
println!("here we are");
println!("{:?}", app.tasks);
Ok(format!("{}", tokens) Ok(format!("{}", tokens)
.parse() .parse()
.map_err(|_| "BUG: error parsing the generated code")?) .map_err(|_| "BUG: error parsing the generated code")?)
......
...@@ -85,6 +85,7 @@ extern crate untagged_option; ...@@ -85,6 +85,7 @@ extern crate untagged_option;
use core::u8; use core::u8;
pub use rtfm_core::{Resource, Static, Threshold}; pub use rtfm_core::{Resource, Static, Threshold};
#[cfg(not(klee))]
pub use cortex_m::asm::{bkpt, nop, wfi}; pub use cortex_m::asm::{bkpt, nop, wfi};
pub use cortex_m_rtfm_macros::app; pub use cortex_m_rtfm_macros::app;
#[doc(hidden)] #[doc(hidden)]
...@@ -92,6 +93,7 @@ pub use untagged_option::UntaggedOption; ...@@ -92,6 +93,7 @@ pub use untagged_option::UntaggedOption;
use cortex_m::interrupt::{self, Nr}; use cortex_m::interrupt::{self, Nr};
#[cfg(not(armv6m))] #[cfg(not(armv6m))]
#[cfg(not(klee))]
use cortex_m::register::basepri; use cortex_m::register::basepri;
pub mod examples; pub mod examples;
...@@ -137,17 +139,51 @@ where ...@@ -137,17 +139,51 @@ where
if ceiling == max_priority { if ceiling == max_priority {
atomic(t, |t| f(data, t)) atomic(t, |t| f(data, t))
} else { } else {
let old = basepri::read(); let mut old = 0;
// klee mode code generation
// the generated code should not access the hardware
if !cfg!(feature = "klee") {
old = basepri::read();
}
let hw = (max_priority - ceiling) << (8 - _nvic_prio_bits); let hw = (max_priority - ceiling) << (8 - _nvic_prio_bits);
// klee mode code generation
// the generated code should not access the hardware
if !cfg!(feature = "klee") {
basepri::write(hw); basepri::write(hw);
if cfg!(feature = "wcet_bkpt") { bkpt(); } }
if cfg!(feature = "wcet_nop") { nop(); }
// wcet_bkpt mode
// put breakpoint at raise ceiling, for tracing execution time
if cfg!(feature = "wcet_bkpt") {
bkpt();
}
// wcet_nop mode
// leave nop in the production code, to keep memory layout the same
if cfg!(feature = "wcet_nop") {
nop();
}
let ret = f(data, &mut Threshold::new(ceiling)); let ret = f(data, &mut Threshold::new(ceiling));
if cfg!(feature = "wcet_bkpt") { bkpt(); } // wcet_bkpt mode
if cfg!(feature = "wcet_nop") { nop(); } // put breakpoint at lower ceiling, for tracing execution time
if cfg!(feature = "wcet_bkpt") {
bkpt();
}
// wcet_nop mode
// leave nop in the production code, to keep memory layout the same
if cfg!(feature = "wcet_nop") {
nop();
}
// klee mode code generation
// the generated code should not access the hardware
if !cfg!(feature = "klee") {
basepri::write(old); basepri::write(old);
}
ret ret
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment