@@ -34,9 +34,61 @@ extern "C" {
3434#include "target.h"
3535#endif
3636#include "wolfboot/version.h"
37-
38- #ifdef WOLFCRYPT_SECURE_MODE
3937#include "wolfboot/wc_secure.h"
38+
39+
40+ #ifndef RAMFUNCTION
41+ #if defined(__WOLFBOOT ) && defined(RAM_CODE )
42+ # if defined(ARCH_ARM )
43+ # define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
44+ # else
45+ # define RAMFUNCTION __attribute__((used,section(".ramcode")))
46+ # endif
47+ #else
48+ # define RAMFUNCTION
49+ #endif
50+ #endif
51+
52+ #ifndef WEAKFUNCTION
53+ # if defined(__GNUC__ ) || defined(__CC_ARM )
54+ # define WEAKFUNCTION __attribute__((weak))
55+ # else
56+ # define WEAKFUNCTION
57+ # endif
58+ #endif
59+
60+ #ifndef UNUSEDFUNCTION
61+ # if defined(__GNUC__ ) || defined(__CC_ARM )
62+ # define UNUSEDFUNCTION __attribute__((unused))
63+ # else
64+ # define UNUSEDFUNCTION
65+ # endif
66+ #endif
67+
68+
69+ /* Helpers for memory alignment */
70+ #ifndef XALIGNED
71+ #if defined(__GNUC__ ) || defined(__llvm__ ) || \
72+ defined(__IAR_SYSTEMS_ICC__ )
73+ #define XALIGNED (x ) __attribute__ ( (aligned (x)))
74+ #elif defined(__KEIL__ )
75+ #define XALIGNED (x ) __align(x)
76+ #elif defined(_MSC_VER )
77+ /* disable align warning, we want alignment ! */
78+ #pragma warning(disable: 4324)
79+ #define XALIGNED (x ) __declspec (align (x))
80+ #else
81+ #define XALIGNED (x ) /* null expansion */
82+ #endif
83+ #endif
84+
85+ #ifndef XALIGNED_STACK
86+ /* Don't enforce stack alignment on IAR */
87+ #if defined (__IAR_SYSTEMS_ICC__ )
88+ #define XALIGNED_STACK (x )
89+ #else
90+ #define XALIGNED_STACK (x ) XALIGNED(x)
91+ #endif
4092#endif
4193
4294
@@ -420,36 +472,36 @@ int wolfBoot_erase_encrypt_key(void);
420472 */
421473
422474/* Call wolfBoot_success from non-secure application */
423- __attribute__(( cmse_nonsecure_entry ))
475+ CSME_NSE_API
424476void wolfBoot_nsc_success (void );
425477
426478/* Call wolfBoot_update_trigger from non-secure application */
427- __attribute__(( cmse_nonsecure_entry ))
479+ CSME_NSE_API
428480void wolfBoot_nsc_update_trigger (void );
429481
430482/* Call wolfBoot_get_image_version from non-secure application */
431- __attribute__(( cmse_nonsecure_entry ))
483+ CSME_NSE_API
432484uint32_t wolfBoot_nsc_get_image_version (uint8_t part );
433485#define wolfBoot_nsc_current_firmware_version () wolfBoot_nsc_get_image_version(PART_BOOT)
434486#define wolfBoot_nsc_update_firmware_version () wolfBoot_nsc_get_image_version(PART_UPDATE)
435487
436488/* Call wolfBoot_get_partition_state from non-secure application */
437- __attribute__(( cmse_nonsecure_entry ))
489+ CSME_NSE_API
438490int wolfBoot_nsc_get_partition_state (uint8_t part , uint8_t * st );
439491
440492/* Erase one or more sectors in the update partition.
441493 * - address: offset within the update partition ('0' corresponds to PARTITION_UPDATE_ADDRESS)
442494 * - len: size, in bytes
443495 */
444- __attribute__(( cmse_nonsecure_entry ))
496+ CSME_NSE_API
445497int wolfBoot_nsc_erase_update (uint32_t address , uint32_t len );
446498
447499/* Write the content of buffer `buf` and size `len` to the update partition,
448500 * at offset address, from non-secure application
449501 * - address: offset within the update partition ('0' corresponds to PARTITION_UPDATE_ADDRESS)
450502 * - len: size, in bytes
451503 */
452- __attribute__(( cmse_nonsecure_entry ))
504+ CSME_NSE_API
453505int wolfBoot_nsc_write_update (uint32_t address , const uint8_t * buf , uint32_t len );
454506
455507#endif /* !__WOLFBOOT && WOLFCRYPT_SECURE_MODE */
0 commit comments