]>
Commit | Line | Data |
---|---|---|
532ac7d7 XL |
1 | #[allow(unused_macros)] |
2 | macro_rules! rsr { | |
3 | ($R:ident) => { | |
4 | impl super::super::sealed::Rsr for $R { | |
5 | unsafe fn __rsr(&self) -> u32 { | |
6 | let r: u32; | |
a2a8927a | 7 | crate::arch::asm!(concat!("mrs {},", stringify!($R)), out(reg) r, options(nomem, nostack)); |
532ac7d7 XL |
8 | r |
9 | } | |
10 | } | |
11 | }; | |
12 | } | |
13 | ||
14 | #[allow(unused_macros)] | |
15 | macro_rules! rsrp { | |
16 | ($R:ident) => { | |
17 | impl super::super::sealed::Rsrp for $R { | |
18 | unsafe fn __rsrp(&self) -> *const u8 { | |
19 | let r: *const u8; | |
a2a8927a | 20 | crate::arch::asm!(concat!("mrs {},", stringify!($R)), out(reg) r, options(nomem, nostack)); |
532ac7d7 XL |
21 | r |
22 | } | |
23 | } | |
24 | }; | |
25 | } | |
26 | ||
27 | #[allow(unused_macros)] | |
28 | macro_rules! wsr { | |
29 | ($R:ident) => { | |
30 | impl super::super::sealed::Wsr for $R { | |
31 | unsafe fn __wsr(&self, value: u32) { | |
a2a8927a | 32 | crate::arch::asm!(concat!("msr ", stringify!($R), ", {}"), in(reg) value, options(nomem, nostack)); |
532ac7d7 XL |
33 | } |
34 | } | |
35 | }; | |
36 | } | |
37 | ||
38 | #[allow(unused_macros)] | |
39 | macro_rules! wsrp { | |
40 | ($R:ident) => { | |
41 | impl super::super::sealed::Wsrp for $R { | |
42 | unsafe fn __wsrp(&self, value: *const u8) { | |
a2a8927a | 43 | crate::arch::asm!(concat!("msr ", stringify!($R), ", {}"), in(reg) value, options(nomem, nostack)); |
532ac7d7 XL |
44 | } |
45 | } | |
46 | }; | |
47 | } | |
48 | ||
49 | #[cfg(target_feature = "mclass")] | |
50 | mod v6m; | |
51 | ||
52 | #[cfg(target_feature = "mclass")] | |
53 | pub use self::v6m::*; | |
54 | ||
55 | #[cfg(all(target_feature = "v7", target_feature = "mclass"))] | |
56 | mod v7m; | |
57 | ||
58 | #[cfg(all(target_feature = "v7", target_feature = "mclass"))] | |
59 | pub use self::v7m::*; | |
60 | ||
61 | #[cfg(not(target_arch = "aarch64"))] | |
62 | mod aarch32; | |
63 | ||
64 | #[cfg(not(target_arch = "aarch64"))] | |
65 | pub use self::aarch32::*; | |
66 | ||
67 | /// Reads a 32-bit system register | |
68 | #[inline(always)] | |
69 | pub unsafe fn __rsr<R>(reg: R) -> u32 | |
70 | where | |
71 | R: super::sealed::Rsr, | |
72 | { | |
73 | reg.__rsr() | |
74 | } | |
75 | ||
76 | /// Reads a 64-bit system register | |
77 | #[cfg(target_arch = "aarch64")] | |
78 | #[inline(always)] | |
79 | pub unsafe fn __rsr64<R>(reg: R) -> u64 | |
80 | where | |
81 | R: super::sealed::Rsr64, | |
82 | { | |
83 | reg.__rsr64() | |
84 | } | |
85 | ||
86 | /// Reads a system register containing an address | |
87 | #[inline(always)] | |
88 | pub unsafe fn __rsrp<R>(reg: R) -> *const u8 | |
89 | where | |
90 | R: super::sealed::Rsrp, | |
91 | { | |
92 | reg.__rsrp() | |
93 | } | |
94 | ||
95 | /// Writes a 32-bit system register | |
96 | #[inline(always)] | |
97 | pub unsafe fn __wsr<R>(reg: R, value: u32) | |
98 | where | |
99 | R: super::sealed::Wsr, | |
100 | { | |
101 | reg.__wsr(value) | |
102 | } | |
103 | ||
104 | /// Writes a 64-bit system register | |
105 | #[cfg(target_arch = "aarch64")] | |
106 | #[inline(always)] | |
107 | pub unsafe fn __wsr64<R>(reg: R, value: u64) | |
108 | where | |
109 | R: super::sealed::Wsr64, | |
110 | { | |
111 | reg.__wsr64(value) | |
112 | } | |
113 | ||
114 | /// Writes a system register containing an address | |
115 | #[inline(always)] | |
116 | pub unsafe fn __wsrp<R>(reg: R, value: *const u8) | |
117 | where | |
118 | R: super::sealed::Wsrp, | |
119 | { | |
120 | reg.__wsrp(value) | |
121 | } |