Tamas Ban | a426089 | 2023-06-07 13:35:04 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2024, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stdint.h> |
| 8 | |
Tamas Ban | 0fbe862 | 2023-06-12 11:33:47 +0200 | [diff] [blame^] | 9 | #include <common/debug.h> |
Tamas Ban | a426089 | 2023-06-07 13:35:04 +0200 | [diff] [blame] | 10 | #include <drivers/arm/rss_comms.h> |
| 11 | #include <drivers/measured_boot/metadata.h> |
| 12 | #include <drivers/measured_boot/rss/dice_prot_env.h> |
| 13 | #include <plat/arm/common/plat_arm.h> |
| 14 | #include <plat/common/platform.h> |
| 15 | #include <platform_def.h> |
| 16 | #include <tools_share/zero_oid.h> |
| 17 | |
| 18 | struct dpe_metadata tc_dpe_metadata[] = { |
| 19 | { |
| 20 | .id = FW_CONFIG_ID, |
| 21 | .signer_id_size = SIGNER_ID_MIN_SIZE, |
| 22 | .sw_type = MBOOT_FW_CONFIG_STRING, |
| 23 | .allow_new_context_to_derive = false, |
| 24 | .retain_parent_context = true, |
| 25 | .create_certificate = false, |
| 26 | .pk_oid = ZERO_OID }, |
| 27 | { |
| 28 | .id = TB_FW_CONFIG_ID, |
| 29 | .signer_id_size = SIGNER_ID_MIN_SIZE, |
| 30 | .sw_type = MBOOT_TB_FW_CONFIG_STRING, |
| 31 | .allow_new_context_to_derive = false, |
| 32 | .retain_parent_context = true, |
| 33 | .create_certificate = false, |
| 34 | .pk_oid = ZERO_OID }, |
| 35 | { |
| 36 | .id = BL2_IMAGE_ID, |
| 37 | .signer_id_size = SIGNER_ID_MIN_SIZE, |
| 38 | .sw_type = MBOOT_BL2_IMAGE_STRING, |
| 39 | .allow_new_context_to_derive = true, |
| 40 | .retain_parent_context = false, |
| 41 | .create_certificate = false, |
| 42 | .pk_oid = ZERO_OID }, |
| 43 | { |
| 44 | .id = DPE_INVALID_ID } |
| 45 | }; |
| 46 | |
Tamas Ban | 0fbe862 | 2023-06-12 11:33:47 +0200 | [diff] [blame^] | 47 | /* Context handle is meant to be used by BL2. Sharing it via TB_FW_CONFIG */ |
| 48 | static int new_ctx_handle; |
| 49 | |
| 50 | void plat_dpe_share_context_handle(int *ctx_handle) |
| 51 | { |
| 52 | new_ctx_handle = *ctx_handle; |
| 53 | } |
Tamas Ban | a426089 | 2023-06-07 13:35:04 +0200 | [diff] [blame] | 54 | |
| 55 | void bl1_plat_mboot_init(void) |
| 56 | { |
| 57 | /* Initialize the communication channel between AP and RSS */ |
| 58 | (void)rss_comms_init(PLAT_RSS_AP_SND_MHU_BASE, |
| 59 | PLAT_RSS_AP_RCV_MHU_BASE); |
| 60 | |
| 61 | dpe_init(tc_dpe_metadata); |
| 62 | } |
| 63 | |
| 64 | void bl1_plat_mboot_finish(void) |
| 65 | { |
Tamas Ban | 0fbe862 | 2023-06-12 11:33:47 +0200 | [diff] [blame^] | 66 | int rc; |
| 67 | |
| 68 | VERBOSE("Share DPE context handle with BL2: 0x%x\n", new_ctx_handle); |
| 69 | rc = arm_set_tb_fw_info(&new_ctx_handle); |
| 70 | if (rc != 0) { |
| 71 | ERROR("Unable to set DPE context handle in TB_FW_CONFIG\n"); |
| 72 | /* |
| 73 | * It is a fatal error because on TC platform, BL2 software |
| 74 | * assumes that a valid DPE context_handle is passed through |
| 75 | * the DTB object by BL1. |
| 76 | */ |
| 77 | plat_panic_handler(); |
| 78 | } |
Tamas Ban | a426089 | 2023-06-07 13:35:04 +0200 | [diff] [blame] | 79 | } |