blob: d2ec345bf6df17a197e93211e38dae796de0a6ec [file] [log] [blame]
/*
* Copyright (c) 2023, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
/*
* Generated by erpcgen 1.9.1 on Fri Jul 21 17:28:31 2023.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "tfm_erpc_server.h"
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
#include <new>
#include "erpc_port.h"
#endif
#include "erpc_manually_constructed.h"
#if 10901 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
#if ERPC_NESTED_CALLS_DETECTION
extern bool nestingDetection;
#endif
ERPC_MANUALLY_CONSTRUCTED_STATIC(psa_client_api_service, s_psa_client_api_service);
//! @brief Function to read struct binary_t
static void read_binary_t_struct(erpc::Codec * codec, binary_t * data);
//! @brief Function to read struct list_binary_1_t
static void read_list_binary_1_t_struct(erpc::Codec * codec, list_binary_1_t * data);
// Read struct binary_t function implementation
static void read_binary_t_struct(erpc::Codec * codec, binary_t * data)
{
if(NULL == data)
{
return;
}
uint8_t * data_local;
codec->readBinary(&data->dataLength, &data_local);
data->data = (uint8_t *) erpc_malloc(data->dataLength * sizeof(uint8_t));
if ((data->data == NULL) && (data->dataLength > 0))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
else
{
memcpy(data->data, data_local, data->dataLength);
}
}
// Read struct list_binary_1_t function implementation
static void read_list_binary_1_t_struct(erpc::Codec * codec, list_binary_1_t * data)
{
if(NULL == data)
{
return;
}
codec->startReadList(&data->elementsCount);
data->elements = (binary_t *) erpc_malloc(data->elementsCount * sizeof(binary_t));
if ((data->elements == NULL) && (data->elementsCount > 0))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
{
read_binary_t_struct(codec, &(data->elements[listCount]));
}
}
//! @brief Function to write struct binary_t
static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data);
//! @brief Function to write struct list_binary_1_t
static void write_list_binary_1_t_struct(erpc::Codec * codec, const list_binary_1_t * data);
// Write struct binary_t function implementation
static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data)
{
if(NULL == data)
{
return;
}
codec->writeBinary(data->dataLength, data->data);
}
// Write struct list_binary_1_t function implementation
static void write_list_binary_1_t_struct(erpc::Codec * codec, const list_binary_1_t * data)
{
if(NULL == data)
{
return;
}
codec->startWriteList(data->elementsCount);
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
{
write_binary_t_struct(codec, &(data->elements[listCount]));
}
}
//! @brief Function to free space allocated inside struct binary_t
static void free_binary_t_struct(binary_t * data);
//! @brief Function to free space allocated inside struct list_binary_1_t
static void free_list_binary_1_t_struct(list_binary_1_t * data);
// Free space allocated inside struct binary_t function implementation
static void free_binary_t_struct(binary_t * data)
{
if (data->data)
{
erpc_free(data->data);
}
}
// Free space allocated inside struct list_binary_1_t function implementation
static void free_list_binary_1_t_struct(list_binary_1_t * data)
{
for (uint32_t listCount = 0; listCount < data->elementsCount; ++listCount)
{
free_binary_t_struct(&data->elements[listCount]);
}
if (data->elements)
{
erpc_free(data->elements);
}
}
// Call the correct server shim based on method unique ID.
erpc_status_t psa_client_api_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory)
{
erpc_status_t erpcStatus;
switch (methodId)
{
case kpsa_client_api_psa_framework_version_id:
{
erpcStatus = psa_framework_version_shim(codec, messageFactory, sequence);
break;
}
case kpsa_client_api_psa_version_id:
{
erpcStatus = psa_version_shim(codec, messageFactory, sequence);
break;
}
case kpsa_client_api_erpc_psa_call_id:
{
erpcStatus = erpc_psa_call_shim(codec, messageFactory, sequence);
break;
}
case kpsa_client_api_psa_connect_id:
{
erpcStatus = psa_connect_shim(codec, messageFactory, sequence);
break;
}
case kpsa_client_api_psa_close_id:
{
erpcStatus = psa_close_shim(codec, messageFactory, sequence);
break;
}
default:
{
erpcStatus = kErpcStatus_InvalidArgument;
break;
}
}
return erpcStatus;
}
// Server shim for psa_framework_version of psa_client_api interface.
erpc_status_t psa_client_api_service::psa_framework_version_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
uint32_t result;
// startReadMessage() was already called before this shim was invoked.
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = psa_framework_version();
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset();
// Build response message.
codec->startWriteMessage(kReplyMessage, kpsa_client_api_service_id, kpsa_client_api_psa_framework_version_id, sequence);
codec->write(result);
err = codec->getStatus();
}
return err;
}
// Server shim for psa_version of psa_client_api interface.
erpc_status_t psa_client_api_service::psa_version_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
uint32_t sid;
uint32_t result;
// startReadMessage() was already called before this shim was invoked.
codec->read(&sid);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = psa_version(sid);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset();
// Build response message.
codec->startWriteMessage(kReplyMessage, kpsa_client_api_service_id, kpsa_client_api_psa_version_id, sequence);
codec->write(result);
err = codec->getStatus();
}
return err;
}
// Server shim for erpc_psa_call of psa_client_api interface.
erpc_status_t psa_client_api_service::erpc_psa_call_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
psa_handle_t handle;
int32_t t;
list_binary_1_t *erpc_in_vec = NULL;
erpc_in_vec = (list_binary_1_t *) erpc_malloc(sizeof(list_binary_1_t));
if (erpc_in_vec == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
list_binary_1_t *erpc_out_vec = NULL;
erpc_out_vec = (list_binary_1_t *) erpc_malloc(sizeof(list_binary_1_t));
if (erpc_out_vec == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
psa_status_t result;
// startReadMessage() was already called before this shim was invoked.
codec->read(&handle);
codec->read(&t);
read_list_binary_1_t_struct(codec, erpc_in_vec);
read_list_binary_1_t_struct(codec, erpc_out_vec);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = erpc_psa_call(handle, t, erpc_in_vec, erpc_out_vec);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset();
// Build response message.
codec->startWriteMessage(kReplyMessage, kpsa_client_api_service_id, kpsa_client_api_erpc_psa_call_id, sequence);
write_list_binary_1_t_struct(codec, erpc_out_vec);
codec->write(result);
err = codec->getStatus();
}
if (erpc_in_vec)
{
free_list_binary_1_t_struct(erpc_in_vec);
}
if (erpc_in_vec)
{
erpc_free(erpc_in_vec);
}
if (erpc_out_vec)
{
free_list_binary_1_t_struct(erpc_out_vec);
}
if (erpc_out_vec)
{
erpc_free(erpc_out_vec);
}
return err;
}
// Server shim for psa_connect of psa_client_api interface.
erpc_status_t psa_client_api_service::psa_connect_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
uint32_t sid;
uint32_t ver;
psa_handle_t result;
// startReadMessage() was already called before this shim was invoked.
codec->read(&sid);
codec->read(&ver);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = psa_connect(sid, ver);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset();
// Build response message.
codec->startWriteMessage(kReplyMessage, kpsa_client_api_service_id, kpsa_client_api_psa_connect_id, sequence);
codec->write(result);
err = codec->getStatus();
}
return err;
}
// Server shim for psa_close of psa_client_api interface.
erpc_status_t psa_client_api_service::psa_close_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
psa_handle_t handle;
// startReadMessage() was already called before this shim was invoked.
codec->read(&handle);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
psa_close(handle);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset();
// Build response message.
codec->startWriteMessage(kReplyMessage, kpsa_client_api_service_id, kpsa_client_api_psa_close_id, sequence);
err = codec->getStatus();
}
return err;
}
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
erpc_service_t create_psa_client_api_service()
{
return new (nothrow) psa_client_api_service();
}
void destroy_psa_client_api_service(erpc_service_t service)
{
if (service)
{
delete (psa_client_api_service *)service;
}
}
#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
erpc_service_t create_psa_client_api_service()
{
s_psa_client_api_service.construct();
return s_psa_client_api_service.get();
}
void destroy_psa_client_api_service()
{
s_psa_client_api_service.destroy();
}
#else
#warning "Unknown eRPC allocation policy!"
#endif