Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 0eb7c91

Browse files
Summer-ARMkenlsoft
authored andcommitted
HAL: Rename platform init function
Align with HAL design document: - Rename 'tfm_spm_hal_post_init' to 'tfm_hal_platform_init'. - Set 'tfm_hal_platform_init' to weak, and platform with specific init operation needs to override it. - Remove 'tfm_spm_hal_post_init_platform' and move the operations to 'tfm_hal_platform_init'. Change-Id: Ia96b3a6bae716d154edab8709eb6e277bafcb45e Signed-off-by: Summer Qin <[email protected]>
1 parent bce2113 commit 0eb7c91

File tree

7 files changed

+34
-57
lines changed

7 files changed

+34
-57
lines changed

platform/ext/common/tfm_platform.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,14 @@
88
#include "target_cfg.h"
99
#include "tfm_spm_hal.h"
1010
#include "uart_stdout.h"
11+
#include "tfm_hal_platform.h"
1112

12-
/* platform-specific hw initialization */
13-
__WEAK enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void)
13+
__WEAK enum tfm_hal_status_t tfm_hal_platform_init(void)
1414
{
15-
return TFM_PLAT_ERR_SUCCESS;
16-
}
17-
18-
enum tfm_plat_err_t tfm_spm_hal_post_init(void)
19-
{
20-
if (tfm_spm_hal_post_init_platform() != TFM_PLAT_ERR_SUCCESS) {
21-
return TFM_PLAT_ERR_SYSTEM_ERR;
22-
}
23-
2415
__enable_irq();
2516
stdio_init();
2617

27-
return TFM_PLAT_ERR_SUCCESS;
18+
return TFM_HAL_SUCCESS;
2819
}
2920

3021
__WEAK void tfm_hal_system_reset(void)

platform/ext/target/cypress/psoc64/spm_hal.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <string.h>
1212

1313
#include "tfm_spm_hal.h"
14+
#include "tfm_hal_platform.h"
1415

1516
#include "device_definition.h"
1617
#include "region_defs.h"
@@ -417,12 +418,15 @@ void mock_tfm_shared_data(void)
417418
memcpy(boot_data, mock_data, sizeof(mock_data));
418419
}
419420

420-
enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void)
421+
enum tfm_hal_status_t tfm_hal_platform_init(void)
421422
{
422423
platform_init();
423424

424425
/* FIXME: Use the actual data from mcuboot */
425426
mock_tfm_shared_data();
426427

427-
return TFM_PLAT_ERR_SUCCESS;
428+
__enable_irq();
429+
stdio_init();
430+
431+
return TFM_HAL_SUCCESS;
428432
}

platform/ext/target/stm/stm32l5xx/secure/tfm_platform_system.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "tfm_spm_hal.h"
1111
#include "uart_stdout.h"
1212
#include "tfm_platform_system.h"
13+
#include "tfm_hal_platform.h"
14+
1315
void tfm_platform_hal_system_reset(void)
1416
{
1517
/* Reset the system */
@@ -23,30 +25,19 @@ tfm_platform_hal_pin_service(const psa_invec *in_vec, uint32_t num_invec,
2325
return TFM_PLAT_ERR_SYSTEM_ERR;
2426
}
2527

26-
__WEAK enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void)
27-
{
28-
return TFM_PLAT_ERR_SUCCESS;
29-
}
30-
31-
enum tfm_plat_err_t tfm_spm_hal_post_init(void)
28+
enum tfm_hal_status_t tfm_hal_platform_init(void)
3229
{
33-
if (tfm_spm_hal_post_init_platform() != TFM_PLAT_ERR_SUCCESS) {
34-
return TFM_PLAT_ERR_SYSTEM_ERR;
35-
}
36-
3730
__enable_irq();
3831
stdio_init();
3932

40-
return TFM_PLAT_ERR_SUCCESS;
33+
return TFM_HAL_SUCCESS;
4134
}
4235

4336
__WEAK void tfm_hal_system_reset(void)
4437
{
4538
NVIC_SystemReset();
4639
}
4740

48-
49-
5041
enum tfm_platform_err_t tfm_platform_hal_ioctl(tfm_platform_ioctl_req_t request,
5142
psa_invec *in_vec,
5243
psa_outvec *out_vec)

platform/include/tfm_hal_platform.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
#ifndef __TFM_HAL_PLATFORM_H__
99
#define __TFM_HAL_PLATFORM_H__
1010

