1 /*
2  * Copyright (c) 2019-2023, Arm Limited. All rights reserved.
3  * Copyright (c) 2022-2024 Cypress Semiconductor Corporation (an Infineon
4  * company) or an affiliate of Cypress Semiconductor Corporation. All rights
5  * reserved.
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  *
9  */
10 
11 #include "ffm/psa_api.h"
12 #include "load/service_defs.h"
13 #include "spm.h"
14 
tfm_spm_client_psa_framework_version(void)15 uint32_t tfm_spm_client_psa_framework_version(void)
16 {
17     return PSA_FRAMEWORK_VERSION;
18 }
19 
tfm_spm_client_psa_version(uint32_t sid)20 uint32_t tfm_spm_client_psa_version(uint32_t sid)
21 {
22     const struct service_t *service;
23     bool ns_caller = tfm_spm_is_ns_caller();
24 
25     /*
26      * It should return PSA_VERSION_NONE if the RoT Service is not
27      * implemented.
28      */
29     service = tfm_spm_get_service_by_sid(sid);
30     if (!service) {
31         return PSA_VERSION_NONE;
32     }
33 
34     /*
35      * It should return PSA_VERSION_NONE if the caller is not authorized
36      * to access the RoT Service.
37      */
38     if (tfm_spm_check_authorization(sid, service, ns_caller) != PSA_SUCCESS) {
39         return PSA_VERSION_NONE;
40     }
41 
42     return service->p_ldinf->version;
43 }
44