Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 1 | From 956b8a8e1dd5702b9c1657f4ec27a7aeddb0758e Mon Sep 17 00:00:00 2001 |
| 2 | From: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> |
| 3 | Date: Mon, 21 Nov 2022 00:08:20 +0000 |
| 4 | Subject: [PATCH] Use the stateless platform service calls |
| 5 | |
| 6 | Calls to psa_connect is not needed and psa_call can be called |
| 7 | directly with a pre defined handle. |
| 8 | |
| 9 | Signed-off-by: Satish Kumar <satish.kumar01@arm.com> |
| 10 | Signed-off-by: Mohamed Omar Asaker <mohamed.omarasaker@arm.com> |
| 11 | Upstream-Status: Inappropriate [Design is to revisted] |
| 12 | |
| 13 | --- |
| 14 | .../provider/capsule_update_provider.c | 24 ++++--------------- |
| 15 | .../provider/corstone1000_fmp_service.c | 10 ++++---- |
| 16 | .../provider/corstone1000_fmp_service.h | 3 +-- |
| 17 | components/service/common/include/psa/sid.h | 6 +++++ |
| 18 | 4 files changed, 16 insertions(+), 27 deletions(-) |
| 19 | |
| 20 | diff --git a/components/service/capsule_update/provider/capsule_update_provider.c b/components/service/capsule_update/provider/capsule_update_provider.c |
| 21 | index 991a2235..6809249f 100644 |
| 22 | --- a/components/service/capsule_update/provider/capsule_update_provider.c |
| 23 | +++ b/components/service/capsule_update/provider/capsule_update_provider.c |
| 24 | @@ -61,7 +61,6 @@ void capsule_update_provider_deinit(struct capsule_update_provider *context) |
| 25 | static rpc_status_t event_handler(uint32_t opcode, struct rpc_caller *caller) |
| 26 | { |
| 27 | uint32_t ioctl_id; |
| 28 | - psa_handle_t handle; |
| 29 | rpc_status_t rpc_status = TS_RPC_CALL_ACCEPTED; |
| 30 | |
| 31 | struct psa_invec in_vec[] = { |
| 32 | @@ -79,31 +78,18 @@ static rpc_status_t event_handler(uint32_t opcode, struct rpc_caller *caller) |
| 33 | case CAPSULE_UPDATE_REQUEST: |
| 34 | /* Openamp call with IOCTL for firmware update*/ |
| 35 | ioctl_id = IOCTL_CORSTONE1000_FWU_FLASH_IMAGES; |
| 36 | - handle = psa_connect(caller, TFM_SP_PLATFORM_IOCTL_SID, |
| 37 | - TFM_SP_PLATFORM_IOCTL_VERSION); |
| 38 | - if (handle <= 0) { |
| 39 | - EMSG("%s Invalid handle", __func__); |
| 40 | - rpc_status = TS_RPC_ERROR_INVALID_PARAMETER; |
| 41 | - return rpc_status; |
| 42 | - } |
| 43 | - psa_call(caller,handle, PSA_IPC_CALL, |
| 44 | + psa_call(caller,TFM_PLATFORM_SERVICE_HANDLE, TFM_PLATFORM_API_ID_IOCTL, |
| 45 | in_vec,IOVEC_LEN(in_vec), NULL, 0); |
| 46 | - set_fmp_image_info(caller, handle); |
| 47 | + set_fmp_image_info(caller); |
| 48 | break; |
| 49 | |
| 50 | case KERNEL_STARTED_EVENT: |
| 51 | ioctl_id = IOCTL_CORSTONE1000_FWU_HOST_ACK; |
| 52 | /*openamp call with IOCTL for kernel start*/ |
| 53 | - handle = psa_connect(caller, TFM_SP_PLATFORM_IOCTL_SID, |
| 54 | - TFM_SP_PLATFORM_IOCTL_VERSION); |
| 55 | - if (handle <= 0) { |
| 56 | - EMSG("%s Invalid handle", __func__); |
| 57 | - rpc_status = TS_RPC_ERROR_INVALID_PARAMETER; |
| 58 | - return rpc_status; |
| 59 | - } |
| 60 | - psa_call(caller,handle, PSA_IPC_CALL, |
| 61 | + |
| 62 | + psa_call(caller,TFM_PLATFORM_SERVICE_HANDLE, TFM_PLATFORM_API_ID_IOCTL, |
| 63 | in_vec,IOVEC_LEN(in_vec), NULL, 0); |
| 64 | - set_fmp_image_info(caller, handle); |
| 65 | + set_fmp_image_info(caller); |
| 66 | break; |
| 67 | default: |
| 68 | EMSG("%s unsupported opcode", __func__); |
| 69 | diff --git a/components/service/capsule_update/provider/corstone1000_fmp_service.c b/components/service/capsule_update/provider/corstone1000_fmp_service.c |
| 70 | index 6a7a47a7..d811af9f 100644 |
| 71 | --- a/components/service/capsule_update/provider/corstone1000_fmp_service.c |
| 72 | +++ b/components/service/capsule_update/provider/corstone1000_fmp_service.c |
| 73 | @@ -238,8 +238,7 @@ static psa_status_t unpack_image_info(void *buffer, uint32_t size) |
| 74 | return PSA_SUCCESS; |
| 75 | } |
| 76 | |
| 77 | -static psa_status_t get_image_info(struct rpc_caller *caller, |
| 78 | - psa_handle_t platform_service_handle) |
| 79 | +static psa_status_t get_image_info(struct rpc_caller *caller) |
| 80 | { |
| 81 | psa_status_t status; |
| 82 | psa_handle_t handle; |
| 83 | @@ -255,7 +254,7 @@ static psa_status_t get_image_info(struct rpc_caller *caller, |
| 84 | |
| 85 | memset(image_info_buffer, 0, IMAGE_INFO_BUFFER_SIZE); |
| 86 | |
| 87 | - psa_call(caller, platform_service_handle, PSA_IPC_CALL, |
| 88 | + psa_call(caller, TFM_PLATFORM_SERVICE_HANDLE, TFM_PLATFORM_API_ID_IOCTL, |
| 89 | in_vec, IOVEC_LEN(in_vec), out_vec, IOVEC_LEN(out_vec)); |
| 90 | |
| 91 | status = unpack_image_info(image_info_buffer, IMAGE_INFO_BUFFER_SIZE); |
| 92 | @@ -288,12 +287,11 @@ static psa_status_t set_image_info(struct rpc_caller *caller) |
| 93 | return PSA_SUCCESS; |
| 94 | } |
| 95 | |
| 96 | -void set_fmp_image_info(struct rpc_caller *caller, |
| 97 | - psa_handle_t platform_service_handle) |
| 98 | +void set_fmp_image_info(struct rpc_caller *caller) |
| 99 | { |
| 100 | psa_status_t status; |
| 101 | |
| 102 | - status = get_image_info(caller, platform_service_handle); |
| 103 | + status = get_image_info(caller); |
| 104 | if (status != PSA_SUCCESS) { |
| 105 | return; |
| 106 | } |
| 107 | diff --git a/components/service/capsule_update/provider/corstone1000_fmp_service.h b/components/service/capsule_update/provider/corstone1000_fmp_service.h |
| 108 | index 95fba2a0..963223e8 100644 |
| 109 | --- a/components/service/capsule_update/provider/corstone1000_fmp_service.h |
| 110 | +++ b/components/service/capsule_update/provider/corstone1000_fmp_service.h |
| 111 | @@ -16,8 +16,7 @@ extern "C" { |
| 112 | |
| 113 | void provision_fmp_variables_metadata(struct rpc_caller *caller); |
| 114 | |
| 115 | -void set_fmp_image_info(struct rpc_caller *caller, |
| 116 | - psa_handle_t platform_service_handle); |
| 117 | +void set_fmp_image_info(struct rpc_caller *caller); |
| 118 | |
| 119 | #ifdef __cplusplus |
| 120 | } /* extern "C" */ |
| 121 | diff --git a/components/service/common/include/psa/sid.h b/components/service/common/include/psa/sid.h |
| 122 | index 7a29cc25..8103a9af 100644 |
| 123 | --- a/components/service/common/include/psa/sid.h |
| 124 | +++ b/components/service/common/include/psa/sid.h |
| 125 | @@ -37,6 +37,12 @@ extern "C" { |
| 126 | #define TFM_CRYPTO_VERSION (1U) |
| 127 | #define TFM_CRYPTO_HANDLE (0x40000100U) |
| 128 | |
| 129 | + |
| 130 | +/******** TFM_PLATFORM_SERVICE *******/ |
| 131 | +#define TFM_PLATFORM_API_ID_IOCTL (1013) |
| 132 | +#define TFM_PLATFORM_SERVICE_HANDLE (0x40000105U) |
| 133 | + |
| 134 | + |
| 135 | /** |
| 136 | * \brief Define a progressive numerical value for each SID which can be used |
| 137 | * when dispatching the requests to the service |
| 138 | -- |
| 139 | 2.25.1 |
| 140 | |