2 * FreeRTOS Kernel V10.4.4
\r
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * SPDX-License-Identifier: MIT
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
8 * this software and associated documentation files (the "Software"), to deal in
\r
9 * the Software without restriction, including without limitation the rights to
\r
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
11 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
12 * subject to the following conditions:
\r
14 * The above copyright notice and this permission notice shall be included in all
\r
15 * copies or substantial portions of the Software.
\r
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
24 * https://www.FreeRTOS.org
\r
25 * https://github.com/FreeRTOS
\r
29 #ifndef __SECURE_CONTEXT_H__
\r
30 #define __SECURE_CONTEXT_H__
\r
32 /* Standard includes. */
\r
35 /* FreeRTOS includes. */
\r
36 #include "FreeRTOSConfig.h"
\r
39 * @brief PSP value when no task's context is loaded.
\r
41 #define securecontextNO_STACK 0x0
\r
44 * @brief Opaque handle.
\r
46 struct SecureContext;
\r
47 typedef struct SecureContext * SecureContextHandle_t;
\r
48 /*-----------------------------------------------------------*/
\r
51 * @brief Initializes the secure context management system.
\r
53 * PSP is set to NULL and therefore a task must allocate and load a context
\r
54 * before calling any secure side function in the thread mode.
\r
56 * @note This function must be called in the handler mode. It is no-op if called
\r
57 * in the thread mode.
\r
59 void SecureContext_Init( void );
\r
62 * @brief Allocates a context on the secure side.
\r
64 * @note This function must be called in the handler mode. It is no-op if called
\r
65 * in the thread mode.
\r
67 * @param[in] ulSecureStackSize Size of the stack to allocate on secure side.
\r
68 * @param[in] ulIsTaskPrivileged 1 if the calling task is privileged, 0 otherwise.
\r
70 * @return Opaque context handle if context is successfully allocated, NULL
\r
73 #if ( configENABLE_MPU == 1 )
\r
74 SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize,
\r
75 uint32_t ulIsTaskPrivileged );
\r
76 #else /* configENABLE_MPU */
\r
77 SecureContextHandle_t SecureContext_AllocateContext( uint32_t ulSecureStackSize );
\r
78 #endif /* configENABLE_MPU */
\r
81 * @brief Frees the given context.
\r
83 * @note This function must be called in the handler mode. It is no-op if called
\r
84 * in the thread mode.
\r
86 * @param[in] xSecureContextHandle Context handle corresponding to the
\r
87 * context to be freed.
\r
89 void SecureContext_FreeContext( SecureContextHandle_t xSecureContextHandle );
\r
92 * @brief Loads the given context.
\r
94 * @note This function must be called in the handler mode. It is no-op if called
\r
95 * in the thread mode.
\r
97 * @param[in] xSecureContextHandle Context handle corresponding to the context
\r
100 void SecureContext_LoadContext( SecureContextHandle_t xSecureContextHandle );
\r
103 * @brief Saves the given context.
\r
105 * @note This function must be called in the handler mode. It is no-op if called
\r
106 * in the thread mode.
\r
108 * @param[in] xSecureContextHandle Context handle corresponding to the context
\r
111 void SecureContext_SaveContext( SecureContextHandle_t xSecureContextHandle );
\r
113 #endif /* __SECURE_CONTEXT_H__ */
\r