Home | History | Annotate | Line # | Download | only in tc
dtvar.h revision 1.1.12.2
      1  1.1.12.1  skrll /*	$NetBSD: dtvar.h,v 1.1.12.2 2004/09/18 14:39:04 skrll Exp $	*/
      2  1.1.12.1  skrll 
      3  1.1.12.1  skrll /*-
      4  1.1.12.1  skrll  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
      5  1.1.12.1  skrll  * All rights reserved.
      6  1.1.12.1  skrll  *
      7  1.1.12.1  skrll  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1.12.1  skrll  * by Andrew Doran.
      9  1.1.12.1  skrll  *
     10  1.1.12.1  skrll  * Redistribution and use in source and binary forms, with or without
     11  1.1.12.1  skrll  * modification, are permitted provided that the following conditions
     12  1.1.12.1  skrll  * are met:
     13  1.1.12.1  skrll  * 1. Redistributions of source code must retain the above copyright
     14  1.1.12.1  skrll  *    notice, this list of conditions and the following disclaimer.
     15  1.1.12.1  skrll  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1.12.1  skrll  *    notice, this list of conditions and the following disclaimer in the
     17  1.1.12.1  skrll  *    documentation and/or other materials provided with the distribution.
     18  1.1.12.1  skrll  * 3. All advertising materials mentioning features or use of this software
     19  1.1.12.1  skrll  *    must display the following acknowledgement:
     20  1.1.12.1  skrll  *        This product includes software developed by the NetBSD
     21  1.1.12.1  skrll  *        Foundation, Inc. and its contributors.
     22  1.1.12.1  skrll  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1.12.1  skrll  *    contributors may be used to endorse or promote products derived
     24  1.1.12.1  skrll  *    from this software without specific prior written permission.
     25  1.1.12.1  skrll  *
     26  1.1.12.1  skrll  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1.12.1  skrll  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1.12.1  skrll  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1.12.1  skrll  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1.12.1  skrll  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1.12.1  skrll  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1.12.1  skrll  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1.12.1  skrll  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1.12.1  skrll  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1.12.1  skrll  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1.12.1  skrll  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1.12.1  skrll  */
     38  1.1.12.1  skrll 
     39  1.1.12.1  skrll #ifndef _DTVAR_H_
     40  1.1.12.1  skrll #define _DTVAR_H_
     41  1.1.12.1  skrll 
     42  1.1.12.1  skrll #define	DT_DEVICE_NO(a)		(((a) - DT_ADDR_FIRST) >> 1)
     43  1.1.12.1  skrll #define	DT_GET_SHORT(b0, b1)	(((b0) << 8) | (b1))
     44  1.1.12.1  skrll 
     45  1.1.12.1  skrll struct dt_msg {
     46  1.1.12.1  skrll 	uint8_t	dst;
     47  1.1.12.1  skrll 	uint8_t	src;
     48  1.1.12.1  skrll 	uint8_t	ctl;
     49  1.1.12.1  skrll 
     50  1.1.12.1  skrll 	/* varzise, checksum byte at end */
     51  1.1.12.1  skrll 	uint8_t	body[DT_MAX_MSG_SIZE-3];
     52  1.1.12.1  skrll 
     53  1.1.12.1  skrll 	union {
     54  1.1.12.1  skrll 		SLIST_ENTRY(dt_msg) slist;
     55  1.1.12.1  skrll 		SIMPLEQ_ENTRY(dt_msg) simpleq;
     56  1.1.12.1  skrll 	} chain;
     57  1.1.12.1  skrll };
     58  1.1.12.1  skrll 
     59  1.1.12.1  skrll #define	DT_CTL(l, s, p)	\
     60  1.1.12.1  skrll     ((l & 0x1f) | ((s & 0x03) << 5) | ((p & 0x01) << 7))
     61  1.1.12.1  skrll #define	DT_CTL_P(c)		((c >> 7) & 0x01)
     62  1.1.12.1  skrll #define	DT_CTL_SUBADDR(c)	((c >> 5) & 0x03)
     63  1.1.12.1  skrll #define	DT_CTL_LEN(c)		(c & 0x1f)
     64  1.1.12.1  skrll 
     65  1.1.12.1  skrll struct dt_device {
     66  1.1.12.1  skrll 	struct	device *dtdv_dv;
     67  1.1.12.1  skrll 	void	(*dtdv_handler)(void *, struct dt_msg *);
     68  1.1.12.1  skrll };
     69  1.1.12.1  skrll 
     70  1.1.12.1  skrll struct dt_state {
     71  1.1.12.1  skrll 	volatile u_int	*ds_data;
     72  1.1.12.1  skrll 	volatile u_int	*ds_poll;
     73  1.1.12.1  skrll 	int		ds_bad_pkts;
     74  1.1.12.1  skrll 	int		ds_state;
     75  1.1.12.1  skrll 	int		ds_escaped;
     76  1.1.12.1  skrll 	int		ds_len;
     77  1.1.12.1  skrll 	int		ds_ptr;
     78  1.1.12.1  skrll };
     79  1.1.12.1  skrll 
     80  1.1.12.1  skrll struct dt_softc {
     81  1.1.12.1  skrll 	struct device	sc_dv;
     82  1.1.12.1  skrll 	struct dt_msg	sc_msg;
     83  1.1.12.1  skrll 	void		*sc_sih;
     84  1.1.12.1  skrll 	SLIST_HEAD(, dt_msg) sc_free;
     85  1.1.12.1  skrll 	SIMPLEQ_HEAD(, dt_msg) sc_queue;
     86  1.1.12.1  skrll };
     87  1.1.12.1  skrll 
     88  1.1.12.1  skrll struct dt_attach_args {
     89  1.1.12.1  skrll 	int	dta_addr;
     90  1.1.12.1  skrll };
     91  1.1.12.1  skrll 
     92  1.1.12.1  skrll #define	DT_GET_ERROR	-1
     93  1.1.12.1  skrll #define	DT_GET_DONE	0
     94  1.1.12.1  skrll #define	DT_GET_NOTYET	1
     95  1.1.12.1  skrll 
     96  1.1.12.1  skrll void	dt_cninit(void);
     97  1.1.12.1  skrll int	dt_identify(int, struct dt_ident *);
     98  1.1.12.1  skrll int	dt_msg_get(struct dt_msg *, int);
     99  1.1.12.1  skrll void	dt_msg_dump(struct dt_msg *);
    100  1.1.12.1  skrll int	dt_establish_handler(struct dt_softc *, struct dt_device *,
    101  1.1.12.1  skrll     struct device *, void (*)(void *, struct dt_msg *));
    102  1.1.12.1  skrll 
    103  1.1.12.1  skrll extern int	dt_kbd_addr;
    104  1.1.12.1  skrll extern struct	dt_device dt_kbd_dv;
    105  1.1.12.1  skrll extern int	dt_ms_addr;
    106  1.1.12.1  skrll extern struct	dt_device dt_ms_dv;
    107  1.1.12.1  skrll extern struct	dt_state dt_state;
    108  1.1.12.1  skrll 
    109  1.1.12.1  skrll #endif	/* !_DTVAR_H_ */
    110