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