--- /dev/null
+/*\r
+ * FreeRTOS Kernel V10.2.0\r
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
+\r
+#ifndef __SECURE_PORT_MACROS_H__\r
+#define __SECURE_PORT_MACROS_H__\r
+\r
+/**\r
+ * @brief Byte alignment requirements.\r
+ */\r
+#define secureportBYTE_ALIGNMENT 8\r
+#define secureportBYTE_ALIGNMENT_MASK ( 0x0007 )\r
+\r
+/**\r
+ * @brief Macro to declare a function as non-secure callable.\r
+ */\r
+#if defined( __IAR_SYSTEMS_ICC__ )\r
+ #define secureportNON_SECURE_CALLABLE __cmse_nonsecure_entry\r
+#else\r
+ #define secureportNON_SECURE_CALLABLE __attribute__((cmse_nonsecure_entry))\r
+#endif\r
+\r
+/**\r
+ * @brief Set the secure PRIMASK value.\r
+ */\r
+#define secureportSET_SECURE_PRIMASK( ulPrimaskValue ) \\r
+ __asm volatile ( "msr primask, %0" : : "r" ( ulPrimaskValue ) : "memory" )\r
+\r
+/**\r
+ * @brief Set the non-secure PRIMASK value.\r
+ */\r
+#define secureportSET_NON_SECURE_PRIMASK( ulPrimaskValue ) \\r
+ __asm volatile ( "msr primask_ns, %0" : : "r" ( ulPrimaskValue ) : "memory" )\r
+\r
+/**\r
+ * @brief Read the PSP value in the given variable.\r
+ */\r
+#define secureportREAD_PSP( pucOutCurrentStackPointer ) \\r
+ __asm volatile ( "mrs %0, psp" : "=r" ( pucOutCurrentStackPointer ) )\r
+\r
+/**\r
+ * @brief Set the PSP to the given value.\r
+ */\r
+#define secureportSET_PSP( pucCurrentStackPointer ) \\r
+ __asm volatile ( "msr psp, %0" : : "r" ( pucCurrentStackPointer ) )\r
+\r
+/**\r
+ * @brief Set the PSPLIM to the given value.\r
+ */\r
+#define secureportSET_PSPLIM( pucStackLimit ) \\r
+ __asm volatile ( "msr psplim, %0" : : "r" ( pucStackLimit ) )\r
+\r
+/**\r
+ * @brief Set the NonSecure MSP to the given value.\r
+ */\r
+#define secureportSET_MSP_NS( pucMainStackPointer ) \\r
+ __asm volatile ( "msr msp_ns, %0" : : "r" ( pucMainStackPointer ) )\r
+\r
+/**\r
+ * @brief Set the CONTROL register to the given value.\r
+ */\r
+#define secureportSET_CONTROL( ulControl ) \\r
+ __asm volatile ( "msr control, %0" : : "r" ( ulControl ) : "memory" )\r
+\r
+/**\r
+ * @brief Read the Interrupt Program Status Register (IPSR) value in the given\r
+ * variable.\r
+ */\r
+#define secureportREAD_IPSR( ulIPSR ) \\r
+ __asm volatile ( "mrs %0, ipsr" : "=r" ( ulIPSR ) )\r
+\r
+/**\r
+ * @brief PRIMASK value to enable interrupts.\r
+ */\r
+#define secureportPRIMASK_ENABLE_INTERRUPTS_VAL 0\r
+\r
+/**\r
+ * @brief PRIMASK value to disable interrupts.\r
+ */\r
+#define secureportPRIMASK_DISABLE_INTERRUPTS_VAL 1\r
+\r
+/**\r
+ * @brief Disable secure interrupts.\r
+ */\r
+#define secureportDISABLE_SECURE_INTERRUPTS() secureportSET_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL )\r
+\r
+/**\r
+ * @brief Disable non-secure interrupts.\r
+ *\r
+ * This effectively disables context switches.\r
+ */\r
+#define secureportDISABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_DISABLE_INTERRUPTS_VAL )\r
+\r
+/**\r
+ * @brief Enable non-secure interrupts.\r
+ */\r
+#define secureportENABLE_NON_SECURE_INTERRUPTS() secureportSET_NON_SECURE_PRIMASK( secureportPRIMASK_ENABLE_INTERRUPTS_VAL )\r
+\r
+/**\r
+ * @brief Assert definition.\r
+ */\r
+#define secureportASSERT( x ) \\r
+ if( ( x ) == 0 ) \\r
+ { \\r
+ secureportDISABLE_SECURE_INTERRUPTS(); \\r
+ secureportDISABLE_NON_SECURE_INTERRUPTS(); \\r
+ for( ;; ); \\r
+ }\r
+\r
+#endif /* __SECURE_PORT_MACROS_H__ */\r