Skip to content

Commit 0d5b976

Browse files
jaccoo01adeaarm
authored andcommitted
RSE: Add getter function for RSE ID
Add a function declaration for a function to get the RSE ID and a default implementation which fetches the value from the OTP. Platforms can define their own version of this function in the case where the RSE ID is not in the OTP. Change-Id: I8d932aa82dbe00bb52376ac398ab8d6284fec0fd Signed-off-by: Jackson Cooper-Driver <[email protected]>
1 parent 9d4d04e commit 0d5b976

File tree

7 files changed

+65
-10
lines changed

7 files changed

+65
-10
lines changed

platform/ext/target/arm/rse/common/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ target_sources(platform_s
249249
$<$<BOOL:${RSE_ENABLE_DCSU_PROVISIONING_COMMS}>:${PLATFORM_DIR}/ext/target/arm/drivers/dcsu/src/dcsu_drv.c>
250250
$<$<BOOL:${RSE_ENABLE_DCSU_PROVISIONING_COMMS}>:${CMAKE_CURRENT_SOURCE_DIR}/rse_dcsu_hal.c>
251251
./platform_shared_measurement_data.c
252+
$<$<BOOL:${RSE_OTP_HAS_RSE_ID}>:${CMAKE_CURRENT_SOURCE_DIR}/rse_get_rse_id_from_otp.c>
252253
)
253254

254255
target_sources(tfm_sprt
@@ -368,6 +369,7 @@ target_sources(platform_bl2
368369
./dpa_hardened_word_copy.c
369370
./rse_persistent_data.c
370371
./platform_shared_measurement_data.c
372+
$<$<BOOL:${RSE_OTP_HAS_RSE_ID}>:${CMAKE_CURRENT_SOURCE_DIR}/rse_get_rse_id_from_otp.c>
371373
)
372374

373375
target_include_directories(platform_bl2
@@ -487,6 +489,7 @@ target_sources(platform_bl1_1
487489
./platform_shared_measurement_data.c
488490
./rse_soc_uid.c
489491
${PLATFORM_DIR}/ext/target/arm/drivers/mpu/armv8m/mpu_armv8m_drv.c
492+
$<$<BOOL:${RSE_OTP_HAS_RSE_ID}>:${CMAKE_CURRENT_SOURCE_DIR}/rse_get_rse_id_from_otp.c>
490493
)
491494

492495
target_compile_definitions(platform_bl1_1

platform/ext/target/arm/rse/common/bl1/bl1_1_shared_symbols.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,4 @@ tfm_plat_increment_nv_counter
131131
rse_count_zero_bits
132132
rse_get_sender_routing_tables
133133
rse_get_receiver_routing_tables
134+
rse_get_rse_id
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef __RSE_GET_RSE_ID_H__
9+
#define __RSE_GET_RSE_ID_H__
10+
11+
#include <stdint.h>
12+
13+
#ifdef __cplusplus
14+
extern "C" {
15+
#endif
16+
17+
enum tfm_plat_err_t rse_get_rse_id(uint32_t *rse_id);
18+
19+
#ifdef __cplusplus
20+
}
21+
#endif
22+
23+
#endif /* __RSE_GET_RSE_ID_H__ */
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#include <stdint.h>
9+
#include <stddef.h>
10+
11+
#include "platform_error_codes.h"
12+
#include "rse_get_rse_id.h"
13+
#include "tfm_plat_otp.h"
14+
15+
/* Default implementation of rse_get_rse_id. Platforms should implement their own version of this function
16+
* when the RSE ID is not in the OTP */
17+
18+
enum tfm_plat_err_t rse_get_rse_id(uint32_t *rse_id)
19+
{
20+
enum tfm_plat_err_t plat_err;
21+
22+
plat_err = tfm_plat_otp_read(PLAT_OTP_ID_RSE_ID, sizeof(*rse_id), (uint8_t *)rse_id);
23+
if (plat_err != TFM_PLAT_ERR_SUCCESS) {
24+
return plat_err;
25+
}
26+
27+
return TFM_PLAT_ERR_SUCCESS;
28+
}

platform/ext/target/arm/rse/common/rse_handshake/rse_handshake.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "dpa_hardened_word_copy.h"
2929
#include "rse_routing_tables.h"
3030
#include "rse_get_routing_tables.h"
31+
#include "rse_get_rse_id.h"
3132

3233
#include <string.h>
3334

@@ -87,16 +88,17 @@ static enum tfm_plat_err_t header_init(struct rse_handshake_msg *msg,
8788
{
8889
enum tfm_plat_err_t plat_err;
8990
cc3xx_err_t cc_err;
91+
uint32_t rse_id;
9092

9193
msg->header.type = type;
9294

93-
plat_err = tfm_plat_otp_read(PLAT_OTP_ID_RSE_ID,
94-
sizeof(msg->header.rse_id),
95-
(uint8_t*)&msg->header.rse_id);
95+
plat_err = rse_get_rse_id(&rse_id);
9696
if (plat_err != TFM_PLAT_ERR_SUCCESS) {
9797
return plat_err;
9898
}
9999

100+
msg->header.rse_id = rse_id;
101+
100102
cc_err = cc3xx_lowlevel_rng_get_random((uint8_t *)&msg->header.ccm_iv,
101103
sizeof(msg->header.ccm_iv),
102104
CC3XX_RNG_DRBG);
@@ -515,7 +517,7 @@ enum tfm_plat_err_t rse_handshake(uint32_t *vhuk_seeds_buf)
515517
uint32_t rse_id;
516518
enum tfm_plat_err_t plat_err;
517519

518-
plat_err = tfm_plat_otp_read(PLAT_OTP_ID_RSE_ID, sizeof(rse_id), (uint8_t *)&rse_id);
520+
plat_err = rse_get_rse_id(&rse_id);
519521
if (plat_err != TFM_PLAT_ERR_SUCCESS) {
520522
return plat_err;
521523
}

platform/ext/target/arm/rse/neoverse_rd/rdv3/host_system.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "host_system.h"
1515
#include "tfm_hal_device_header.h"
1616
#include "tfm_plat_otp.h"
17+
#include "rse_get_rse_id.h"
1718
#ifdef RD_SYSCTRL_NOC_S3
1819
#include "noc_s3_lib.h"
1920

@@ -284,9 +285,7 @@ static int read_chip_id(uint32_t *chip_id)
284285
int err;
285286
uint32_t otp_chip_id;
286287

287-
err = tfm_plat_otp_read(PLAT_OTP_ID_RSE_ID,
288-
sizeof(otp_chip_id),
289-
(uint8_t*)&otp_chip_id);
288+
err = rse_get_rse_id(&otp_chip_id);
290289
if (err != 0)
291290
return err;
292291

platform/ext/target/arm/rse/neoverse_rd/rdv3r1/host_system.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "host_system.h"
1414
#include "tfm_hal_device_header.h"
1515
#include "tfm_plat_otp.h"
16+
#include "rse_get_rse_id.h"
1617
#ifdef RD_SYSCTRL_NOC_S3
1718
#include "noc_s3_lib.h"
1819

@@ -285,9 +286,7 @@ static int read_chip_id(uint32_t *chip_id)
285286
int err;
286287
uint32_t otp_chip_id;
287288

288-
err = tfm_plat_otp_read(PLAT_OTP_ID_RSE_ID,
289-
sizeof(otp_chip_id),
290-
(uint8_t*)&otp_chip_id);
289+
err = rse_get_rse_id(&otp_chip_id);
291290
if (err != 0)
292291
return err;
293292

0 commit comments

Comments
 (0)