|
33 | 33 | //! ```
|
34 | 34 |
|
35 | 35 | use crate::asm::{tt, tta, ttat, ttt};
|
36 |
| -use bitfield::bitfield; |
| 36 | +use modular_bitfield::bitfield; |
37 | 37 |
|
38 | 38 | /// Memory access behaviour: determine which privilege execution mode is used and which Memory
|
39 | 39 | /// Protection Unit (MPU) is used.
|
@@ -62,35 +62,35 @@ pub struct TestTarget {
|
62 | 62 | access_type: AccessType,
|
63 | 63 | }
|
64 | 64 |
|
65 |
| -bitfield! { |
66 |
| - /// Test Target Response Payload |
67 |
| - /// |
68 |
| - /// Provides the response payload from a TT, TTA, TTT or TTAT instruction. |
69 |
| - #[derive(PartialEq, Copy, Clone)] |
70 |
| - struct TtResp(u32); |
71 |
| - impl Debug; |
72 |
| - mregion, _: 7, 0; |
73 |
| - sregion, _: 15, 8; |
74 |
| - mrvalid, _: 16; |
75 |
| - srvalid, _: 17; |
76 |
| - r, _: 18; |
77 |
| - rw, _: 19; |
78 |
| - nsr, _: 20; |
79 |
| - nsrw, _: 21; |
80 |
| - s, _: 22; |
81 |
| - irvalid, _: 23; |
82 |
| - iregion, _: 31, 24; |
| 65 | +/// Test Target Response Payload |
| 66 | +/// |
| 67 | +/// Provides the response payload from a TT, TTA, TTT or TTAT instruction. |
| 68 | +#[bitfield] |
| 69 | +#[repr(u32)] |
| 70 | +#[derive(Debug, Copy, Clone, PartialEq)] |
| 71 | +pub struct TtResp { |
| 72 | + mregion: u8, |
| 73 | + sregion: u8, |
| 74 | + mrvalid: bool, |
| 75 | + srvalid: bool, |
| 76 | + r: bool, |
| 77 | + rw: bool, |
| 78 | + nsr: bool, |
| 79 | + nsrw: bool, |
| 80 | + s: bool, |
| 81 | + irvalid: bool, |
| 82 | + iregion: u8, |
83 | 83 | }
|
84 | 84 |
|
85 | 85 | impl TestTarget {
|
86 | 86 | /// Creates a Test Target Response Payload by testing addr using access_type.
|
87 | 87 | #[inline]
|
88 | 88 | pub fn check(addr: *mut u32, access_type: AccessType) -> Self {
|
89 | 89 | let tt_resp = match access_type {
|
90 |
| - AccessType::Current => TtResp(tt(addr)), |
91 |
| - AccessType::Unprivileged => TtResp(ttt(addr)), |
92 |
| - AccessType::NonSecure => TtResp(tta(addr)), |
93 |
| - AccessType::NonSecureUnprivileged => TtResp(ttat(addr)), |
| 90 | + AccessType::Current => TtResp::from(tt(addr)), |
| 91 | + AccessType::Unprivileged => TtResp::from(ttt(addr)), |
| 92 | + AccessType::NonSecure => TtResp::from(tta(addr)), |
| 93 | + AccessType::NonSecureUnprivileged => TtResp::from(ttat(addr)), |
94 | 94 | };
|
95 | 95 |
|
96 | 96 | TestTarget {
|
@@ -140,7 +140,7 @@ impl TestTarget {
|
140 | 140 | /// Get the raw u32 value returned by the TT instruction used.
|
141 | 141 | #[inline]
|
142 | 142 | pub fn as_u32(self) -> u32 {
|
143 |
| - self.tt_resp.0 |
| 143 | + u32::from(self.tt_resp) |
144 | 144 | }
|
145 | 145 |
|
146 | 146 | /// Read accessibility of the target address. Only returns the MPU settings without checking
|
|
0 commit comments