You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tz_context.h 2.6KB

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