1 /* ISDN4BSD code */ 2 /* $NetBSD: daicvar.h,v 1.5 2002/04/14 12:24:26 martin Exp $ */ 3 4 /*- 5 * Copyright (c) 2002 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation 9 * by Martin Husemann <martin@netbsd.org>. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40 #ifndef DIEHLISDNVAR 41 #define DIEHLISDNVAR 42 #if defined(KERNEL) || defined(_KERNEL) 43 44 #define DAIC_MAX_PORT 4 45 #define DAIC_ISA_MEMSIZE 2048 46 #define DAIC_ISA_QUADSIZE (DAIC_MAX_PORT*DAIC_ISA_MEMSIZE) 47 #define DAIC_MAX_ACTIVE (2*DAIC_MAX_PORT) /* simlutaneous connections on one instance */ 48 49 /* A queue of pending outgoing calls */ 50 struct outcallentry { 51 TAILQ_ENTRY(outcallentry) queue; 52 unsigned int cdid; /* call descriptor id for layer 4 */ 53 u_int8_t dchan_id; /* task id for microcode */ 54 u_int8_t rc; /* return code */ 55 }; 56 57 /* One active connection */ 58 struct daic_connection { 59 u_int cdid; /* layer 4 call descriptor id */ 60 struct ifqueue tx_queue; /* outgoing data */ 61 struct ifqueue rx_queue; /* incoming data */ 62 isdn_link_t isdn_linktab; /* description of ourself */ 63 const struct isdn_l4_driver_functions 64 *l4_driver; /* layer 4 driver */ 65 void *l4_driver_softc; /* layer 4 driver instance */ 66 u_int8_t dchan_inst; /* d-channel instance */ 67 u_int8_t dchan_rc; /* return code for dchannel requests */ 68 u_int8_t bchan_inst; /* b-channel instance */ 69 u_int8_t bchan_rc; /* return code for bchannel requests */ 70 }; 71 72 /* 73 * One BRI as exposed to the upper layers, with all the internal management 74 * information we need for it. A pointer to this is passed as the driver 75 * token. 76 */ 77 struct daic_unit { 78 struct daic_softc *du_sc; /* pointer to softc */ 79 const struct isdn_l3_driver *du_l3; 80 int du_port; /* port number (on multi BRI cards) */ 81 int du_state; /* state of board, see below */ 82 #define DAIC_STATE_COLD 0 /* nothing happened to the board */ 83 #define DAIC_STATE_DOWNLOAD 1 /* the card is waiting for protocol code */ 84 #define DAIC_STATE_TESTING 2 /* waiting for first interrupt from card */ 85 #define DAIC_STATE_RUNNING 3 /* the protocol is running */ 86 #define DAIC_STATE_DIAGNOSTIC 4 /* temporary disabled for diagnostics */ 87 88 int du_assign; /* allocate new protocol instance */ 89 #define DAIC_ASSIGN_PENDING 1 /* we are awaiting a new ID */ 90 #define DAIC_ASSIGN_SLEEPING 2 /* somebody sleeping, wakeup after we got the ID */ 91 #define DAIC_ASSIGN_GLOBAL 4 /* result is a global d-channel id */ 92 #define DAIC_ASSIGN_NOGLOBAL 8 /* need to assign a global d-channel id */ 93 94 u_int8_t du_global_dchan; /* handle of global dchannel instance */ 95 u_int8_t du_request_res; /* result of requests */ 96 u_int8_t du_assign_res; /* result of assigns */ 97 }; 98 99 /* superclass of all softc structs for attachments, you should 100 * always be able to cast an attachments struct device *self to this. */ 101 struct daic_softc { 102 struct device sc_dev; 103 bus_space_tag_t sc_iot; /* bus identifier */ 104 bus_space_handle_t sc_ioh; /* mem handle */ 105 int sc_cardtype; /* variant of card */ 106 #define DAIC_TYPE_S 0 107 #define DAIC_TYPE_SX 1 108 #define DAIC_TYPE_SCOM 2 109 #define DAIC_TYPE_QUAD 3 110 111 struct daic_unit sc_port[DAIC_MAX_PORT]; 112 113 /* one record for each b-channel we could handle concurrently */ 114 struct daic_connection sc_con[DAIC_MAX_ACTIVE]; 115 116 /* a tailq of ougoing calls no yet assigned to any b-channel */ 117 TAILQ_HEAD(outcallhead, outcallentry) sc_outcalls[DAIC_MAX_PORT]; 118 }; 119 120 /* 121 * functions exported from MI part 122 */ 123 extern int daic_probe __P((bus_space_tag_t bus, bus_space_handle_t io)); 124 extern void daic_attach __P((struct device *self, struct daic_softc *sc)); 125 extern int daic_intr __P((struct daic_softc *)); 126 127 #endif 128 #endif 129