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 */ |
| 20 | int mctp_serial_get_fd(struct mctp_binding_serial *serial); |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 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 | |
Jeremy Kerr | 597b369 | 2019-09-03 16:24:48 +0800 | [diff] [blame] | 26 | /* direct function call IO */ |
Andrew Jeffery | ad772b9 | 2020-01-10 16:04:18 +1030 | [diff] [blame] | 27 | typedef int (*mctp_serial_tx_fn)(void *data, void *buf, size_t len) |
| 28 | __attribute__((warn_unused_result)); |
Jeremy Kerr | 597b369 | 2019-09-03 16:24:48 +0800 | [diff] [blame] | 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 | |
Deepak Kodihalli | b11ad2c | 2019-02-28 03:42:22 -0600 | [diff] [blame] | 34 | #ifdef __cplusplus |
| 35 | } |
| 36 | #endif |
| 37 | |
Jeremy Kerr | 4cdc200 | 2019-02-07 16:49:12 +0800 | [diff] [blame] | 38 | #endif /* _LIBMCTP_SERIAL_H */ |