xref: /openbmc/libmctp/libmctp-serial.h (revision a721c2d8)
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 (*mctp_serial_tx_fn)(void *data, void *buf, size_t len)
30 	__attribute__((warn_unused_result));
31 void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial,
32 			   mctp_serial_tx_fn fn, void *data);
33 int mctp_serial_rx(struct mctp_binding_serial *serial, const void *buf,
34 		   size_t len);
35 
36 #ifdef __cplusplus
37 }
38 #endif
39 
40 #endif /* _LIBMCTP_SERIAL_H */
41