Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef SERVICE_CLIENT_H |
| 8 | #define SERVICE_CLIENT_H |
| 9 | |
| 10 | #include <stddef.h> |
| 11 | #include <psa/error.h> |
Imre Kis | 11f39ee | 2023-07-04 13:52:14 +0200 | [diff] [blame] | 12 | #include "components/rpc/common/caller/rpc_caller_session.h" |
Julian Hall | 3e61454 | 2021-07-29 11:47:47 +0100 | [diff] [blame] | 13 | #include <service/common/client/service_info.h> |
Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | /** |
| 20 | * @brief Common service client structure |
| 21 | * |
| 22 | * Holds common service objects needed for client access to a service instance. |
| 23 | * Includes common information about the service that will have been discovered |
| 24 | * in some way. The TS discovery protocol provides a way to do this. If |
Julian Hall | 3e61454 | 2021-07-29 11:47:47 +0100 | [diff] [blame] | 25 | * service info is not available, the service_info structure stays in its |
Imre Kis | 11f39ee | 2023-07-04 13:52:14 +0200 | [diff] [blame] | 26 | * initialised state. |
Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 27 | */ |
| 28 | struct service_client |
| 29 | { |
Imre Kis | 11f39ee | 2023-07-04 13:52:14 +0200 | [diff] [blame] | 30 | struct rpc_caller_session *session; |
Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 31 | int rpc_status; |
Julian Hall | 3e61454 | 2021-07-29 11:47:47 +0100 | [diff] [blame] | 32 | struct service_info service_info; |
Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | /** |
| 36 | * @brief Initialises the service client |
| 37 | * |
| 38 | * Initialises the service client, including discovery of service info |
| 39 | * if supported by the service provider. |
| 40 | * |
| 41 | * @param[in] context service_client instance |
| 42 | * @param[in] rpc_caller RPC caller to use |
| 43 | * |
| 44 | * @return A status indicating the success/failure of the operation |
| 45 | */ |
| 46 | psa_status_t service_client_init( |
| 47 | struct service_client *context, |
Imre Kis | 11f39ee | 2023-07-04 13:52:14 +0200 | [diff] [blame] | 48 | struct rpc_caller_session *session); |
Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 49 | |
| 50 | /** |
| 51 | * @brief De-initialises the service client |
| 52 | * |
| 53 | * @param[in] context service_client instance |
| 54 | */ |
| 55 | void service_client_deinit( |
| 56 | struct service_client *context); |
| 57 | |
| 58 | /** |
| 59 | * @brief Set the service info |
| 60 | * |
| 61 | * Service info will have been discovered in some way. |
| 62 | * |
| 63 | * @param[in] context service_client instance |
Julian Hall | 3e61454 | 2021-07-29 11:47:47 +0100 | [diff] [blame] | 64 | * @param[in] service_info service_info object |
Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 65 | */ |
Julian Hall | 3e61454 | 2021-07-29 11:47:47 +0100 | [diff] [blame] | 66 | void service_client_set_service_info( |
Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 67 | struct service_client *context, |
Julian Hall | 3e61454 | 2021-07-29 11:47:47 +0100 | [diff] [blame] | 68 | const struct service_info *service_info); |
Julian Hall | 99a57e3 | 2021-07-28 14:18:50 +0100 | [diff] [blame] | 69 | |
| 70 | #ifdef __cplusplus |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | #endif /* SERVICE_CLIENT_H */ |