blob: 79dc9cb49e765038fd0cda022a795beebbb516ef [file] [log] [blame]
Manish V Badarkhecc2c7432022-02-24 20:22:39 +00001/*
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
10#include <stdint.h>
Manish V Badarkhead035ce2022-06-21 18:08:50 +010011#include <plat/common/platform.h>
12#include <services/drtm_svc.h>
Manish V Badarkhecc2c7432022-02-24 20:22:39 +000013
Manish Pandeyfef989c2022-06-21 15:36:45 +010014struct __packed drtm_dl_dma_prot_args_v1 {
15 uint64_t dma_prot_table_paddr;
16 uint64_t dma_prot_table_size;
17};
18
Manish V Badarkhead035ce2022-06-21 18:08:50 +010019/* Values for DRTM_PROTECT_MEMORY */
20enum dma_prot_type {
21 PROTECT_NONE = -1,
22 PROTECT_MEM_ALL = 0,
23 PROTECT_MEM_REGION = 2,
24};
25
26struct dma_prot {
27 enum dma_prot_type type;
28};
29
30#define DRTM_MEM_REGION_PAGES_AND_TYPE(pages, type) \
31 (((uint64_t)(pages) & (((uint64_t)1 << 52) - 1)) \
32 | (((uint64_t)(type) & 0x7) << 52))
33
34#define PAGES_AND_TYPE(pages, type) \
35 .region_size_type = DRTM_MEM_REGION_PAGES_AND_TYPE(pages, type)
36
Manish Pandeyfef989c2022-06-21 15:36:45 +010037/* Opaque / encapsulated type. */
38typedef struct drtm_dl_dma_prot_args_v1 drtm_dl_dma_prot_args_v1_t;
39
Manish V Badarkhecc2c7432022-02-24 20:22:39 +000040bool drtm_dma_prot_init(void);
Manish V Badarkhead035ce2022-06-21 18:08:50 +010041enum drtm_retc drtm_dma_prot_check_args(const drtm_dl_dma_prot_args_v1_t *a,
42 int a_dma_prot_type,
43 drtm_mem_region_t p);
44enum drtm_retc drtm_dma_prot_engage(const drtm_dl_dma_prot_args_v1_t *a,
45 int a_dma_prot_type);
46enum drtm_retc drtm_dma_prot_disengage(void);
47uint64_t drtm_unprotect_mem(void *ctx);
48void drtm_dma_prot_serialise_table(uint8_t *dst, size_t *size_out);
Manish V Badarkhecc2c7432022-02-24 20:22:39 +000049
50#endif /* DRTM_DMA_PROT_H */