Skip to content

Commit 525d463

Browse files
authored
Merge pull request #9997 from kfnta/alzix/platform_rename
platform reset API rename
2 parents ba24cb2 + 661613c commit 525d463

File tree

10 files changed

+34
-30
lines changed

10 files changed

+34
-30
lines changed

TESTS/psa/attestation/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Specification specification(greentea_test_setup, cases);
136136
int main()
137137
{
138138
psa_status_t status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
139-
TEST_ASSERT_EQUAL(PSA_LIFECYCLE_SUCCESS, status);
139+
TEST_ASSERT_EQUAL(PSA_SUCCESS, status);
140140
#if (defined(COMPONENT_PSA_SRV_IPC) || defined(MBEDTLS_ENTROPY_NV_SEED))
141141
uint8_t seed[MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE] = {0};
142142
/* inject some seed for test*/

TESTS/psa/its_ps/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ utest::v1::status_t case_its_teardown_handler(const Case *const source, const si
157157
{
158158
psa_status_t status;
159159
status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
160-
TEST_ASSERT_EQUAL(PSA_LIFECYCLE_SUCCESS, status);
160+
TEST_ASSERT_EQUAL(PSA_SUCCESS, status);
161161
return greentea_case_teardown_handler(source, passed, failed, reason);
162162
}
163163

@@ -167,7 +167,7 @@ utest::v1::status_t case_its_setup_handler(const Case *const source, const size_
167167
psa_status_t status;
168168
if (stype == its) {
169169
status = mbed_psa_reboot_and_request_new_security_state(PSA_LIFECYCLE_ASSEMBLY_AND_TEST);
170-
TEST_ASSERT_EQUAL(PSA_LIFECYCLE_SUCCESS, status);
170+
TEST_ASSERT_EQUAL(PSA_SUCCESS, status);
171171
} else {
172172
status = psa_ps_reset();
173173
TEST_ASSERT_EQUAL(PSA_SUCCESS, status);

components/TARGET_PSA/inc/psa/client.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define __MBED_OS_DEFAULT_PSA_CLIENT_API_H__
2727

2828
#include <stddef.h>
29+
#include "psa/error.h"
2930

3031
#if !defined(UINT32_MAX)
3132
#define UINT32_MAX ((uint32_t)-1)
@@ -37,13 +38,11 @@
3738

3839
#define PSA_FRAMEWORK_VERSION (0x0100) /**< Version of the PSA Framework API. */
3940
#define PSA_VERSION_NONE (0L) /**< Identifier for an unimplemented Root of Trust (RoT) Service. */
40-
#define PSA_SUCCESS (0L) /**< A general result code for calls to psa_call() indicating success.*/
4141
#define PSA_CONNECTION_REFUSED (INT32_MIN + 1) /**< The return value from psa_connect() if the RoT Service or SPM was unable to establish a connection.*/
4242
#define PSA_CONNECTION_BUSY (INT32_MIN + 2) /**< The return value from psa_connect() if the RoT Service rejects the connection for a transient reason.*/
4343
#define PSA_DROP_CONNECTION (INT32_MIN) /**< The result code in a call to psa_reply() to indicate a nonrecoverable error in the client.*/
4444
#define PSA_NULL_HANDLE ((psa_handle_t)0) /**< Denotes an invalid handle.*/
4545

46-
typedef int32_t psa_status_t;
4746
typedef int32_t psa_handle_t;
4847

4948
typedef struct psa_invec {

components/TARGET_PSA/inc/psa/lifecycle.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424

2525
#include <stddef.h>
2626
#include <stdint.h>
27+
#include "mbed_toolchain.h"
28+
#include "psa/error.h"
2729

2830
#ifdef __cplusplus
2931
extern "C"
3032
{
3133
#endif
3234

33-
typedef int32_t psa_status_t;
34-
3535
#define PSA_LIFECYCLE_STATE_MASK (0xff00u) /**< A mask value that extracts the main lifecycle state */
3636
#define PSA_LIFECYCLE_SUBSTATE_MASK (0x00ffu) /**< A mask value that extracts the IMPLEMENTATION DEFINED lifecycle sub-state */
3737

@@ -43,9 +43,6 @@ typedef int32_t psa_status_t;
4343
#define PSA_LIFECYCLE_RECOVERABLE_PSA_ROT_DEBUG (0x5000u) /**< Recoverable PSA RoT Debug state */
4444
#define PSA_LIFECYCLE_DECOMMISSIONED (0x6000u) /**< Decommissioned state */
4545

46-
#define PSA_LIFECYCLE_SUCCESS 0
47-
#define PSA_LIFECYCLE_ERROR (INT32_MIN + 1000)
48-
4946
/** \brief Get PSA RoT lifecycle state
5047
*
5148
* \retval The main state and sub-state are encoded as follows:@n
@@ -56,16 +53,24 @@ uint32_t psa_security_lifecycle_state(void);
5653

5754
/** \brief Request state change
5855
*
59-
* State change requested and the system.
60-
* TODO when not drunk
56+
* State change requested and the reset the system.
57+
* \note System reset will not be performed when switching from PSA_LIFECYCLE_ASSEMBLY_AND_TEST
58+
* to PSA_LIFECYCLE_ASSEMBLY_AND_TEST.
59+
*
60+
* \note state change to follwing states will delete PSA internal storage:
61+
* - PSA_LIFECYCLE_ASSEMBLY_AND_TEST
62+
* - PSA_LIFECYCLE_PSA_ROT_PROVISIONING
63+
* - PSA_LIFECYCLE_DECOMMISSIONED
6164
*/
6265
psa_status_t mbed_psa_reboot_and_request_new_security_state(uint32_t new_state);
6366

6467

6568
/** \brief Resets the system
6669
*
70+
* PSA targets do not allow NSPE to access system power domain.
71+
* This API requests system reset to be carried out by SPE once all critical secure tasks are finished.
6772
*/
68-
void psa_system_reset();
73+
MBED_NORETURN void mbed_psa_system_reset();
6974

7075
#ifdef __cplusplus
7176
}

components/TARGET_PSA/services/platform/COMPONENT_PSA_SRV_EMUL/platform_emul.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
uint32_t psa_security_lifecycle_state(void)
2222
{
2323
uint32_t lc_state = 0;
24-
psa_status_t status = PSA_LIFECYCLE_SUCCESS;
24+
psa_status_t status = PSA_SUCCESS;
2525
status = psa_platfrom_lifecycle_get_impl(&lc_state);
26-
if (status != PSA_LIFECYCLE_SUCCESS) {
26+
if (status != PSA_SUCCESS) {
2727
lc_state = PSA_LIFECYCLE_UNKNOWN;
2828
}
2929
return lc_state;
@@ -34,7 +34,7 @@ psa_status_t mbed_psa_reboot_and_request_new_security_state(uint32_t new_state)
3434
return psa_platfrom_lifecycle_change_request_impl(new_state);
3535
}
3636

37-
void psa_system_reset(void)
37+
void mbed_psa_system_reset(void)
3838
{
39-
psa_system_reset_impl();
39+
mbed_psa_system_reset_impl();
4040
}

components/TARGET_PSA/services/platform/COMPONENT_PSA_SRV_IMPL/platform_srv_impl.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "psa/lifecycle.h"
1919
#include "psa/internal_trusted_storage.h"
2020
#include "platform_srv_impl.h"
21-
#include "mbed_toolchain.h"
2221
#include "cmsis.h"
2322

2423
#ifndef MBED_CONF_LIFECYCLE_STATE
@@ -28,7 +27,7 @@
2827
psa_status_t psa_platfrom_lifecycle_get_impl(uint32_t *lc_state)
2928
{
3029
*lc_state = MBED_CONF_LIFECYCLE_STATE;
31-
return PSA_LIFECYCLE_SUCCESS;
30+
return PSA_SUCCESS;
3231
}
3332

3433
psa_status_t psa_its_reset();
@@ -38,10 +37,10 @@ psa_status_t psa_platfrom_lifecycle_change_request_impl(uint32_t state)
3837
if (PSA_LIFECYCLE_ASSEMBLY_AND_TEST == state) {
3938
return psa_its_reset();
4039
}
41-
return PSA_LIFECYCLE_ERROR;
40+
return PSA_ERROR_NOT_SUPPORTED;
4241
}
4342

44-
MBED_WEAK void psa_system_reset_impl(void)
43+
MBED_WEAK void mbed_psa_system_reset_impl(void)
4544
{
4645
/* Reset the system */
4746
NVIC_SystemReset();

components/TARGET_PSA/services/platform/COMPONENT_PSA_SRV_IMPL/platform_srv_impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
#define __PLATFROM_SRV_IMPL_H__
2020

2121
#include "psa/client.h"
22+
#include "mbed_toolchain.h"
2223

2324
psa_status_t psa_platfrom_lifecycle_get_impl(uint32_t *lc_state);
2425
psa_status_t psa_platfrom_lifecycle_change_request_impl(uint32_t lc_state);
25-
void psa_system_reset_impl(void);
26+
MBED_NORETURN void mbed_psa_system_reset_impl(void);
2627

2728
#endif // __PLATFROM_SRV_IMPL_H__

components/TARGET_PSA/services/platform/COMPONENT_PSA_SRV_IPC/platform_ipc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "psa/lifecycle.h"
2020
#include "psa/client.h"
2121
#include "mbed_toolchain.h"
22+
#include "mbed_error.h"
2223

2324
uint32_t psa_security_lifecycle_state(void)
2425
{
@@ -57,12 +58,11 @@ psa_status_t mbed_psa_reboot_and_request_new_security_state(uint32_t new_state)
5758
return status;
5859
}
5960

60-
MBED_NORETURN void psa_system_reset(void)
61+
void mbed_psa_system_reset(void)
6162
{
6263
psa_handle_t conn = psa_connect(PSA_PLATFORM_SYSTEM_RESET, 1);
63-
if (conn <= PSA_NULL_HANDLE) {
64-
return;
64+
if (conn > PSA_NULL_HANDLE) {
65+
psa_call(conn, NULL, 0, NULL, 0);
6566
}
66-
67-
psa_call(conn, NULL, 0, NULL, 0);
67+
error("reset failed - cannot connect to service handle=%ld", conn);
6868
}

components/TARGET_PSA/services/platform/COMPONENT_SPE/platform_partition.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ static psa_status_t lifecycle_change_request(psa_msg_t *msg)
5252

5353
}
5454

55-
static psa_status_t system_reset_request(psa_msg_t *msg)
55+
static MBED_NORETURN psa_status_t system_reset_request(psa_msg_t *msg)
5656
{
5757
(void)msg;
58-
psa_system_reset_impl();
58+
mbed_psa_system_reset_impl();
5959
}
6060

6161
static void message_handler(psa_msg_t *msg, SignalHandler handler)

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC55S69/TARGET_M33_NS/device/cmsis_nvic_virtual.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121

2222
void __NVIC_TFMSystemReset(void)
2323
{
24-
psa_system_reset();
24+
mbed_psa_system_reset();
2525
}

0 commit comments

Comments
 (0)