drtm_dma_prot.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2022 Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef DRTM_DMA_PROT_H
  8. #define DRTM_DMA_PROT_H
  9. #include <stdint.h>
  10. #include <plat/common/platform.h>
  11. #include <services/drtm_svc.h>
  12. struct __packed drtm_dl_dma_prot_args_v1 {
  13. uint64_t dma_prot_table_paddr;
  14. uint64_t dma_prot_table_size;
  15. };
  16. /* Values for DRTM_PROTECT_MEMORY */
  17. enum dma_prot_type {
  18. PROTECT_NONE = -1,
  19. PROTECT_MEM_ALL = 0,
  20. PROTECT_MEM_REGION = 2,
  21. };
  22. struct dma_prot {
  23. enum dma_prot_type type;
  24. };
  25. #define DRTM_MEM_REGION_PAGES_AND_TYPE(pages, type) \
  26. (((uint64_t)(pages) & (((uint64_t)1 << 52) - 1)) \
  27. | (((uint64_t)(type) & 0x7) << 52))
  28. #define PAGES_AND_TYPE(pages, type) \
  29. .region_size_type = DRTM_MEM_REGION_PAGES_AND_TYPE(pages, type)
  30. /* Opaque / encapsulated type. */
  31. typedef struct drtm_dl_dma_prot_args_v1 drtm_dl_dma_prot_args_v1_t;
  32. bool drtm_dma_prot_init(void);
  33. enum drtm_retc drtm_dma_prot_check_args(const drtm_dl_dma_prot_args_v1_t *a,
  34. int a_dma_prot_type,
  35. drtm_mem_region_t p);
  36. enum drtm_retc drtm_dma_prot_engage(const drtm_dl_dma_prot_args_v1_t *a,
  37. int a_dma_prot_type);
  38. enum drtm_retc drtm_dma_prot_disengage(void);
  39. uint64_t drtm_unprotect_mem(void *ctx);
  40. void drtm_dma_prot_serialise_table(uint8_t *dst, size_t *size_out);
  41. #endif /* DRTM_DMA_PROT_H */