Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 1 | /* |
Kevin Peng | 0eca5ea | 2023-07-21 17:32:31 +0800 | [diff] [blame^] | 2 | * Copyright (c) 2023, Arm Limited. All rights reserved. |
Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | /* |
Kevin Peng | 0eca5ea | 2023-07-21 17:32:31 +0800 | [diff] [blame^] | 9 | * Generated by erpcgen 1.9.1 on Fri Jul 21 17:28:31 2023. |
Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 10 | * |
| 11 | * AUTOGENERATED - DO NOT EDIT |
| 12 | */ |
| 13 | |
| 14 | |
| 15 | #include "erpc_client_manager.h" |
| 16 | #if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC |
| 17 | #include "erpc_port.h" |
| 18 | #endif |
| 19 | #include "erpc_codec.h" |
| 20 | extern "C" |
| 21 | { |
Kevin Peng | 0eca5ea | 2023-07-21 17:32:31 +0800 | [diff] [blame^] | 22 | #include "tfm_erpc.h" |
Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | #if 10901 != ERPC_VERSION_NUMBER |
| 26 | #error "The generated shim code version is different to the rest of eRPC code." |
| 27 | #endif |
| 28 | |
| 29 | using namespace erpc; |
| 30 | using namespace std; |
| 31 | |
| 32 | extern ClientManager *g_client; |
| 33 | |
| 34 | //! @brief Function to write struct binary_t |
| 35 | static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data); |
| 36 | |
| 37 | //! @brief Function to write struct list_binary_1_t |
| 38 | static void write_list_binary_1_t_struct(erpc::Codec * codec, const list_binary_1_t * data); |
| 39 | |
| 40 | |
| 41 | // Write struct binary_t function implementation |
| 42 | static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data) |
| 43 | { |
| 44 | if(NULL == data) |
| 45 | { |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | codec->writeBinary(data->dataLength, data->data); |
| 50 | } |
| 51 | |
| 52 | // Write struct list_binary_1_t function implementation |
| 53 | static void write_list_binary_1_t_struct(erpc::Codec * codec, const list_binary_1_t * data) |
| 54 | { |
| 55 | if(NULL == data) |
| 56 | { |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | codec->startWriteList(data->elementsCount); |
| 61 | for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount) |
| 62 | { |
| 63 | write_binary_t_struct(codec, &(data->elements[listCount])); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | |
| 68 | //! @brief Function to read struct binary_t |
| 69 | static void read_binary_t_struct(erpc::Codec * codec, binary_t * data); |
| 70 | |
| 71 | //! @brief Function to read struct list_binary_1_t |
| 72 | static void read_list_binary_1_t_struct(erpc::Codec * codec, list_binary_1_t * data); |
| 73 | |
| 74 | |
| 75 | // Read struct binary_t function implementation |
| 76 | static void read_binary_t_struct(erpc::Codec * codec, binary_t * data) |
| 77 | { |
| 78 | if(NULL == data) |
| 79 | { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | uint8_t * data_local; |
| 84 | codec->readBinary(&data->dataLength, &data_local); |
| 85 | memcpy(data->data, data_local, data->dataLength); |
| 86 | } |
| 87 | |
| 88 | // Read struct list_binary_1_t function implementation |
| 89 | static void read_list_binary_1_t_struct(erpc::Codec * codec, list_binary_1_t * data) |
| 90 | { |
| 91 | if(NULL == data) |
| 92 | { |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | codec->startReadList(&data->elementsCount); |
| 97 | for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount) |
| 98 | { |
| 99 | read_binary_t_struct(codec, &(data->elements[listCount])); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | |
| 104 | |
| 105 | // psa_client_api interface psa_framework_version function client shim. |
| 106 | uint32_t psa_framework_version(void) |
| 107 | { |
| 108 | erpc_status_t err = kErpcStatus_Success; |
| 109 | |
| 110 | uint32_t result; |
| 111 | |
| 112 | #if ERPC_PRE_POST_ACTION |
| 113 | pre_post_action_cb preCB = g_client->getPreCB(); |
| 114 | if (preCB) |
| 115 | { |
| 116 | preCB(); |
| 117 | } |
| 118 | #endif |
| 119 | |
| 120 | // Get a new request. |
| 121 | RequestContext request = g_client->createRequest(false); |
| 122 | |
| 123 | // Encode the request. |
| 124 | Codec * codec = request.getCodec(); |
| 125 | |
| 126 | if (codec == NULL) |
| 127 | { |
| 128 | err = kErpcStatus_MemoryError; |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | codec->startWriteMessage(kInvocationMessage, kpsa_client_api_service_id, kpsa_client_api_psa_framework_version_id, request.getSequence()); |
| 133 | |
| 134 | // Send message to server |
| 135 | // Codec status is checked inside this function. |
| 136 | g_client->performRequest(request); |
| 137 | |
| 138 | codec->read(&result); |
| 139 | |
| 140 | err = codec->getStatus(); |
| 141 | } |
| 142 | |
| 143 | // Dispose of the request. |
| 144 | g_client->releaseRequest(request); |
| 145 | |
| 146 | // Invoke error handler callback function |
| 147 | g_client->callErrorHandler(err, kpsa_client_api_psa_framework_version_id); |
| 148 | |
| 149 | #if ERPC_PRE_POST_ACTION |
| 150 | pre_post_action_cb postCB = g_client->getPostCB(); |
| 151 | if (postCB) |
| 152 | { |
| 153 | postCB(); |
| 154 | } |
| 155 | #endif |
| 156 | |
| 157 | |
| 158 | if (err != kErpcStatus_Success) |
| 159 | { |
| 160 | result = 0xFFFFFFFFU; |
| 161 | } |
| 162 | |
| 163 | return result; |
| 164 | } |
| 165 | |
| 166 | // psa_client_api interface psa_version function client shim. |
| 167 | uint32_t psa_version(uint32_t sid) |
| 168 | { |
| 169 | erpc_status_t err = kErpcStatus_Success; |
| 170 | |
| 171 | uint32_t result; |
| 172 | |
| 173 | #if ERPC_PRE_POST_ACTION |
| 174 | pre_post_action_cb preCB = g_client->getPreCB(); |
| 175 | if (preCB) |
| 176 | { |
| 177 | preCB(); |
| 178 | } |
| 179 | #endif |
| 180 | |
| 181 | // Get a new request. |
| 182 | RequestContext request = g_client->createRequest(false); |
| 183 | |
| 184 | // Encode the request. |
| 185 | Codec * codec = request.getCodec(); |
| 186 | |
| 187 | if (codec == NULL) |
| 188 | { |
| 189 | err = kErpcStatus_MemoryError; |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | codec->startWriteMessage(kInvocationMessage, kpsa_client_api_service_id, kpsa_client_api_psa_version_id, request.getSequence()); |
| 194 | |
| 195 | codec->write(sid); |
| 196 | |
| 197 | // Send message to server |
| 198 | // Codec status is checked inside this function. |
| 199 | g_client->performRequest(request); |
| 200 | |
| 201 | codec->read(&result); |
| 202 | |
| 203 | err = codec->getStatus(); |
| 204 | } |
| 205 | |
| 206 | // Dispose of the request. |
| 207 | g_client->releaseRequest(request); |
| 208 | |
| 209 | // Invoke error handler callback function |
| 210 | g_client->callErrorHandler(err, kpsa_client_api_psa_version_id); |
| 211 | |
| 212 | #if ERPC_PRE_POST_ACTION |
| 213 | pre_post_action_cb postCB = g_client->getPostCB(); |
| 214 | if (postCB) |
| 215 | { |
| 216 | postCB(); |
| 217 | } |
| 218 | #endif |
| 219 | |
| 220 | |
| 221 | if (err != kErpcStatus_Success) |
| 222 | { |
| 223 | result = 0xFFFFFFFFU; |
| 224 | } |
| 225 | |
| 226 | return result; |
| 227 | } |
| 228 | |
| 229 | // psa_client_api interface erpc_psa_call function client shim. |
| 230 | psa_status_t erpc_psa_call(psa_handle_t handle, int32_t t, const list_binary_1_t * erpc_in_vec, list_binary_1_t * erpc_out_vec) |
| 231 | { |
| 232 | erpc_status_t err = kErpcStatus_Success; |
| 233 | |
| 234 | psa_status_t result; |
| 235 | |
| 236 | #if ERPC_PRE_POST_ACTION |
| 237 | pre_post_action_cb preCB = g_client->getPreCB(); |
| 238 | if (preCB) |
| 239 | { |
| 240 | preCB(); |
| 241 | } |
| 242 | #endif |
| 243 | |
| 244 | // Get a new request. |
| 245 | RequestContext request = g_client->createRequest(false); |
| 246 | |
| 247 | // Encode the request. |
| 248 | Codec * codec = request.getCodec(); |
| 249 | |
| 250 | if (codec == NULL) |
| 251 | { |
| 252 | err = kErpcStatus_MemoryError; |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | codec->startWriteMessage(kInvocationMessage, kpsa_client_api_service_id, kpsa_client_api_erpc_psa_call_id, request.getSequence()); |
| 257 | |
| 258 | codec->write(handle); |
| 259 | |
| 260 | codec->write(t); |
| 261 | |
| 262 | write_list_binary_1_t_struct(codec, erpc_in_vec); |
| 263 | |
| 264 | write_list_binary_1_t_struct(codec, erpc_out_vec); |
| 265 | |
| 266 | // Send message to server |
| 267 | // Codec status is checked inside this function. |
| 268 | g_client->performRequest(request); |
| 269 | |
| 270 | read_list_binary_1_t_struct(codec, erpc_out_vec); |
| 271 | |
| 272 | codec->read(&result); |
| 273 | |
| 274 | err = codec->getStatus(); |
| 275 | } |
| 276 | |
| 277 | // Dispose of the request. |
| 278 | g_client->releaseRequest(request); |
| 279 | |
| 280 | // Invoke error handler callback function |
| 281 | g_client->callErrorHandler(err, kpsa_client_api_erpc_psa_call_id); |
| 282 | |
| 283 | #if ERPC_PRE_POST_ACTION |
| 284 | pre_post_action_cb postCB = g_client->getPostCB(); |
| 285 | if (postCB) |
| 286 | { |
| 287 | postCB(); |
| 288 | } |
| 289 | #endif |
| 290 | |
| 291 | |
| 292 | if (err != kErpcStatus_Success) |
| 293 | { |
| 294 | result = -1; |
| 295 | } |
| 296 | |
| 297 | return result; |
| 298 | } |
Kevin Peng | 0eca5ea | 2023-07-21 17:32:31 +0800 | [diff] [blame^] | 299 | |
| 300 | // psa_client_api interface psa_connect function client shim. |
| 301 | psa_handle_t psa_connect(uint32_t sid, uint32_t ver) |
| 302 | { |
| 303 | erpc_status_t err = kErpcStatus_Success; |
| 304 | |
| 305 | psa_handle_t result; |
| 306 | |
| 307 | #if ERPC_PRE_POST_ACTION |
| 308 | pre_post_action_cb preCB = g_client->getPreCB(); |
| 309 | if (preCB) |
| 310 | { |
| 311 | preCB(); |
| 312 | } |
| 313 | #endif |
| 314 | |
| 315 | // Get a new request. |
| 316 | RequestContext request = g_client->createRequest(false); |
| 317 | |
| 318 | // Encode the request. |
| 319 | Codec * codec = request.getCodec(); |
| 320 | |
| 321 | if (codec == NULL) |
| 322 | { |
| 323 | err = kErpcStatus_MemoryError; |
| 324 | } |
| 325 | else |
| 326 | { |
| 327 | codec->startWriteMessage(kInvocationMessage, kpsa_client_api_service_id, kpsa_client_api_psa_connect_id, request.getSequence()); |
| 328 | |
| 329 | codec->write(sid); |
| 330 | |
| 331 | codec->write(ver); |
| 332 | |
| 333 | // Send message to server |
| 334 | // Codec status is checked inside this function. |
| 335 | g_client->performRequest(request); |
| 336 | |
| 337 | codec->read(&result); |
| 338 | |
| 339 | err = codec->getStatus(); |
| 340 | } |
| 341 | |
| 342 | // Dispose of the request. |
| 343 | g_client->releaseRequest(request); |
| 344 | |
| 345 | // Invoke error handler callback function |
| 346 | g_client->callErrorHandler(err, kpsa_client_api_psa_connect_id); |
| 347 | |
| 348 | #if ERPC_PRE_POST_ACTION |
| 349 | pre_post_action_cb postCB = g_client->getPostCB(); |
| 350 | if (postCB) |
| 351 | { |
| 352 | postCB(); |
| 353 | } |
| 354 | #endif |
| 355 | |
| 356 | |
| 357 | if (err != kErpcStatus_Success) |
| 358 | { |
| 359 | result = -1; |
| 360 | } |
| 361 | |
| 362 | return result; |
| 363 | } |
| 364 | |
| 365 | // psa_client_api interface psa_close function client shim. |
| 366 | void psa_close(psa_handle_t handle) |
| 367 | { |
| 368 | erpc_status_t err = kErpcStatus_Success; |
| 369 | |
| 370 | |
| 371 | #if ERPC_PRE_POST_ACTION |
| 372 | pre_post_action_cb preCB = g_client->getPreCB(); |
| 373 | if (preCB) |
| 374 | { |
| 375 | preCB(); |
| 376 | } |
| 377 | #endif |
| 378 | |
| 379 | // Get a new request. |
| 380 | RequestContext request = g_client->createRequest(false); |
| 381 | |
| 382 | // Encode the request. |
| 383 | Codec * codec = request.getCodec(); |
| 384 | |
| 385 | if (codec == NULL) |
| 386 | { |
| 387 | err = kErpcStatus_MemoryError; |
| 388 | } |
| 389 | else |
| 390 | { |
| 391 | codec->startWriteMessage(kInvocationMessage, kpsa_client_api_service_id, kpsa_client_api_psa_close_id, request.getSequence()); |
| 392 | |
| 393 | codec->write(handle); |
| 394 | |
| 395 | // Send message to server |
| 396 | // Codec status is checked inside this function. |
| 397 | g_client->performRequest(request); |
| 398 | |
| 399 | err = codec->getStatus(); |
| 400 | } |
| 401 | |
| 402 | // Dispose of the request. |
| 403 | g_client->releaseRequest(request); |
| 404 | |
| 405 | // Invoke error handler callback function |
| 406 | g_client->callErrorHandler(err, kpsa_client_api_psa_close_id); |
| 407 | |
| 408 | #if ERPC_PRE_POST_ACTION |
| 409 | pre_post_action_cb postCB = g_client->getPostCB(); |
| 410 | if (postCB) |
| 411 | { |
| 412 | postCB(); |
| 413 | } |
| 414 | #endif |
| 415 | |
| 416 | |
| 417 | return; |
| 418 | } |