1 /*
2  * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
3  * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
4  * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  */
9 
10 #ifndef __TFM_HAL_PLATFORM_H__
11 #define __TFM_HAL_PLATFORM_H__
12 
13 #include <stddef.h>
14 #include <stdint.h>
15 
16 #include "fih.h"
17 #include "tfm_hal_defs.h"
18 #include "cmsis_compiler.h"
19 
20 /**
21  * \brief This function performs the platform-specific initialization.
22  *
23  * This function is called after architecture and platform common initialization
24  * has finished during system early startup.
25  *
26  * \retval TFM_HAL_SUCCESS          Init success.
27  * \retval TFM_HAL_ERROR_GENERIC    Generic errors.
28  */
29 FIH_RET_TYPE(enum tfm_hal_status_t) tfm_hal_platform_init(void);
30 
31 /**
32  * \brief Get system reset syndrome
33  *
34  * \return Returns the reset syndrome value
35  */
36 uint32_t tfm_hal_get_reset_syndrome(void);
37 
38 /**
39  * \brief Clear a particular system reset syndrome bit
40  *
41  * \param[in] bit_pos       Bit position to clear
42  */
43 void tfm_hal_clear_reset_syndrome_bit(uint8_t bit_pos);
44 
45 /**
46  * \brief System reset
47  */
48 __NO_RETURN void tfm_hal_system_reset(void);
49 
50 /**
51  * \brief System halt
52  */
53 __NO_RETURN void tfm_hal_system_halt(void);
54 
55 /**
56  * \brief Set up the RNG for use with random delays.
57  *
58  * \retval TFM_HAL_SUCCESS        Platform specific random number generation
59  *                                initialization succeeded.
60  * \retval Other code             Initialization failed.
61  */
62 int32_t tfm_hal_random_init(void);
63 
64 /**
65  * \brief Get a random number from an RNG seeded with an entropy source.
66  *
67  * \param[out] rand               Buffer to hold the random value
68  * \param[in] size                The size of the buffer
69  *
70  * \retval TFM_HAL_SUCCESS        Platform specific random number generation
71  *                                succeed.
72  * \retval Other code             generation failed.
73  */
74 int32_t tfm_hal_random_generate(uint8_t *rand, size_t size);
75 
76 /**
77  * \brief Get the VTOR value of non-secure image
78  *
79  * \return Returns the address where the vector table of the non-secure image
80  *         is located
81  */
82 uint32_t tfm_hal_get_ns_VTOR(void);
83 
84 /**
85  * \brief Get the entry point of the non-secure image
86  *
87  * \return Returns the address of the non-secure image entry point
88  */
89 uint32_t tfm_hal_get_ns_entry_point(void);
90 
91 #ifdef TFM_PARTITION_NS_AGENT_TZ
92 /**
93  * \brief Get the initial address of non-secure image main stack
94  *
95  * \return Returns the initial non-secure MSP
96  */
97 uint32_t tfm_hal_get_ns_MSP(void);
98 #endif /* TFM_PARTITION_NS_AGENT_TZ */
99 
100 #endif /* __TFM_HAL_PLATFORM_H__ */
101