XCORE SDK
XCORE Software Development Kit
rtos_rpc.h
1 // Copyright 2020-2021 XMOS LIMITED.
2 // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 
10 #ifndef RTOS_RPC_H_
11 #define RTOS_RPC_H_
12 
13 #include <stdint.h>
14 
15 #include "rtos_intertile.h"
16 
24 #define RPC_PARAM_TYPE(param) {sizeof(typeof(param)), 0, 1, 0}
25 
33 #define RPC_PARAM_RETURN(type) {sizeof(type), 0, 0, 1}
34 
43 #define RPC_PARAM_IN_BUFFER(param, length) {sizeof(typeof((param)[0])) * (length), 1, 1, 0}
44 
55 #define RPC_PARAM_OUT_BUFFER(param, length) {sizeof(typeof((param)[0])) * (length), 1, 0, 1}
56 
67 #define RPC_PARAM_INOUT_BUFFER(param, length) {sizeof(typeof((param)[0])) * (length), 1, 1, 1}
68 
74 #define RPC_PARAM_LIST_END {0, 0, 0, 0}
75 
80 typedef struct {
81  uint32_t length : 24;
82  uint8_t ptr : 1;
83  uint8_t input : 1;
84  uint8_t output : 1;
86 
91 typedef struct {
92  int fcode;
95  void *params;
96  void *msg_buf;
97 } rpc_msg_t;
98 
116 int rpc_request_marshall_va(uint8_t **msg, int fcode, const rpc_param_desc_t param_desc[], va_list ap);
117 
136 int rpc_request_marshall(uint8_t **msg, int fcode, const rpc_param_desc_t param_desc[], ...);
137 
145 void rpc_request_parse(rpc_msg_t *rpc_msg, uint8_t *msg_buf);
146 
156 void rpc_request_unmarshall_va(rpc_msg_t *rpc_msg, va_list ap);
157 
168 void rpc_request_unmarshall(rpc_msg_t *rpc_msg, ...);
169 
184 int rpc_response_marshall_va(uint8_t **msg, const rpc_msg_t *rpc_msg, va_list ap);
185 
201 int rpc_response_marshall(uint8_t **msg, const rpc_msg_t *rpc_msg, ...);
202 
210 void rpc_response_parse(rpc_msg_t *rpc_msg, uint8_t *msg_buf);
211 
222 void rpc_response_unmarshall_va(const rpc_msg_t *rpc_msg, const rpc_param_desc_t param_desc[], va_list ap);
223 
234 void rpc_response_unmarshall(const rpc_msg_t *rpc_msg, const rpc_param_desc_t param_desc[], ...);
235 
253 void rpc_client_call_generic(rtos_intertile_t *intertile_ctx, uint8_t port, int fcode, const rpc_param_desc_t param_desc[], ...);
254 
255 #endif /* RTOS_RPC_H_ */
Definition: rtos_rpc.h:91
void * msg_buf
Definition: rtos_rpc.h:96
rpc_param_desc_t * param_desc
Definition: rtos_rpc.h:94
void * params
Definition: rtos_rpc.h:95
int param_count
Definition: rtos_rpc.h:93
int fcode
Definition: rtos_rpc.h:92
Definition: rtos_rpc.h:80
uint32_t length
Definition: rtos_rpc.h:81
uint8_t input
Definition: rtos_rpc.h:83
uint8_t output
Definition: rtos_rpc.h:84
uint8_t ptr
Definition: rtos_rpc.h:82
Definition: rtos_intertile.h:36