Skip to content

Commit 47921b5

Browse files
authored
Merge pull request #555 from Tiwalun/support-more-interrupts-armv8m
Allow up to 496 interrupts on ARMv8-M
2 parents 2438071 + 7d57d08 commit 47921b5

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

cortex-m-rt/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ INCLUDE device.x"#
5959
} else if target.starts_with("thumbv8m") {
6060
println!("cargo:rustc-cfg=cortex_m");
6161
println!("cargo:rustc-cfg=armv8m");
62-
240
62+
496
6363
} else {
6464
// Non ARM target. We assume you're just testing the syntax.
6565
// This value seems as good as any.

cortex-m-rt/src/lib.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@
258258
//!
259259
//! - `__INTERRUPTS`. This is the device specific interrupt portion of the vector table; its exact
260260
//! size depends on the target device but if the `"device"` feature has not been enabled it will
261-
//! have a size of 32 vectors (on ARMv6-M) or 240 vectors (on ARMv7-M). This array is located after
262-
//! `__EXCEPTIONS` in the `.vector_table` section.
261+
//! have a size of 32 vectors (on ARMv6-M), 240 vectors (on ARMv7-M) or 496 vectors (on ARMv8-M).
262+
//! This array is located after `__EXCEPTIONS` in the `.vector_table` section.
263263
//!
264264
//! - `__pre_init`. This is a function to be run before RAM is initialized. It defaults to an empty
265265
//! function. As this runs before RAM is initialised, it is not sound to use a Rust function for
@@ -1234,7 +1234,7 @@ pub static __EXCEPTIONS: [Vector; 14] = [
12341234

12351235
// If we are not targeting a specific device we bind all the potential device specific interrupts
12361236
// to the default handler
1237-
#[cfg(all(any(not(feature = "device"), test), not(armv6m)))]
1237+
#[cfg(all(any(not(feature = "device"), test), not(armv6m), not(armv8m)))]
12381238
#[doc(hidden)]
12391239
#[cfg_attr(cortex_m, link_section = ".vector_table.interrupts")]
12401240
#[no_mangle]
@@ -1246,6 +1246,19 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 240] = [{
12461246
DefaultHandler
12471247
}; 240];
12481248

1249+
// ARMv8-M can have up to 496 device specific interrupts
1250+
#[cfg(all(not(feature = "device"), armv8m))]
1251+
#[doc(hidden)]
1252+
#[cfg_attr(cortex_m, link_section = ".vector_table.interrupts")]
1253+
#[no_mangle]
1254+
pub static __INTERRUPTS: [unsafe extern "C" fn(); 496] = [{
1255+
extern "C" {
1256+
fn DefaultHandler();
1257+
}
1258+
1259+
DefaultHandler
1260+
}; 496];
1261+
12491262
// ARMv6-M can only have a maximum of 32 device specific interrupts
12501263
#[cfg(all(not(feature = "device"), armv6m))]
12511264
#[doc(hidden)]

0 commit comments

Comments
 (0)