1*f7864055Sthorpej /* $NetBSD: gfttyvar.h,v 1.2 2024/01/06 17:52:43 thorpej Exp $ */ 2bcb5d394Sthorpej 3bcb5d394Sthorpej /*- 4bcb5d394Sthorpej * Copyright (c) 2023 The NetBSD Foundation, Inc. 5bcb5d394Sthorpej * All rights reserved. 6bcb5d394Sthorpej * 7bcb5d394Sthorpej * This code is derived from software contributed to The NetBSD Foundation 8bcb5d394Sthorpej * by Jason R. Thorpe. 9bcb5d394Sthorpej * 10bcb5d394Sthorpej * Redistribution and use in source and binary forms, with or without 11bcb5d394Sthorpej * modification, are permitted provided that the following conditions 12bcb5d394Sthorpej * are met: 13bcb5d394Sthorpej * 1. Redistributions of source code must retain the above copyright 14bcb5d394Sthorpej * notice, this list of conditions and the following disclaimer. 15bcb5d394Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 16bcb5d394Sthorpej * notice, this list of conditions and the following disclaimer in the 17bcb5d394Sthorpej * documentation and/or other materials provided with the distribution. 18bcb5d394Sthorpej * 19bcb5d394Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20bcb5d394Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21bcb5d394Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22bcb5d394Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23bcb5d394Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24bcb5d394Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25bcb5d394Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26bcb5d394Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27bcb5d394Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28bcb5d394Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29bcb5d394Sthorpej * POSSIBILITY OF SUCH DAMAGE. 30bcb5d394Sthorpej */ 31bcb5d394Sthorpej 32bcb5d394Sthorpej #ifndef _DEV_GOLDFISH_GFTTYVAR_H_ 33bcb5d394Sthorpej #define _DEV_GOLDFISH_GFTTYVAR_H_ 34bcb5d394Sthorpej 35*f7864055Sthorpej #include <sys/bus.h> 36*f7864055Sthorpej #include <sys/mutex.h> 37*f7864055Sthorpej #include <sys/tty.h> 38*f7864055Sthorpej 39bcb5d394Sthorpej struct gftty_config { 40bcb5d394Sthorpej bus_space_tag_t c_bst; 41bcb5d394Sthorpej bus_space_handle_t c_bsh; 42bcb5d394Sthorpej uint32_t c_version; 43bcb5d394Sthorpej }; 44bcb5d394Sthorpej 45bcb5d394Sthorpej struct gftty_softc { 46bcb5d394Sthorpej device_t sc_dev; 47bcb5d394Sthorpej struct gftty_config *sc_config; 48*f7864055Sthorpej 49*f7864055Sthorpej void *sc_ih; 50*f7864055Sthorpej void *sc_rx_si; 51*f7864055Sthorpej 52*f7864055Sthorpej bus_dma_tag_t sc_dmat; 53*f7864055Sthorpej bus_dmamap_t sc_tx_dma; 54*f7864055Sthorpej bus_dmamap_t sc_rx_dma; 55*f7864055Sthorpej 56*f7864055Sthorpej kmutex_t sc_hwlock; /* locks DMA pointer */ 57*f7864055Sthorpej 58*f7864055Sthorpej struct tty *sc_tty; 59*f7864055Sthorpej char *sc_rxbufs[2]; 60*f7864055Sthorpej bus_addr_t sc_rxaddrs[2]; 61*f7864055Sthorpej char *sc_rxbuf; /* tty lock */ 62*f7864055Sthorpej bus_addr_t sc_rxaddr; /* tty lock */ 63*f7864055Sthorpej int sc_rxpos; /* tty lock */ 64*f7864055Sthorpej int sc_rxcur; /* tty lock */ 65bcb5d394Sthorpej }; 66bcb5d394Sthorpej 67bcb5d394Sthorpej void gftty_attach(struct gftty_softc *sc); 68bcb5d394Sthorpej bool gftty_is_console(struct gftty_softc *sc); 69bcb5d394Sthorpej void gftty_alloc_config(struct gftty_softc *sc, bus_space_tag_t, 70bcb5d394Sthorpej bus_space_handle_t); 71*f7864055Sthorpej int gftty_intr(void *); 72bcb5d394Sthorpej void gftty_cnattach(bus_space_tag_t, bus_space_handle_t); 73bcb5d394Sthorpej 74bcb5d394Sthorpej #endif /* _DEV_GOLDFISH_GFTTYVAR_H_ */ 75