File tree Expand file tree Collapse file tree 5 files changed +66
-0
lines changed
ext/target/nordic_nrf/common/core
secure_fw/partitions/platform Expand file tree Collapse file tree 5 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ extern "C" {
2727#define TFM_PLATFORM_API_ID_NV_INCREMENT (1011)
2828#define TFM_PLATFORM_API_ID_SYSTEM_RESET (1012)
2929#define TFM_PLATFORM_API_ID_IOCTL (1013)
30+ #define TFM_PLATFORM_API_ID_SYSTEM_OFF (1014)
3031
3132/*!
3233 * \enum tfm_platform_err_t
@@ -53,6 +54,14 @@ typedef int32_t tfm_platform_ioctl_req_t;
5354 */
5455enum tfm_platform_err_t tfm_platform_system_reset (void );
5556
57+ /*!
58+ * \brief System off function to move the system to the lowest power state
59+ *
60+ * \return On success the processor will go to system off, in case of error it returns
61+ * values as specified by the \ref tfm_platform_err_t
62+ */
63+ enum tfm_platform_err_t tfm_platform_system_off (void );
64+
5665/*!
5766 * \brief Performs a platform-specific service
5867 *
Original file line number Diff line number Diff line change @@ -26,6 +26,21 @@ enum tfm_platform_err_t tfm_platform_system_reset(void)
2626
2727}
2828
29+ enum tfm_platform_err_t tfm_platform_system_off (void )
30+ {
31+ psa_status_t status = PSA_ERROR_CONNECTION_REFUSED ;
32+
33+ status = psa_call (TFM_PLATFORM_SERVICE_HANDLE ,
34+ TFM_PLATFORM_API_ID_SYSTEM_OFF ,
35+ NULL , 0 , NULL , 0 );
36+
37+ if (status < PSA_SUCCESS ) {
38+ return TFM_PLATFORM_ERR_SYSTEM_ERROR ;
39+ } else {
40+ return (enum tfm_platform_err_t )status ;
41+ }
42+ }
43+
2944enum tfm_platform_err_t
3045tfm_platform_ioctl (tfm_platform_ioctl_req_t request ,
3146 psa_invec * input , psa_outvec * output )
Original file line number Diff line number Diff line change @@ -158,6 +158,18 @@ if(TFM_SPM_LOG_RAW_ENABLED)
158158 )
159159endif ()
160160
161+ if (TFM_NRF_SYSTEM_OFF_SERVICE)
162+ target_sources (platform_s
163+ PRIVATE
164+ ${HAL_NORDIC_PATH} /nrfx/helpers/nrfx_ram_ctrl.c
165+ )
166+
167+ target_compile_definitions (platform_s
168+ PUBLIC
169+ TFM_NRF_SYSTEM_OFF_SERVICE
170+ )
171+ endif ()
172+
161173target_compile_options (platform_s
162174 PUBLIC
163175 ${COMPILER_CMSE_FLAG}
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ extern "C" {
2828TFM_LINK_SET_RO_IN_PARTITION_SECTION ("TFM_SP_PLATFORM" , "PSA-ROT" )
2929void tfm_platform_hal_system_reset (void );
3030
31+ /**
32+ * \brief Set system power state to off.
33+ *
34+ * \details Requests the system to enter a low-power state.
35+ */
36+ TFM_LINK_SET_RO_IN_PARTITION_SECTION ("TFM_SP_PLATFORM" , "PSA-ROT" )
37+ enum tfm_platform_err_t tfm_platform_hal_system_off (void );
38+
3139/*!
3240 * \brief Performs a platform-specific service
3341 *
Original file line number Diff line number Diff line change @@ -39,6 +39,24 @@ enum tfm_platform_err_t platform_sp_system_reset(void)
3939 return TFM_PLATFORM_ERR_SUCCESS ;
4040}
4141
42+ #if TFM_NRF_SYSTEM_OFF_SERVICE
43+ enum tfm_platform_err_t platform_sp_system_off (void )
44+ {
45+ /* FIXME: The system off functionality is only supported in isolation
46+ * level 1.
47+ */
48+
49+ return tfm_platform_hal_system_off ();
50+ }
51+
52+ static psa_status_t platform_sp_system_off_psa_api (const psa_msg_t * msg )
53+ {
54+ (void )msg ; /* unused parameter */
55+
56+ return platform_sp_system_off ();
57+ }
58+ #endif /* TFM_NRF_SYSTEM_OFF_SERVICE */
59+
4260static psa_status_t platform_sp_system_reset_psa_api (const psa_msg_t * msg )
4361{
4462 (void )msg ; /* unused parameter */
@@ -225,6 +243,10 @@ psa_status_t tfm_platform_service_sfn(const psa_msg_t *msg)
225243#endif /* PLATFORM_NV_COUNTER_MODULE_DISABLED */
226244 case TFM_PLATFORM_API_ID_SYSTEM_RESET :
227245 return platform_sp_system_reset_psa_api (msg );
246+ #if TFM_NRF_SYSTEM_OFF_SERVICE
247+ case TFM_PLATFORM_API_ID_SYSTEM_OFF :
248+ return platform_sp_system_off_psa_api (msg );
249+ #endif /* TFM_NRF_SYSTEM_OFF_SERVICE */
228250 case TFM_PLATFORM_API_ID_IOCTL :
229251 return platform_sp_ioctl_psa_api (msg );
230252 default :
You can’t perform that action at this time.
0 commit comments