1 /*
2  * ng_bt3c_var.h
3  */
4 
5 /*-
6  * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $Id: ng_bt3c_var.h,v 1.1 2002/11/24 19:46:54 max Exp $
31  * $FreeBSD: src/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_var.h,v 1.4 2006/07/05 17:18:47 emax Exp $
32  * $DragonFly: src/sys/netgraph7/bluetooth/drivers/bt3c/ng_bt3c_var.h,v 1.2 2008/06/26 23:05:40 dillon Exp $
33  *
34  * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
35  *
36  * Based on information obrained from: Jose Orlando Pereira <jop@di.uminho.pt>
37  * and disassembled w2k driver.
38  *
39  * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
40  *
41  */
42 
43 #ifndef _NG_BT3C_VAR_H_
44 #define _NG_BT3C_VAR_H_
45 
46 /* Debug printf's */
47 #define NG_BT3C_ALERT	if (sc->debug >= NG_BT3C_ALERT_LEVEL) device_printf
48 #define NG_BT3C_ERR	if (sc->debug >= NG_BT3C_ERR_LEVEL)   device_printf
49 #define NG_BT3C_WARN	if (sc->debug >= NG_BT3C_WARN_LEVEL)  device_printf
50 #define NG_BT3C_INFO	if (sc->debug >= NG_BT3C_INFO_LEVEL)  device_printf
51 
52 /* Device registers */
53 #define	BT3C_DATA_L		0x00		/* data low byte */
54 #define	BT3C_DATA_H		0x01		/* high byte */
55 #define	BT3C_ADDR_L		0x02		/* address low byte */
56 #define	BT3C_ADDR_H		0x03		/* high byte */
57 #define	BT3C_CONTROL		0x04		/* control */
58 
59 #define BT3C_FIFO_SIZE		256
60 
61 /* Device softc structure */
62 struct bt3c_softc {
63 	/* Device specific */
64 	device_t		 dev;		/* pointer back to device */
65 	int			 iobase_rid;	/* iobase RID */
66 	struct resource		*iobase;	/* iobase */
67 	bus_space_tag_t		 iot;		/* I/O tag */
68 	bus_space_handle_t	 ioh;		/* I/O handle */
69 	int			 irq_rid;       /* irq RID */
70 	struct resource		*irq;		/* irq */
71 	void			*irq_cookie;	/* irq cookie */
72 
73 	/* Netgraph specific */
74 	node_p			 node;		/* pointer back to node */
75 	hook_p			 hook;		/* hook */
76 
77 	ng_bt3c_node_debug_ep	 debug;		/* debug level */
78 	u_int16_t		 flags;		/* device flags */
79 #define BT3C_ANTENNA_OUT	(1 << 0)	/* antena is out */
80 #define BT3C_XMIT		(1 << 1)	/* xmit in progress */
81 
82 	ng_bt3c_node_state_ep	 state;		/* receiving state */
83 
84 	ng_bt3c_node_stat_ep	 stat;		/* statistic */
85 #define NG_BT3C_STAT_PCKTS_SENT(s)	(s).pckts_sent ++
86 #define NG_BT3C_STAT_BYTES_SENT(s, n)	(s).bytes_sent += (n)
87 #define NG_BT3C_STAT_PCKTS_RECV(s)	(s).pckts_recv ++
88 #define NG_BT3C_STAT_BYTES_RECV(s, n)	(s).bytes_recv += (n)
89 #define NG_BT3C_STAT_OERROR(s)		(s).oerrors ++
90 #define NG_BT3C_STAT_IERROR(s)		(s).ierrors ++
91 #define NG_BT3C_STAT_RESET(s)		bzero(&(s), sizeof((s)))
92 
93 	u_int32_t		 status;	/* from ISR */
94 	void			*ith;		/* ithread handler */
95 
96 	struct mbuf		*m;		/* current frame */
97 	u_int32_t		 want;		/* # of chars we want */
98 
99 	struct ifqueue		 inq;		/* queue of incoming mbuf's */
100 	struct ifqueue		 outq;		/* queue of outgoing mbuf's */
101 #define BT3C_DEFAULTQLEN	 12		/* XXX max. size of out queue */
102 };
103 
104 typedef struct bt3c_softc	bt3c_softc_t;
105 typedef struct bt3c_softc *	bt3c_softc_p;
106 
107 #endif /* ndef _NG_BT3C_VAR_H_ */
108 
109