mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
Added check for resource usage and to generate an compile error for thumbv6 exceptions
This commit is contained in:
parent
9f38a39377
commit
0f8bdbdd3f
2 changed files with 39 additions and 1 deletions
|
@ -110,12 +110,32 @@ pub fn codegen(
|
||||||
|
|
||||||
let mut prio_to_masks = HashMap::new();
|
let mut prio_to_masks = HashMap::new();
|
||||||
let device = &extra.device;
|
let device = &extra.device;
|
||||||
|
let mut uses_exceptions_with_resources = false;
|
||||||
|
|
||||||
for (&priority, name) in interrupt_ids.chain(app.hardware_tasks.values().flat_map(|task| {
|
for (&priority, name) in interrupt_ids.chain(app.hardware_tasks.values().flat_map(|task| {
|
||||||
if !util::is_exception(&task.args.binds) {
|
if !util::is_exception(&task.args.binds) {
|
||||||
Some((&task.args.priority, &task.args.binds))
|
Some((&task.args.priority, &task.args.binds))
|
||||||
} else {
|
} else {
|
||||||
// TODO: exceptions not implemented
|
// If any resource to the exception uses non-lock-free or non-local resources this is
|
||||||
|
// not allwed on thumbv6.
|
||||||
|
uses_exceptions_with_resources = uses_exceptions_with_resources
|
||||||
|
|| task
|
||||||
|
.args
|
||||||
|
.shared_resources
|
||||||
|
.iter()
|
||||||
|
.map(|(ident, access)| {
|
||||||
|
if access.is_exclusive() {
|
||||||
|
if let Some(r) = app.shared_resources.get(ident) {
|
||||||
|
!r.properties.lock_free
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.any(|v| v);
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})) {
|
})) {
|
||||||
|
@ -146,5 +166,13 @@ pub fn codegen(
|
||||||
const #masks_name: [u32; 3] = [#(#mask_arr),*];
|
const #masks_name: [u32; 3] = [#(#mask_arr),*];
|
||||||
));
|
));
|
||||||
|
|
||||||
|
if uses_exceptions_with_resources {
|
||||||
|
mod_app.push(quote!(
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
const __rtic_internal_V6_ERROR: () = rtic::export::v6_panic();
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
(mod_app, mod_resources)
|
(mod_app, mod_resources)
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,3 +339,13 @@ pub const fn create_mask<const N: usize>(list_of_shifts: [u32; N]) -> u32 {
|
||||||
|
|
||||||
mask
|
mask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(armv6m))]
|
||||||
|
pub const fn v6_panic() {
|
||||||
|
// For non-v6 all is fine
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(armv6m)]
|
||||||
|
pub const fn v6_panic() {
|
||||||
|
panic!("Exceptions with shared resources are not allowed when compiling for thumbv6. Use local resources or `#[lock_free]` shared resources");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue