Skip to content

Commit 3408883

Browse files
committed
Merge branch 'master' into apply-cfg
2 parents 423b9ef + 1cb6baf commit 3408883

10 files changed

+421
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ links = "cortex-m" # prevent multiple versions of this crate to be linked toget
1818
[dependencies]
1919
bare-metal = { version = "0.2.0", features = ["const-fn"] }
2020
volatile-register = "0.2.0"
21+
bitfield = "0.13.2"
2122

2223
[features]
2324
cm7-r0p1 = []

asm-v8.s

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.section .text.__tt
2+
.global __tt
3+
.thumb_func
4+
__tt:
5+
tt r0, r0
6+
bx lr
7+
8+
.section .text.__ttt
9+
.global __ttt
10+
.thumb_func
11+
__ttt:
12+
ttt r0, r0
13+
bx lr
14+
15+
.section .text.__tta
16+
.global __tta
17+
.thumb_func
18+
__tta:
19+
tta r0, r0
20+
bx lr
21+
22+
.section .text.__ttat
23+
.global __ttat
24+
.thumb_func
25+
__ttat:
26+
ttat r0, r0
27+
bx lr

assemble.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,18 @@ ar crs bin/thumbv7em-none-eabi.a bin/$crate.o bin/$crate-v7.o bin/$crate-cm7-r0p
2323
ar crs bin/thumbv7em-none-eabihf.a bin/$crate.o bin/$crate-v7.o bin/$crate-cm7-r0p1.o
2424

2525
arm-none-eabi-as -march=armv8-m.base asm.s -o bin/$crate.o
26-
ar crs bin/thumbv8m.base-none-eabi.a bin/$crate.o
26+
arm-none-eabi-as -march=armv8-m.base asm-v8.s -o bin/$crate-v8.o
27+
ar crs bin/thumbv8m.base-none-eabi.a bin/$crate.o bin/$crate-v8.o
2728

2829
arm-none-eabi-as -march=armv8-m.main asm.s -o bin/$crate.o
2930
arm-none-eabi-as -march=armv8-m.main asm-v7.s -o bin/$crate-v7.o
31+
arm-none-eabi-as -march=armv8-m.main asm-v8.s -o bin/$crate-v8.o
3032
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
33+
ar crs bin/thumbv8m.main-none-eabi.a bin/$crate.o bin/$crate-v7.o bin/$crate-v8.o bin/$crate-v8-main.o
34+
ar crs bin/thumbv8m.main-none-eabihf.a bin/$crate.o bin/$crate-v7.o bin/$crate-v8.o bin/$crate-v8-main.o
3335

3436
rm bin/$crate.o
3537
rm bin/$crate-v7.o
3638
rm bin/$crate-cm7-r0p1.o
39+
rm bin/$crate-v8.o
3740
rm bin/$crate-v8-main.o

bin/thumbv8m.base-none-eabi.a

1.07 KB
Binary file not shown.

bin/thumbv8m.main-none-eabi.a

1.07 KB
Binary file not shown.

bin/thumbv8m.main-none-eabihf.a

1.07 KB
Binary file not shown.

