Robert Lopez / CMSIS5
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tz_context.h Source File

tz_context.h

00001 /******************************************************************************
00002  * @file     tz_context.h
00003  * @brief    Context Management for Armv8-M TrustZone
00004  * @version  V1.0.1
00005  * @date     10. January 2018
00006  ******************************************************************************/
00007 /*
00008  * Copyright (c) 2017-2018 Arm Limited. All rights reserved.
00009  *
00010  * SPDX-License-Identifier: Apache-2.0
00011  *
00012  * Licensed under the Apache License, Version 2.0 (the License); you may
00013  * not use this file except in compliance with the License.
00014  * You may obtain a copy of the License at
00015  *
00016  * www.apache.org/licenses/LICENSE-2.0
00017  *
00018  * Unless required by applicable law or agreed to in writing, software
00019  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00020  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00021  * See the License for the specific language governing permissions and
00022  * limitations under the License.
00023  */
00024 
00025 #if   defined ( __ICCARM__ )
00026   #pragma system_include         /* treat file as system include file for MISRA check */
00027 #elif defined (__clang__)
00028   #pragma clang system_header   /* treat file as system include file */
00029 #endif
00030 
00031 #ifndef TZ_CONTEXT_H
00032 #define TZ_CONTEXT_H
00033  
00034 #include <stdint.h>
00035  
00036 #ifndef TZ_MODULEID_T
00037 #define TZ_MODULEID_T
00038 /// \details Data type that identifies secure software modules called by a process.
00039 typedef uint32_t TZ_ModuleId_t;
00040 #endif
00041  
00042 /// \details TZ Memory ID identifies an allocated memory slot.
00043 typedef uint32_t TZ_MemoryId_t;
00044   
00045 /// Initialize secure context memory system
00046 /// \return execution status (1: success, 0: error)
00047 uint32_t TZ_InitContextSystem_S (void);
00048  
00049 /// Allocate context memory for calling secure software modules in TrustZone
00050 /// \param[in]  module   identifies software modules called from non-secure mode
00051 /// \return value != 0 id TrustZone memory slot identifier
00052 /// \return value 0    no memory available or internal error
00053 TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module);
00054  
00055 /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
00056 /// \param[in]  id  TrustZone memory slot identifier
00057 /// \return execution status (1: success, 0: error)
00058 uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id);
00059  
00060 /// Load secure context (called on RTOS thread context switch)
00061 /// \param[in]  id  TrustZone memory slot identifier
00062 /// \return execution status (1: success, 0: error)
00063 uint32_t TZ_LoadContext_S (TZ_MemoryId_t id);
00064  
00065 /// Store secure context (called on RTOS thread context switch)
00066 /// \param[in]  id  TrustZone memory slot identifier
00067 /// \return execution status (1: success, 0: error)
00068 uint32_t TZ_StoreContext_S (TZ_MemoryId_t id);
00069  
00070 #endif  // TZ_CONTEXT_H
00071