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