Keil Logo

Non-secure function pointer intrinsics

6.9 Non-secure function pointer intrinsics

A non-secure function pointer is a function pointer that has its LSB unset.

The following table describes the non-secure function pointer intrinsics that are available when __ARM_FEATURE_CMSE is set to 3:

Intrinsic Description
cmse_nsfptr_create(p)

Returns the value of p with its LSB cleared. The argument p can be any function pointer type.

Arm recommends that the return type of this intrinsic is identical to the type of its argument.

cmse_is_nsfptr(p) Returns non-zero if p has LSB unset, zero otherwise. The argument p can be any function pointer type.

Example

The following example shows how to use these intrinsics:

#include <arm_cmse.h>
typedef void __attribute__((cmse_nonsecure_call)) nsfunc(void);
void default_callback(void) { … }

// fp can point to a secure function or a non-secure function
nsfunc *fp = (nsfunc *) default_callback;           // secure function pointer

void __attribute__((cmse_nonsecure_entry)) entry(nsfunc *callback) {
    fp = cmse_nsfptr_create(callback);  // non-secure function pointer
}

void call_callback(void) {
    if (cmse_is_nsfptr(fp)) fp();       // non-secure function call
    else ((void (*)(void)) fp)();       // normal function call
}
Non-ConfidentialPDF file icon PDF version100067_0612_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.