diff options
Diffstat (limited to 'sys/dev/awi')
| -rw-r--r-- | sys/dev/awi/README | 60 | ||||
| -rw-r--r-- | sys/dev/awi/am79c930.c | 450 | ||||
| -rw-r--r-- | sys/dev/awi/am79c930reg.h | 126 | ||||
| -rw-r--r-- | sys/dev/awi/am79c930var.h | 79 | ||||
| -rw-r--r-- | sys/dev/awi/awi_wep.c | 528 | ||||
| -rw-r--r-- | sys/dev/awi/awi_wicfg.c | 625 | ||||
| -rw-r--r-- | sys/dev/awi/awireg.h | 460 | ||||
| -rw-r--r-- | sys/dev/awi/awivar.h | 222 | ||||
| -rw-r--r-- | sys/dev/awi/if_awi_pccard.c | 250 |
9 files changed, 0 insertions, 2800 deletions
diff --git a/sys/dev/awi/README b/sys/dev/awi/README deleted file mode 100644 index 38aaec59de92..000000000000 --- a/sys/dev/awi/README +++ /dev/null @@ -1,60 +0,0 @@ -# $Id: README,v 1.19 2000/03/24 08:13:24 onoe Exp $ -# $FreeBSD$ - -===== Configuration - ifconfig awi0 link0 - changes to encapsulation from 802.2 LLC/SNAP (default) to - ether encapsulation. MELCO access point and PAO's ux driver - use this. - -===== Supported Cards - Any IEEE 802.11 cards use AMD Am79C930 and Harris (Intersil) Chipset - with PCnetMobile firmware by AMD. - BayStack 650 1Mbps Frequency Hopping PCCARD adapter - BayStack 660 2Mbps Direct Sequence PCCARD adapter - Icom SL-200 2Mbps Direct Sequence PCCARD adapter - Melco WLI-PCM 2Mbps Direct Sequence PCCARD adapter - NEL SSMagic 2Mbps Direct Sequence PCCARD adapter - Netwave AirSurfer Plus - 1Mbps Frequency Hopping PCCARD adapter - Netwave AirSurfer Pro - 2Mbps Direct Sequence PCCARD adapter - -===== Known Problems - WEP is not supported. - Does not create IBSS itself. - - Cannot configure at all on FreeBSD: - selection of infrastructure/adhoc mode - ESSID - ... - -===== How to add - -*** NetBSD current - already merged into current source tree. - - pcmcia: update the awi driver, which now supports AMD 79c930-based - 802.11DS cards as well as 802.11FH cards, and can operate - in infrastructure mode, adhoc mode, and wi(4) compatible - adhoc mode. [onoe 20000322] - -*** FreeBSD-current - make directory /sys/dev/awi and put all files there. - move if_ieee80211.h to /sys/net - add following lines to /sys/conf/files - dev/awi/am79c930.c optional awi - dev/awi/awi.c optional awi - dev/awi/if_awi_pccard.c optional awi card - add following line to config file - device awi0 - config and make kernel - - add description of your card to /etc/pccard.conf - ex. - card "AMD" "Am79C930" - config 0x1 "awi0" ? - card "Icom" "SL-200" - config 0x1 "awi0" ? - card "Bay Networks" "BayStack 650 Wireless LAN" - config 0x1 "awi0" ? diff --git a/sys/dev/awi/am79c930.c b/sys/dev/awi/am79c930.c deleted file mode 100644 index aa9c97f5a538..000000000000 --- a/sys/dev/awi/am79c930.c +++ /dev/null @@ -1,450 +0,0 @@ -/* $NetBSD: am79c930.c,v 1.5 2000/03/23 13:57:58 onoe Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Am79c930 chip driver. - * - * This is used by the awi driver to use the shared - * memory attached to the 79c930 to communicate with the firmware running - * in the 930's on-board 80188 core. - * - * The 79c930 can be mapped into just I/O space, or also have a - * memory mapping; the mapping must be set up by the bus front-end - * before am79c930_init is called. - */ - -/* - * operations: - * - * read_8, read_16, read_32, read_64, read_bytes - * write_8, write_16, write_32, write_64, write_bytes - * (two versions, depending on whether memory-space or i/o space is in use). - * - * interrupt E.C. - * start isr - * end isr - */ - -#include <sys/param.h> -#include <sys/systm.h> -#ifndef __FreeBSD__ -#include <sys/device.h> -#endif - -#include <machine/cpu.h> -#ifdef __FreeBSD__ -#include <machine/bus_pio.h> -#include <machine/bus_memio.h> -#endif -#include <machine/bus.h> -#ifdef __NetBSD__ -#include <machine/intr.h> -#endif - -#ifdef __NetBSD__ -#include <dev/ic/am79c930reg.h> -#include <dev/ic/am79c930var.h> -#endif -#ifdef __FreeBSD__ -#include <dev/awi/am79c930reg.h> -#include <dev/awi/am79c930var.h> -#endif - -#define AM930_DELAY(x) /*nothing*/ - -void am79c930_regdump __P((struct am79c930_softc *sc)); - -static void io_write_1 __P((struct am79c930_softc *, u_int32_t, u_int8_t)); -static void io_write_2 __P((struct am79c930_softc *, u_int32_t, u_int16_t)); -static void io_write_4 __P((struct am79c930_softc *, u_int32_t, u_int32_t)); -static void io_write_bytes __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t)); - -static u_int8_t io_read_1 __P((struct am79c930_softc *, u_int32_t)); -static u_int16_t io_read_2 __P((struct am79c930_softc *, u_int32_t)); -static u_int32_t io_read_4 __P((struct am79c930_softc *, u_int32_t)); -static void io_read_bytes __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t)); - -static void mem_write_1 __P((struct am79c930_softc *, u_int32_t, u_int8_t)); -static void mem_write_2 __P((struct am79c930_softc *, u_int32_t, u_int16_t)); -static void mem_write_4 __P((struct am79c930_softc *, u_int32_t, u_int32_t)); -static void mem_write_bytes __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t)); - -static u_int8_t mem_read_1 __P((struct am79c930_softc *, u_int32_t)); -static u_int16_t mem_read_2 __P((struct am79c930_softc *, u_int32_t)); -static u_int32_t mem_read_4 __P((struct am79c930_softc *, u_int32_t)); -static void mem_read_bytes __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t)); - -static struct am79c930_ops iospace_ops = { - io_write_1, - io_write_2, - io_write_4, - io_write_bytes, - io_read_1, - io_read_2, - io_read_4, - io_read_bytes -}; - -struct am79c930_ops memspace_ops = { - mem_write_1, - mem_write_2, - mem_write_4, - mem_write_bytes, - mem_read_1, - mem_read_2, - mem_read_4, - mem_read_bytes -}; - -static void io_write_1 (sc, off, val) - struct am79c930_softc *sc; - u_int32_t off; - u_int8_t val; -{ - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA, val); - AM930_DELAY(1); -} - -static void io_write_2 (sc, off, val) - struct am79c930_softc *sc; - u_int32_t off; - u_int16_t val; -{ - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA, val & 0xff); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA, (val>>8)&0xff); - AM930_DELAY(1); -} - -static void io_write_4 (sc, off, val) - struct am79c930_softc *sc; - u_int32_t off; - u_int32_t val; -{ - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,val & 0xff); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>8)&0xff); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>16)&0xff); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,(val>>24)&0xff); - AM930_DELAY(1); -} - -static void io_write_bytes (sc, off, ptr, len) - struct am79c930_softc *sc; - u_int32_t off; - u_int8_t *ptr; - size_t len; -{ - int i; - - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - for (i=0; i<len; i++) - bus_space_write_1(sc->sc_iot,sc->sc_ioh,AM79C930_IODPA,ptr[i]); -} - -static u_int8_t io_read_1 (sc, off) - struct am79c930_softc *sc; - u_int32_t off; -{ - u_int8_t val; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA); - AM930_DELAY(1); - return val; -} - -static u_int16_t io_read_2 (sc, off) - struct am79c930_softc *sc; - u_int32_t off; -{ - u_int16_t val; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA); - AM930_DELAY(1); - val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 8; - AM930_DELAY(1); - return val; -} - -static u_int32_t io_read_4 (sc, off) - struct am79c930_softc *sc; - u_int32_t off; -{ - u_int32_t val; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - val = bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA); - AM930_DELAY(1); - val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 8; - AM930_DELAY(1); - val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 16; - AM930_DELAY(1); - val |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, AM79C930_IODPA) << 24; - AM930_DELAY(1); - return val; -} - -static void io_read_bytes (sc, off, ptr, len) - struct am79c930_softc *sc; - u_int32_t off; - u_int8_t *ptr; - size_t len; -{ - int i; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_HI, - ((off>>8)& 0x7f)); - AM930_DELAY(1); - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_LMA_LO, (off&0xff)); - AM930_DELAY(1); - for (i=0; i<len; i++) - ptr[i] = bus_space_read_1(sc->sc_iot, sc->sc_ioh, - AM79C930_IODPA); -} - -static void mem_write_1 (sc, off, val) - struct am79c930_softc *sc; - u_int32_t off; - u_int8_t val; -{ - bus_space_write_1(sc->sc_memt, sc->sc_memh, off, val); -} - -static void mem_write_2 (sc, off, val) - struct am79c930_softc *sc; - u_int32_t off; - u_int16_t val; -{ - bus_space_tag_t t = sc->sc_memt; - bus_space_handle_t h = sc->sc_memh; - - /* could be unaligned */ - if ((off & 0x1) == 0) - bus_space_write_2(t, h, off, val); - else { - bus_space_write_1(t, h, off, val & 0xff); - bus_space_write_1(t, h, off+1, (val >> 8) & 0xff); - } -} - -static void mem_write_4 (sc, off, val) - struct am79c930_softc *sc; - u_int32_t off; - u_int32_t val; -{ - bus_space_tag_t t = sc->sc_memt; - bus_space_handle_t h = sc->sc_memh; - - /* could be unaligned */ - if ((off & 0x3) == 0) - bus_space_write_4(t, h, off, val); - else { - bus_space_write_1(t, h, off, val & 0xff); - bus_space_write_1(t, h, off+1, (val >> 8) & 0xff); - bus_space_write_1(t, h, off+2, (val >> 16) & 0xff); - bus_space_write_1(t, h, off+3, (val >> 24) & 0xff); - } -} - -static void mem_write_bytes (sc, off, ptr, len) - struct am79c930_softc *sc; - u_int32_t off; - u_int8_t *ptr; - size_t len; -{ - bus_space_write_region_1 (sc->sc_memt, sc->sc_memh, off, ptr, len); -} - - -static u_int8_t mem_read_1 (sc, off) - struct am79c930_softc *sc; - u_int32_t off; -{ - return bus_space_read_1(sc->sc_memt, sc->sc_memh, off); -} - -static u_int16_t mem_read_2 (sc, off) - struct am79c930_softc *sc; - u_int32_t off; -{ - /* could be unaligned */ - if ((off & 0x1) == 0) - return bus_space_read_2(sc->sc_memt, sc->sc_memh, off); - else - return - bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) | - (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8); -} - -static u_int32_t mem_read_4 (sc, off) - struct am79c930_softc *sc; - u_int32_t off; -{ - /* could be unaligned */ - if ((off & 0x3) == 0) - return bus_space_read_4(sc->sc_memt, sc->sc_memh, off); - else - return - bus_space_read_1(sc->sc_memt, sc->sc_memh, off ) | - (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+1) << 8) | - (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+2) <<16) | - (bus_space_read_1(sc->sc_memt, sc->sc_memh, off+3) <<24); -} - - - -static void mem_read_bytes (sc, off, ptr, len) - struct am79c930_softc *sc; - u_int32_t off; - u_int8_t *ptr; - size_t len; -{ - bus_space_read_region_1 (sc->sc_memt, sc->sc_memh, off, ptr, len); -} - - - - -/* - * Set bits in GCR. - */ - -void am79c930_gcr_setbits (sc, bits) - struct am79c930_softc *sc; - u_int8_t bits; -{ - u_int8_t gcr = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR); - - gcr |= bits; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_GCR, gcr); -} - -/* - * Clear bits in GCR. - */ - -void am79c930_gcr_clearbits (sc, bits) - struct am79c930_softc *sc; - u_int8_t bits; -{ - u_int8_t gcr = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR); - - gcr &= ~bits; - - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_GCR, gcr); -} - -u_int8_t am79c930_gcr_read (sc) - struct am79c930_softc *sc; -{ - return bus_space_read_1 (sc->sc_iot, sc->sc_ioh, AM79C930_GCR); -} - -#if 0 -void am79c930_regdump (sc) - struct am79c930_softc *sc; -{ - u_int8_t buf[8]; - int i; - - AM930_DELAY(5); - for (i=0; i<8; i++) { - buf[i] = bus_space_read_1 (sc->sc_iot, sc->sc_ioh, i); - AM930_DELAY(5); - } - printf("am79c930: regdump:"); - for (i=0; i<8; i++) { - printf(" %02x", buf[i]); - } - printf("\n"); -} -#endif - -void am79c930_chip_init (sc, how) - struct am79c930_softc *sc; -{ - /* zero the bank select register, and leave it that way.. */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, AM79C930_BSS, 0); - if (how) - sc->sc_ops = &memspace_ops; - else - sc->sc_ops = &iospace_ops; -} - - diff --git a/sys/dev/awi/am79c930reg.h b/sys/dev/awi/am79c930reg.h deleted file mode 100644 index 64b3e239fab1..000000000000 --- a/sys/dev/awi/am79c930reg.h +++ /dev/null @@ -1,126 +0,0 @@ -/* $NetBSD: am79c930reg.h,v 1.3 2000/03/22 11:22:22 onoe Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Device register definitions gleaned from from the AMD "Am79C930 - * PCnet(tm)-Mobile Single Chip Wireless LAN Media Access Controller" - * data sheet, AMD Pub #20183, Rev B, amendment/0, issue date August 1997. - * - * As of 1999/10/23, this was available from AMD's web site in PDF - * form. - */ - - -/* - * The 79c930 contains a bus interface unit, a media access - * controller, and a tranceiver attachment interface. - * The MAC contains an 80188 CPU core. - * typical devices built around this chip typically add 32k or 64k of - * memory for buffers. - * - * The 80188 runs firmware which handles most of the 802.11 gorp, and - * communicates with the host using shared data structures in this - * memory; the specifics of the shared memory layout are not covered - * in this source file; see <dev/ic/am80211fw.h> for details of that layer. - */ - -/* - * Device Registers - */ - -#define AM79C930_IO_BASE 0 -#define AM79C930_IO_SIZE 16 -#define AM79C930_IO_SIZE_BIG 40 -#define AM79C930_IO_ALIGN 0x40 /* am79c930 decodes lower 6bits */ - - -#define AM79C930_GCR 0 /* General Config Register */ - -#define AM79C930_GCR_SWRESET 0x80 /* software reset */ -#define AM79C930_GCR_CORESET 0x40 /* core reset */ -#define AM79C930_GCR_DISPWDN 0x20 /* disable powerdown */ -#define AM79C930_GCR_ECWAIT 0x10 /* embedded controller wait */ -#define AM79C930_GCR_ECINT 0x08 /* interrupt from embedded ctrlr */ -#define AM79C930_GCR_INT2EC 0x04 /* interrupt to embedded ctrlr */ -#define AM79C930_GCR_ENECINT 0x02 /* enable interrupts from e.c. */ -#define AM79C930_GCR_DAM 0x01 /* direct access mode (read only) */ - -#define AM79C930_GCR_BITS "\020\1DAM\2ENECINT\3INT2EC\4ECINT\5ECWAIT\6DISPWDN\7CORESET\010SWRESET" - -#define AM79C930_BSS 1 /* Bank Switching Select register */ - -#define AM79C930_BSS_ECATR 0x80 /* E.C. ALE test read */ -#define AM79C930_BSS_FS 0x20 /* Flash Select */ -#define AM79C930_BSS_MBS 0x18 /* Memory Bank Select */ -#define AM79C930_BSS_EIOW 0x04 /* Expand I/O Window */ -#define AM79C930_BSS_TBS 0x03 /* TAI Bank Select */ - -#define AM79C930_LMA_LO 2 /* Local Memory Address register (low byte) */ - -#define AM79C930_LMA_HI 3 /* Local Memory Address register (high byte) */ - - /* set this bit to turn off ISAPnP version */ -#define AM79C930_LMA_HI_ISAPWRDWN 0x80 - -/* - * mmm, inconsistancy in chip documentation: - * According to page 79--80, all four of the following are equivalent - * and address the single byte pointed at by BSS_{FS,MBS} | LMA_{HI,LO} - * According to tables on p63 and p67, they're the LSB through MSB - * of a 32-bit word. - */ - -#define AM79C930_IODPA 4 /* I/O Data port A */ -#define AM79C930_IODPB 5 /* I/O Data port B */ -#define AM79C930_IODPC 6 /* I/O Data port C */ -#define AM79C930_IODPD 7 /* I/O Data port D */ - - -/* - * Tranceiver Attachment Interface Registers (TIR space) - * (omitted for now, since host access to them is for diagnostic - * purposes only). - */ - -/* - * memory space goo. - */ - -#define AM79C930_MEM_SIZE 0x8000 /* 32k */ -#define AM79C930_MEM_BASE 0x0 /* starting at 0 */ diff --git a/sys/dev/awi/am79c930var.h b/sys/dev/awi/am79c930var.h deleted file mode 100644 index 1e45c6817a9d..000000000000 --- a/sys/dev/awi/am79c930var.h +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD$ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#define AM79C930_BUS_PCMCIA 1 -#define AM79C930_BUS_ISAPNP 2 /* not implemented */ - -struct am79c930_softc -{ - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; - - bus_space_tag_t sc_memt; - bus_space_handle_t sc_memh; - - struct am79c930_ops *sc_ops; - - int sc_bustype; -}; - -struct am79c930_ops -{ - void (*write_1) __P((struct am79c930_softc *, u_int32_t, u_int8_t)); - void (*write_2) __P((struct am79c930_softc *, u_int32_t, u_int16_t)); - void (*write_4) __P((struct am79c930_softc *, u_int32_t, u_int32_t)); - void (*write_bytes) __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t)); - - u_int8_t (*read_1) __P((struct am79c930_softc *, u_int32_t)); - u_int16_t (*read_2) __P((struct am79c930_softc *, u_int32_t)); - u_int32_t (*read_4) __P((struct am79c930_softc *, u_int32_t)); - void (*read_bytes) __P((struct am79c930_softc *, u_int32_t, u_int8_t *, size_t)); -}; - -void am79c930_chip_init __P((struct am79c930_softc *sc, int)); - -void am79c930_gcr_setbits __P((struct am79c930_softc *sc, u_int8_t bits)); -void am79c930_gcr_clearbits __P((struct am79c930_softc *sc, u_int8_t bits)); - -u_int8_t am79c930_gcr_read __P((struct am79c930_softc *sc)); - -#define am79c930_hard_reset(sc) am79c930_gcr_setbits(sc, AM79C930_GCR_CORESET) -#define am79c930_hard_reset_off(sc) am79c930_gcr_clearbits(sc, AM79C930_GCR_CORESET) - - diff --git a/sys/dev/awi/awi_wep.c b/sys/dev/awi/awi_wep.c deleted file mode 100644 index a8f76ec793e0..000000000000 --- a/sys/dev/awi/awi_wep.c +++ /dev/null @@ -1,528 +0,0 @@ -/* $NetBSD: awi_wep.c,v 1.4 2000/08/14 11:28:03 onoe Exp $ */ -/* $FreeBSD$ */ - -/* - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Atsushi Onoe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * WEP support framework for the awi driver. - * - * No actual encryption capability is provided here, but any can be added - * to awi_wep_algo table below. - * - * Note that IEEE802.11 specification states WEP uses RC4 with 40bit key, - * which is a proprietary encryption algorithm available under license - * from RSA Data Security Inc. Using another algorithm, includes null - * encryption provided here, the awi driver cannot be able to communicate - * with other stations. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/mbuf.h> -#include <sys/malloc.h> -#include <sys/socket.h> -#include <sys/errno.h> -#include <sys/sockio.h> -#if defined(__FreeBSD__) && __FreeBSD__ >= 4 -#include <sys/bus.h> -#else -#include <sys/device.h> -#endif - -#include <net/if.h> -#include <net/if_dl.h> -#ifdef __FreeBSD__ -#include <net/ethernet.h> -#include <net/if_arp.h> -#else -#include <net/if_ether.h> -#endif -#include <net/if_media.h> -#include <net/if_ieee80211.h> - -#include <machine/cpu.h> -#include <machine/bus.h> -#ifdef __FreeBSD__ -#endif - -#ifdef __NetBSD__ -#include <dev/ic/am79c930reg.h> -#include <dev/ic/am79c930var.h> -#include <dev/ic/awireg.h> -#include <dev/ic/awivar.h> - -#include <crypto/arc4/arc4.h> -#endif - -#ifdef __FreeBSD__ -#include <dev/awi/am79c930reg.h> -#include <dev/awi/am79c930var.h> -#include <dev/awi/awireg.h> -#include <dev/awi/awivar.h> - -#include <crypto/rc4/rc4.h> -static __inline int -arc4_ctxlen(void) -{ - return sizeof(struct rc4_state); -} - -static __inline void -arc4_setkey(void *ctx, u_int8_t *key, int keylen) -{ - rc4_init(ctx, key, keylen); -} - -static __inline void -arc4_encrypt(void *ctx, u_int8_t *dst, u_int8_t *src, int len) -{ - rc4_crypt(ctx, src, dst, len); -} -#endif - -static void awi_crc_init __P((void)); -static u_int32_t awi_crc_update __P((u_int32_t crc, u_int8_t *buf, int len)); - -static int awi_null_ctxlen __P((void)); -static void awi_null_setkey __P((void *ctx, u_int8_t *key, int keylen)); -static void awi_null_copy __P((void *ctx, u_int8_t *dst, u_int8_t *src, int len)); - -/* XXX: the order should be known to wiconfig/user */ - -static struct awi_wep_algo awi_wep_algo[] = { -/* 0: no wep */ - { "no" }, /* dummy for no wep */ - -/* 1: normal wep (arc4) */ - { "arc4", arc4_ctxlen, arc4_setkey, - arc4_encrypt, arc4_encrypt }, - -/* 2: debug wep (null) */ - { "null", awi_null_ctxlen, awi_null_setkey, - awi_null_copy, awi_null_copy }, - /* dummy for wep without encryption */ -}; - -int -awi_wep_setnwkey(sc, nwkey) - struct awi_softc *sc; - struct ieee80211_nwkey *nwkey; -{ - int i, len, error; - u_int8_t keybuf[AWI_MAX_KEYLEN]; - - if (nwkey->i_defkid <= 0 || - nwkey->i_defkid > IEEE80211_WEP_NKID) - return EINVAL; - error = 0; - for (i = 0; i < IEEE80211_WEP_NKID; i++) { - if (nwkey->i_key[i].i_keydat == NULL) - continue; - len = nwkey->i_key[i].i_keylen; - if (len > sizeof(keybuf)) { - error = EINVAL; - break; - } - error = copyin(nwkey->i_key[i].i_keydat, keybuf, len); - if (error) - break; - error = awi_wep_setkey(sc, i, keybuf, len); - if (error) - break; - } - if (error == 0) { - sc->sc_wep_defkid = nwkey->i_defkid - 1; - error = awi_wep_setalgo(sc, nwkey->i_wepon); - if (error == 0 && sc->sc_enabled) { - awi_stop(sc); - error = awi_init(sc); - } - } - return error; -} - -int -awi_wep_getnwkey(sc, nwkey) - struct awi_softc *sc; - struct ieee80211_nwkey *nwkey; -{ - int i, len, error, suerr; - u_int8_t keybuf[AWI_MAX_KEYLEN]; - - nwkey->i_wepon = awi_wep_getalgo(sc); - nwkey->i_defkid = sc->sc_wep_defkid + 1; - /* do not show any keys to non-root user */ -#ifdef __FreeBSD__ - suerr = suser(curproc); -#else - suerr = suser(curproc->p_ucred, &curproc->p_acflag); -#endif - error = 0; - for (i = 0; i < IEEE80211_WEP_NKID; i++) { - if (nwkey->i_key[i].i_keydat == NULL) - continue; - if (suerr) { - error = suerr; - break; - } - len = sizeof(keybuf); - error = awi_wep_getkey(sc, i, keybuf, &len); - if (error) - break; - if (nwkey->i_key[i].i_keylen < len) { - error = ENOSPC; - break; - } - nwkey->i_key[i].i_keylen = len; - error = copyout(keybuf, nwkey->i_key[i].i_keydat, len); - if (error) - break; - } - return error; -} - -int -awi_wep_getalgo(sc) - struct awi_softc *sc; -{ - - if (sc->sc_wep_algo == NULL) - return 0; - return sc->sc_wep_algo - awi_wep_algo; -} - -int -awi_wep_setalgo(sc, algo) - struct awi_softc *sc; - int algo; -{ - struct awi_wep_algo *awa; - int ctxlen; - - awi_crc_init(); /* XXX: not belongs here */ - if (algo < 0 || algo > sizeof(awi_wep_algo)/sizeof(awi_wep_algo[0])) - return EINVAL; - awa = &awi_wep_algo[algo]; - if (awa->awa_name == NULL) - return EINVAL; - if (awa->awa_ctxlen == NULL) { - awa = NULL; - ctxlen = 0; - } else - ctxlen = awa->awa_ctxlen(); - if (sc->sc_wep_ctx != NULL) { - free(sc->sc_wep_ctx, M_DEVBUF); - sc->sc_wep_ctx = NULL; - } - if (ctxlen) { - sc->sc_wep_ctx = malloc(ctxlen, M_DEVBUF, M_NOWAIT); - if (sc->sc_wep_ctx == NULL) - return ENOMEM; - } - sc->sc_wep_algo = awa; - return 0; -} - -int -awi_wep_setkey(sc, kid, key, keylen) - struct awi_softc *sc; - int kid; - unsigned char *key; - int keylen; -{ - - if (kid < 0 || kid >= IEEE80211_WEP_NKID) - return EINVAL; - if (keylen < 0 || keylen + IEEE80211_WEP_IVLEN > AWI_MAX_KEYLEN) - return EINVAL; - sc->sc_wep_keylen[kid] = keylen; - if (keylen > 0) - memcpy(sc->sc_wep_key[kid] + IEEE80211_WEP_IVLEN, key, keylen); - return 0; -} - -int -awi_wep_getkey(sc, kid, key, keylen) - struct awi_softc *sc; - int kid; - unsigned char *key; - int *keylen; -{ - - if (kid < 0 || kid >= IEEE80211_WEP_NKID) - return EINVAL; - if (*keylen < sc->sc_wep_keylen[kid]) - return ENOSPC; - *keylen = sc->sc_wep_keylen[kid]; - if (*keylen > 0) - memcpy(key, sc->sc_wep_key[kid] + IEEE80211_WEP_IVLEN, *keylen); - return 0; -} - -struct mbuf * -awi_wep_encrypt(sc, m0, txflag) - struct awi_softc *sc; - struct mbuf *m0; - int txflag; -{ - struct mbuf *m, *n, *n0; - struct ieee80211_frame *wh; - struct awi_wep_algo *awa; - int left, len, moff, noff, keylen, kid; - u_int32_t iv, crc; - u_int8_t *key, *ivp; - void *ctx; - u_int8_t crcbuf[IEEE80211_WEP_CRCLEN]; - - n0 = NULL; - awa = sc->sc_wep_algo; - if (awa == NULL) - goto fail; - ctx = sc->sc_wep_ctx; - m = m0; - left = m->m_pkthdr.len; - MGET(n, M_DONTWAIT, m->m_type); - n0 = n; - if (n == NULL) - goto fail; - M_COPY_PKTHDR(n, m); - len = IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN; - if (txflag) { - n->m_pkthdr.len += len; - } else { - n->m_pkthdr.len -= len; - left -= len; - } - n->m_len = MHLEN; - if (n->m_pkthdr.len >= MINCLSIZE) { - MCLGET(n, M_DONTWAIT); - if (n->m_flags & M_EXT) - n->m_len = n->m_ext.ext_size; - } - len = sizeof(struct ieee80211_frame); - memcpy(mtod(n, caddr_t), mtod(m, caddr_t), len); - left -= len; - moff = len; - noff = len; - if (txflag) { - kid = sc->sc_wep_defkid; - wh = mtod(n, struct ieee80211_frame *); - wh->i_fc[1] |= IEEE80211_FC1_WEP; - iv = random(); - /* - * store IV, byte order is not the matter since it's random. - * assuming IEEE80211_WEP_IVLEN is 3 - */ - ivp = mtod(n, u_int8_t *) + noff; - ivp[0] = (iv >> 16) & 0xff; - ivp[1] = (iv >> 8) & 0xff; - ivp[2] = iv & 0xff; - ivp[3] = kid & 0x03; /* clear pad and keyid */ - noff += IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN; - } else { - ivp = mtod(m, u_int8_t *) + moff; - moff += IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN; - kid = ivp[IEEE80211_WEP_IVLEN] & 0x03; - } - key = sc->sc_wep_key[kid]; - keylen = sc->sc_wep_keylen[kid]; - /* assuming IEEE80211_WEP_IVLEN is 3 */ - key[0] = ivp[0]; - key[1] = ivp[1]; - key[2] = ivp[2]; - awa->awa_setkey(ctx, key, IEEE80211_WEP_IVLEN + keylen); - - /* encrypt with calculating CRC */ - crc = ~0; - while (left > 0) { - len = m->m_len - moff; - if (len == 0) { - m = m->m_next; - moff = 0; - continue; - } - if (len > n->m_len - noff) { - len = n->m_len - noff; - if (len == 0) { - MGET(n->m_next, M_DONTWAIT, n->m_type); - if (n->m_next == NULL) - goto fail; - n = n->m_next; - n->m_len = MLEN; - if (left >= MINCLSIZE) { - MCLGET(n, M_DONTWAIT); - if (n->m_flags & M_EXT) - n->m_len = n->m_ext.ext_size; - } - noff = 0; - continue; - } - } - if (len > left) - len = left; - if (txflag) { - awa->awa_encrypt(ctx, mtod(n, caddr_t) + noff, - mtod(m, caddr_t) + moff, len); - crc = awi_crc_update(crc, mtod(m, caddr_t) + moff, len); - } else { - awa->awa_decrypt(ctx, mtod(n, caddr_t) + noff, - mtod(m, caddr_t) + moff, len); - crc = awi_crc_update(crc, mtod(n, caddr_t) + noff, len); - } - left -= len; - moff += len; - noff += len; - } - crc = ~crc; - if (txflag) { - LE_WRITE_4(crcbuf, crc); - if (n->m_len >= noff + sizeof(crcbuf)) - n->m_len = noff + sizeof(crcbuf); - else { - n->m_len = noff; - MGET(n->m_next, M_DONTWAIT, n->m_type); - if (n->m_next == NULL) - goto fail; - n = n->m_next; - n->m_len = sizeof(crcbuf); - noff = 0; - } - awa->awa_encrypt(ctx, mtod(n, caddr_t) + noff, crcbuf, - sizeof(crcbuf)); - } else { - n->m_len = noff; - for (noff = 0; noff < sizeof(crcbuf); noff += len) { - len = sizeof(crcbuf) - noff; - if (len > m->m_len - moff) - len = m->m_len - moff; - if (len > 0) - awa->awa_decrypt(ctx, crcbuf + noff, - mtod(m, caddr_t) + moff, len); - m = m->m_next; - moff = 0; - } - if (crc != LE_READ_4(crcbuf)) - goto fail; - } - m_freem(m0); - return n0; - - fail: - m_freem(m0); - m_freem(n0); - return NULL; -} - -/* - * CRC 32 -- routine from RFC 2083 - */ - -/* Table of CRCs of all 8-bit messages */ -static u_int32_t awi_crc_table[256]; -static int awi_crc_table_computed = 0; - -/* Make the table for a fast CRC. */ -static void -awi_crc_init() -{ - u_int32_t c; - int n, k; - - if (awi_crc_table_computed) - return; - for (n = 0; n < 256; n++) { - c = (u_int32_t)n; - for (k = 0; k < 8; k++) { - if (c & 1) - c = 0xedb88320UL ^ (c >> 1); - else - c = c >> 1; - } - awi_crc_table[n] = c; - } - awi_crc_table_computed = 1; -} - -/* - * Update a running CRC with the bytes buf[0..len-1]--the CRC - * should be initialized to all 1's, and the transmitted value - * is the 1's complement of the final running CRC - */ - -static u_int32_t -awi_crc_update(crc, buf, len) - u_int32_t crc; - u_int8_t *buf; - int len; -{ - u_int8_t *endbuf; - - for (endbuf = buf + len; buf < endbuf; buf++) - crc = awi_crc_table[(crc ^ *buf) & 0xff] ^ (crc >> 8); - return crc; -} - -/* - * Null -- do nothing but copy. - */ - -static int -awi_null_ctxlen() -{ - - return 0; -} - -static void -awi_null_setkey(ctx, key, keylen) - void *ctx; - u_char *key; - int keylen; -{ -} - -static void -awi_null_copy(ctx, dst, src, len) - void *ctx; - u_char *dst; - u_char *src; - int len; -{ - - memcpy(dst, src, len); -} diff --git a/sys/dev/awi/awi_wicfg.c b/sys/dev/awi/awi_wicfg.c deleted file mode 100644 index 80882ba3035a..000000000000 --- a/sys/dev/awi/awi_wicfg.c +++ /dev/null @@ -1,625 +0,0 @@ -/* $NetBSD: awi_wicfg.c,v 1.3 2000/07/06 17:22:25 onoe Exp $ */ -/* $FreeBSD$ */ - -/* - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Atsushi Onoe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * WaveLAN compatible configuration support routines for the awi driver. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/mbuf.h> -#include <sys/malloc.h> -#include <sys/socket.h> -#include <sys/errno.h> -#include <sys/sockio.h> -#if defined(__FreeBSD__) && __FreeBSD__ >= 4 -#include <sys/bus.h> -#else -#include <sys/device.h> -#endif - -#include <net/if.h> -#include <net/if_dl.h> -#ifdef __FreeBSD__ -#include <net/ethernet.h> -#include <net/if_arp.h> -#else -#include <net/if_ether.h> -#endif -#include <net/if_media.h> -#include <net/if_ieee80211.h> - -#include <machine/cpu.h> -#include <machine/bus.h> -#ifdef __FreeBSD__ -#endif - -#ifdef __NetBSD__ -#include <dev/ic/am79c930reg.h> -#include <dev/ic/am79c930var.h> -#include <dev/ic/awireg.h> -#include <dev/ic/awivar.h> - -#include <dev/pcmcia/if_wi_ieee.h> /* XXX */ -#endif -#ifdef __FreeBSD__ -#include <dev/awi/am79c930reg.h> -#include <dev/awi/am79c930var.h> - -#undef _KERNEL /* XXX */ -#include <i386/include/if_wavelan_ieee.h> /* XXX */ -#define _KERNEL /* XXX */ -#include <dev/awi/awireg.h> -#include <dev/awi/awivar.h> -#endif - -static int awi_cfgget __P((struct ifnet *ifp, u_long cmd, caddr_t data)); -static int awi_cfgset __P((struct ifnet *ifp, u_long cmd, caddr_t data)); - -int -awi_wicfg(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - int error; - - switch (cmd) { - case SIOCGWAVELAN: - error = awi_cfgget(ifp, cmd, data); - break; - case SIOCSWAVELAN: -#ifdef __FreeBSD__ - error = suser(curproc); -#else - error = suser(curproc->p_ucred, &curproc->p_acflag); -#endif - if (error) - break; - error = awi_cfgset(ifp, cmd, data); - break; - default: - error = EINVAL; - break; - } - return error; -} - -static int -awi_cfgget(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - int i, error, keylen; - char *p; - struct awi_softc *sc = (struct awi_softc *)ifp->if_softc; - struct ifreq *ifr = (struct ifreq *)data; - struct wi_ltv_keys *keys; - struct wi_key *k; - struct wi_req wreq; -#ifdef WICACHE - struct wi_sigcache wsc; - struct awi_bss *bp; -#endif /* WICACHE */ - - error = copyin(ifr->ifr_data, &wreq, sizeof(wreq)); - if (error) - return error; - switch (wreq.wi_type) { - case WI_RID_SERIALNO: - memcpy(wreq.wi_val, sc->sc_banner, AWI_BANNER_LEN); - wreq.wi_len = (AWI_BANNER_LEN + 1) / 2; - break; - case WI_RID_NODENAME: - strcpy((char *)&wreq.wi_val[1], hostname); - wreq.wi_val[0] = strlen(hostname); - wreq.wi_len = (1 + wreq.wi_val[0] + 1) / 2; - break; - case WI_RID_OWN_SSID: - p = sc->sc_ownssid; - wreq.wi_val[0] = p[1]; - memcpy(&wreq.wi_val[1], p + 2, p[1]); - wreq.wi_len = (1 + wreq.wi_val[0] + 1) / 2; - break; - case WI_RID_CURRENT_SSID: - if (ifp->if_flags & IFF_RUNNING) { - p = sc->sc_bss.essid; - wreq.wi_val[0] = p[1]; - memcpy(&wreq.wi_val[1], p + 2, p[1]); - } else { - wreq.wi_val[0] = 0; - wreq.wi_val[1] = '\0'; - } - wreq.wi_len = (1 + wreq.wi_val[0] + 1) / 2; - break; - case WI_RID_DESIRED_SSID: - p = sc->sc_mib_mac.aDesired_ESS_ID; - wreq.wi_val[0] = p[1]; - memcpy(&wreq.wi_val[1], p + 2, p[1]); - wreq.wi_len = (1 + wreq.wi_val[0] + 1) / 2; - break; - case WI_RID_CURRENT_BSSID: - if (ifp->if_flags & IFF_RUNNING) - memcpy(wreq.wi_val, sc->sc_bss.bssid, ETHER_ADDR_LEN); - else - memset(wreq.wi_val, 0, ETHER_ADDR_LEN); - wreq.wi_len = ETHER_ADDR_LEN / 2; - break; - case WI_RID_CHANNEL_LIST: - if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) { - wreq.wi_val[0] = sc->sc_scan_min; - wreq.wi_val[1] = sc->sc_scan_max; - wreq.wi_len = 2; - } else { - wreq.wi_val[0] = 0; - for (i = sc->sc_scan_min; i <= sc->sc_scan_max; i++) - wreq.wi_val[0] |= 1 << (i - 1); - wreq.wi_len = 1; - } - break; - case WI_RID_OWN_CHNL: - wreq.wi_val[0] = sc->sc_ownch; - wreq.wi_len = 1; - break; - case WI_RID_CURRENT_CHAN: - if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) - wreq.wi_val[0] = sc->sc_bss.pattern; - else - wreq.wi_val[0] = sc->sc_bss.chanset; - wreq.wi_len = 1; - break; - case WI_RID_COMMS_QUALITY: - wreq.wi_val[0] = 0; /* quality */ - wreq.wi_val[1] = sc->sc_bss.rssi; /* signal */ - wreq.wi_val[2] = 0; /* noise */ - wreq.wi_len = 3; - break; - case WI_RID_PROMISC: - wreq.wi_val[0] = sc->sc_mib_mac.aPromiscuous_Enable; - wreq.wi_len = 1; - break; - case WI_RID_PORTTYPE: - if (sc->sc_mib_local.Network_Mode) - wreq.wi_val[0] = 1; - else if (!sc->sc_no_bssid) - wreq.wi_val[0] = 2; - else - wreq.wi_val[0] = 3; - wreq.wi_len = 1; - break; - case WI_RID_MAC_NODE: - memcpy(wreq.wi_val, sc->sc_mib_addr.aMAC_Address, - ETHER_ADDR_LEN); - wreq.wi_len = ETHER_ADDR_LEN / 2; - break; - case WI_RID_TX_RATE: - case WI_RID_CUR_TX_RATE: - wreq.wi_val[0] = sc->sc_tx_rate / 10; - wreq.wi_len = 1; - break; - case WI_RID_RTS_THRESH: - wreq.wi_val[0] = LE_READ_2(&sc->sc_mib_mac.aRTS_Threshold); - wreq.wi_len = 1; - break; - case WI_RID_CREATE_IBSS: - wreq.wi_val[0] = sc->sc_start_bss; - wreq.wi_len = 1; - break; - case WI_RID_SYSTEM_SCALE: - wreq.wi_val[0] = 1; /* low density ... not supported */ - wreq.wi_len = 1; - break; - case WI_RID_PM_ENABLED: - wreq.wi_val[0] = sc->sc_mib_local.Power_Saving_Mode_Dis ? 0 : 1; - wreq.wi_len = 1; - break; - case WI_RID_MAX_SLEEP: - wreq.wi_val[0] = 0; /* not implemented */ - wreq.wi_len = 1; - break; - case WI_RID_WEP_AVAIL: - wreq.wi_val[0] = 1; - wreq.wi_len = 1; - break; - case WI_RID_ENCRYPTION: - wreq.wi_val[0] = awi_wep_getalgo(sc); - wreq.wi_len = 1; - break; - case WI_RID_TX_CRYPT_KEY: - wreq.wi_val[0] = sc->sc_wep_defkid; - wreq.wi_len = 1; - break; - case WI_RID_DEFLT_CRYPT_KEYS: - keys = (struct wi_ltv_keys *)&wreq; - /* do not show keys to non-root user */ -#ifdef __FreeBSD__ - error = suser(curproc); -#else - error = suser(curproc->p_ucred, &curproc->p_acflag); -#endif - if (error) { - memset(keys, 0, sizeof(*keys)); - error = 0; - break; - } - for (i = 0; i < IEEE80211_WEP_NKID; i++) { - k = &keys->wi_keys[i]; - keylen = sizeof(k->wi_keydat); - error = awi_wep_getkey(sc, i, k->wi_keydat, &keylen); - if (error) - break; - k->wi_keylen = keylen; - } - wreq.wi_len = sizeof(*keys) / 2; - break; - case WI_RID_MAX_DATALEN: - wreq.wi_val[0] = LE_READ_2(&sc->sc_mib_mac.aMax_Frame_Length); - wreq.wi_len = 1; - break; - case WI_RID_IFACE_STATS: - /* not implemented yet */ - wreq.wi_len = 0; - break; -#ifdef WICACHE - case WI_RID_READ_CACHE: - for (bp = TAILQ_FIRST(&sc->sc_scan), i = 0; - bp != NULL && i < MAXWICACHE; - bp = TAILQ_NEXT(bp, list), i++) { - memcpy(wsc.macsrc, bp->esrc, ETHER_ADDR_LEN); - /*XXX*/ - memcpy(&wsc.ipsrc, bp->bssid, sizeof(wsc.ipsrc)); - wsc.signal = bp->rssi; - wsc.noise = 0; - wsc.quality = 0; - memcpy((caddr_t)wreq.wi_val + sizeof(wsc) * i, - &wsc, sizeof(wsc)); - } - wreq.wi_len = sizeof(wsc) * i / 2; - break; -#endif /* WICACHE */ - default: - error = EINVAL; - break; - } - if (error == 0) { - wreq.wi_len++; - error = copyout(&wreq, ifr->ifr_data, sizeof(wreq)); - } - return error; -} - -static int -awi_cfgset(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - caddr_t data; -{ - int i, error, rate, oregion; - u_int8_t *phy_rates; - struct awi_softc *sc = (struct awi_softc *)ifp->if_softc; - struct ifreq *ifr = (struct ifreq *)data; - struct wi_ltv_keys *keys; - struct wi_key *k; - struct wi_req wreq; - - error = copyin(ifr->ifr_data, &wreq, sizeof(wreq)); - if (error) - return error; - if (wreq.wi_len-- < 1) - return EINVAL; - switch (wreq.wi_type) { - case WI_RID_SERIALNO: - case WI_RID_NODENAME: - error = EPERM; - break; - case WI_RID_OWN_SSID: - if (wreq.wi_len < (1 + wreq.wi_val[0] + 1) / 2) { - error = EINVAL; - break; - } - if (wreq.wi_val[0] > IEEE80211_NWID_LEN) { - error = EINVAL; - break; - } - memset(sc->sc_ownssid, 0, AWI_ESS_ID_SIZE); - sc->sc_ownssid[0] = IEEE80211_ELEMID_SSID; - sc->sc_ownssid[1] = wreq.wi_val[0]; - memcpy(&sc->sc_ownssid[2], &wreq.wi_val[1], wreq.wi_val[0]); - if (!sc->sc_mib_local.Network_Mode && - !sc->sc_no_bssid && sc->sc_start_bss) - error = ENETRESET; - break; - case WI_RID_CURRENT_SSID: - error = EPERM; - break; - case WI_RID_DESIRED_SSID: - if (wreq.wi_len < (1 + wreq.wi_val[0] + 1) / 2) { - error = EINVAL; - break; - } - if (wreq.wi_val[0] > IEEE80211_NWID_LEN) { - error = EINVAL; - break; - } - memset(sc->sc_mib_mac.aDesired_ESS_ID, 0, AWI_ESS_ID_SIZE); - sc->sc_mib_mac.aDesired_ESS_ID[0] = IEEE80211_ELEMID_SSID; - sc->sc_mib_mac.aDesired_ESS_ID[1] = wreq.wi_val[0]; - memcpy(&sc->sc_mib_mac.aDesired_ESS_ID[2], &wreq.wi_val[1], - wreq.wi_val[0]); - if (sc->sc_mib_local.Network_Mode || !sc->sc_no_bssid) - error = ENETRESET; - break; - case WI_RID_CURRENT_BSSID: - error = EPERM; - break; - case WI_RID_CHANNEL_LIST: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - oregion = sc->sc_mib_phy.aCurrent_Reg_Domain; - if (wreq.wi_val[0] == oregion) - break; - sc->sc_mib_phy.aCurrent_Reg_Domain = wreq.wi_val[0]; - error = awi_init_region(sc); - if (error) { - sc->sc_mib_phy.aCurrent_Reg_Domain = oregion; - break; - } - error = ENETRESET; - break; - case WI_RID_OWN_CHNL: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - if (wreq.wi_val[0] < sc->sc_scan_min || - wreq.wi_val[0] > sc->sc_scan_max) { - error = EINVAL; - break; - } - sc->sc_ownch = wreq.wi_val[0]; - if (!sc->sc_mib_local.Network_Mode) - error = ENETRESET; - break; - case WI_RID_CURRENT_CHAN: - error = EPERM; - break; - case WI_RID_COMMS_QUALITY: - error = EPERM; - break; - case WI_RID_PROMISC: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - if (ifp->if_flags & IFF_PROMISC) { - if (wreq.wi_val[0] == 0) { - ifp->if_flags &= ~IFF_PROMISC; - error = ENETRESET; - } - } else { - if (wreq.wi_val[0] != 0) { - ifp->if_flags |= IFF_PROMISC; - error = ENETRESET; - } - } - break; - case WI_RID_PORTTYPE: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - switch (wreq.wi_val[0]) { - case 1: - sc->sc_mib_local.Network_Mode = 1; - sc->sc_no_bssid = 0; - error = ENETRESET; - break; - case 2: - sc->sc_mib_local.Network_Mode = 0; - sc->sc_no_bssid = 0; - error = ENETRESET; - break; - case 3: - if (sc->sc_mib_phy.IEEE_PHY_Type == AWI_PHY_TYPE_FH) { - error = EINVAL; - break; - } - sc->sc_mib_local.Network_Mode = 0; - sc->sc_no_bssid = 1; - error = ENETRESET; - break; - default: - error = EINVAL; - break; - } - break; - case WI_RID_MAC_NODE: - /* XXX: should be implemented? */ - error = EPERM; - break; - case WI_RID_TX_RATE: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - phy_rates = sc->sc_mib_phy.aSuprt_Data_Rates; - switch (wreq.wi_val[0]) { - case 1: - case 2: - case 5: - case 11: - rate = wreq.wi_val[0] * 10; - if (rate == 50) - rate += 5; /*XXX*/ - break; - case 3: - case 6: - case 7: - /* auto rate */ - phy_rates = sc->sc_mib_phy.aSuprt_Data_Rates; - rate = AWI_RATE_1MBIT; - for (i = 0; i < phy_rates[1]; i++) { - if (AWI_80211_RATE(phy_rates[2 + i]) > rate) - rate = AWI_80211_RATE(phy_rates[2 + i]); - } - break; - default: - rate = 0; - error = EINVAL; - break; - } - if (error) - break; - for (i = 0; i < phy_rates[1]; i++) { - if (rate == AWI_80211_RATE(phy_rates[2 + i])) - break; - } - if (i == phy_rates[1]) { - error = EINVAL; - break; - } - sc->sc_tx_rate = rate; - break; - case WI_RID_CUR_TX_RATE: - error = EPERM; - break; - case WI_RID_RTS_THRESH: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - LE_WRITE_2(&sc->sc_mib_mac.aRTS_Threshold, wreq.wi_val[0]); - error = ENETRESET; - break; - case WI_RID_CREATE_IBSS: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - sc->sc_start_bss = wreq.wi_val[0] ? 1 : 0; - error = ENETRESET; - break; - case WI_RID_SYSTEM_SCALE: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - if (wreq.wi_val[0] != 1) - error = EINVAL; /* not supported */ - break; - case WI_RID_PM_ENABLED: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - if (wreq.wi_val[0] != 0) - error = EINVAL; /* not implemented */ - break; - case WI_RID_MAX_SLEEP: - error = EINVAL; /* not implemented */ - break; - case WI_RID_WEP_AVAIL: - error = EPERM; - break; - case WI_RID_ENCRYPTION: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - error = awi_wep_setalgo(sc, wreq.wi_val[0]); - if (error) - break; - error = ENETRESET; - break; - case WI_RID_TX_CRYPT_KEY: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - if (wreq.wi_val[0] >= IEEE80211_WEP_NKID) { - error = EINVAL; - break; - } - sc->sc_wep_defkid = wreq.wi_val[1]; - break; - case WI_RID_DEFLT_CRYPT_KEYS: - if (wreq.wi_len != sizeof(*keys) / 2) { - error = EINVAL; - break; - } - keys = (struct wi_ltv_keys *)&wreq; - for (i = 0; i < IEEE80211_WEP_NKID; i++) { - k = &keys->wi_keys[i]; - error = awi_wep_setkey(sc, i, k->wi_keydat, - k->wi_keylen); - if (error) - break; - } - break; - case WI_RID_MAX_DATALEN: - if (wreq.wi_len != 1) { - error = EINVAL; - break; - } - if (wreq.wi_val[0] < 350 || wreq.wi_val[0] > 2304) { - error = EINVAL; - break; - } - LE_WRITE_2(&sc->sc_mib_mac.aMax_Frame_Length, wreq.wi_val[0]); - break; - case WI_RID_IFACE_STATS: - error = EPERM; - break; - default: - error = EINVAL; - break; - } - if (error == ENETRESET) { - if (sc->sc_enabled) { - awi_stop(sc); - error = awi_init(sc); - } else - error = 0; - } - return error; -} diff --git a/sys/dev/awi/awireg.h b/sys/dev/awi/awireg.h deleted file mode 100644 index dc936eb730ec..000000000000 --- a/sys/dev/awi/awireg.h +++ /dev/null @@ -1,460 +0,0 @@ -/* $NetBSD: awireg.h,v 1.3 2000/03/22 11:22:22 onoe Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * The firmware typically loaded onto Am79C930-based 802.11 interfaces - * uses a 32k or larger shared memory buffer to communicate with the - * host. - * - * Depending on the exact configuration of the device, this buffer may - * either be mapped into PCMCIA memory space, or accessible a byte at - * a type through PCMCIA I/O space. - * - * This header defines offsets into this shared memory. - */ - - -/* - * LAST_TXD block. 5 32-bit words. - * - * There are five different output queues; this defines pointers to - * the last completed descriptor for each one. - */ -#define AWI_LAST_TXD 0x3ec /* last completed Tx Descr */ - -#define AWI_LAST_BCAST_TXD AWI_LAST_TXD+0 -#define AWI_LAST_MGT_TXD AWI_LAST_TXD+4 -#define AWI_LAST_DATA_TXD AWI_LAST_TXD+8 -#define AWI_LAST_PS_POLL_TXD AWI_LAST_TXD+12 -#define AWI_LAST_CF_POLL_TXD AWI_LAST_TXD+16 - -/* - * Banner block; null-terminated string. - * - * The doc says it contains - * "PCnetMobile:v2.00 mmddyy APIx.x\0" - */ - -#define AWI_BANNER 0x480 /* Version string */ -#define AWI_BANNER_LEN 0x20 - -/* - * Command block protocol: - * write command byte to a zero value. - * write command status to a zero value. - * write arguments to AWI_COMMAND_PARAMS - * write command byte to a non-zero value. - * wait for command status to be non-zero. - * write command byte to a zero value. - * write command status to a zero value. - */ - -#define AWI_CMD 0x4a0 /* Command opcode byte */ - -#define AWI_CMD_IDLE 0x0 -#define AWI_CMD_NOP 0x1 - -#define AWI_CMD_SET_MIB 0x2 -#define AWI_CMD_GET_MIB 0x9 - -#define AWI_CA_MIB_TYPE 0x0 -#define AWI_CA_MIB_SIZE 0x1 -#define AWI_CA_MIB_INDEX 0x2 -#define AWI_CA_MIB_DATA 0x4 - -#define AWI_MIB_LOCAL 0x0 -#define AWI_MIB_ADDR 0x2 -#define AWI_MIB_MAC 0x3 -#define AWI_MIB_STAT 0x4 -#define AWI_MIB_MGT 0x5 -#define AWI_MIB_DRVR 0x6 -#define AWI_MIB_PHY 0x7 - - -#define AWI_CMD_INIT_TX 0x3 - -#define AWI_CA_TX_LEN 0x14 -#define AWI_CA_TX_DATA 0x0 -#define AWI_CA_TX_MGT 0x4 -#define AWI_CA_TX_BCAST 0x8 -#define AWI_CA_TX_PS 0xc -#define AWI_CA_TX_CF 0x10 - -#define AWI_CMD_FLUSH_TX 0x4 - -#define AWI_CA_FTX_LEN 0x5 -#define AWI_CA_FTX_DATA 0x0 -#define AWI_CA_FTX_MGT 0x1 -#define AWI_CA_FTX_BCAST 0x2 -#define AWI_CA_FTX_PS 0x3 -#define AWI_CA_FTX_CF 0x4 - -#define AWI_CMD_INIT_RX 0x5 -#define AWI_CA_IRX_LEN 0x8 -#define AWI_CA_IRX_DATA_DESC 0x0 /* return */ -#define AWI_CA_IRX_PS_DESC 0x4 /* return */ - -#define AWI_CMD_KILL_RX 0x6 - -#define AWI_CMD_SLEEP 0x7 -#define AWI_CA_SLEEP_LEN 0x8 -#define AWI_CA_WAKEUP 0x0 /* uint64 */ - -#define AWI_CMD_WAKE 0x8 - -#define AWI_CMD_SCAN 0xa -#define AWI_CA_SCAN_LEN 0x6 -#define AWI_CA_SCAN_DURATION 0x0 -#define AWI_CA_SCAN_SET 0x2 -#define AWI_CA_SCAN_PATTERN 0x3 -#define AWI_CA_SCAN_IDX 0x4 -#define AWI_CA_SCAN_SUSP 0x5 - -#define AWI_CMD_SYNC 0xb -#define AWI_CA_SYNC_LEN 0x14 -#define AWI_CA_SYNC_SET 0x0 -#define AWI_CA_SYNC_PATTERN 0x1 -#define AWI_CA_SYNC_IDX 0x2 -#define AWI_CA_SYNC_STARTBSS 0x3 -#define AWI_CA_SYNC_DWELL 0x4 -#define AWI_CA_SYNC_MBZ 0x6 -#define AWI_CA_SYNC_TIMESTAMP 0x8 -#define AWI_CA_SYNC_REFTIME 0x10 - -#define AWI_CMD_RESUME 0xc - -#define AWI_CMD_STATUS 0x4a1 /* Command status */ - -#define AWI_STAT_IDLE 0x0 -#define AWI_STAT_OK 0x1 -#define AWI_STAT_BADCMD 0x2 -#define AWI_STAT_BADPARM 0x3 -#define AWI_STAT_NOTIMP 0x4 -#define AWI_STAT_BADRES 0x5 -#define AWI_STAT_BADMODE 0x6 - -#define AWI_ERROR_OFFSET 0x4a2 /* Offset to erroneous parameter */ -#define AWI_CMD_PARAMS 0x4a4 /* Command parameters */ - -#define AWI_CSB 0x4f0 /* Control/Status block */ - -#define AWI_SELFTEST 0x4f0 - -#define AWI_SELFTEST_INIT 0x00 /* initial */ -#define AWI_SELFTEST_FIRMCKSUM 0x01 /* firmware cksum running */ -#define AWI_SELFTEST_HARDWARE 0x02 /* hardware tests running */ -#define AWI_SELFTEST_MIB 0x03 /* mib initializing */ - -#define AWI_SELFTEST_MIB_FAIL 0xfa -#define AWI_SELFTEST_RADIO_FAIL 0xfb -#define AWI_SELFTEST_MAC_FAIL 0xfc -#define AWI_SELFTEST_FLASH_FAIL 0xfd -#define AWI_SELFTEST_RAM_FAIL 0xfe -#define AWI_SELFTEST_PASSED 0xff - -#define AWI_STA_STATE 0x4f1 - -#define AWI_STA_AP 0x20 /* acting as AP */ -#define AWI_STA_NOPSP 0x10 /* Power Saving disabled */ -#define AWI_STA_DOZE 0x08 /* about to go to sleep */ -#define AWI_STA_PSP 0x04 /* enable PSP */ -#define AWI_STA_RXEN 0x02 /* enable RX */ -#define AWI_STA_TXEN 0x01 /* enable TX */ - -#define AWI_INTSTAT 0x4f3 -#define AWI_INTMASK 0x4f4 - -/* Bits in AWI_INTSTAT/AWI_INTMASK */ - -#define AWI_INT_GROGGY 0x80 /* about to wake up */ -#define AWI_INT_CFP_ENDING 0x40 /* cont. free period ending */ -#define AWI_INT_DTIM 0x20 /* beacon outgoing */ -#define AWI_INT_CFP_START 0x10 /* cont. free period starting */ -#define AWI_INT_SCAN_CMPLT 0x08 /* scan complete */ -#define AWI_INT_TX 0x04 /* tx done */ -#define AWI_INT_RX 0x02 /* rx done */ -#define AWI_INT_CMD 0x01 /* cmd done */ - -/* - * The following are used to implement a locking protocol between host - * and MAC to protect the interrupt status and mask fields. - * - * driver: read lockout_host byte; if zero, set lockout_mac to non-zero, - * then reread lockout_host byte; if still zero, host has lock. - * if non-zero, clear lockout_mac, loop. - */ - -#define AWI_LOCKOUT_MAC 0x4f5 -#define AWI_LOCKOUT_HOST 0x4f6 - - -#define AWI_INTSTAT2 0x4f7 -#define AWI_INTMASK2 0x4fd - -/* Bits in AWI_INTSTAT2/INTMASK2 */ -#define AWI_INT2_RXMGT 0x80 /* mgt/ps recieved */ -#define AWI_INT2_RXDATA 0x40 /* data received */ -#define AWI_INT2_TXMGT 0x10 /* mgt tx done */ -#define AWI_INT2_TXCF 0x08 /* CF tx done */ -#define AWI_INT2_TXPS 0x04 /* PS tx done */ -#define AWI_INT2_TXBCAST 0x02 /* Broadcast tx done */ -#define AWI_INT2_TXDATA 0x01 /* data tx done */ - -#define AWI_DIS_PWRDN 0x4fc /* disable powerdown if set */ - -#define AWI_DRIVERSTATE 0x4fe /* driver state */ - -#define AWI_DRV_STATEMASK 0x0f - -#define AWI_DRV_RESET 0x0 -#define AWI_DRV_INFSY 0x1 /* inf synced */ -#define AWI_DRV_ADHSC 0x2 /* adhoc scan */ -#define AWI_DRV_ADHSY 0x3 /* adhoc synced */ -#define AWI_DRV_INFSC 0x4 /* inf scanning */ -#define AWI_DRV_INFAUTH 0x5 /* inf authed */ -#define AWI_DRV_INFASSOC 0x6 /* inf associated */ -#define AWI_DRV_INFTOSS 0x7 /* inf handoff */ -#define AWI_DRV_APNONE 0x8 /* AP activity: no assoc */ -#define AWI_DRV_APQUIET 0xc /* AP: >=one assoc, no traffic */ -#define AWI_DRV_APLO 0xd /* AP: >=one assoc, light tfc */ -#define AWI_DRV_APMED 0xe /* AP: >=one assoc, mod tfc */ -#define AWI_DRV_APHIGH 0xf /* AP: >=one assoc, heavy tfc */ - -#define AWI_DRV_AUTORXLED 0x10 -#define AWI_DRV_AUTOTXLED 0x20 -#define AWI_DRV_RXLED 0x40 -#define AWI_DRV_TXLED 0x80 - -#define AWI_VBM 0x500 /* Virtual Bit Map */ - -#define AWI_BUFFERS 0x600 /* Buffers */ -#define AWI_BUFFERS_END 0x6000 - -/* - * Receive descriptors; there are a linked list of these chained - * through the "NEXT" fields, starting from XXX - */ - -#define AWI_RXD_SIZE 0x18 - -#define AWI_RXD_NEXT 0x4 -#define AWI_RXD_NEXT_LAST 0x80000000 - - -#define AWI_RXD_HOST_DESC_STATE 0x9 - -#define AWI_RXD_ST_OWN 0x80 /* host owns this */ -#define AWI_RXD_ST_CONSUMED 0x40 /* host is done */ -#define AWI_RXD_ST_LF 0x20 /* last frag */ -#define AWI_RXD_ST_CRC 0x08 /* CRC error */ -#define AWI_RXD_ST_OFLO 0x02 /* possible buffer overrun */ -#define AWI_RXD_ST_RXERROR 0x01 /* this frame is borked; discard me */ - -#define AWI_RXD_RSSI 0xa /* 1 byte: radio strength indicator */ -#define AWI_RXD_INDEX 0xb /* 1 byte: FH hop index or DS channel */ -#define AWI_RXD_LOCALTIME 0xc /* 4 bytes: local time of RX */ -#define AWI_RXD_START_FRAME 0x10 /* 4 bytes: ptr to first received byte */ -#define AWI_RXD_LEN 0x14 /* 2 bytes: rx len in bytes */ -#define AWI_RXD_RATE 0x16 /* 1 byte: rx rate in 1e5 bps */ - -/* - * Transmit descriptors. - */ - -#define AWI_TXD_SIZE 0x18 - -#define AWI_TXD_START 0x00 /* pointer to start of frame */ -#define AWI_TXD_NEXT 0x04 /* pointer to next TXD */ -#define AWI_TXD_LENGTH 0x08 /* length of frame */ -#define AWI_TXD_STATE 0x0a /* state */ - -#define AWI_TXD_ST_OWN 0x80 /* MAC owns this */ -#define AWI_TXD_ST_DONE 0x40 /* MAC is done */ -#define AWI_TXD_ST_REJ 0x20 /* MAC doesn't like */ -#define AWI_TXD_ST_MSDU 0x10 /* MSDU timeout */ -#define AWI_TXD_ST_ABRT 0x08 /* TX aborted */ -#define AWI_TXD_ST_RETURNED 0x04 /* TX returned */ -#define AWI_TXD_ST_RETRY 0x02 /* TX retries exceeded */ -#define AWI_TXD_ST_ERROR 0x01 /* TX error */ - -#define AWI_TXD_RATE 0x0b /* rate */ - -#define AWI_RATE_1MBIT 10 -#define AWI_RATE_2MBIT 20 - -#define AWI_TXD_NDA 0x0c /* num DIFS attempts */ -#define AWI_TXD_NDF 0x0d /* num DIFS failures */ -#define AWI_TXD_NSA 0x0e /* num SIFS attempts */ -#define AWI_TXD_NSF 0x0f /* num SIFS failures */ - -#define AWI_TXD_NRA 0x14 /* num RTS attempts */ -#define AWI_TXD_NDTA 0x15 /* num data attempts */ -#define AWI_TXD_CTL 0x16 /* control */ - -#define AWI_TXD_CTL_PSN 0x80 /* preserve sequence in MAC frame */ -#define AWI_TXD_CTL_BURST 0x02 /* host is doing 802.11 fragmt. */ -#define AWI_TXD_CTL_FRAGS 0x01 /* override normal fragmentation */ - -/* - * MIB structures. - */ - -#define AWI_ESS_ID_SIZE (IEEE80211_NWID_LEN+2) -struct awi_mib_local { - u_int8_t Fragmentation_Dis; - u_int8_t Add_PLCP_Dis; - u_int8_t MAC_Hdr_Prsv; - u_int8_t Rx_Mgmt_Que_En; - u_int8_t Re_Assembly_Dis; - u_int8_t Strip_PLCP_Dis; - u_int8_t Rx_Error_Dis; - u_int8_t Power_Saving_Mode_Dis; - u_int8_t Accept_All_Multicast_Dis; - u_int8_t Check_Seq_Cntl_Dis; - u_int8_t Flush_CFP_Queue_On_CF_End; - u_int8_t Network_Mode; - u_int8_t PWD_Lvl; - u_int8_t CFP_Mode; - u_int8_t Tx_Buffer_Offset[4]; - u_int8_t Tx_Buffer_Size[4]; - u_int8_t Rx_Buffer_Offset[4]; - u_int8_t Rx_Buffer_Size[4]; - u_int8_t Acting_as_AP; - u_int8_t Fill_CFP; -}; - -struct awi_mib_mac { - u_int8_t _Reserved1[2]; - u_int8_t _Reserved2[2]; - u_int8_t aRTS_Threshold[2]; - u_int8_t aCW_max[2]; - u_int8_t aCW_min[2]; - u_int8_t aPromiscuous_Enable; - u_int8_t _Reserved3; - u_int8_t _Reserved4[4]; - u_int8_t aShort_Retry_Limit; - u_int8_t aLong_Retry_Limit; - u_int8_t aMax_Frame_Length[2]; - u_int8_t aFragmentation_Threshold[2]; - u_int8_t aProbe_Delay[2]; - u_int8_t aMin_Probe_Response_Time[2]; - u_int8_t aMax_Probe_Response_Time[2]; - u_int8_t aMax_Transmit_MSDU_Lifetime[4]; - u_int8_t aMax_Receive_MSDU_Lifetime[4]; - u_int8_t aStation_Basic_Rate[2]; - u_int8_t aDesired_ESS_ID[AWI_ESS_ID_SIZE]; -}; - -struct awi_mib_stat { - u_int8_t aTransmitted_MPDU_Count[4]; - u_int8_t aTransmitted_MSDU_Count[4]; - u_int8_t aOctets_Transmitted_Cnt[4]; - u_int8_t aMulticast_Transmitted_Frame_Count[2]; - u_int8_t aBroadcast_Transmitted_Frame_Count[2]; - u_int8_t aFailed_Count[4]; - u_int8_t aRetry_Count[4]; - u_int8_t aMultiple_Retry_Count[4]; - u_int8_t aFrame_Duplicate_Count[4]; - u_int8_t aRTS_Success_Count[4]; - u_int8_t aRTS_Failure_Count[4]; - u_int8_t aACK_Failure_Count[4]; - u_int8_t aReceived_Frame_Count [4]; - u_int8_t aOctets_Received_Count[4]; - u_int8_t aMulticast_Received_Count[2]; - u_int8_t aBroadcast_Received_Count[2]; - u_int8_t aFCS_Error_Count[4]; - u_int8_t aError_Count[4]; - u_int8_t aWEP_Undecryptable_Count[4]; -}; - -struct awi_mib_mgt { - u_int8_t aPower_Mgt_Mode; - u_int8_t aScan_Mode; -#define AWI_SCAN_PASSIVE 0x00 -#define AWI_SCAN_ACTIVE 0x01 -#define AWI_SCAN_BACKGROUND 0x02 - u_int8_t aScan_State; - u_int8_t aDTIM_Period; - u_int8_t aATIM_Window[2]; - u_int8_t Wep_Required; - u_int8_t _Reserved1; - u_int8_t aBeacon_Period[2]; - u_int8_t aPassive_Scan_Duration[2]; - u_int8_t aListen_Interval[2]; - u_int8_t aMedium_Occupancy_Limit[2]; - u_int8_t aMax_MPDU_Time[2]; - u_int8_t aCFP_Max_Duration[2]; - u_int8_t aCFP_Rate; - u_int8_t Do_Not_Receive_DTIMs; - u_int8_t aStation_ID[2]; - u_int8_t aCurrent_BSS_ID[ETHER_ADDR_LEN]; - u_int8_t aCurrent_ESS_ID[AWI_ESS_ID_SIZE]; -}; - -#define AWI_GROUP_ADDR_SIZE 4 -struct awi_mib_addr { - u_int8_t aMAC_Address[ETHER_ADDR_LEN]; - u_int8_t aGroup_Addresses[AWI_GROUP_ADDR_SIZE][ETHER_ADDR_LEN]; - u_int8_t aTransmit_Enable_Status; - u_int8_t _Reserved1; -}; - -#define AWI_PWR_LEVEL_SIZE 4 -struct awi_mib_phy { - u_int8_t aSlot_Time[2]; - u_int8_t aSIFS[2]; - u_int8_t aMPDU_Maximum[2]; - u_int8_t aHop_Time[2]; - u_int8_t aSuprt_Data_Rates[4]; - u_int8_t aCurrent_Reg_Domain; -#define AWI_REG_DOMAIN_US 0x10 -#define AWI_REG_DOMAIN_CA 0x20 -#define AWI_REG_DOMAIN_EU 0x30 -#define AWI_REG_DOMAIN_ES 0x31 -#define AWI_REG_DOMAIN_FR 0x32 -#define AWI_REG_DOMAIN_JP 0x40 - u_int8_t aPreamble_Lngth; - u_int8_t aPLCP_Hdr_Lngth; - u_int8_t Pwr_Up_Time[AWI_PWR_LEVEL_SIZE][2]; - u_int8_t IEEE_PHY_Type; -#define AWI_PHY_TYPE_FH 1 -#define AWI_PHY_TYPE_DS 2 -#define AWI_PHY_TYPE_IR 3 - u_int8_t RCR_33A_Bits[8]; -}; diff --git a/sys/dev/awi/awivar.h b/sys/dev/awi/awivar.h deleted file mode 100644 index 8e86f841a006..000000000000 --- a/sys/dev/awi/awivar.h +++ /dev/null @@ -1,222 +0,0 @@ -/* $NetBSD: awivar.h,v 1.12 2000/07/21 04:48:56 onoe Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Bill Sommerfeld - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* timer values in msec */ -#define AWI_SELFTEST_TIMEOUT 5000 -#define AWI_CMD_TIMEOUT 2000 -#define AWI_LOCKOUT_TIMEOUT 50 -#define AWI_ASCAN_DURATION 100 -#define AWI_ASCAN_WAIT 3000 -#define AWI_PSCAN_DURATION 200 -#define AWI_PSCAN_WAIT 5000 -#define AWI_TRANS_TIMEOUT 2000 - -#define AWI_NTXBUFS 4 -#define AWI_MAX_KEYLEN 16 - -enum awi_status { - AWI_ST_INIT, - AWI_ST_SCAN, - AWI_ST_SETSS, - AWI_ST_SYNC, - AWI_ST_AUTH, - AWI_ST_ASSOC, - AWI_ST_RUNNING -}; - -struct awi_bss -{ - TAILQ_ENTRY(awi_bss) list; - u_int8_t esrc[ETHER_ADDR_LEN]; - u_int8_t chanset; /* channel set to use */ - u_int8_t pattern; /* hop pattern to use */ - u_int8_t index; /* index to use */ - u_int8_t rssi; /* strength of this beacon */ - u_int16_t dwell_time; /* dwell time */ - u_int8_t timestamp[8]; /* timestamp of this bss */ - u_int8_t bssid[ETHER_ADDR_LEN]; - u_int16_t capinfo; - u_int32_t rxtime; /* unit's local time */ - u_int16_t interval; /* beacon interval */ - u_int8_t txrate; - u_int8_t fails; - u_int8_t essid[IEEE80211_NWID_LEN + 2]; -}; - -struct awi_wep_algo { - char *awa_name; - int (*awa_ctxlen) __P((void)); - void (*awa_setkey) __P((void *, u_char *, int)); - void (*awa_encrypt) __P((void *, u_char *, u_char *, int)); - void (*awa_decrypt) __P((void *, u_char *, u_char *, int)); -}; - -struct awi_softc -{ -#ifdef __NetBSD__ - struct device sc_dev; - struct ethercom sc_ec; - void *sc_ih; /* interrupt handler */ -#endif -#ifdef __FreeBSD__ -#if __FreeBSD__ >= 4 - struct { - char dv_xname[64]; /*XXX*/ - } sc_dev; -#else - struct device sc_dev; -#endif - struct arpcom sc_ec; -#endif - struct am79c930_softc sc_chip; - struct ifnet *sc_ifp; - int (*sc_enable) __P((struct awi_softc *)); - void (*sc_disable) __P((struct awi_softc *)); - - struct ifmedia sc_media; - enum awi_status sc_status; - unsigned int sc_enabled:1, - sc_busy:1, - sc_cansleep:1, - sc_invalid:1, - sc_enab_intr:1, - sc_format_llc:1, - sc_start_bss:1, - sc_rawbpf:1, - sc_no_bssid:1, - sc_active_scan:1, - sc_attached:1; /* attach has succeeded */ - u_int8_t sc_cmd_inprog; - int sc_sleep_cnt; - - int sc_mgt_timer; - - TAILQ_HEAD(, awi_bss) sc_scan; - u_int8_t sc_scan_cur; - u_int8_t sc_scan_min; - u_int8_t sc_scan_max; - u_int8_t sc_scan_set; - struct awi_bss sc_bss; - u_int8_t sc_ownssid[IEEE80211_NWID_LEN + 2]; - u_int8_t sc_ownch; - - int sc_rx_timer; - u_int32_t sc_rxdoff; - u_int32_t sc_rxmoff; - struct mbuf *sc_rxpend; - - int sc_tx_timer; - u_int8_t sc_tx_rate; - struct ifqueue sc_mgtq; - u_int32_t sc_txbase; - u_int32_t sc_txend; - u_int32_t sc_txnext; - u_int32_t sc_txdone; - - int sc_wep_keylen[IEEE80211_WEP_NKID]; /* keylen */ - u_int8_t sc_wep_key[IEEE80211_WEP_NKID][AWI_MAX_KEYLEN]; - int sc_wep_defkid; - void *sc_wep_ctx; /* work area */ - struct awi_wep_algo *sc_wep_algo; - - u_char sc_banner[AWI_BANNER_LEN]; - struct awi_mib_local sc_mib_local; - struct awi_mib_addr sc_mib_addr; - struct awi_mib_mac sc_mib_mac; - struct awi_mib_stat sc_mib_stat; - struct awi_mib_mgt sc_mib_mgt; - struct awi_mib_phy sc_mib_phy; -}; - -#define awi_read_1(sc, off) ((sc)->sc_chip.sc_ops->read_1)(&sc->sc_chip, off) -#define awi_read_2(sc, off) ((sc)->sc_chip.sc_ops->read_2)(&sc->sc_chip, off) -#define awi_read_4(sc, off) ((sc)->sc_chip.sc_ops->read_4)(&sc->sc_chip, off) -#define awi_read_bytes(sc, off, ptr, len) ((sc)->sc_chip.sc_ops->read_bytes)(&sc->sc_chip, off, ptr, len) - -#define awi_write_1(sc, off, val) \ - ((sc)->sc_chip.sc_ops->write_1)(&sc->sc_chip, off, val) -#define awi_write_2(sc, off, val) \ - ((sc)->sc_chip.sc_ops->write_2)(&sc->sc_chip, off, val) -#define awi_write_4(sc, off, val) \ - ((sc)->sc_chip.sc_ops->write_4)(&sc->sc_chip, off, val) -#define awi_write_bytes(sc, off, ptr, len) \ - ((sc)->sc_chip.sc_ops->write_bytes)(&sc->sc_chip, off, ptr, len) - -#define awi_drvstate(sc, state) \ - awi_write_1(sc, AWI_DRIVERSTATE, \ - ((state) | AWI_DRV_AUTORXLED|AWI_DRV_AUTOTXLED)) - -/* unalligned little endian access */ -#define LE_READ_2(p) \ - (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8)) -#define LE_READ_4(p) \ - (((u_int8_t *)(p))[0] | (((u_int8_t *)(p))[1] << 8) | \ - (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24)) -#define LE_WRITE_2(p, v) \ - ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \ - (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff))) -#define LE_WRITE_4(p, v) \ - ((((u_int8_t *)(p))[0] = ((u_int32_t)(v) & 0xff)), \ - (((u_int8_t *)(p))[1] = (((u_int32_t)(v) >> 8) & 0xff)), \ - (((u_int8_t *)(p))[2] = (((u_int32_t)(v) >> 16) & 0xff)), \ - (((u_int8_t *)(p))[3] = (((u_int32_t)(v) >> 24) & 0xff))) - -#define AWI_80211_RATE(rate) (((rate) & 0x7f) * 5) - -int awi_attach __P((struct awi_softc *)); -int awi_intr __P((void *)); -void awi_reset __P((struct awi_softc *)); -#ifdef __NetBSD__ -int awi_activate __P((struct device *, enum devact)); -int awi_detach __P((struct awi_softc *)); -void awi_power __P((struct awi_softc *, int)); -#endif - -void awi_stop __P((struct awi_softc *sc)); -int awi_init __P((struct awi_softc *sc)); -int awi_init_region __P((struct awi_softc *)); -int awi_wicfg __P((struct ifnet *, u_long, caddr_t)); - -int awi_wep_setnwkey __P((struct awi_softc *, struct ieee80211_nwkey *)); -int awi_wep_getnwkey __P((struct awi_softc *, struct ieee80211_nwkey *)); -int awi_wep_getalgo __P((struct awi_softc *)); -int awi_wep_setalgo __P((struct awi_softc *, int)); -int awi_wep_setkey __P((struct awi_softc *, int, unsigned char *, int)); -int awi_wep_getkey __P((struct awi_softc *, int, unsigned char *, int *)); -struct mbuf *awi_wep_encrypt __P((struct awi_softc *, struct mbuf *, int)); diff --git a/sys/dev/awi/if_awi_pccard.c b/sys/dev/awi/if_awi_pccard.c deleted file mode 100644 index be55de57cccf..000000000000 --- a/sys/dev/awi/if_awi_pccard.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2000 Atsushi Onoe <onoe@sm.sony.co.jp> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/socket.h> - -#include <sys/module.h> -#include <sys/bus.h> - -#include <machine/bus.h> -#include <machine/resource.h> -#include <sys/rman.h> - -#include <net/if.h> -#include <net/if_arp.h> -#include <net/if_media.h> -#include <net/ethernet.h> -#include <net/if_ieee80211.h> - - -#include <dev/awi/am79c930reg.h> -#include <dev/awi/am79c930var.h> -#include <dev/awi/awireg.h> -#include <dev/awi/awivar.h> - -struct awi_pccard_softc { - struct awi_softc sc_awi; - - u_int8_t sc_version[AWI_BANNER_LEN]; - int sc_intr_mask; - void *sc_intrhand; - struct resource *sc_irq_res; - int sc_irq_rid; - struct resource *sc_port_res; - int sc_port_rid; - struct resource *sc_mem_res; - int sc_mem_rid; -}; - -/* - * Initialize the device - called from Slot manager. - */ -static int -awi_pccard_probe(device_t dev) -{ - struct awi_pccard_softc *psc = device_get_softc(dev); - struct awi_softc *sc = &psc->sc_awi; - int error = 0; - - psc->sc_port_rid = 0; - psc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, - &psc->sc_port_rid, 0, ~0, 16, RF_ACTIVE); - if (!psc->sc_port_res) - return ENOMEM; - - sc->sc_chip.sc_iot = rman_get_bustag(psc->sc_port_res); - sc->sc_chip.sc_ioh = rman_get_bushandle(psc->sc_port_res); - am79c930_chip_init(&sc->sc_chip, 0); - DELAY(1000); - - awi_read_bytes(sc, AWI_BANNER, psc->sc_version, AWI_BANNER_LEN); - if (memcmp(psc->sc_version, "PCnetMobile:", 12) != 0) { - device_printf(dev, "awi_pccard_probe: bad banner: %12D\n", - psc->sc_version, " "); - error = ENXIO; - } else - device_set_desc(dev, psc->sc_version); - bus_release_resource(dev, SYS_RES_IOPORT, psc->sc_port_rid, - psc->sc_port_res); - - return error; -} - -static int -awi_pccard_attach(device_t dev) -{ - struct awi_pccard_softc *psc = device_get_softc(dev); - struct awi_softc *sc = &psc->sc_awi; - struct ifnet *ifp = &sc->sc_ec.ac_if; - int error = 0; - - psc->sc_port_res = 0; - psc->sc_irq_res = 0; - psc->sc_mem_res = 0; - psc->sc_intrhand = 0; - - ifp->if_name = device_get_name(dev); - ifp->if_unit = device_get_unit(dev); - if (ifp->if_name == NULL) { - printf("awi%d: awi_pccard_attach: cannot get device name\n", - device_get_unit(dev)); - goto fail; - } - snprintf(sc->sc_dev.dv_xname, sizeof(sc->sc_dev.dv_xname), - "%s%d", ifp->if_name, ifp->if_unit); - - psc->sc_port_rid = 0; - psc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, - &psc->sc_port_rid, 0, ~0, 16, RF_ACTIVE); - if (!psc->sc_port_res) { - device_printf(dev, "awi_pccard_attach: port alloc failed\n"); - goto fail; - } - sc->sc_chip.sc_iot = rman_get_bustag(psc->sc_port_res); - sc->sc_chip.sc_ioh = rman_get_bushandle(psc->sc_port_res); - - psc->sc_irq_rid = 0; - psc->sc_irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, - &psc->sc_irq_rid, 0, ~0, 1, RF_ACTIVE); - if (!psc->sc_irq_res) { - device_printf(dev, "awi_pccard_attach: irq alloc failed\n"); - goto fail; - } - - psc->sc_mem_rid = 0; -#if 1 - /* - * XXX: awi needs to access memory with 8bit, - * but pccardd apparently maps memory with MDF_16BITS flag. - * So memory mapped access is disabled and use IO port instead. - */ - psc->sc_mem_res = 0; -#else - psc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, - &psc->sc_mem_rid, 0, ~0, 0x8000, RF_ACTIVE); -#endif - if (psc->sc_mem_res) { - sc->sc_chip.sc_memt = rman_get_bustag(psc->sc_mem_res); - sc->sc_chip.sc_memh = rman_get_bushandle(psc->sc_mem_res); - am79c930_chip_init(&sc->sc_chip, 1); - } else - am79c930_chip_init(&sc->sc_chip, 0); - - error = bus_setup_intr(dev, psc->sc_irq_res, INTR_TYPE_NET, - (void (*)(void *))awi_intr, sc, &psc->sc_intrhand); - if (error) { - device_printf(dev, "awi_pccard_attach: intr setup failed\n"); - goto fail; - } - - sc->sc_cansleep = 1; - sc->sc_enabled = 1; - sc->sc_ifp = &sc->sc_ec.ac_if; - - error = awi_attach(sc); - sc->sc_enabled = 0; /*XXX*/ - if (error == 0) - return 0; - device_printf(dev, "awi_pccard_attach: awi_attach failed\n"); - - fail: - if (psc->sc_intrhand) { - bus_teardown_intr(dev, psc->sc_irq_res, psc->sc_intrhand); - psc->sc_intrhand = 0; - } - if (psc->sc_port_res) { - bus_release_resource(dev, SYS_RES_IOPORT, psc->sc_port_rid, - psc->sc_port_res); - psc->sc_port_res = 0; - } - if (psc->sc_irq_res) { - bus_release_resource(dev, SYS_RES_IRQ, psc->sc_irq_rid, - psc->sc_irq_res); - psc->sc_irq_res = 0; - } - if (psc->sc_mem_res) { - bus_release_resource(dev, SYS_RES_MEMORY, psc->sc_mem_rid, - psc->sc_mem_res); - psc->sc_mem_res = 0; - } - if (error == 0) - error = ENXIO; - return error; -} - -static int -awi_pccard_detach(device_t dev) -{ - struct awi_pccard_softc *psc = device_get_softc(dev); - struct awi_softc *sc = &psc->sc_awi; - struct ifnet *ifp = &sc->sc_ec.ac_if; - - ether_ifdetach(ifp, ETHER_BPF_SUPPORTED); - ifp->if_flags &= ~IFF_RUNNING; - if (psc->sc_intrhand) { - bus_teardown_intr(dev, psc->sc_irq_res, psc->sc_intrhand); - psc->sc_intrhand = 0; - } - if (psc->sc_port_res) { - bus_release_resource(dev, SYS_RES_IOPORT, psc->sc_port_rid, - psc->sc_port_res); - psc->sc_port_res = 0; - } - if (psc->sc_irq_res) { - bus_release_resource(dev, SYS_RES_IRQ, psc->sc_irq_rid, - psc->sc_irq_res); - psc->sc_irq_res = 0; - } - if (psc->sc_mem_res) { - bus_release_resource(dev, SYS_RES_MEMORY, psc->sc_mem_rid, - psc->sc_mem_res); - psc->sc_mem_res = 0; - } - return 0; -} - -static device_method_t awi_pccard_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, awi_pccard_probe), - DEVMETHOD(device_attach, awi_pccard_attach), - DEVMETHOD(device_detach, awi_pccard_detach), - - { 0, 0 } -}; - -static driver_t awi_pccard_driver = { - "awi", - awi_pccard_methods, - sizeof(struct awi_pccard_softc), -}; - -extern devclass_t awi_devclass; - -DRIVER_MODULE(awi, pccard, awi_pccard_driver, awi_devclass, 0, 0); |
