xref: /openbmc/libmctp/libmctp-serial.h (revision 6586fc10)
1 /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
2 
3 #ifndef _LIBMCTP_SERIAL_H
4 #define _LIBMCTP_SERIAL_H
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 #include <libmctp.h>
11 
12 struct mctp_binding_serial;
13 
14 struct mctp_binding_serial *mctp_serial_init(void);
15 void mctp_serial_destroy(struct mctp_binding_serial *serial);
16 
17 struct mctp_binding *mctp_binding_serial_core(struct mctp_binding_serial *b);
18 
19 /* file-based IO */
20 struct pollfd;
21 int mctp_serial_init_pollfd(struct mctp_binding_serial *serial,
22 			    struct pollfd *pollfd);
23 
24 int mctp_serial_read(struct mctp_binding_serial *serial);
25 int mctp_serial_open_path(struct mctp_binding_serial *serial, const char *path);
26 void mctp_serial_open_fd(struct mctp_binding_serial *serial, int fd);
27 
28 /* direct function call IO */
29 typedef int
30 	__attribute__((warn_unused_result)) (*mctp_serial_tx_fn)(void *data,
31 								 void *buf,
32 								 size_t len);
33 void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial,
34 			   mctp_serial_tx_fn fn, void *data);
35 int mctp_serial_rx(struct mctp_binding_serial *serial, const void *buf,
36 		   size_t len);
37 
38 #ifdef __cplusplus
39 }
40 #endif
41 
42 #endif /* _LIBMCTP_SERIAL_H */
43