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