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 int mctp_serial_get_fd(struct mctp_binding_serial *serial); 21 int mctp_serial_read(struct mctp_binding_serial *serial); 22 int mctp_serial_open_path(struct mctp_binding_serial *serial, 23 const char *path); 24 void mctp_serial_open_fd(struct mctp_binding_serial *serial, int fd); 25 26 /* direct function call IO */ 27 typedef int (*mctp_serial_tx_fn)(void *data, void *buf, size_t len) 28 __attribute__((warn_unused_result)); 29 void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial, 30 mctp_serial_tx_fn fn, void *data); 31 int mctp_serial_rx(struct mctp_binding_serial *serial, 32 const void *buf, size_t len); 33 34 #ifdef __cplusplus 35 } 36 #endif 37 38 #endif /* _LIBMCTP_SERIAL_H */ 39