File tree 8 files changed +138
-2
lines changed
8 files changed +138
-2
lines changed Original file line number Diff line number Diff line change
1
+ .section .text .__msplim_r
2
+ .global __msplim_r
3
+ .thumb_func
4
+ __msplim_r:
5
+ mrs r0, MSPLIM
6
+ bx lr
7
+
8
+ .section .text .__msplim_w
9
+ .global __msplim_w
10
+ .thumb_func
11
+ __msplim_w:
12
+ msr MSPLIM, r0
13
+ bx lr
14
+
15
+ .section .text .__psplim_r
16
+ .global __psplim_r
17
+ .thumb_func
18
+ __psplim_r:
19
+ mrs r0, PSPLIM
20
+ bx lr
21
+
22
+ .section .text .__psplim_w
23
+ .global __psplim_w
24
+ .thumb_func
25
+ __psplim_w:
26
+ msr PSPLIM, r0
27
+ bx lr
28
+
Original file line number Diff line number Diff line change @@ -26,8 +26,12 @@ arm-none-eabi-as -march=armv8-m.base asm.s -o bin/$crate.o
26
26
ar crs bin/thumbv8m.base-none-eabi.a bin/$crate .o
27
27
28
28
arm-none-eabi-as -march=armv8-m.main asm.s -o bin/$crate .o
29
- ar crs bin/thumbv8m.main-none-eabi.a bin/$crate .o
29
+ arm-none-eabi-as -march=armv8-m.main asm-v7.s -o bin/$crate -v7.o
30
+ arm-none-eabi-as -march=armv8-m.main asm-v8-main.s -o bin/$crate -v8-main.o
31
+ ar crs bin/thumbv8m.main-none-eabi.a bin/$crate .o bin/$crate -v7.o bin/$crate -v8-main.o
32
+ ar crs bin/thumbv8m.main-none-eabihf.a bin/$crate .o bin/$crate -v7.o bin/$crate -v8-main.o
30
33
31
34
rm bin/$crate .o
32
35
rm bin/$crate -v7.o
33
36
rm bin/$crate -cm7-r0p1.o
37
+ rm bin/$crate -v8-main.o
Original file line number Diff line number Diff line change @@ -26,9 +26,13 @@ fn main() {
26
26
println ! ( "cargo:rustc-cfg=cortex_m" ) ;
27
27
println ! ( "cargo:rustc-cfg=armv7m" ) ;
28
28
//println!("cargo:rustc-cfg=armv7em");
29
- } else if target. starts_with ( "thumbv8m" ) {
29
+ } else if target. starts_with ( "thumbv8m.base " ) {
30
30
println ! ( "cargo:rustc-cfg=cortex_m" ) ;
31
31
println ! ( "cargo:rustc-cfg=armv8m" ) ;
32
+ } else if target. starts_with ( "thumbv8m.main" ) {
33
+ println ! ( "cargo:rustc-cfg=cortex_m" ) ;
34
+ println ! ( "cargo:rustc-cfg=armv8m" ) ;
35
+ println ! ( "cargo:rustc-cfg=armv8m_main" ) ;
32
36
}
33
37
34
38
if target. ends_with ( "-eabihf" ) {
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ pub mod primask;
43
43
44
44
pub mod psp;
45
45
46
+ #[ cfg( armv8m_main) ]
47
+ pub mod msplim;
48
+
49
+ #[ cfg( armv8m_main) ]
50
+ pub mod psplim;
51
+
46
52
// Accessing these registers requires inline assembly because their contents are tied to the current
47
53
// stack frame
48
54
#[ cfg( any( feature = "inline-asm" , target_arch = "x86_64" ) ) ]
Original file line number Diff line number Diff line change
1
+ //! Main Stack Pointer Limit Register
2
+
3
+ /// Reads the CPU register
4
+ #[ inline]
5
+ pub fn read ( ) -> u32 {
6
+ match ( ) {
7
+ #[ cfg( all( cortex_m, feature = "inline-asm" ) ) ]
8
+ ( ) => {
9
+ let r;
10
+ unsafe { asm ! ( "mrs $0,MSPLIM" : "=r" ( r) :: : "volatile" ) }
11
+ r
12
+ }
13
+
14
+ #[ cfg( all( cortex_m, not( feature = "inline-asm" ) ) ) ]
15
+ ( ) => unsafe {
16
+ extern "C" {
17
+ fn __msplim_r ( ) -> u32 ;
18
+ }
19
+
20
+ __msplim_r ( )
21
+ } ,
22
+
23
+ #[ cfg( not( cortex_m) ) ]
24
+ ( ) => unimplemented ! ( ) ,
25
+ }
26
+ }
27
+
28
+ /// Writes `bits` to the CPU register
29
+ #[ inline]
30
+ pub unsafe fn write ( _bits : u32 ) {
31
+ match ( ) {
32
+ #[ cfg( all( cortex_m, feature = "inline-asm" ) ) ]
33
+ ( ) => asm ! ( "msr MSPLIM,$0" :: "r" ( _bits) :: "volatile" ) ,
34
+
35
+ #[ cfg( all( cortex_m, not( feature = "inline-asm" ) ) ) ]
36
+ ( ) => {
37
+ extern "C" {
38
+ fn __msplim_w ( _: u32 ) ;
39
+ }
40
+
41
+ __msplim_w ( _bits) ;
42
+ }
43
+
44
+ #[ cfg( not( cortex_m) ) ]
45
+ ( ) => unimplemented ! ( ) ,
46
+ }
47
+ }
Original file line number Diff line number Diff line change
1
+ //! Process Stack Pointer Limit Register
2
+
3
+ /// Reads the CPU register
4
+ #[ inline]
5
+ pub fn read ( ) -> u32 {
6
+ match ( ) {
7
+ #[ cfg( all( cortex_m, feature = "inline-asm" ) ) ]
8
+ ( ) => {
9
+ let r;
10
+ unsafe { asm ! ( "mrs $0,PSPLIM" : "=r" ( r) :: : "volatile" ) }
11
+ r
12
+ }
13
+
14
+ #[ cfg( all( cortex_m, not( feature = "inline-asm" ) ) ) ]
15
+ ( ) => unsafe {
16
+ extern "C" {
17
+ fn __psplim_r ( ) -> u32 ;
18
+ }
19
+
20
+ __psplim_r ( )
21
+ } ,
22
+
23
+ #[ cfg( not( cortex_m) ) ]
24
+ ( ) => unimplemented ! ( ) ,
25
+ }
26
+ }
27
+
28
+ /// Writes `bits` to the CPU register
29
+ #[ inline]
30
+ pub unsafe fn write ( _bits : u32 ) {
31
+ match ( ) {
32
+ #[ cfg( all( cortex_m, feature = "inline-asm" ) ) ]
33
+ ( ) => asm ! ( "msr PSPLIM,$0" :: "r" ( _bits) :: "volatile" ) ,
34
+
35
+ #[ cfg( all( cortex_m, not( feature = "inline-asm" ) ) ) ]
36
+ ( ) => {
37
+ extern "C" {
38
+ fn __psplim_w ( _: u32 ) ;
39
+ }
40
+
41
+ __psplim_w ( _bits) ;
42
+ }
43
+
44
+ #[ cfg( not( cortex_m) ) ]
45
+ ( ) => unimplemented ! ( ) ,
46
+ }
47
+ }
You can’t perform that action at this time.
0 commit comments