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