1 /* 2 * Copyright (c) 2017-2023 Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Licensed under the Apache License, Version 2.0 (the License); you may 7 * not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /* 20 * CMSIS Core(M) Context Management for Armv8-M TrustZone 21 */ 22 23 #if defined ( __ICCARM__ ) 24 #pragma system_include /* treat file as system include file for MISRA check */ 25 #elif defined (__clang__) 26 #pragma clang system_header /* treat file as system include file */ 27 #endif 28 29 #ifndef TZ_CONTEXT_H 30 #define TZ_CONTEXT_H 31 32 #include <stdint.h> 33 34 #ifndef TZ_MODULEID_T 35 #define TZ_MODULEID_T 36 /// \details Data type that identifies secure software modules called by a process. 37 typedef uint32_t TZ_ModuleId_t; 38 #endif 39 40 /// \details TZ Memory ID identifies an allocated memory slot. 41 typedef uint32_t TZ_MemoryId_t; 42 43 /// Initialize secure context memory system 44 /// \return execution status (1: success, 0: error) 45 uint32_t TZ_InitContextSystem_S (void); 46 47 /// Allocate context memory for calling secure software modules in TrustZone 48 /// \param[in] module identifies software modules called from non-secure mode 49 /// \return value != 0 id TrustZone memory slot identifier 50 /// \return value 0 no memory available or internal error 51 TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 52 53 /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 54 /// \param[in] id TrustZone memory slot identifier 55 /// \return execution status (1: success, 0: error) 56 uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 57 58 /// Load secure context (called on RTOS thread context switch) 59 /// \param[in] id TrustZone memory slot identifier 60 /// \return execution status (1: success, 0: error) 61 uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 62 63 /// Store secure context (called on RTOS thread context switch) 64 /// \param[in] id TrustZone memory slot identifier 65 /// \return execution status (1: success, 0: error) 66 uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 67 68 #endif // TZ_CONTEXT_H 69