aboutsummaryrefslogtreecommitdiff
path: root/macros/src
diff options
context:
space:
mode:
authorGravatar bors[bot] <26634292+bors[bot]@users.noreply.github.com> 2022-07-27 19:15:09 +0000
committerGravatar GitHub <noreply@github.com> 2022-07-27 19:15:09 +0000
commitb87fca3d21d92018ac4d50b200cf8e77cb577028 (patch)
tree48f6da77b0c2ba1bb54e6ad8f30f5dad0e3765d7 /macros/src
parentd4816e054b556e326c5e3d4c40f7120372aafc50 (diff)
parent368ab1d4fb780386f3162c7a84502e301af7f3b0 (diff)
downloadrtic-b87fca3d21d92018ac4d50b200cf8e77cb577028.tar.gz
rtic-b87fca3d21d92018ac4d50b200cf8e77cb577028.tar.zst
rtic-b87fca3d21d92018ac4d50b200cf8e77cb577028.zip
Merge #652
652: Remove use of basepri register on thumbv8m.base r=AfoHT a=neonquill The basepri register appears to be aviable on thumbv8m.main but not thumbv8m.base. At the very least, attempting to compile against a Cortex-M23 based Microchip ATSAML10E16A generates an error: ``` error[E0432]: unresolved import `cortex_m::register::basepri` --> /Users/dwatson/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rtic-1.1.3/src/export.rs:25:5 | 25 | use cortex_m::register::basepri; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `basepri` in `register` ``` I wasn't sure if it made more sense to replace the `armv7m` config flag with something related to basepri availability or to get closer to matching the cortex-m use of several architecture specific flags. In the end i chose to make the minimal change possible and just narrowed the existing `thumbv8m` check. Context: [cortex-m:src/register/mod.rs](https://github.com/rust-embedded/cortex-m/blob/4e908625204a1e95dd3fd5bdcd8d66d6bc11c3bc/src/register/mod.rs#L33): ``` #[cfg(all(not(armv6m), not(armv8m_base)))] pub mod basepri; ``` [cortex-m:build.rs](https://github.com/rust-embedded/cortex-m/blob/4e908625204a1e95dd3fd5bdcd8d66d6bc11c3bc/build.rs#L21): ``` } else if target.starts_with("thumbv8m.base") { println!("cargo:rustc-cfg=cortex_m"); println!("cargo:rustc-cfg=armv8m"); println!("cargo:rustc-cfg=armv8m_base"); ``` Co-authored-by: David Watson <david@neonquill.com>
Diffstat (limited to 'macros/src')
-rw-r--r--macros/src/codegen/assertions.rs11
-rw-r--r--macros/src/codegen/shared_resources.rs19
-rw-r--r--macros/src/codegen/util.rs5
3 files changed, 26 insertions, 9 deletions
diff --git a/macros/src/codegen/assertions.rs b/macros/src/codegen/assertions.rs
index f6a098b5..66e54095 100644
--- a/macros/src/codegen/assertions.rs
+++ b/macros/src/codegen/assertions.rs
@@ -22,15 +22,16 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
}
let device = &extra.device;
- let arm_v6_checks: Vec<_> = app
+ let chunks_name = util::priority_mask_chunks_ident();
+ let no_basepri_checks: Vec<_> = app
.hardware_tasks
.iter()
.filter_map(|(_, task)| {
if !util::is_exception(&task.args.binds) {
let interrupt_name = &task.args.binds;
Some(quote!(
- if (#device::Interrupt::#interrupt_name as u32) > 31 {
- ::core::panic!("An interrupt above value 31 is used while in armv6");
+ if (#device::Interrupt::#interrupt_name as usize) >= (#chunks_name * 32) {
+ ::core::panic!("An interrupt out of range is used while in armv6 or armv8m.base");
}
))
} else {
@@ -41,8 +42,8 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec<TokenStream
let const_check = quote! {
const _CONST_CHECK: () = {
- if rtic::export::is_armv6() {
- #(#arm_v6_checks)*
+ if !rtic::export::have_basepri() {
+ #(#no_basepri_checks)*
} else {
// TODO: Add armv7 checks here
}
diff --git a/macros/src/codegen/shared_resources.rs b/macros/src/codegen/shared_resources.rs
index 08d77cc3..4a750070 100644
--- a/macros/src/codegen/shared_resources.rs
+++ b/macros/src/codegen/shared_resources.rs
@@ -118,6 +118,8 @@ pub fn codegen(
let device = &extra.device;
let mut uses_exceptions_with_resources = false;
+ let mut mask_ids = Vec::new();
+
for (&priority, name) in interrupt_ids.chain(app.hardware_tasks.values().flat_map(|task| {
if !util::is_exception(&task.args.binds) {
Some((&task.args.priority, &task.args.binds))
@@ -147,12 +149,13 @@ pub fn codegen(
})) {
let v = prio_to_masks.entry(priority - 1).or_insert(Vec::new());
v.push(quote!(#device::Interrupt::#name as u32));
+ mask_ids.push(quote!(#device::Interrupt::#name as u32));
}
- // Call rtic::export::create_mask([u32; N]), where the array is the list of shifts
+ // Call rtic::export::create_mask([Mask; N]), where the array is the list of shifts
let mut mask_arr = Vec::new();
- // NOTE: 0..3 assumes max 4 priority levels according to M0 spec
+ // NOTE: 0..3 assumes max 4 priority levels according to M0, M23 spec
for i in 0..3 {
let v = if let Some(v) = prio_to_masks.get(&i) {
v.clone()
@@ -165,18 +168,26 @@ pub fn codegen(
));
}
+ // Generate a constant for the number of chunks needed by Mask.
+ let chunks_name = util::priority_mask_chunks_ident();
+ mod_app.push(quote!(
+ #[doc(hidden)]
+ #[allow(non_upper_case_globals)]
+ const #chunks_name: usize = rtic::export::compute_mask_chunks([#(#mask_ids),*]);
+ ));
+
let masks_name = util::priority_masks_ident();
mod_app.push(quote!(
#[doc(hidden)]
#[allow(non_upper_case_globals)]
- const #masks_name: [u32; 3] = [#(#mask_arr),*];
+ const #masks_name: [rtic::export::Mask<#chunks_name>; 3] = [#(#mask_arr),*];
));
if uses_exceptions_with_resources {
mod_app.push(quote!(
#[doc(hidden)]
#[allow(non_upper_case_globals)]
- const __rtic_internal_V6_ERROR: () = rtic::export::v6_panic();
+ const __rtic_internal_V6_ERROR: () = rtic::export::no_basepri_panic();
));
}
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs
index 0f3dca7c..0a3edc20 100644
--- a/macros/src/codegen/util.rs
+++ b/macros/src/codegen/util.rs
@@ -253,6 +253,11 @@ pub fn static_shared_resource_ident(name: &Ident) -> Ident {
mark_internal_name(&format!("shared_resource_{}", name))
}
+/// Generates an Ident for the number of 32 bit chunks used for Mask storage.
+pub fn priority_mask_chunks_ident() -> Ident {
+ mark_internal_name("MASK_CHUNKS")
+}
+
pub fn priority_masks_ident() -> Ident {
mark_internal_name("MASKS")
}
sg191/bun/commit/test/js/node/process/process.test.js?h=dylan/github-api-option&id=a9e1792607fea89944526ed5478a3a82db2932eb&follow=1'>fix: support uint8 exit code range (#6303)Gravatar Liz 2-2/+11 The exit code support is between 0-255 and not only in the signed positive range (0-127). Node.js does not seam to throw on a bigger integer and just wraps around, but throwing a error is a good approach and makes the behaviour more defined. This allows the range to be 0-255 Fixes: https://github.com/oven-sh/bun/issues/6284 2023-10-09Fix array variables preview in debugger (#6379)Gravatar 2hu 1-1/+4 2023-10-07feat(KeyObject) (#5940)Gravatar Ciro Spaciari 106-67/+9342 * oops * createSecretKey but weird error * use the right prototype, do not add a function called export lol * HMAC JWT export + base64 fix * Fix Equals, Fix Get KeySize, add complete export RSA * fix RSA export * add EC exports * X25519 and ED25519 export + fixes * fix default exports * better asymmetricKeyType * fix private exports * fix symmetricKeySize * createPublicKey validations + refactor * jwt + der fixes * oopsies * add PEM into createPublicKey * cleanup * WIP * bunch of fixes * public from private + private OKP * encrypted keys fixes * oops * fix clear tls error, add some support to jwk and other formats on publicEncrypt/publicDecrypt * more fixes and tests working * more fixes more tests * more clear hmac errors * more tests and fixes * add generateKeyPair * more tests passing, some skips * fix EC key from private * fix OKP JWK * nodejs ignores ext and key_ops on KeyObject.exports * add EC sign verify test * some fixes * add crypto.generateKeyPairSync(type, options) * more fixes and more tests * fix hmac tests * jsonwebtoken tests * oops * oops2 * generated files * revert package.json * vm tests * todos instead of failues * toBunString -> toString * undo simdutf * improvements * unlikely * cleanup * cleanup 2 * oops * move _generateKeyPairSync checks to native 2023-10-07Exclude more filesGravatar Jarred Sumner 1-1/+1 2023-10-07Exclude more filesGravatar Jarred Sumner 1-1/+2 2023-10-07Update settings.jsonGravatar Jarred Sumner 1-1/+2 2023-10-07Update settings.jsonGravatar Jarred Sumner 1-2/+3 2023-10-06fix a couple install testsGravatar Dylan Conway 1-8/+8 2023-10-06formatGravatar Dylan Conway 1-1/+2 2023-10-06Fix memory leak in fetch() (#6350)Gravatar Jarred Sumner 1-2/+0 Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-10-06[types] allow onLoad plugin callbacks to return undefined (#6346)Gravatar Silver 1-1/+1 Returning undefined simply falls through to the next plugin, or to the default loader. This is defined by esbuild, and supported by Bun, but the types don't reflect it properly. 2023-10-06docs: `file.stream()` is not a promise (#6337)Gravatar Paul Nodet 1-1/+1