187
187
//! required, but some bootloaders do not set VTOR before jumping to application code, leading to
188
188
//! your main function executing but interrupt handlers not being used.
189
189
//!
190
+ //! ## `set-msplim`
191
+ //!
192
+ //! If this feature is enabled, the main stack pointer limit register (MSPLIM) is initialized in
193
+ //! the reset handler to the `_stack_end` value from the linker script. This feature is only
194
+ //! available on ARMv8-M Mainline and helps enforce stack limits by defining the lowest valid
195
+ //! stack address.
196
+ //!
190
197
//! ## `zero-init-ram`
191
198
//!
192
199
//! If this feature is enabled, RAM is initialized with zeros during startup from the `_ram_start`
266
273
//!
267
274
//! - `__INTERRUPTS`. This is the device specific interrupt portion of the vector table; its exact
268
275
//! size depends on the target device but if the `"device"` feature has not been enabled it will
269
- //! have a size of 32 vectors (on ARMv6-M), 240 vectors (on ARMv7-M) or 496 vectors (on ARMv8-M).
276
+ //! have a size of 32 vectors (on ARMv6-M), 240 vectors (on ARMv7-M, ARMv8-M Baseline) or 480
277
+ //! vectors (on ARMv8-M Mainline).
270
278
//! This array is located after `__EXCEPTIONS` in the `.vector_table` section.
271
279
//!
272
280
//! - `__pre_init`. This is a function to be run before RAM is initialized. It defaults to an empty
@@ -544,6 +552,13 @@ cfg_global_asm! {
544
552
ldr r1, =__vector_table
545
553
str r1, [r0]" ,
546
554
555
+ // If enabled, set the Main Stack Pointer Limit (MSPLIM) to the end of the stack.
556
+ // This feature is only available on ARMv8-M Mainline, where it helps enforce stack limits
557
+ // by defining the lowest valid stack address.
558
+ #[ cfg( all( armv8m_main, feature = "set-msplim" ) ) ]
559
+ "ldr r0, =_stack_end
560
+ msr MSPLIM, r0" ,
561
+
547
562
// Run user pre-init code which must be executed immediately after startup, before the
548
563
// potentially time-consuming memory initialisation takes place.
549
564
// Example use cases include disabling default watchdogs or enabling RAM.
@@ -1245,7 +1260,7 @@ pub static __EXCEPTIONS: [Vector; 14] = [
1245
1260
1246
1261
// If we are not targeting a specific device we bind all the potential device specific interrupts
1247
1262
// to the default handler
1248
- #[ cfg( all( any( not( feature = "device" ) , test) , not( armv6m) , not( armv8m ) ) ) ]
1263
+ #[ cfg( all( any( not( feature = "device" ) , test) , not( armv6m) , not( armv8m_main ) ) ) ]
1249
1264
#[ doc( hidden) ]
1250
1265
#[ cfg_attr( cortex_m, link_section = ".vector_table.interrupts" ) ]
1251
1266
#[ no_mangle]
@@ -1257,18 +1272,18 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 240] = [{
1257
1272
DefaultHandler
1258
1273
} ; 240 ] ;
1259
1274
1260
- // ARMv8-M can have up to 496 device specific interrupts
1261
- #[ cfg( all( not( feature = "device" ) , armv8m ) ) ]
1275
+ // ARMv8-M Mainline can have up to 480 device specific interrupts
1276
+ #[ cfg( all( not( feature = "device" ) , armv8m_main ) ) ]
1262
1277
#[ doc( hidden) ]
1263
1278
#[ cfg_attr( cortex_m, link_section = ".vector_table.interrupts" ) ]
1264
1279
#[ no_mangle]
1265
- pub static __INTERRUPTS: [ unsafe extern "C" fn ( ) ; 496 ] = [ {
1280
+ pub static __INTERRUPTS: [ unsafe extern "C" fn ( ) ; 480 ] = [ {
1266
1281
extern "C" {
1267
1282
fn DefaultHandler ( ) ;
1268
1283
}
1269
1284
1270
1285
DefaultHandler
1271
- } ; 496 ] ;
1286
+ } ; 480 ] ;
1272
1287
1273
1288
// ARMv6-M can only have a maximum of 32 device specific interrupts
1274
1289
#[ cfg( all( not( feature = "device" ) , armv6m) ) ]
0 commit comments