blob: dc7cb995ef29401b3cdd58bb3e73048a5d494682 [file] [log] [blame]
Jeremy Kerr3d36ee22019-05-30 11:15:37 +08001/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */
Jeremy Kerr4cdc2002019-02-07 16:49:12 +08002
3#ifndef _LIBMCTP_SERIAL_H
4#define _LIBMCTP_SERIAL_H
5
Deepak Kodihallib11ad2c2019-02-28 03:42:22 -06006#ifdef __cplusplus
7extern "C" {
8#endif
9
Jeremy Kerr8682ef22019-05-30 17:46:44 +080010#include <libmctp.h>
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080011
12struct mctp_binding_serial;
13
14struct mctp_binding_serial *mctp_serial_init(void);
Andrew Jefferyf8b47492020-03-10 23:48:59 +103015void mctp_serial_destroy(struct mctp_binding_serial *serial);
Jeremy Kerr597b3692019-09-03 16:24:48 +080016
Jeremy Kerr3b36d172019-09-04 11:56:09 +080017struct mctp_binding *mctp_binding_serial_core(struct mctp_binding_serial *b);
Jeremy Kerr597b3692019-09-03 16:24:48 +080018
19/* file-based IO */
Andrew Jeffery1111c6a2022-07-25 20:44:39 +093020struct pollfd;
21int mctp_serial_init_pollfd(struct mctp_binding_serial *serial,
22 struct pollfd *pollfd);
23
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080024int mctp_serial_read(struct mctp_binding_serial *serial);
Andrew Jefferyad7bbe72022-09-30 14:27:32 +093025int mctp_serial_open_path(struct mctp_binding_serial *serial, const char *path);
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080026void mctp_serial_open_fd(struct mctp_binding_serial *serial, int fd);
27
Jeremy Kerr597b3692019-09-03 16:24:48 +080028/* direct function call IO */
Andrew Jefferyad772b92020-01-10 16:04:18 +103029typedef int (*mctp_serial_tx_fn)(void *data, void *buf, size_t len)
30 __attribute__((warn_unused_result));
Jeremy Kerr597b3692019-09-03 16:24:48 +080031void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial,
Andrew Jefferyad7bbe72022-09-30 14:27:32 +093032 mctp_serial_tx_fn fn, void *data);
33int mctp_serial_rx(struct mctp_binding_serial *serial, const void *buf,
34 size_t len);
Jeremy Kerr597b3692019-09-03 16:24:48 +080035
Deepak Kodihallib11ad2c2019-02-28 03:42:22 -060036#ifdef __cplusplus
37}
38#endif
39
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080040#endif /* _LIBMCTP_SERIAL_H */