1 /*
2 * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <assert.h>
8 #include <stdint.h>
9
10 #include <common/desc_image_load.h>
11 #include <drivers/measured_boot/event_log/event_log.h>
12 #include <drivers/measured_boot/rss/rss_measured_boot.h>
13 #include <plat/arm/common/plat_arm.h>
14 #include <plat/common/platform.h>
15
16 extern event_log_metadata_t fvp_event_log_metadata[];
17 extern struct rss_mboot_metadata fvp_rss_mboot_metadata[];
18
plat_event_log_get_metadata(void)19 const event_log_metadata_t *plat_event_log_get_metadata(void)
20 {
21 return fvp_event_log_metadata;
22 }
23
plat_rss_mboot_get_metadata(void)24 struct rss_mboot_metadata *plat_rss_mboot_get_metadata(void)
25 {
26 return fvp_rss_mboot_metadata;
27 }
28
plat_mboot_measure_image(unsigned int image_id,image_info_t * image_data)29 int plat_mboot_measure_image(unsigned int image_id, image_info_t *image_data)
30 {
31 int err;
32 int rc = 0;
33
34 /* Calculate image hash and record data in Event Log */
35 err = event_log_measure_and_record(image_data->image_base,
36 image_data->image_size,
37 image_id);
38 if (err != 0) {
39 ERROR("%s%s image id %u (%i)\n",
40 "Failed to ", "record in event log", image_id, err);
41 rc = err;
42 }
43
44 /* Calculate image hash and record data in RSS */
45 err = rss_mboot_measure_and_record(image_data->image_base,
46 image_data->image_size,
47 image_id);
48 if (err != 0) {
49 ERROR("%s%s image id %u (%i)\n",
50 "Failed to ", "record in RSS", image_id, err);
51 rc = (rc == 0) ? err : -1;
52 }
53
54 return rc;
55 }
56