Home | History | Annotate | Line # | Download | only in ic
comvar.h revision 1.39
      1 /*	$NetBSD: comvar.h,v 1.39 2001/01/14 23:50:28 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  * 3. All advertising materials mentioning features or use of this software
     15  *    must display the following acknowledgement:
     16  *      This product includes software developed by Christopher G. Demetriou
     17  *	for the NetBSD Project.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #include "rnd.h"
     34 #include "opt_multiprocessor.h"
     35 #include "opt_lockdebug.h"
     36 #include "opt_com.h"
     37 
     38 #if NRND > 0 && defined(RND_COM)
     39 #include <sys/rnd.h>
     40 #endif
     41 
     42 #include <sys/callout.h>
     43 #include <sys/timepps.h>
     44 #if (defined(MULTIPROCESSOR) || defined(LOCKDEBUG)) && defined(COM_MPLOCK)
     45 #include <sys/lock.h>
     46 #endif
     47 
     48 int comcnattach __P((bus_space_tag_t, bus_addr_t, int, int, tcflag_t));
     49 
     50 #ifdef KGDB
     51 int com_kgdb_attach __P((bus_space_tag_t, bus_addr_t, int, int, tcflag_t));
     52 #endif
     53 
     54 int com_is_console __P((bus_space_tag_t, bus_addr_t, bus_space_handle_t *));
     55 
     56 /* Hardware flag masks */
     57 #define	COM_HW_NOIEN	0x01
     58 #define	COM_HW_FIFO	0x02
     59 #define	COM_HW_HAYESP	0x04
     60 #define	COM_HW_FLOW	0x08
     61 #define	COM_HW_DEV_OK	0x20
     62 #define	COM_HW_CONSOLE	0x40
     63 #define	COM_HW_KGDB	0x80
     64 #define	COM_HW_TXFIFO_DISABLE	0x100
     65 
     66 /* Buffer size for character buffer */
     67 #define	COM_RING_SIZE	2048
     68 
     69 struct com_softc {
     70 	struct device sc_dev;
     71 	void *sc_si;
     72 	struct tty *sc_tty;
     73 
     74 	struct callout sc_diag_callout;
     75 
     76 	bus_addr_t sc_iobase;			/* XXX ISA-centric name */
     77 	int sc_frequency;
     78 
     79 	bus_space_tag_t sc_iot;
     80 	bus_space_handle_t sc_ioh;
     81 	bus_space_handle_t sc_hayespioh;
     82 
     83 	u_int sc_overflows,
     84 	      sc_floods,
     85 	      sc_errors;
     86 
     87 	int sc_hwflags,
     88 	    sc_swflags;
     89 	u_int sc_fifolen;
     90 
     91 	u_int sc_r_hiwat,
     92 	      sc_r_lowat;
     93 	u_char *volatile sc_rbget,
     94 	       *volatile sc_rbput;
     95  	volatile u_int sc_rbavail;
     96 	u_char *sc_rbuf,
     97 	       *sc_ebuf;
     98 
     99  	u_char *sc_tba;
    100  	u_int sc_tbc,
    101 	      sc_heldtbc;
    102 
    103 	volatile u_char sc_rx_flags,
    104 #define	RX_TTY_BLOCKED		0x01
    105 #define	RX_TTY_OVERFLOWED	0x02
    106 #define	RX_IBUF_BLOCKED		0x04
    107 #define	RX_IBUF_OVERFLOWED	0x08
    108 #define	RX_ANY_BLOCK		0x0f
    109 			sc_tx_busy,
    110 			sc_tx_done,
    111 			sc_tx_stopped,
    112 			sc_st_check,
    113 			sc_rx_ready;
    114 
    115 	volatile u_char sc_heldchange;
    116 	volatile u_char sc_msr, sc_msr_delta, sc_msr_mask, sc_mcr,
    117 	    sc_mcr_active, sc_lcr, sc_ier, sc_fifo, sc_dlbl, sc_dlbh, sc_efr;
    118 	u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
    119 
    120 	/* power management hooks */
    121 	int (*enable) __P((struct com_softc *));
    122 	void (*disable) __P((struct com_softc *));
    123 	int enabled;
    124 
    125 	/* PPS signal on DCD, with or without inkernel clock disciplining */
    126 	u_char	sc_ppsmask;			/* pps signal mask */
    127 	u_char	sc_ppsassert;			/* pps leading edge */
    128 	u_char	sc_ppsclear;			/* pps trailing edge */
    129 	pps_info_t ppsinfo;
    130 	pps_params_t ppsparam;
    131 
    132 #if NRND > 0 && defined(RND_COM)
    133 	rndsource_element_t  rnd_source;
    134 #endif
    135 #if (defined(MULTIPROCESSOR) || defined(LOCKDEBUG)) && defined(COM_MPLOCK)
    136 	struct simplelock	sc_lock;
    137 #endif
    138 };
    139 
    140 /* Macros to clear/set/test flags. */
    141 #define SET(t, f)	(t) |= (f)
    142 #define CLR(t, f)	(t) &= ~(f)
    143 #define ISSET(t, f)	((t) & (f))
    144 
    145 int comprobe1 __P((bus_space_tag_t, bus_space_handle_t));
    146 int comintr __P((void *));
    147 void com_attach_subr __P((struct com_softc *));
    148 int cominit __P((bus_space_tag_t, bus_addr_t, int, int, tcflag_t,
    149 	bus_space_handle_t *));
    150 int com_detach __P((struct device *, int));
    151 int com_activate __P((struct device *, enum devact));
    152 
    153 #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS
    154 #ifdef __NO_SOFT_SERIAL_INTERRUPT
    155 #define	IPL_SERIAL	IPL_TTY
    156 #define	splserial()	spltty()
    157 #define	IPL_SOFTSERIAL	IPL_TTY
    158 #define	splsoftserial()	spltty()
    159 #endif
    160 #endif
    161