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