Jeremy Kerr | 3d36ee2 | 2019-05-30 11:15:37 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */ |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 2 | |
| 3 | #ifndef _LIBMCTP_SERIAL_H |
| 4 | #define _LIBMCTP_SERIAL_H |
| 5 | |
Deepak Kodihalli | b11ad2c | 2019-02-28 03:42:22 -0600 | [diff] [blame] | 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | |
Jeremy Kerr | 8682ef2 | 2019-05-30 17:46:44 +0800 | [diff] [blame] | 10 | #include <libmctp.h> |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 11 | |
| 12 | struct mctp_binding_serial; |
| 13 | |
| 14 | struct mctp_binding_serial *mctp_serial_init(void); |
Andrew Jeffery | f8b4749 | 2020-03-10 23:48:59 +1030 | [diff] [blame] | 15 | void mctp_serial_destroy(struct mctp_binding_serial *serial); |
Jeremy Kerr | 597b369 | 2019-09-03 16:24:48 +0800 | [diff] [blame] | 16 | |
Jeremy Kerr | 3b36d17 | 2019-09-04 11:56:09 +0800 | [diff] [blame] | 17 | struct mctp_binding *mctp_binding_serial_core(struct mctp_binding_serial *b); |
Jeremy Kerr | 597b369 | 2019-09-03 16:24:48 +0800 | [diff] [blame] | 18 | |
| 19 | /* file-based IO */ |
Andrew Jeffery | 1111c6a | 2022-07-25 20:44:39 +0930 | [diff] [blame] | 20 | struct pollfd; |
| 21 | int mctp_serial_init_pollfd(struct mctp_binding_serial *serial, |
| 22 | struct pollfd *pollfd); |
| 23 | |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 24 | int mctp_serial_read(struct mctp_binding_serial *serial); |
Andrew Jeffery | ad7bbe7 | 2022-09-30 14:27:32 +0930 | [diff] [blame] | 25 | int mctp_serial_open_path(struct mctp_binding_serial *serial, const char *path); |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 26 | void mctp_serial_open_fd(struct mctp_binding_serial *serial, int fd); |
| 27 | |
Jeremy Kerr | 597b369 | 2019-09-03 16:24:48 +0800 | [diff] [blame] | 28 | /* direct function call IO */ |
Andrew Jeffery | ad772b9 | 2020-01-10 16:04:18 +1030 | [diff] [blame] | 29 | typedef int (*mctp_serial_tx_fn)(void *data, void *buf, size_t len) |
| 30 | __attribute__((warn_unused_result)); |
Jeremy Kerr | 597b369 | 2019-09-03 16:24:48 +0800 | [diff] [blame] | 31 | void mctp_serial_set_tx_fn(struct mctp_binding_serial *serial, |
Andrew Jeffery | ad7bbe7 | 2022-09-30 14:27:32 +0930 | [diff] [blame] | 32 | mctp_serial_tx_fn fn, void *data); |
| 33 | int mctp_serial_rx(struct mctp_binding_serial *serial, const void *buf, |
| 34 | size_t len); |
Jeremy Kerr | 597b369 | 2019-09-03 16:24:48 +0800 | [diff] [blame] | 35 | |
Deepak Kodihalli | b11ad2c | 2019-02-28 03:42:22 -0600 | [diff] [blame] | 36 | #ifdef __cplusplus |
| 37 | } |
| 38 | #endif |
| 39 | |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 40 | #endif /* _LIBMCTP_SERIAL_H */ |