1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef RPC_CALLER_H
#define RPC_CALLER_H
#include <stddef.h>
#include <stdint.h>
#include "rpc_status.h"
/*
* The rpc_caller puplic interface may be exported as a public interface to
* a shared library.
*/
#ifdef EXPORT_PUBLIC_INTERFACE_RPC_CALLER
#define RPC_CALLER_EXPORTED __attribute__((__visibility__("default")))
#else
#define RPC_CALLER_EXPORTED
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Defines an abstract interface for calling operations provided by an rpc endpoint.
* Concrete specializations will map the an RPC or direct calling mechanism to
* suite the deployment.
*/
typedef void *rpc_call_handle;
struct rpc_caller
{
void *context;
/* A concrete rpc_caller implements these methods */
rpc_call_handle (*call_begin)(void *context, uint8_t **req_buf, size_t req_len);
rpc_status_t (*call_invoke)(void *context, rpc_call_handle handle, uint32_t opcode,
int *opstatus, uint8_t **resp_buf, size_t *resp_len);
void (*call_end)(void *context, rpc_call_handle handle);
};
/*
* Starts a call transaction. The returned handle is an identifier for the
* transaction and must be passed as a parameter to call_invoke() and
* call_end(). A concrete rpc_caller may perform resource allocation during
* this call. This will include a buffer for the request message parameters.
* Returns a NULL handle on failure.
*/
RPC_CALLER_EXPORTED rpc_call_handle rpc_caller_begin(struct rpc_caller *s,
uint8_t **req_buf, size_t req_len);
/*
* Invokes the operation identified by the opcode. This method blocks
* until the operation completes. The status of the call is returned. An
* additional endpoint specific status value is also returned. If a response
* message was received, the concrete rpc_caller will have allocated a
* buffer for the reponse. This buffer will hold valid data until the point when
* call_end() is called for the transaction.
*/
RPC_CALLER_EXPORTED rpc_status_t rpc_caller_invoke(struct rpc_caller *s, rpc_call_handle handle,
uint32_t opcode, int *opstatus, uint8_t **resp_buf, size_t *resp_len);
/*
* Ends the call transaction, allowing any resource associated with the
* transaction to be freed.
*/
RPC_CALLER_EXPORTED void rpc_caller_end(struct rpc_caller *s, rpc_call_handle handle);
#ifdef __cplusplus
}
#endif
#endif /* RPC_CALLER_H */
|