1 /*
2  * Copyright (c) 2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef RSS_MEASURED_BOOT_H
8 #define RSS_MEASURED_BOOT_H
9 
10 #include <stdint.h>
11 
12 #include <common/debug.h>
13 #include <measured_boot.h>
14 
15 #define RSS_MBOOT_INVALID_ID	UINT32_MAX
16 
17 /*
18  * Each boot measurement has some metadata (i.e. a string) that identifies
19  * what was measured and how. The sw_type field of the rss_mboot_metadata
20  * structure represents the role of the software component that was measured.
21  * The below macros define strings suitable for the sw_type.
22  * The key thing is to choose meaningful strings so that when the attestation
23  * token is verified, then the different components can be identified.
24  */
25 #define RSS_MBOOT_BL2_STRING		"BL_2"
26 #define RSS_MBOOT_BL31_STRING		"SECURE_RT_EL3"
27 #define RSS_MBOOT_HW_CONFIG_STRING	"HW_CONFIG"
28 #define RSS_MBOOT_FW_CONFIG_STRING	"FW_CONFIG"
29 #define RSS_MBOOT_TB_FW_CONFIG_STRING	"TB_FW_CONFIG"
30 #define RSS_MBOOT_SOC_FW_CONFIG_STRING	"SOC_FW_CONFIG"
31 #define RSS_MBOOT_RMM_STRING		"RMM"
32 
33 
34 struct rss_mboot_metadata {
35 	unsigned int id;
36 	uint8_t slot;
37 	uint8_t signer_id[SIGNER_ID_MAX_SIZE];
38 	size_t  signer_id_size;
39 	uint8_t version[VERSION_MAX_SIZE];
40 	size_t  version_size;
41 	uint8_t sw_type[SW_TYPE_MAX_SIZE];
42 	size_t  sw_type_size;
43 	bool    lock_measurement;
44 };
45 
46 /* Functions' declarations */
47 void rss_measured_boot_init(void);
48 struct rss_mboot_metadata *plat_rss_mboot_get_metadata(void);
49 int rss_mboot_measure_and_record(uintptr_t data_base, uint32_t data_size,
50 				 uint32_t data_id);
51 
52 /* TODO: These metadata are currently not available during TF-A boot */
53 int rss_mboot_set_signer_id(unsigned int img_id, const void *pk_ptr, size_t pk_len);
54 
55 #endif /* RSS_MEASURED_BOOT_H */
56