blob: 73a28a4392c7992ca5916febff2354b35423143b [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 */
Matt Johnston7c51d832024-12-10 18:36:53 +080029typedef int
30 __attribute__((warn_unused_result)) (*mctp_serial_tx_fn)(void *data,
31 void *buf,
32 size_t len);
Jeremy Kerr597b3692019-09-03 16:24:48 +080033void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial,
Andrew Jefferyad7bbe72022-09-30 14:27:32 +093034 mctp_serial_tx_fn fn, void *data);
35int mctp_serial_rx(struct mctp_binding_serial *serial, const void *buf,
36 size_t len);
Jeremy Kerr597b3692019-09-03 16:24:48 +080037
Deepak Kodihallib11ad2c2019-02-28 03:42:22 -060038#ifdef __cplusplus
39}
40#endif
41
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080042#endif /* _LIBMCTP_SERIAL_H */