You copied the Doc URL to your clipboard.

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
}
Was this page helpful? Yes No