1d1c5d0cfSMark Johnston /*- 2d1c5d0cfSMark Johnston * SPDX-License-Identifier: BSD-2-Clause 3d1c5d0cfSMark Johnston * 4d1c5d0cfSMark Johnston * Copyright (c) 2012 NetApp, Inc. 5d1c5d0cfSMark Johnston * Copyright (c) 2013 Neel Natu <neel@freebsd.org> 6d1c5d0cfSMark Johnston * All rights reserved. 7d1c5d0cfSMark Johnston * 8d1c5d0cfSMark Johnston * Redistribution and use in source and binary forms, with or without 9d1c5d0cfSMark Johnston * modification, are permitted provided that the following conditions 10d1c5d0cfSMark Johnston * are met: 11d1c5d0cfSMark Johnston * 1. Redistributions of source code must retain the above copyright 12d1c5d0cfSMark Johnston * notice, this list of conditions and the following disclaimer. 13d1c5d0cfSMark Johnston * 2. Redistributions in binary form must reproduce the above copyright 14d1c5d0cfSMark Johnston * notice, this list of conditions and the following disclaimer in the 15d1c5d0cfSMark Johnston * documentation and/or other materials provided with the distribution. 16d1c5d0cfSMark Johnston * 17d1c5d0cfSMark Johnston * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 18d1c5d0cfSMark Johnston * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19d1c5d0cfSMark Johnston * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20d1c5d0cfSMark Johnston * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 21d1c5d0cfSMark Johnston * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22d1c5d0cfSMark Johnston * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23d1c5d0cfSMark Johnston * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24d1c5d0cfSMark Johnston * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25d1c5d0cfSMark Johnston * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26d1c5d0cfSMark Johnston * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27d1c5d0cfSMark Johnston * SUCH DAMAGE. 28d1c5d0cfSMark Johnston */ 29d1c5d0cfSMark Johnston 30d1c5d0cfSMark Johnston #ifndef _UART_BACKEND_H_ 31d1c5d0cfSMark Johnston #define _UART_BACKEND_H_ 32d1c5d0cfSMark Johnston 33d1c5d0cfSMark Johnston #include <stdbool.h> 34d1c5d0cfSMark Johnston 35d1c5d0cfSMark Johnston #include "mevent.h" 36d1c5d0cfSMark Johnston 37d1c5d0cfSMark Johnston struct uart_softc; 38d1c5d0cfSMark Johnston struct vm_snapshot_meta; 39d1c5d0cfSMark Johnston 40d1c5d0cfSMark Johnston void uart_rxfifo_drain(struct uart_softc *sc, bool loopback); 41d1c5d0cfSMark Johnston int uart_rxfifo_getchar(struct uart_softc *sc); 42d1c5d0cfSMark Johnston int uart_rxfifo_numchars(struct uart_softc *sc); 43d1c5d0cfSMark Johnston int uart_rxfifo_putchar(struct uart_softc *sc, uint8_t ch, bool loopback); 44d1c5d0cfSMark Johnston void uart_rxfifo_reset(struct uart_softc *sc, int size); 45d1c5d0cfSMark Johnston int uart_rxfifo_size(struct uart_softc *sc); 46d1c5d0cfSMark Johnston #ifdef BHYVE_SNAPSHOT 47d1c5d0cfSMark Johnston int uart_rxfifo_snapshot(struct uart_softc *sc, 48d1c5d0cfSMark Johnston struct vm_snapshot_meta *meta); 49d1c5d0cfSMark Johnston #endif 50d1c5d0cfSMark Johnston 51d1c5d0cfSMark Johnston struct uart_softc *uart_init(void); 52d1c5d0cfSMark Johnston int uart_tty_open(struct uart_softc *sc, const char *path, 53d1c5d0cfSMark Johnston void (*drain)(int, enum ev_type, void *), void *arg); 54*e10b9d66SSHENG-YI HONG void uart_softc_lock(struct uart_softc *sc); 55*e10b9d66SSHENG-YI HONG void uart_softc_unlock(struct uart_softc *sc); 56d1c5d0cfSMark Johnston #endif /* _UART_BACKEND_H_ */ 57