blob: 8a70101e11ce5a06f6245dd7f9d3d2f0ee5d9414 [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 */
20int mctp_serial_get_fd(struct mctp_binding_serial *serial);
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080021int mctp_serial_read(struct mctp_binding_serial *serial);
22int mctp_serial_open_path(struct mctp_binding_serial *serial,
23 const char *path);
24void mctp_serial_open_fd(struct mctp_binding_serial *serial, int fd);
25
Jeremy Kerr597b3692019-09-03 16:24:48 +080026/* direct function call IO */
Andrew Jefferyad772b92020-01-10 16:04:18 +103027typedef int (*mctp_serial_tx_fn)(void *data, void *buf, size_t len)
28 __attribute__((warn_unused_result));
Jeremy Kerr597b3692019-09-03 16:24:48 +080029void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial,
30 mctp_serial_tx_fn fn, void *data);
31int mctp_serial_rx(struct mctp_binding_serial *serial,
32 const void *buf, size_t len);
33
Deepak Kodihallib11ad2c2019-02-28 03:42:22 -060034#ifdef __cplusplus
35}
36#endif
37
Jeremy Kerr4cdc2002019-02-07 16:49:12 +080038#endif /* _LIBMCTP_SERIAL_H */