11+
#include "tfm_hal_defs.h"
12+
13+
/**
14+
* \brief This function performs the platform-specific initialization.
15+
*
16+
* This function is called after architecture and platform common initialization
17+
* has finished during system early startup.
18+
*
19+
* \retval TFM_HAL_SUCCESS Init success.
20+
* \retval TFM_HAL_ERROR_GENERIC Generic errors.
21+
*/
22+
enum tfm_hal_status_t tfm_hal_platform_init(void);
23+
1124
/**
1225
* \brief System reset
1326
*/

platform/include/tfm_spm_hal.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,6 @@ struct tfm_spm_partition_memory_data_t
6868
};
6969
#endif
7070

71-
/**
72-
* \brief This function initializes peripherals common to all platforms.
73-
*
74-
* Contrarily to SystemInit() intended for a high-priority hw initialization
75-
* (for example clock and power subsystems), and called on a very early boot
76-
* stage from startup code, this function is called from C code, hence variables
77-
* and other drivers data are protected from being cleared up by the C library
78-
* init.
79-
* In addition to performing initialization common to all platforms, it also
80-
* calls tfm_spm_hal_post_init_platform() function which implements
81-
* initialization of platform-specific peripherals and other hw.
82-
*
83-
* \return Returns values as specified by the \ref tfm_plat_err_t
84-
*/
85-
enum tfm_plat_err_t tfm_spm_hal_post_init(void);
86-
87-
/**
88-
* \brief This function initializes platform-specific peripherals and hardware.
89-
*
90-
* Called from tfm_spm_hal_post_init(), this function is intended for
91-
* platform-specific portion of hardware initialization.
92-
*
93-
* \return Returns values as specified by the \ref tfm_plat_err_t
94-
*/
95-
enum tfm_plat_err_t tfm_spm_hal_post_init_platform(void);
96-
9771
/**
9872
* \brief This function initialises the HW used for isolation, and sets the
9973
* default configuration for them.

secure_fw/spm/cmsis_func/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "log/tfm_log.h"
99
#include "region.h"
1010
#include "spm_func.h"
11+
#include "tfm_hal_platform.h"
1112
#include "tfm_internal.h"
1213
#include "tfm_irq_list.h"
1314
#include "tfm_nspm.h"
@@ -33,6 +34,7 @@ REGION_DECLARE(Image$$, ARM_LIB_STACK_MSP, $$ZI$$Base);
3334
static int32_t tfm_core_init(void)
3435
{
3536
size_t i;
37+
enum tfm_hal_status_t hal_status = TFM_HAL_ERROR_GENERIC;
3638
enum tfm_plat_err_t plat_err = TFM_PLAT_ERR_SYSTEM_ERR;
3739
enum irq_target_state_t irq_target_state = TFM_IRQ_TARGET_STATE_SECURE;
3840

@@ -64,8 +66,8 @@ static int32_t tfm_core_init(void)
6466
}
6567

6668
/* Performs platform specific initialization */
67-
plat_err = tfm_spm_hal_post_init();
68-
if (plat_err != TFM_PLAT_ERR_SUCCESS) {
69+
hal_status = tfm_hal_platform_init();
70+
if (hal_status != TFM_HAL_SUCCESS) {
6971
return TFM_ERROR_GENERIC;
7072
}
7173

secure_fw/spm/cmsis_psa/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "log/tfm_log.h"
99
#include "region.h"
1010
#include "spm_ipc.h"
11+
#include "tfm_hal_platform.h"
1112
#include "tfm_internal.h"
1213
#include "tfm_irq_list.h"
1314
#include "tfm_nspm.h"
@@ -33,6 +34,7 @@ REGION_DECLARE(Image$$, ARM_LIB_STACK_MSP, $$ZI$$Base);
3334
static int32_t tfm_core_init(void)
3435
{
3536
size_t i;
37+
enum tfm_hal_status_t hal_status = TFM_HAL_ERROR_GENERIC;
3638
enum tfm_plat_err_t plat_err = TFM_PLAT_ERR_SYSTEM_ERR;
3739
enum irq_target_state_t irq_target_state = TFM_IRQ_TARGET_STATE_SECURE;
3840

@@ -64,8 +66,8 @@ static int32_t tfm_core_init(void)
6466
}
6567

6668
/* Performs platform specific initialization */
67-
plat_err = tfm_spm_hal_post_init();
68-
if (plat_err != TFM_PLAT_ERR_SUCCESS) {
69+
hal_status = tfm_hal_platform_init();
70+
if (hal_status != TFM_HAL_SUCCESS) {
6971
return TFM_ERROR_GENERIC;
7072
}
7173

0 commit comments

Comments
 (0)