tz_context.h 2.4 KB

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