xref: /rk3399_ARM-atf/include/plat/common/plat_drtm.h (revision 70b5967ebc2d3a591262edb54b769cf4713d10e8)
1d72c486bSLucian Paul-Trifu /*
27792bdbdSManish V Badarkhe  * Copyright (c) 2022-2025, Arm Limited. All rights reserved.
3d72c486bSLucian Paul-Trifu  *
4d72c486bSLucian Paul-Trifu  * SPDX-License-Identifier: BSD-3-Clause
5d72c486bSLucian Paul-Trifu  */
6d72c486bSLucian Paul-Trifu 
7d72c486bSLucian Paul-Trifu #ifndef PLAT_DRTM_H
8d72c486bSLucian Paul-Trifu #define PLAT_DRTM_H
9d72c486bSLucian Paul-Trifu 
102a1cdee4Sjohpow01 #include <stdint.h>
112a1cdee4Sjohpow01 #include <lib/xlat_tables/xlat_tables_compat.h>
122a1cdee4Sjohpow01 
132a1cdee4Sjohpow01 typedef struct {
142a1cdee4Sjohpow01 	uint8_t max_num_mem_prot_regions;
152a1cdee4Sjohpow01 	uint8_t dma_protection_support;
162a1cdee4Sjohpow01 } plat_drtm_dma_prot_features_t;
172a1cdee4Sjohpow01 
182a1cdee4Sjohpow01 typedef struct {
192a1cdee4Sjohpow01 	bool tpm_based_hash_support;
20c86cfa35SStuart Yoder 	uint16_t firmware_hash_algorithm;
212a1cdee4Sjohpow01 } plat_drtm_tpm_features_t;
222a1cdee4Sjohpow01 
232a1cdee4Sjohpow01 typedef struct {
242a1cdee4Sjohpow01 	uint64_t region_address;
252a1cdee4Sjohpow01 	uint64_t region_size_type;
262a1cdee4Sjohpow01 } __attribute__((packed)) drtm_mem_region_t;
272a1cdee4Sjohpow01 
282a1cdee4Sjohpow01 /*
29b94d5909SStuart Yoder  * Memory region descriptor table structure as per DRTM 1.0 section 3.13
302a1cdee4Sjohpow01  * Table 11 MEMORY_REGION_DESCRIPTOR_TABLE
312a1cdee4Sjohpow01  */
322a1cdee4Sjohpow01 typedef struct {
332a1cdee4Sjohpow01 	uint16_t revision;
342a1cdee4Sjohpow01 	uint16_t reserved;
352a1cdee4Sjohpow01 	uint32_t num_regions;
362a1cdee4Sjohpow01 	drtm_mem_region_t region[];
372a1cdee4Sjohpow01 } __attribute__((packed)) drtm_memory_region_descriptor_table_t;
382a1cdee4Sjohpow01 
392a1cdee4Sjohpow01 /* platform specific address map functions */
402a1cdee4Sjohpow01 const mmap_region_t *plat_get_addr_mmap(void);
412a1cdee4Sjohpow01 
42d72c486bSLucian Paul-Trifu /* platform-specific DMA protection functions */
43d72c486bSLucian Paul-Trifu bool plat_has_non_host_platforms(void);
44d72c486bSLucian Paul-Trifu bool plat_has_unmanaged_dma_peripherals(void);
45d72c486bSLucian Paul-Trifu unsigned int plat_get_total_smmus(void);
46d72c486bSLucian Paul-Trifu void plat_enumerate_smmus(const uintptr_t **smmus_out,
47d72c486bSLucian Paul-Trifu 			  size_t *smmu_count_out);
482a1cdee4Sjohpow01 const plat_drtm_dma_prot_features_t *plat_drtm_get_dma_prot_features(void);
492a1cdee4Sjohpow01 uint64_t plat_drtm_dma_prot_get_max_table_bytes(void);
502a1cdee4Sjohpow01 
512a1cdee4Sjohpow01 /* platform-specific TPM functions */
522a1cdee4Sjohpow01 const plat_drtm_tpm_features_t *plat_drtm_get_tpm_features(void);
532a1cdee4Sjohpow01 
542a1cdee4Sjohpow01 /*
552a1cdee4Sjohpow01  * TODO: Implement these functions as per the platform use case,
562a1cdee4Sjohpow01  * as of now none of the platform uses these functions
572a1cdee4Sjohpow01  */
582a1cdee4Sjohpow01 uint64_t plat_drtm_get_min_size_normal_world_dce(void);
592a1cdee4Sjohpow01 uint64_t plat_drtm_get_tcb_hash_table_size(void);
602a1cdee4Sjohpow01 uint64_t plat_drtm_get_imp_def_dlme_region_size(void);
612a1cdee4Sjohpow01 uint64_t plat_drtm_get_tcb_hash_features(void);
627792bdbdSManish V Badarkhe uint64_t plat_drtm_get_acpi_tables_region_size(void);
63*0f7ebef7SManish V Badarkhe uint64_t plat_drtm_get_dlme_img_auth_features(void);
64d72c486bSLucian Paul-Trifu 
65586f60ccSManish V Badarkhe /* DRTM error handling functions */
66586f60ccSManish V Badarkhe int plat_set_drtm_error(uint64_t error_code);
67586f60ccSManish V Badarkhe int plat_get_drtm_error(uint64_t *error_code);
68586f60ccSManish V Badarkhe 
69d5f225d9SManish V Badarkhe /*
70d5f225d9SManish V Badarkhe  * Platform-specific function to ensure passed region lies within
71d5f225d9SManish V Badarkhe  * Non-Secure region of DRAM
72d5f225d9SManish V Badarkhe  */
73d5f225d9SManish V Badarkhe int plat_drtm_validate_ns_region(uintptr_t region_start,
74d5f225d9SManish V Badarkhe 				 size_t region_size);
75d5f225d9SManish V Badarkhe 
76d72c486bSLucian Paul-Trifu #endif /* PLAT_DRTM_H */
77