spm_mm_private.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2017-2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef SPM_MM_PRIVATE_H
  7. #define SPM_MM_PRIVATE_H
  8. #include <context.h>
  9. #include "spm_common.h"
  10. /*******************************************************************************
  11. * Constants that allow assembler code to preserve callee-saved registers of the
  12. * C runtime context while performing a security state switch.
  13. ******************************************************************************/
  14. #define SP_C_RT_CTX_X19 0x0
  15. #define SP_C_RT_CTX_X20 0x8
  16. #define SP_C_RT_CTX_X21 0x10
  17. #define SP_C_RT_CTX_X22 0x18
  18. #define SP_C_RT_CTX_X23 0x20
  19. #define SP_C_RT_CTX_X24 0x28
  20. #define SP_C_RT_CTX_X25 0x30
  21. #define SP_C_RT_CTX_X26 0x38
  22. #define SP_C_RT_CTX_X27 0x40
  23. #define SP_C_RT_CTX_X28 0x48
  24. #define SP_C_RT_CTX_X29 0x50
  25. #define SP_C_RT_CTX_X30 0x58
  26. #define SP_C_RT_CTX_SIZE 0x60
  27. #define SP_C_RT_CTX_ENTRIES (SP_C_RT_CTX_SIZE >> DWORD_SHIFT)
  28. #ifndef __ASSEMBLER__
  29. #include <stdint.h>
  30. #include <lib/spinlock.h>
  31. #include <lib/xlat_tables/xlat_tables_v2.h>
  32. typedef enum sp_state {
  33. SP_STATE_RESET = 0,
  34. SP_STATE_IDLE,
  35. SP_STATE_BUSY
  36. } sp_state_t;
  37. typedef struct sp_context {
  38. uint64_t c_rt_ctx;
  39. cpu_context_t cpu_ctx;
  40. xlat_ctx_t *xlat_ctx_handle;
  41. sp_state_t state;
  42. spinlock_t state_lock;
  43. } sp_context_t;
  44. void spm_sp_setup(sp_context_t *sp_ctx);
  45. int32_t spm_memory_attributes_get_smc_handler(sp_context_t *sp_ctx,
  46. uintptr_t base_va);
  47. int spm_memory_attributes_set_smc_handler(sp_context_t *sp_ctx,
  48. u_register_t page_address,
  49. u_register_t pages_count,
  50. u_register_t smc_attributes);
  51. #endif /* __ASSEMBLER__ */
  52. #endif /* SPM_MM_PRIVATE_H */