ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_nsc_veneer.h
Go to the documentation of this file.
1
42
43#pragma once
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49#include <stdint.h>
50
51#include "ra8_attributes.h"
52
53/* ra8_attributes.h carries a generic, annotation-only RA8_NSC_VENEER so that
54 * translation units which never touch the NSC boundary can still be scanned by
55 * the libclang annotation gate. This header is the single authority for the
56 * macro: the Secure-world form must also carry
57 * __attribute__((cmse_nonsecure_entry)), which is what actually emits the
58 * secure-gateway (SG) veneer. Undefining first makes this file win regardless
59 * of include order -- without it, a TU that reached ra8_attributes.h after this
60 * header would silently replace the cmse form with the annotation-only form and
61 * drop the SG veneer, breaking the S/NS boundary with no diagnostic beyond a
62 * macro-redefinition warning. Both branches below re-attach the annotation so
63 * the gate still sees every veneer. */
64#undef RA8_NSC_VENEER
65
66/* __ARM_FEATURE_CMSE bit 1 marks a Secure-world (-mcmse) compile: only there
67 * is cmse_nonsecure_entry meaningful. NS TUs share RA8_TRUSTZONE_ENABLE but
68 * compile without -mcmse and must take the plain-declaration branch. */
69#if defined(RA8_TRUSTZONE_ENABLE) && defined(__ARM_FEATURE_CMSE) && ((__ARM_FEATURE_CMSE & 2) != 0)
70
71#include <arm_cmse.h>
72
85#define RA8_NSC_VENEER RA8_INTERNAL_ANNOTATE("ra8_nsc_veneer") __attribute__((cmse_nonsecure_entry))
86
96#define RA8_NSC_CHECK_NS_RANGE_R(ptr, len) \
97 do { \
98 if (cmse_check_address_range((void*)(uintptr_t)(ptr), \
99 (uint32_t)(len), \
100 CMSE_NONSECURE | CMSE_MPU_READ) == nullptr) { \
101 return k_ra8_err_invalid_arg; \
102 } \
103 } while (0)
104
109#define RA8_NSC_CHECK_NS_RANGE_RW(ptr, len) \
110 do { \
111 if (cmse_check_address_range((void*)(uintptr_t)(ptr), \
112 (uint32_t)(len), \
113 CMSE_NONSECURE | CMSE_MPU_READWRITE) == nullptr) { \
114 return k_ra8_err_invalid_arg; \
115 } \
116 } while (0)
117
118#else /* !RA8_TRUSTZONE_ENABLE or a non-Secure-world compile */
119
121#define RA8_NSC_VENEER RA8_INTERNAL_ANNOTATE("ra8_nsc_veneer")
123#define RA8_NSC_CHECK_NS_RANGE_R(ptr, len) ((void)(ptr), (void)(len))
125#define RA8_NSC_CHECK_NS_RANGE_RW(ptr, len) ((void)(ptr), (void)(len))
126
127#endif /* RA8_TRUSTZONE_ENABLE && Secure-world (-mcmse) compile */
128
129#ifdef __cplusplus
130}
131#endif
Annotation-attribute framework macros for ra8-firmware.