src/asm.rs

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,144 @@ pub fn dmb() {
222222
() => unimplemented!(),
223223
}
224224
}
225+
226+
/// Test Target
227+
///
228+
/// Queries the Security state and access permissions of a memory location.
229+
/// Returns a Test Target Response Payload (cf section D1.2.215 of
230+
/// Armv8-M Architecture Reference Manual).
231+
#[inline]
232+
#[cfg(armv8m)]
233+
// The __tt function does not dereference the pointer received.
234+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
235+
pub fn tt(addr: *mut u32) -> u32 {
236+
match () {
237+
#[cfg(all(cortex_m, feature = "inline-asm"))]
238+
() => {
239+
let tt_resp: u32;
240+
unsafe {
241+
asm!("tt $0, $1" : "=r"(tt_resp) : "r"(addr) :: "volatile");
242+
}
243+
tt_resp
244+
}
245+
246+
#[cfg(all(cortex_m, not(feature = "inline-asm")))]
247+
() => unsafe {
248+
extern "C" {
249+
fn __tt(_: *mut u32) -> u32;
250+
}
251+
252+
__tt(addr)
253+
},
254+
255+
#[cfg(not(cortex_m))]
256+
() => unimplemented!(),
257+
}
258+
}
259+
260+
/// Test Target Unprivileged
261+
///
262+
/// Queries the Security state and access permissions of a memory location for an unprivileged
263+
/// access to that location.
264+
/// Returns a Test Target Response Payload (cf section D1.2.215 of
265+
/// Armv8-M Architecture Reference Manual).
266+
#[inline]
267+
#[cfg(armv8m)]
268+
// The __ttt function does not dereference the pointer received.
269+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
270+
pub fn ttt(addr: *mut u32) -> u32 {
271+
match () {
272+
#[cfg(all(cortex_m, feature = "inline-asm"))]
273+
() => {
274+
let tt_resp: u32;
275+
unsafe {
276+
asm!("ttt $0, $1" : "=r"(tt_resp) : "r"(addr) :: "volatile");
277+
}
278+
tt_resp
279+
}
280+
281+
#[cfg(all(cortex_m, not(feature = "inline-asm")))]
282+
() => unsafe {
283+
extern "C" {
284+
fn __ttt(_: *mut u32) -> u32;
285+
}
286+
287+
__ttt(addr)
288+
},
289+
290+
#[cfg(not(cortex_m))]
291+
() => unimplemented!(),
292+
}
293+
}
294+
295+
/// Test Target Alternate Domain
296+
///
297+
/// Queries the Security state and access permissions of a memory location for a Non-Secure access
298+
/// to that location. This instruction is only valid when executing in Secure state and is
299+
/// undefined if used from Non-Secure state.
300+
/// Returns a Test Target Response Payload (cf section D1.2.215 of
301+
/// Armv8-M Architecture Reference Manual).
302+
#[inline]
303+
#[cfg(armv8m)]
304+
// The __tta function does not dereference the pointer received.
305+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
306+
pub fn tta(addr: *mut u32) -> u32 {
307+
match () {
308+
#[cfg(all(cortex_m, feature = "inline-asm"))]
309+
() => {
310+
let tt_resp: u32;
311+
unsafe {
312+
asm!("tta $0, $1" : "=r"(tt_resp) : "r"(addr) :: "volatile");
313+
}
314+
tt_resp
315+
}
316+
317+
#[cfg(all(cortex_m, not(feature = "inline-asm")))]
318+
() => unsafe {
319+
extern "C" {
320+
fn __tta(_: *mut u32) -> u32;
321+
}
322+
323+
__tta(addr)
324+
},
325+
326+
#[cfg(not(cortex_m))]
327+
() => unimplemented!(),
328+
}
329+
}
330+
331+
/// Test Target Alternate Domain Unprivileged
332+
///
333+
/// Queries the Security state and access permissions of a memory location for a Non-Secure and
334+
/// unprivileged access to that location. This instruction is only valid when executing in Secure
335+
/// state and is undefined if used from Non-Secure state.
336+
/// Returns a Test Target Response Payload (cf section D1.2.215 of
337+
/// Armv8-M Architecture Reference Manual).
338+
#[inline]
339+
#[cfg(armv8m)]
340+
// The __ttat function does not dereference the pointer received.
341+
#[allow(clippy::not_unsafe_ptr_arg_deref)]
342+
pub fn ttat(addr: *mut u32) -> u32 {
343+
match () {
344+
#[cfg(all(cortex_m, feature = "inline-asm"))]
345+
() => {
346+
let tt_resp: u32;
347+
unsafe {
348+
asm!("ttat $0, $1" : "=r"(tt_resp) : "r"(addr) :: "volatile");
349+
}
350+
tt_resp
351+
}
352+
353+
#[cfg(all(cortex_m, not(feature = "inline-asm")))]
354+
() => unsafe {
355+
extern "C" {
356+
fn __ttat(_: *mut u32) -> u32;
357+
}
358+
359+
__ttat(addr)
360+
},
361+
362+
#[cfg(not(cortex_m))]
363+
() => unimplemented!(),
364+
}
365+
}

0 commit comments

Comments
 (0)