blob: 70a6aee8a90df90824d1f60f33c8a40e2550f7aa [file] [log] [blame]
Julian Hall99a57e32021-07-28 14:18:50 +01001/*
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 Kis11f39ee2023-07-04 13:52:14 +020012#include "components/rpc/common/caller/rpc_caller_session.h"
Julian Hall3e614542021-07-29 11:47:47 +010013#include <service/common/client/service_info.h>
Julian Hall99a57e32021-07-28 14:18:50 +010014
15#ifdef __cplusplus
16extern "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 Hall3e614542021-07-29 11:47:47 +010025 * service info is not available, the service_info structure stays in its
Imre Kis11f39ee2023-07-04 13:52:14 +020026 * initialised state.
Julian Hall99a57e32021-07-28 14:18:50 +010027 */
28struct service_client
29{
Imre Kis11f39ee2023-07-04 13:52:14 +020030 struct rpc_caller_session *session;
Julian Hall99a57e32021-07-28 14:18:50 +010031 int rpc_status;
Julian Hall3e614542021-07-29 11:47:47 +010032 struct service_info service_info;
Julian Hall99a57e32021-07-28 14:18:50 +010033};
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 */
46psa_status_t service_client_init(
47 struct service_client *context,
Imre Kis11f39ee2023-07-04 13:52:14 +020048 struct rpc_caller_session *session);
Julian Hall99a57e32021-07-28 14:18:50 +010049
50/**
51 * @brief De-initialises the service client
52 *
53 * @param[in] context service_client instance
54 */
55void 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 Hall3e614542021-07-29 11:47:47 +010064 * @param[in] service_info service_info object
Julian Hall99a57e32021-07-28 14:18:50 +010065 */
Julian Hall3e614542021-07-29 11:47:47 +010066void service_client_set_service_info(
Julian Hall99a57e32021-07-28 14:18:50 +010067 struct service_client *context,
Julian Hall3e614542021-07-29 11:47:47 +010068 const struct service_info *service_info);
Julian Hall99a57e32021-07-28 14:18:50 +010069
70#ifdef __cplusplus
71}
72#endif
73
74#endif /* SERVICE_CLIENT_H */