Home | History | Annotate | Line # | Download | only in dev
plcomvar.h revision 1.1
      1 /*	$NetBSD: plcomvar.h,v 1.1 2001/10/27 16:22:07 rearnsha 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_plcom.h"
     37 #include "opt_kgdb.h"
     38 
     39 #if NRND > 0 && defined(RND_COM)
     40 #include <sys/rnd.h>
     41 #endif
     42 
     43 #include <sys/callout.h>
     44 #include <sys/timepps.h>
     45 #if (defined(MULTIPROCESSOR) || defined(LOCKDEBUG)) && defined(COM_MPLOCK)
     46 #include <sys/lock.h>
     47 #endif
     48 
     49 int  plcomcnattach	(bus_space_tag_t, bus_addr_t, int, int, tcflag_t, int);
     50 void plcomcndetach	(void);
     51 
     52 #ifdef KGDB
     53 int  plcom_kgdb_attach	(bus_space_tag_t, bus_addr_t, int, int, tcflag_t);
     54 #endif
     55 
     56 int  plcom_is_console	(bus_space_tag_t, int, bus_space_handle_t *);
     57 
     58 /* Hardware flag masks */
     59 #define	PLCOM_HW_NOIEN		0x01
     60 #define	PLCOM_HW_FIFO		0x02
     61 #define	PLCOM_HW_HAYESP		0x04
     62 #define	PLCOM_HW_FLOW		0x08
     63 #define	PLCOM_HW_DEV_OK		0x20
     64 #define	PLCOM_HW_CONSOLE	0x40
     65 #define	PLCOM_HW_KGDB		0x80
     66 #define	PLCOM_HW_TXFIFO_DISABLE	0x100
     67 
     68 /* Buffer size for character buffer */
     69 #define	PLCOM_RING_SIZE		2048
     70 
     71 struct plcom_softc {
     72 	struct device sc_dev;
     73 	void *sc_si;
     74 	struct tty *sc_tty;
     75 
     76 	struct callout sc_diag_callout;
     77 
     78 	bus_addr_t sc_iounit;
     79 	int sc_frequency;
     80 
     81 	bus_space_tag_t sc_iot;
     82 	bus_space_handle_t sc_ioh;
     83 
     84 	u_int sc_overflows,
     85 	      sc_floods,
     86 	      sc_errors;
     87 
     88 	int sc_hwflags,
     89 	    sc_swflags;
     90 	u_int sc_fifolen;
     91 
     92 	u_int sc_r_hiwat,
     93 	      sc_r_lowat;
     94 	u_char *volatile sc_rbget,
     95 	       *volatile sc_rbput;
     96  	volatile u_int sc_rbavail;
     97 	u_char *sc_rbuf,
     98 	       *sc_ebuf;
     99 
    100  	u_char *sc_tba;
    101  	u_int sc_tbc,
    102 	      sc_heldtbc;
    103 
    104 	volatile u_char sc_rx_flags,
    105 #define	RX_TTY_BLOCKED		0x01
    106 #define	RX_TTY_OVERFLOWED	0x02
    107 #define	RX_IBUF_BLOCKED		0x04
    108 #define	RX_IBUF_OVERFLOWED	0x08
    109 #define	RX_ANY_BLOCK		0x0f
    110 			sc_tx_busy,
    111 			sc_tx_done,
    112 			sc_tx_stopped,
    113 			sc_st_check,
    114 			sc_rx_ready;
    115 
    116 	volatile u_char sc_heldchange;
    117 	volatile u_char sc_msr, sc_msr_delta, sc_msr_mask, sc_mcr,
    118 	    sc_mcr_active, sc_lcr, sc_cr, sc_dlbl, sc_dlbh;
    119 	u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
    120 	u_int sc_fifo;
    121 
    122 	/* Support routine to program mcr lines, if present.  */
    123 	void	(*sc_set_mcr)(void *, int, u_int);
    124 	void	*sc_set_mcr_arg;
    125 
    126 	/* power management hooks */
    127 	int (*enable) (struct plcom_softc *);
    128 	void (*disable) (struct plcom_softc *);
    129 	int enabled;
    130 
    131 	/* PPS signal on DCD, with or without inkernel clock disciplining */
    132 	u_char	sc_ppsmask;			/* pps signal mask */
    133 	u_char	sc_ppsassert;			/* pps leading edge */
    134 	u_char	sc_ppsclear;			/* pps trailing edge */
    135 	pps_info_t ppsinfo;
    136 	pps_params_t ppsparam;
    137 
    138 #if NRND > 0 && defined(RND_COM)
    139 	rndsource_element_t  rnd_source;
    140 #endif
    141 #if (defined(MULTIPROCESSOR) || defined(LOCKDEBUG)) && defined(COM_MPLOCK)
    142 	struct simplelock	sc_lock;
    143 #endif
    144 };
    145 
    146 /* Macros to clear/set/test flags. */
    147 #define SET(t, f)	(t) |= (f)
    148 #define CLR(t, f)	(t) &= ~(f)
    149 #define ISSET(t, f)	((t) & (f))
    150 
    151 int  plcomprobe1	(bus_space_tag_t, bus_space_handle_t);
    152 int  plcomintr		(void *);
    153 void plcom_attach_subr	(struct plcom_softc *);
    154 int  plcom_detach	(struct device *, int);
    155 int  plcom_activate	(struct device *, enum devact);
    156 
    157 #ifndef __HAVE_GENERIC_SOFT_INTERRUPTS
    158 #ifdef __NO_SOFT_SERIAL_INTERRUPT
    159 #define	IPL_SERIAL	IPL_TTY
    160 #define	splserial()	spltty()
    161 #define	IPL_SOFTSERIAL	IPL_TTY
    162 #define	splsoftserial()	spltty()
    163 #endif
    164 #endif
    165