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