Vendor import of netgraph from FreeBSD-current 20080626
[dragonfly.git] / sys / netgraph7 / bluetooth / drivers / bt3c / ng_bt3c_var.h
bloba3bca3cabf231683f96b5f30c28c23fd4a53f6bf
1 /*
2 * ng_bt3c_var.h
3 */
5 /*-
6 * Copyright (c) 2001-2002 Maksim Yevmenkin <m_evmenkin@yahoo.com>
7 * All rights reserved.
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.
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.
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 $
33 * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
35 * Based on information obrained from: Jose Orlando Pereira <jop@di.uminho.pt>
36 * and disassembled w2k driver.
38 * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
42 #ifndef _NG_BT3C_VAR_H_
43 #define _NG_BT3C_VAR_H_
45 /* Debug printf's */
46 #define NG_BT3C_ALERT if (sc->debug >= NG_BT3C_ALERT_LEVEL) device_printf
47 #define NG_BT3C_ERR if (sc->debug >= NG_BT3C_ERR_LEVEL) device_printf
48 #define NG_BT3C_WARN if (sc->debug >= NG_BT3C_WARN_LEVEL) device_printf
49 #define NG_BT3C_INFO if (sc->debug >= NG_BT3C_INFO_LEVEL) device_printf
51 /* Device registers */
52 #define BT3C_DATA_L 0x00 /* data low byte */
53 #define BT3C_DATA_H 0x01 /* high byte */
54 #define BT3C_ADDR_L 0x02 /* address low byte */
55 #define BT3C_ADDR_H 0x03 /* high byte */
56 #define BT3C_CONTROL 0x04 /* control */
58 #define BT3C_FIFO_SIZE 256
60 /* Device softc structure */
61 struct bt3c_softc {
62 /* Device specific */
63 device_t dev; /* pointer back to device */
64 int iobase_rid; /* iobase RID */
65 struct resource *iobase; /* iobase */
66 bus_space_tag_t iot; /* I/O tag */
67 bus_space_handle_t ioh; /* I/O handle */
68 int irq_rid; /* irq RID */
69 struct resource *irq; /* irq */
70 void *irq_cookie; /* irq cookie */
72 /* Netgraph specific */
73 node_p node; /* pointer back to node */
74 hook_p hook; /* hook */
76 ng_bt3c_node_debug_ep debug; /* debug level */
77 u_int16_t flags; /* device flags */
78 #define BT3C_ANTENNA_OUT (1 << 0) /* antena is out */
79 #define BT3C_XMIT (1 << 1) /* xmit in progress */
81 ng_bt3c_node_state_ep state; /* receiving state */
83 ng_bt3c_node_stat_ep stat; /* statistic */
84 #define NG_BT3C_STAT_PCKTS_SENT(s) (s).pckts_sent ++
85 #define NG_BT3C_STAT_BYTES_SENT(s, n) (s).bytes_sent += (n)
86 #define NG_BT3C_STAT_PCKTS_RECV(s) (s).pckts_recv ++
87 #define NG_BT3C_STAT_BYTES_RECV(s, n) (s).bytes_recv += (n)
88 #define NG_BT3C_STAT_OERROR(s) (s).oerrors ++
89 #define NG_BT3C_STAT_IERROR(s) (s).ierrors ++
90 #define NG_BT3C_STAT_RESET(s) bzero(&(s), sizeof((s)))
92 u_int32_t status; /* from ISR */
93 void *ith; /* ithread handler */
95 struct mbuf *m; /* current frame */
96 u_int32_t want; /* # of chars we want */
98 struct ifqueue inq; /* queue of incoming mbuf's */
99 struct ifqueue outq; /* queue of outgoing mbuf's */
100 #define BT3C_DEFAULTQLEN 12 /* XXX max. size of out queue */
103 typedef struct bt3c_softc bt3c_softc_t;
104 typedef struct bt3c_softc * bt3c_softc_p;
106 #endif /* ndef _NG_BT3C_VAR_H_ */