@@ -222,3 +222,144 @@ pub fn dmb() {
222
222
( ) => unimplemented ! ( ) ,
223
223
}
224
224
}
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