xref: /openbmc/libmctp/libmctp-serial.h (revision 8f53d631)
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,
26 		const char *path);
27 void mctp_serial_open_fd(struct mctp_binding_serial *serial, int fd);
28 
29 /* direct function call IO */
30 typedef int (*mctp_serial_tx_fn)(void *data, void *buf, size_t len)
31 	__attribute__((warn_unused_result));
32 void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial,
33 		mctp_serial_tx_fn fn, void *data);
34 int mctp_serial_rx(struct mctp_binding_serial *serial,
35 		const void *buf, size_t len);
36 
37 #ifdef __cplusplus
38 }
39 #endif
40 
41 #endif /* _LIBMCTP_SERIAL_H */
42