diff options
author | imp <imp@FreeBSD.org> | 2007-08-29 21:16:50 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2007-08-29 21:16:50 +0000 |
commit | d64c39104c067800a5e1195efb809ec9d81b0872 (patch) | |
tree | 1e4b1f068f5214d1e83ace3b5d58be4d6a3106e0 /sys/dev/usb | |
parent | dcee85272ccd62af7c3b5ca7a7f63796552500f6 (diff) | |
download | FreeBSD-src-d64c39104c067800a5e1195efb809ec9d81b0872.zip FreeBSD-src-d64c39104c067800a5e1195efb809ec9d81b0872.tar.gz |
A port of the zyd driver from NetBSD by . This supports the ZyDAS
ZD1211/ZD1211B USB IEEE 802.11b/g wireless network devices. Not (yet)
connected to the build process (next batch of commits once I've looped
the current back back).
Submitted by: Weongyo Jeong
Reviewed by: sam@
Approved by: re@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/if_zyd.c | 2694 | ||||
-rw-r--r-- | sys/dev/usb/if_zydfw.h | 1185 | ||||
-rw-r--r-- | sys/dev/usb/if_zydreg.h | 1246 |
3 files changed, 5125 insertions, 0 deletions
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c new file mode 100644 index 0000000..fe89cdd --- /dev/null +++ b/sys/dev/usb/if_zyd.c @@ -0,0 +1,2694 @@ +/* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */ +/* $NetBSD: if_zyd.c,v 1.7 2007/06/21 04:04:29 kiyohara Exp $ */ +/* $FreeBSD$ */ + +/*- + * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> + * Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * ZyDAS ZD1211/ZD1211B USB WLAN driver. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/sockio.h> +#include <sys/mbuf.h> +#include <sys/malloc.h> +#include <sys/kernel.h> +#include <sys/module.h> +#include <sys/socket.h> +#include <sys/sysctl.h> +#include <sys/endian.h> +#include <sys/linker.h> + +#include <net/if.h> +#include <net/if_arp.h> +#include <net/ethernet.h> +#include <net/if_dl.h> +#include <net/if_media.h> +#include <net/if_types.h> + +#include <sys/bus.h> +#include <machine/bus.h> + +#include <net80211/ieee80211_var.h> +#include <net80211/ieee80211_amrr.h> +#include <net80211/ieee80211_radiotap.h> +#include <net80211/ieee80211_proto.h> +#include <net80211/ieee80211_node.h> +#include <net80211/ieee80211_regdomain.h> + +#include <net/bpf.h> + +#include <dev/usb/usb.h> +#include <dev/usb/usbdi.h> +#include <dev/usb/usbdi_util.h> +#include <dev/usb/usbdivar.h> +#include "usbdevs.h" +#include <dev/usb/usb_ethersubr.h> + +#include <dev/mii/mii.h> +#include <dev/mii/miivar.h> + +#include <dev/usb/if_zydreg.h> +#include <dev/usb/if_zydfw.h> + +#ifdef USB_DEBUG +#define ZYD_DEBUG +#endif + +#ifdef ZYD_DEBUG +#define DPRINTF(x) do { if (zyddebug > 0) printf x; } while (0) +#define DPRINTFN(n, x) do { if (zyddebug > (n)) printf x; } while (0) +int zyddebug = 0; +#else +#define DPRINTF(x) +#define DPRINTFN(n, x) +#endif + +static const struct zyd_phy_pair zyd_def_phy[] = ZYD_DEF_PHY; +static const struct zyd_phy_pair zyd_def_phyB[] = ZYD_DEF_PHYB; + +/* various supported device vendors/products */ +#define ZYD_ZD1211_DEV(v, p) \ + { { USB_VENDOR_##v, USB_PRODUCT_##v##_##p }, ZYD_ZD1211 } +#define ZYD_ZD1211B_DEV(v, p) \ + { { USB_VENDOR_##v, USB_PRODUCT_##v##_##p }, ZYD_ZD1211B } +static const struct zyd_type { + struct usb_devno dev; + uint8_t rev; +#define ZYD_ZD1211 0 +#define ZYD_ZD1211B 1 +} zyd_devs[] = { + ZYD_ZD1211_DEV(3COM2, 3CRUSB10075), + ZYD_ZD1211_DEV(ABOCOM, WL54), + ZYD_ZD1211_DEV(ASUS, WL159G), + ZYD_ZD1211_DEV(CYBERTAN, TG54USB), + ZYD_ZD1211_DEV(DRAYTEK, VIGOR550), + ZYD_ZD1211_DEV(PLANEX2, GWUS54GZL), + ZYD_ZD1211_DEV(PLANEX3, GWUS54GZ), + ZYD_ZD1211_DEV(PLANEX3, GWUS54MINI), + ZYD_ZD1211_DEV(SAGEM, XG760A), + ZYD_ZD1211_DEV(SENAO, NUB8301), + ZYD_ZD1211_DEV(SITECOMEU, WL113), + ZYD_ZD1211_DEV(SWEEX, ZD1211), + ZYD_ZD1211_DEV(TEKRAM, QUICKWLAN), + ZYD_ZD1211_DEV(TEKRAM, ZD1211_1), + ZYD_ZD1211_DEV(TEKRAM, ZD1211_2), + ZYD_ZD1211_DEV(TWINMOS, G240), + ZYD_ZD1211_DEV(UMEDIA, ALL0298V2), + ZYD_ZD1211_DEV(UMEDIA, TEW429UB_A), + ZYD_ZD1211_DEV(UMEDIA, TEW429UB), + ZYD_ZD1211_DEV(WISTRONNEWEB, UR055G), + ZYD_ZD1211_DEV(ZCOM, ZD1211), + ZYD_ZD1211_DEV(ZYDAS, ZD1211), + ZYD_ZD1211_DEV(ZYXEL, AG225H), + ZYD_ZD1211_DEV(ZYXEL, ZYAIRG220), + ZYD_ZD1211_DEV(ZYXEL, G200V2), + + ZYD_ZD1211B_DEV(ACCTON, SMCWUSBG), + ZYD_ZD1211B_DEV(ACCTON, ZD1211B), + ZYD_ZD1211B_DEV(ASUS, A9T_WIFI), + ZYD_ZD1211B_DEV(BELKIN, F5D7050_V4000), + ZYD_ZD1211B_DEV(BELKIN, ZD1211B), + ZYD_ZD1211B_DEV(CISCOLINKSYS, WUSBF54G), + ZYD_ZD1211B_DEV(FIBERLINE, WL430U), + ZYD_ZD1211B_DEV(MELCO, KG54L), + ZYD_ZD1211B_DEV(PHILIPS, SNU5600), + ZYD_ZD1211B_DEV(SAGEM, XG76NA), + ZYD_ZD1211B_DEV(SITECOMEU, ZD1211B), + ZYD_ZD1211B_DEV(UMEDIA, TEW429UBC1), +#if 0 /* Shall we needs? */ + ZYD_ZD1211B_DEV(UNKNOWN1, ZD1211B_1), + ZYD_ZD1211B_DEV(UNKNOWN1, ZD1211B_2), + ZYD_ZD1211B_DEV(UNKNOWN2, ZD1211B), + ZYD_ZD1211B_DEV(UNKNOWN3, ZD1211B), +#endif + ZYD_ZD1211B_DEV(USR, USR5423), + ZYD_ZD1211B_DEV(VTECH, ZD1211B), + ZYD_ZD1211B_DEV(ZCOM, ZD1211B), + ZYD_ZD1211B_DEV(ZYDAS, ZD1211B), + ZYD_ZD1211B_DEV(ZYXEL, M202), + ZYD_ZD1211B_DEV(ZYXEL, G220V2), +}; +#define zyd_lookup(v, p) \ + ((const struct zyd_type *)usb_lookup(zyd_devs, v, p)) + +static device_probe_t zyd_match; +static device_attach_t zyd_attach; +static device_detach_t zyd_detach; + +static int zyd_attachhook(struct zyd_softc *); +static int zyd_complete_attach(struct zyd_softc *); +static int zyd_open_pipes(struct zyd_softc *); +static void zyd_close_pipes(struct zyd_softc *); +static int zyd_alloc_tx_list(struct zyd_softc *); +static void zyd_free_tx_list(struct zyd_softc *); +static int zyd_alloc_rx_list(struct zyd_softc *); +static void zyd_free_rx_list(struct zyd_softc *); +static struct ieee80211_node *zyd_node_alloc(struct ieee80211_node_table *); +static int zyd_media_change(struct ifnet *); +static void zyd_task(void *); +static int zyd_newstate(struct ieee80211com *, enum ieee80211_state, int); +static int zyd_cmd(struct zyd_softc *, uint16_t, const void *, int, + void *, int, u_int); +static int zyd_read16(struct zyd_softc *, uint16_t, uint16_t *); +static int zyd_read32(struct zyd_softc *, uint16_t, uint32_t *); +static int zyd_write16(struct zyd_softc *, uint16_t, uint16_t); +static int zyd_write32(struct zyd_softc *, uint16_t, uint32_t); +static int zyd_rfwrite(struct zyd_softc *, uint32_t); +static void zyd_lock_phy(struct zyd_softc *); +static void zyd_unlock_phy(struct zyd_softc *); +static int zyd_rfmd_init(struct zyd_rf *); +static int zyd_rfmd_switch_radio(struct zyd_rf *, int); +static int zyd_rfmd_set_channel(struct zyd_rf *, uint8_t); +static int zyd_al2230_init(struct zyd_rf *); +static int zyd_al2230_switch_radio(struct zyd_rf *, int); +static int zyd_al2230_set_channel(struct zyd_rf *, uint8_t); +static int zyd_al2230_init_b(struct zyd_rf *); +static int zyd_al7230B_init(struct zyd_rf *); +static int zyd_al7230B_switch_radio(struct zyd_rf *, int); +static int zyd_al7230B_set_channel(struct zyd_rf *, uint8_t); +static int zyd_al2210_init(struct zyd_rf *); +static int zyd_al2210_switch_radio(struct zyd_rf *, int); +static int zyd_al2210_set_channel(struct zyd_rf *, uint8_t); +static int zyd_gct_init(struct zyd_rf *); +static int zyd_gct_switch_radio(struct zyd_rf *, int); +static int zyd_gct_set_channel(struct zyd_rf *, uint8_t); +static int zyd_maxim_init(struct zyd_rf *); +static int zyd_maxim_switch_radio(struct zyd_rf *, int); +static int zyd_maxim_set_channel(struct zyd_rf *, uint8_t); +static int zyd_maxim2_init(struct zyd_rf *); +static int zyd_maxim2_switch_radio(struct zyd_rf *, int); +static int zyd_maxim2_set_channel(struct zyd_rf *, uint8_t); +static int zyd_rf_attach(struct zyd_softc *, uint8_t); +static const char *zyd_rf_name(uint8_t); +static int zyd_hw_init(struct zyd_softc *); +static int zyd_read_eeprom(struct zyd_softc *); +static int zyd_set_macaddr(struct zyd_softc *, const uint8_t *); +static int zyd_set_bssid(struct zyd_softc *, const uint8_t *); +static int zyd_switch_radio(struct zyd_softc *, int); +static void zyd_set_led(struct zyd_softc *, int, int); +static int zyd_set_rxfilter(struct zyd_softc *); +static void zyd_set_chan(struct zyd_softc *, struct ieee80211_channel *); +static int zyd_set_beacon_interval(struct zyd_softc *, int); +static uint8_t zyd_plcp_signal(int); +static void zyd_intr(usbd_xfer_handle, usbd_private_handle, usbd_status); +static void zyd_rx_data(struct zyd_softc *, const uint8_t *, uint16_t); +static void zyd_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status); +static void zyd_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status); +static int zyd_tx_mgt(struct zyd_softc *, struct mbuf *, + struct ieee80211_node *); +static int zyd_tx_data(struct zyd_softc *, struct mbuf *, + struct ieee80211_node *); +static void zyd_start(struct ifnet *); +static void zyd_watchdog(void *); +static int zyd_ioctl(struct ifnet *, u_long, caddr_t); +static void zyd_init(void *); +static void zyd_stop(struct zyd_softc *, int); +static int zyd_loadfirmware(struct zyd_softc *, u_char *, size_t); +static void zyd_iter_func(void *, struct ieee80211_node *); +static void zyd_amrr_timeout(void *); +static void zyd_newassoc(struct ieee80211_node *, int); +static void zyd_scantask(void *); +static void zyd_scan_start(struct ieee80211com *); +static void zyd_scan_end(struct ieee80211com *); +static void zyd_set_channel(struct ieee80211com *); + +static int +zyd_match(device_t dev) +{ + struct usb_attach_arg *uaa = device_get_ivars(dev); + + if (!uaa->iface) + return UMATCH_NONE; + + return (zyd_lookup(uaa->vendor, uaa->product) != NULL) ? + UMATCH_VENDOR_PRODUCT : UMATCH_NONE; +} + +static int +zyd_attachhook(struct zyd_softc *sc) +{ + u_char *firmware; + int len, error; + + if (sc->mac_rev == ZYD_ZD1211) { + firmware = (u_char *)zd1211_firmware; + len = sizeof(zd1211_firmware); + } else { + firmware = (u_char *)zd1211b_firmware; + len = sizeof(zd1211b_firmware); + } + + error = zyd_loadfirmware(sc, firmware, len); + if (error != 0) { + device_printf(sc->sc_dev, + "could not load firmware (error=%d)\n", error); + return error; + } + + sc->sc_flags |= ZD1211_FWLOADED; + + /* complete the attach process */ + return zyd_complete_attach(sc); +} + +static int +zyd_attach(device_t dev) +{ + struct zyd_softc *sc = device_get_softc(dev); + struct usb_attach_arg *uaa = device_get_ivars(dev); + usb_device_descriptor_t* ddesc; + struct ifnet *ifp; + + sc->sc_dev = dev; + + ifp = sc->sc_ifp = if_alloc(IFT_ETHER); + if (ifp == NULL) { + device_printf(dev, "can not if_alloc()\n"); + return ENXIO; + } + + sc->sc_udev = uaa->device; + sc->sc_flags = 0; + sc->mac_rev = zyd_lookup(uaa->vendor, uaa->product)->rev; + + ddesc = usbd_get_device_descriptor(sc->sc_udev); + if (UGETW(ddesc->bcdDevice) < 0x4330) { + device_printf(dev, "device version mismatch: 0x%x " + "(only >= 43.30 supported)\n", + UGETW(ddesc->bcdDevice)); + return -1; + } + + ifp->if_softc = sc; + if_initname(ifp, "zyd", device_get_unit(sc->sc_dev)); + ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; + ifp->if_init = zyd_init; + ifp->if_ioctl = zyd_ioctl; + ifp->if_start = zyd_start; + IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN); + IFQ_SET_READY(&ifp->if_snd); + + STAILQ_INIT(&sc->sc_rqh); + + zyd_attachhook(sc); + + return 0; +} + +static int +zyd_complete_attach(struct zyd_softc *sc) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = sc->sc_ifp; + usbd_status error; + int bands; + + mtx_init(&sc->sc_mtx, device_get_nameunit(sc->sc_dev), MTX_NETWORK_LOCK, + MTX_DEF | MTX_RECURSE); + + usb_init_task(&sc->sc_scantask, zyd_scantask, sc); + usb_init_task(&sc->sc_task, zyd_task, sc); + + callout_init(&sc->sc_amrr_ch, 0); + callout_init(&sc->sc_watchdog_ch, 0); + + error = usbd_set_config_no(sc->sc_udev, ZYD_CONFIG_NO, 1); + if (error != 0) { + device_printf(sc->sc_dev, "setting config no failed\n"); + goto fail; + } + + error = usbd_device2interface_handle(sc->sc_udev, ZYD_IFACE_INDEX, + &sc->sc_iface); + if (error != 0) { + device_printf(sc->sc_dev, "getting interface handle failed\n"); + goto fail; + } + + if ((error = zyd_open_pipes(sc)) != 0) { + device_printf(sc->sc_dev, "could not open pipes\n"); + goto fail; + } + + if ((error = zyd_read_eeprom(sc)) != 0) { + device_printf(sc->sc_dev, "could not read EEPROM\n"); + goto fail; + } + + if ((error = zyd_rf_attach(sc, sc->rf_rev)) != 0) { + device_printf(sc->sc_dev, "could not attach RF, rev 0x%x\n", + sc->rf_rev); + goto fail; + } + + if ((error = zyd_hw_init(sc)) != 0) { + device_printf(sc->sc_dev, "hardware initialization failed\n"); + goto fail; + } + + device_printf(sc->sc_dev, + "HMAC ZD1211%s, FW %02x.%02x, RF %s, PA %x, address %s\n", + (sc->mac_rev == ZYD_ZD1211) ? "": "B", + sc->fw_rev >> 8, sc->fw_rev & 0xff, zyd_rf_name(sc->rf_rev), + sc->pa_rev, ether_sprintf(ic->ic_myaddr)); + + ic->ic_ifp = ifp; + ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */ + ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */ + ic->ic_state = IEEE80211_S_INIT; + + /* set device capabilities */ + ic->ic_caps = + IEEE80211_C_MONITOR /* monitor mode */ + | IEEE80211_C_SHPREAMBLE /* short preamble supported */ + | IEEE80211_C_SHSLOT /* short slot time supported */ + | IEEE80211_C_BGSCAN /* capable of bg scanning */ + | IEEE80211_C_WPA /* 802.11i */ + ; + + bands = 0; + setbit(&bands, IEEE80211_MODE_11B); + setbit(&bands, IEEE80211_MODE_11G); + ieee80211_init_channels(ic, 0, CTRY_DEFAULT, bands, 0, 1); + + ieee80211_ifattach(ic); + ic->ic_node_alloc = zyd_node_alloc; + ic->ic_newassoc = zyd_newassoc; + + /* enable s/w bmiss handling in sta mode */ + ic->ic_flags_ext |= IEEE80211_FEXT_SWBMISS; + ic->ic_scan_start = zyd_scan_start; + ic->ic_scan_end = zyd_scan_end; + ic->ic_set_channel = zyd_set_channel; + + /* override state transition machine */ + sc->sc_newstate = ic->ic_newstate; + ic->ic_newstate = zyd_newstate; + ieee80211_media_init(ic, zyd_media_change, ieee80211_media_status); + ieee80211_amrr_init(&sc->amrr, ic, + IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD, + IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD); + + bpfattach2(ifp, DLT_IEEE802_11_RADIO, + sizeof(struct ieee80211_frame) + sizeof(sc->sc_txtap), + &sc->sc_drvbpf); + + sc->sc_rxtap_len = sizeof(sc->sc_rxtap); + sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len); + sc->sc_rxtap.wr_ihdr.it_present = htole32(ZYD_RX_RADIOTAP_PRESENT); + + sc->sc_txtap_len = sizeof(sc->sc_txtap); + sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len); + sc->sc_txtap.wt_ihdr.it_present = htole32(ZYD_TX_RADIOTAP_PRESENT); + + if (bootverbose) + ieee80211_announce(ic); + + usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); + + return error; + +fail: + mtx_destroy(&sc->sc_mtx); + + return error; +} + +static int +zyd_detach(device_t dev) +{ + struct zyd_softc *sc = device_get_softc(dev); + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = sc->sc_ifp; + + if (!device_is_attached(dev)) + return 0; + + /* protect a race when we have listeners related with the driver. */ + ifp->if_flags &= ~IFF_UP; + + zyd_stop(sc, 1); + usb_rem_task(sc->sc_udev, &sc->sc_scantask); + usb_rem_task(sc->sc_udev, &sc->sc_task); + callout_stop(&sc->sc_amrr_ch); + callout_stop(&sc->sc_watchdog_ch); + + zyd_close_pipes(sc); + + bpfdetach(ifp); + ieee80211_ifdetach(ic); + if_free(ifp); + + mtx_destroy(&sc->sc_mtx); + + usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); + + return 0; +} + +static int +zyd_open_pipes(struct zyd_softc *sc) +{ + usb_endpoint_descriptor_t *edesc; + int isize; + usbd_status error; + + /* interrupt in */ + edesc = usbd_get_endpoint_descriptor(sc->sc_iface, 0x83); + if (edesc == NULL) + return EINVAL; + + isize = UGETW(edesc->wMaxPacketSize); + if (isize == 0) /* should not happen */ + return EINVAL; + + sc->ibuf = malloc(isize, M_USBDEV, M_NOWAIT); + if (sc->ibuf == NULL) + return ENOMEM; + + error = usbd_open_pipe_intr(sc->sc_iface, 0x83, USBD_SHORT_XFER_OK, + &sc->zyd_ep[ZYD_ENDPT_IIN], sc, sc->ibuf, isize, zyd_intr, + USBD_DEFAULT_INTERVAL); + if (error != 0) { + device_printf(sc->sc_dev, "open rx intr pipe failed: %s\n", + usbd_errstr(error)); + goto fail; + } + + /* interrupt out (not necessarily an interrupt pipe) */ + error = usbd_open_pipe(sc->sc_iface, 0x04, USBD_EXCLUSIVE_USE, + &sc->zyd_ep[ZYD_ENDPT_IOUT]); + if (error != 0) { + device_printf(sc->sc_dev, "open tx intr pipe failed: %s\n", + usbd_errstr(error)); + goto fail; + } + + /* bulk in */ + error = usbd_open_pipe(sc->sc_iface, 0x82, USBD_EXCLUSIVE_USE, + &sc->zyd_ep[ZYD_ENDPT_BIN]); + if (error != 0) { + device_printf(sc->sc_dev, "open rx pipe failed: %s\n", + usbd_errstr(error)); + goto fail; + } + + /* bulk out */ + error = usbd_open_pipe(sc->sc_iface, 0x01, USBD_EXCLUSIVE_USE, + &sc->zyd_ep[ZYD_ENDPT_BOUT]); + if (error != 0) { + device_printf(sc->sc_dev, "open tx pipe failed: %s\n", + usbd_errstr(error)); + goto fail; + } + + return 0; + +fail: zyd_close_pipes(sc); + return error; +} + +static void +zyd_close_pipes(struct zyd_softc *sc) +{ + int i; + + for (i = 0; i < ZYD_ENDPT_CNT; i++) { + if (sc->zyd_ep[i] != NULL) { + usbd_abort_pipe(sc->zyd_ep[i]); + usbd_close_pipe(sc->zyd_ep[i]); + sc->zyd_ep[i] = NULL; + } + } + if (sc->ibuf != NULL) { + free(sc->ibuf, M_USBDEV); + sc->ibuf = NULL; + } +} + +static int +zyd_alloc_tx_list(struct zyd_softc *sc) +{ + int i, error; + + sc->tx_queued = 0; + + for (i = 0; i < ZYD_TX_LIST_CNT; i++) { + struct zyd_tx_data *data = &sc->tx_data[i]; + + data->sc = sc; /* backpointer for callbacks */ + + data->xfer = usbd_alloc_xfer(sc->sc_udev); + if (data->xfer == NULL) { + device_printf(sc->sc_dev, + "could not allocate tx xfer\n"); + error = ENOMEM; + goto fail; + } + data->buf = usbd_alloc_buffer(data->xfer, ZYD_MAX_TXBUFSZ); + if (data->buf == NULL) { + device_printf(sc->sc_dev, + "could not allocate tx buffer\n"); + error = ENOMEM; + goto fail; + } + + /* clear Tx descriptor */ + bzero(data->buf, sizeof(struct zyd_tx_desc)); + } + return 0; + +fail: zyd_free_tx_list(sc); + return error; +} + +static void +zyd_free_tx_list(struct zyd_softc *sc) +{ + int i; + + for (i = 0; i < ZYD_TX_LIST_CNT; i++) { + struct zyd_tx_data *data = &sc->tx_data[i]; + + if (data->xfer != NULL) { + usbd_free_xfer(data->xfer); + data->xfer = NULL; + } + if (data->ni != NULL) { + ieee80211_free_node(data->ni); + data->ni = NULL; + } + } +} + +static int +zyd_alloc_rx_list(struct zyd_softc *sc) +{ + int i, error; + + for (i = 0; i < ZYD_RX_LIST_CNT; i++) { + struct zyd_rx_data *data = &sc->rx_data[i]; + + data->sc = sc; /* backpointer for callbacks */ + + data->xfer = usbd_alloc_xfer(sc->sc_udev); + if (data->xfer == NULL) { + device_printf(sc->sc_dev, + "could not allocate rx xfer\n"); + error = ENOMEM; + goto fail; + } + data->buf = usbd_alloc_buffer(data->xfer, ZYX_MAX_RXBUFSZ); + if (data->buf == NULL) { + device_printf(sc->sc_dev, + "could not allocate rx buffer\n"); + error = ENOMEM; + goto fail; + } + } + return 0; + +fail: zyd_free_rx_list(sc); + return error; +} + +static void +zyd_free_rx_list(struct zyd_softc *sc) +{ + int i; + + for (i = 0; i < ZYD_RX_LIST_CNT; i++) { + struct zyd_rx_data *data = &sc->rx_data[i]; + + if (data->xfer != NULL) { + usbd_free_xfer(data->xfer); + data->xfer = NULL; + } + } +} + +/* ARGUSED */ +static struct ieee80211_node * +zyd_node_alloc(struct ieee80211_node_table *nt __unused) +{ + struct zyd_node *zn; + + zn = malloc(sizeof(struct zyd_node), M_80211_NODE, M_NOWAIT | M_ZERO); + return zn != NULL ? &zn->ni : NULL; +} + +static int +zyd_media_change(struct ifnet *ifp) +{ + struct zyd_softc *sc = ifp->if_softc; + int error; + + error = ieee80211_media_change(ifp); + if (error != ENETRESET) + return error; + + if ((ifp->if_flags & IFF_UP) == IFF_UP && + (ifp->if_drv_flags & IFF_DRV_RUNNING) == IFF_DRV_RUNNING) + zyd_init(sc); + + return 0; +} + +static void +zyd_task(void *arg) +{ + struct zyd_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + enum ieee80211_state ostate; + + ostate = ic->ic_state; + + switch (sc->sc_state) { + case IEEE80211_S_RUN: + { + struct ieee80211_node *ni = ic->ic_bss; + + zyd_set_chan(sc, ic->ic_curchan); + + if (ic->ic_opmode != IEEE80211_M_MONITOR) { + /* turn link LED on */ + zyd_set_led(sc, ZYD_LED1, 1); + + /* make data LED blink upon Tx */ + zyd_write32(sc, sc->fwbase + ZYD_FW_LINK_STATUS, 1); + + zyd_set_bssid(sc, ni->ni_bssid); + } + + if (ic->ic_opmode == IEEE80211_M_STA) { + /* fake a join to init the tx rate */ + zyd_newassoc(ni, 1); + } + + /* start automatic rate control timer */ + if (ic->ic_fixed_rate == IEEE80211_FIXED_RATE_NONE) + callout_reset(&sc->sc_amrr_ch, hz, + zyd_amrr_timeout, sc); + + break; + } + default: + break; + } + + sc->sc_newstate(ic, sc->sc_state, sc->sc_arg); +} + +static int +zyd_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) +{ + struct zyd_softc *sc = ic->ic_ifp->if_softc; + + usb_rem_task(sc->sc_udev, &sc->sc_task); + callout_stop(&sc->sc_amrr_ch); + + /* do it in a process context */ + sc->sc_state = nstate; + sc->sc_arg = arg; + + if (nstate == IEEE80211_S_INIT) + sc->sc_newstate(ic, nstate, arg); + else + usb_add_task(sc->sc_udev, &sc->sc_task, USB_TASKQ_DRIVER); + + return 0; +} + +static int +zyd_cmd(struct zyd_softc *sc, uint16_t code, const void *idata, int ilen, + void *odata, int olen, u_int flags) +{ + usbd_xfer_handle xfer; + struct zyd_cmd cmd; + struct rq rq; + uint16_t xferflags; + usbd_status error; + + if ((xfer = usbd_alloc_xfer(sc->sc_udev)) == NULL) + return ENOMEM; + + cmd.code = htole16(code); + bcopy(idata, cmd.data, ilen); + + xferflags = USBD_FORCE_SHORT_XFER; + if (!(flags & ZYD_CMD_FLAG_READ)) + xferflags |= USBD_SYNCHRONOUS; + else { + rq.idata = idata; + rq.odata = odata; + rq.len = olen / sizeof(struct zyd_pair); + STAILQ_INSERT_TAIL(&sc->sc_rqh, &rq, rq); + } + + usbd_setup_xfer(xfer, sc->zyd_ep[ZYD_ENDPT_IOUT], 0, &cmd, + sizeof(uint16_t) + ilen, xferflags, ZYD_INTR_TIMEOUT, NULL); + error = usbd_transfer(xfer); + if (error != USBD_IN_PROGRESS && error != 0) { + device_printf(sc->sc_dev, "could not send command (error=%s)\n", + usbd_errstr(error)); + (void)usbd_free_xfer(xfer); + return EIO; + } + if (!(flags & ZYD_CMD_FLAG_READ)) { + (void)usbd_free_xfer(xfer); + return 0; /* write: don't wait for reply */ + } + /* wait at most one second for command reply */ + error = tsleep(odata, PCATCH, "zydcmd", hz); + if (error == EWOULDBLOCK) + device_printf(sc->sc_dev, "zyd_read sleep timeout\n"); + STAILQ_REMOVE(&sc->sc_rqh, &rq, rq, rq); + + (void)usbd_free_xfer(xfer); + return error; +} + +static int +zyd_read16(struct zyd_softc *sc, uint16_t reg, uint16_t *val) +{ + struct zyd_pair tmp; + int error; + + reg = htole16(reg); + error = zyd_cmd(sc, ZYD_CMD_IORD, ®, sizeof(reg), &tmp, sizeof(tmp), + ZYD_CMD_FLAG_READ); + if (error == 0) + *val = le16toh(tmp.val); + return error; +} + +static int +zyd_read32(struct zyd_softc *sc, uint16_t reg, uint32_t *val) +{ + struct zyd_pair tmp[2]; + uint16_t regs[2]; + int error; + + regs[0] = htole16(ZYD_REG32_HI(reg)); + regs[1] = htole16(ZYD_REG32_LO(reg)); + error = zyd_cmd(sc, ZYD_CMD_IORD, regs, sizeof(regs), tmp, sizeof(tmp), + ZYD_CMD_FLAG_READ); + if (error == 0) + *val = le16toh(tmp[0].val) << 16 | le16toh(tmp[1].val); + return error; +} + +static int +zyd_write16(struct zyd_softc *sc, uint16_t reg, uint16_t val) +{ + struct zyd_pair pair; + + pair.reg = htole16(reg); + pair.val = htole16(val); + + return zyd_cmd(sc, ZYD_CMD_IOWR, &pair, sizeof(pair), NULL, 0, 0); +} + +static int +zyd_write32(struct zyd_softc *sc, uint16_t reg, uint32_t val) +{ + struct zyd_pair pair[2]; + + pair[0].reg = htole16(ZYD_REG32_HI(reg)); + pair[0].val = htole16(val >> 16); + pair[1].reg = htole16(ZYD_REG32_LO(reg)); + pair[1].val = htole16(val & 0xffff); + + return zyd_cmd(sc, ZYD_CMD_IOWR, pair, sizeof(pair), NULL, 0, 0); +} + +static int +zyd_rfwrite(struct zyd_softc *sc, uint32_t val) +{ + struct zyd_rf *rf = &sc->sc_rf; + struct zyd_rfwrite req; + uint16_t cr203; + int i; + + (void)zyd_read16(sc, ZYD_CR203, &cr203); + cr203 &= ~(ZYD_RF_IF_LE | ZYD_RF_CLK | ZYD_RF_DATA); + + req.code = htole16(2); + req.width = htole16(rf->width); + for (i = 0; i < rf->width; i++) { + req.bit[i] = htole16(cr203); + if (val & (1 << (rf->width - 1 - i))) + req.bit[i] |= htole16(ZYD_RF_DATA); + } + return zyd_cmd(sc, ZYD_CMD_RFCFG, &req, 4 + 2 * rf->width, NULL, 0, 0); +} + +static void +zyd_lock_phy(struct zyd_softc *sc) +{ + uint32_t tmp; + + (void)zyd_read32(sc, ZYD_MAC_MISC, &tmp); + tmp &= ~ZYD_UNLOCK_PHY_REGS; + (void)zyd_write32(sc, ZYD_MAC_MISC, tmp); +} + +static void +zyd_unlock_phy(struct zyd_softc *sc) +{ + uint32_t tmp; + + (void)zyd_read32(sc, ZYD_MAC_MISC, &tmp); + tmp |= ZYD_UNLOCK_PHY_REGS; + (void)zyd_write32(sc, ZYD_MAC_MISC, tmp); +} + +/* + * RFMD RF methods. + */ +static int +zyd_rfmd_init(struct zyd_rf *rf) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_RFMD_PHY; + static const uint32_t rfini[] = ZYD_RFMD_RF; + int i, error; + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + + /* init RFMD radio */ + for (i = 0; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + return 0; +#undef N +} + +static int +zyd_rfmd_switch_radio(struct zyd_rf *rf, int on) +{ + struct zyd_softc *sc = rf->rf_sc; + + (void)zyd_write16(sc, ZYD_CR10, on ? 0x89 : 0x15); + (void)zyd_write16(sc, ZYD_CR11, on ? 0x00 : 0x81); + + return 0; +} + +static int +zyd_rfmd_set_channel(struct zyd_rf *rf, uint8_t chan) +{ + struct zyd_softc *sc = rf->rf_sc; + static const struct { + uint32_t r1, r2; + } rfprog[] = ZYD_RFMD_CHANTABLE; + + (void)zyd_rfwrite(sc, rfprog[chan - 1].r1); + (void)zyd_rfwrite(sc, rfprog[chan - 1].r2); + + return 0; +} + +/* + * AL2230 RF methods. + */ +static int +zyd_al2230_init(struct zyd_rf *rf) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_AL2230_PHY; + static const uint32_t rfini[] = ZYD_AL2230_RF; + int i, error; + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + + /* init AL2230 radio */ + for (i = 0; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + return 0; +#undef N +} + +static int +zyd_al2230_init_b(struct zyd_rf *rf) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_AL2230_PHY_B; + static const uint32_t rfini[] = ZYD_AL2230_RF_B; + int i, error; + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + + /* init AL2230 radio */ + for (i = 0; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + return 0; +#undef N +} + +static int +zyd_al2230_switch_radio(struct zyd_rf *rf, int on) +{ + struct zyd_softc *sc = rf->rf_sc; + int on251 = (sc->mac_rev == ZYD_ZD1211) ? 0x3f : 0x7f; + + (void)zyd_write16(sc, ZYD_CR11, on ? 0x00 : 0x04); + (void)zyd_write16(sc, ZYD_CR251, on ? on251 : 0x2f); + + return 0; +} + +static int +zyd_al2230_set_channel(struct zyd_rf *rf, uint8_t chan) +{ + struct zyd_softc *sc = rf->rf_sc; + static const struct { + uint32_t r1, r2, r3; + } rfprog[] = ZYD_AL2230_CHANTABLE; + + (void)zyd_rfwrite(sc, rfprog[chan - 1].r1); + (void)zyd_rfwrite(sc, rfprog[chan - 1].r2); + (void)zyd_rfwrite(sc, rfprog[chan - 1].r3); + + (void)zyd_write16(sc, ZYD_CR138, 0x28); + (void)zyd_write16(sc, ZYD_CR203, 0x06); + + return 0; +} + +/* + * AL7230B RF methods. + */ +static int +zyd_al7230B_init(struct zyd_rf *rf) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini_1[] = ZYD_AL7230B_PHY_1; + static const struct zyd_phy_pair phyini_2[] = ZYD_AL7230B_PHY_2; + static const struct zyd_phy_pair phyini_3[] = ZYD_AL7230B_PHY_3; + static const uint32_t rfini_1[] = ZYD_AL7230B_RF_1; + static const uint32_t rfini_2[] = ZYD_AL7230B_RF_2; + int i, error; + + /* for AL7230B, PHY and RF need to be initialized in "phases" */ + + /* init RF-dependent PHY registers, part one */ + for (i = 0; i < N(phyini_1); i++) { + error = zyd_write16(sc, phyini_1[i].reg, phyini_1[i].val); + if (error != 0) + return error; + } + /* init AL7230B radio, part one */ + for (i = 0; i < N(rfini_1); i++) { + if ((error = zyd_rfwrite(sc, rfini_1[i])) != 0) + return error; + } + /* init RF-dependent PHY registers, part two */ + for (i = 0; i < N(phyini_2); i++) { + error = zyd_write16(sc, phyini_2[i].reg, phyini_2[i].val); + if (error != 0) + return error; + } + /* init AL7230B radio, part two */ + for (i = 0; i < N(rfini_2); i++) { + if ((error = zyd_rfwrite(sc, rfini_2[i])) != 0) + return error; + } + /* init RF-dependent PHY registers, part three */ + for (i = 0; i < N(phyini_3); i++) { + error = zyd_write16(sc, phyini_3[i].reg, phyini_3[i].val); + if (error != 0) + return error; + } + + return 0; +#undef N +} + +static int +zyd_al7230B_switch_radio(struct zyd_rf *rf, int on) +{ + struct zyd_softc *sc = rf->rf_sc; + + (void)zyd_write16(sc, ZYD_CR11, on ? 0x00 : 0x04); + (void)zyd_write16(sc, ZYD_CR251, on ? 0x3f : 0x2f); + + return 0; +} + +static int +zyd_al7230B_set_channel(struct zyd_rf *rf, uint8_t chan) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct { + uint32_t r1, r2; + } rfprog[] = ZYD_AL7230B_CHANTABLE; + static const uint32_t rfsc[] = ZYD_AL7230B_RF_SETCHANNEL; + int i, error; + + (void)zyd_write16(sc, ZYD_CR240, 0x57); + (void)zyd_write16(sc, ZYD_CR251, 0x2f); + + for (i = 0; i < N(rfsc); i++) { + if ((error = zyd_rfwrite(sc, rfsc[i])) != 0) + return error; + } + + (void)zyd_write16(sc, ZYD_CR128, 0x14); + (void)zyd_write16(sc, ZYD_CR129, 0x12); + (void)zyd_write16(sc, ZYD_CR130, 0x10); + (void)zyd_write16(sc, ZYD_CR38, 0x38); + (void)zyd_write16(sc, ZYD_CR136, 0xdf); + + (void)zyd_rfwrite(sc, rfprog[chan - 1].r1); + (void)zyd_rfwrite(sc, rfprog[chan - 1].r2); + (void)zyd_rfwrite(sc, 0x3c9000); + + (void)zyd_write16(sc, ZYD_CR251, 0x3f); + (void)zyd_write16(sc, ZYD_CR203, 0x06); + (void)zyd_write16(sc, ZYD_CR240, 0x08); + + return 0; +#undef N +} + +/* + * AL2210 RF methods. + */ +static int +zyd_al2210_init(struct zyd_rf *rf) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_AL2210_PHY; + static const uint32_t rfini[] = ZYD_AL2210_RF; + uint32_t tmp; + int i, error; + + (void)zyd_write32(sc, ZYD_CR18, 2); + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + /* init AL2210 radio */ + for (i = 0; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + (void)zyd_write16(sc, ZYD_CR47, 0x1e); + (void)zyd_read32(sc, ZYD_CR_RADIO_PD, &tmp); + (void)zyd_write32(sc, ZYD_CR_RADIO_PD, tmp & ~1); + (void)zyd_write32(sc, ZYD_CR_RADIO_PD, tmp | 1); + (void)zyd_write32(sc, ZYD_CR_RFCFG, 0x05); + (void)zyd_write32(sc, ZYD_CR_RFCFG, 0x00); + (void)zyd_write16(sc, ZYD_CR47, 0x1e); + (void)zyd_write32(sc, ZYD_CR18, 3); + + return 0; +#undef N +} + +static int +zyd_al2210_switch_radio(struct zyd_rf *rf, int on) +{ + /* vendor driver does nothing for this RF chip */ + + return 0; +} + +static int +zyd_al2210_set_channel(struct zyd_rf *rf, uint8_t chan) +{ + struct zyd_softc *sc = rf->rf_sc; + static const uint32_t rfprog[] = ZYD_AL2210_CHANTABLE; + uint32_t tmp; + + (void)zyd_write32(sc, ZYD_CR18, 2); + (void)zyd_write16(sc, ZYD_CR47, 0x1e); + (void)zyd_read32(sc, ZYD_CR_RADIO_PD, &tmp); + (void)zyd_write32(sc, ZYD_CR_RADIO_PD, tmp & ~1); + (void)zyd_write32(sc, ZYD_CR_RADIO_PD, tmp | 1); + (void)zyd_write32(sc, ZYD_CR_RFCFG, 0x05); + + (void)zyd_write32(sc, ZYD_CR_RFCFG, 0x00); + (void)zyd_write16(sc, ZYD_CR47, 0x1e); + + /* actually set the channel */ + (void)zyd_rfwrite(sc, rfprog[chan - 1]); + + (void)zyd_write32(sc, ZYD_CR18, 3); + + return 0; +} + +/* + * GCT RF methods. + */ +static int +zyd_gct_init(struct zyd_rf *rf) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_GCT_PHY; + static const uint32_t rfini[] = ZYD_GCT_RF; + int i, error; + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + /* init cgt radio */ + for (i = 0; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + return 0; +#undef N +} + +static int +zyd_gct_switch_radio(struct zyd_rf *rf, int on) +{ + /* vendor driver does nothing for this RF chip */ + + return 0; +} + +static int +zyd_gct_set_channel(struct zyd_rf *rf, uint8_t chan) +{ + struct zyd_softc *sc = rf->rf_sc; + static const uint32_t rfprog[] = ZYD_GCT_CHANTABLE; + + (void)zyd_rfwrite(sc, 0x1c0000); + (void)zyd_rfwrite(sc, rfprog[chan - 1]); + (void)zyd_rfwrite(sc, 0x1c0008); + + return 0; +} + +/* + * Maxim RF methods. + */ +static int +zyd_maxim_init(struct zyd_rf *rf) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_MAXIM_PHY; + static const uint32_t rfini[] = ZYD_MAXIM_RF; + uint16_t tmp; + int i, error; + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + (void)zyd_read16(sc, ZYD_CR203, &tmp); + (void)zyd_write16(sc, ZYD_CR203, tmp & ~(1 << 4)); + + /* init maxim radio */ + for (i = 0; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + (void)zyd_read16(sc, ZYD_CR203, &tmp); + (void)zyd_write16(sc, ZYD_CR203, tmp | (1 << 4)); + + return 0; +#undef N +} + +static int +zyd_maxim_switch_radio(struct zyd_rf *rf, int on) +{ + /* vendor driver does nothing for this RF chip */ + + return 0; +} + +static int +zyd_maxim_set_channel(struct zyd_rf *rf, uint8_t chan) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_MAXIM_PHY; + static const uint32_t rfini[] = ZYD_MAXIM_RF; + static const struct { + uint32_t r1, r2; + } rfprog[] = ZYD_MAXIM_CHANTABLE; + uint16_t tmp; + int i, error; + + /* + * Do the same as we do when initializing it, except for the channel + * values coming from the two channel tables. + */ + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + (void)zyd_read16(sc, ZYD_CR203, &tmp); + (void)zyd_write16(sc, ZYD_CR203, tmp & ~(1 << 4)); + + /* first two values taken from the chantables */ + (void)zyd_rfwrite(sc, rfprog[chan - 1].r1); + (void)zyd_rfwrite(sc, rfprog[chan - 1].r2); + + /* init maxim radio - skipping the two first values */ + for (i = 2; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + (void)zyd_read16(sc, ZYD_CR203, &tmp); + (void)zyd_write16(sc, ZYD_CR203, tmp | (1 << 4)); + + return 0; +#undef N +} + +/* + * Maxim2 RF methods. + */ +static int +zyd_maxim2_init(struct zyd_rf *rf) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_MAXIM2_PHY; + static const uint32_t rfini[] = ZYD_MAXIM2_RF; + uint16_t tmp; + int i, error; + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + (void)zyd_read16(sc, ZYD_CR203, &tmp); + (void)zyd_write16(sc, ZYD_CR203, tmp & ~(1 << 4)); + + /* init maxim2 radio */ + for (i = 0; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + (void)zyd_read16(sc, ZYD_CR203, &tmp); + (void)zyd_write16(sc, ZYD_CR203, tmp | (1 << 4)); + + return 0; +#undef N +} + +static int +zyd_maxim2_switch_radio(struct zyd_rf *rf, int on) +{ + /* vendor driver does nothing for this RF chip */ + + return 0; +} + +static int +zyd_maxim2_set_channel(struct zyd_rf *rf, uint8_t chan) +{ +#define N(a) (sizeof(a) / sizeof((a)[0])) + struct zyd_softc *sc = rf->rf_sc; + static const struct zyd_phy_pair phyini[] = ZYD_MAXIM2_PHY; + static const uint32_t rfini[] = ZYD_MAXIM2_RF; + static const struct { + uint32_t r1, r2; + } rfprog[] = ZYD_MAXIM2_CHANTABLE; + uint16_t tmp; + int i, error; + + /* + * Do the same as we do when initializing it, except for the channel + * values coming from the two channel tables. + */ + + /* init RF-dependent PHY registers */ + for (i = 0; i < N(phyini); i++) { + error = zyd_write16(sc, phyini[i].reg, phyini[i].val); + if (error != 0) + return error; + } + (void)zyd_read16(sc, ZYD_CR203, &tmp); + (void)zyd_write16(sc, ZYD_CR203, tmp & ~(1 << 4)); + + /* first two values taken from the chantables */ + (void)zyd_rfwrite(sc, rfprog[chan - 1].r1); + (void)zyd_rfwrite(sc, rfprog[chan - 1].r2); + + /* init maxim2 radio - skipping the two first values */ + for (i = 2; i < N(rfini); i++) { + if ((error = zyd_rfwrite(sc, rfini[i])) != 0) + return error; + } + (void)zyd_read16(sc, ZYD_CR203, &tmp); + (void)zyd_write16(sc, ZYD_CR203, tmp | (1 << 4)); + + return 0; +#undef N +} + +static int +zyd_rf_attach(struct zyd_softc *sc, uint8_t type) +{ + struct zyd_rf *rf = &sc->sc_rf; + + rf->rf_sc = sc; + + switch (type) { + case ZYD_RF_RFMD: + rf->init = zyd_rfmd_init; + rf->switch_radio = zyd_rfmd_switch_radio; + rf->set_channel = zyd_rfmd_set_channel; + rf->width = 24; /* 24-bit RF values */ + break; + case ZYD_RF_AL2230: + if (sc->mac_rev == ZYD_ZD1211B) + rf->init = zyd_al2230_init_b; + else + rf->init = zyd_al2230_init; + rf->switch_radio = zyd_al2230_switch_radio; + rf->set_channel = zyd_al2230_set_channel; + rf->width = 24; /* 24-bit RF values */ + break; + case ZYD_RF_AL7230B: + rf->init = zyd_al7230B_init; + rf->switch_radio = zyd_al7230B_switch_radio; + rf->set_channel = zyd_al7230B_set_channel; + rf->width = 24; /* 24-bit RF values */ + break; + case ZYD_RF_AL2210: + rf->init = zyd_al2210_init; + rf->switch_radio = zyd_al2210_switch_radio; + rf->set_channel = zyd_al2210_set_channel; + rf->width = 24; /* 24-bit RF values */ + break; + case ZYD_RF_GCT: + rf->init = zyd_gct_init; + rf->switch_radio = zyd_gct_switch_radio; + rf->set_channel = zyd_gct_set_channel; + rf->width = 21; /* 21-bit RF values */ + break; + case ZYD_RF_MAXIM_NEW: + rf->init = zyd_maxim_init; + rf->switch_radio = zyd_maxim_switch_radio; + rf->set_channel = zyd_maxim_set_channel; + rf->width = 18; /* 18-bit RF values */ + break; + case ZYD_RF_MAXIM_NEW2: + rf->init = zyd_maxim2_init; + rf->switch_radio = zyd_maxim2_switch_radio; + rf->set_channel = zyd_maxim2_set_channel; + rf->width = 18; /* 18-bit RF values */ + break; + default: + device_printf(sc->sc_dev, + "sorry, radio \"%s\" is not supported yet\n", + zyd_rf_name(type)); + return EINVAL; + } + return 0; +} + +static const char * +zyd_rf_name(uint8_t type) +{ + static const char * const zyd_rfs[] = { + "unknown", "unknown", "UW2451", "UCHIP", "AL2230", + "AL7230B", "THETA", "AL2210", "MAXIM_NEW", "GCT", + "PV2000", "RALINK", "INTERSIL", "RFMD", "MAXIM_NEW2", + "PHILIPS" + }; + + return zyd_rfs[(type > 15) ? 0 : type]; +} + +static int +zyd_hw_init(struct zyd_softc *sc) +{ + struct zyd_rf *rf = &sc->sc_rf; + const struct zyd_phy_pair *phyp; + int error; + + /* specify that the plug and play is finished */ + (void)zyd_write32(sc, ZYD_MAC_AFTER_PNP, 1); + + (void)zyd_read16(sc, ZYD_FIRMWARE_BASE_ADDR, &sc->fwbase); + DPRINTF(("firmware base address=0x%04x\n", sc->fwbase)); + + /* retrieve firmware revision number */ + (void)zyd_read16(sc, sc->fwbase + ZYD_FW_FIRMWARE_REV, &sc->fw_rev); + + (void)zyd_write32(sc, ZYD_CR_GPI_EN, 0); + (void)zyd_write32(sc, ZYD_MAC_CONT_WIN_LIMIT, 0x7f043f); + + /* disable interrupts */ + (void)zyd_write32(sc, ZYD_CR_INTERRUPT, 0); + + /* PHY init */ + zyd_lock_phy(sc); + phyp = (sc->mac_rev == ZYD_ZD1211B) ? zyd_def_phyB : zyd_def_phy; + for (; phyp->reg != 0; phyp++) { + if ((error = zyd_write16(sc, phyp->reg, phyp->val)) != 0) + goto fail; + } + zyd_unlock_phy(sc); + + /* HMAC init */ + zyd_write32(sc, ZYD_MAC_ACK_EXT, 0x00000020); + zyd_write32(sc, ZYD_CR_ADDA_MBIAS_WT, 0x30000808); + + if (sc->mac_rev == ZYD_ZD1211) { + zyd_write32(sc, ZYD_MAC_RETRY, 0x00000002); + } else { + zyd_write32(sc, ZYD_MAC_RETRY, 0x02020202); + zyd_write32(sc, ZYD_MACB_TXPWR_CTL4, 0x007f003f); + zyd_write32(sc, ZYD_MACB_TXPWR_CTL3, 0x007f003f); + zyd_write32(sc, ZYD_MACB_TXPWR_CTL2, 0x003f001f); + zyd_write32(sc, ZYD_MACB_TXPWR_CTL1, 0x001f000f); + zyd_write32(sc, ZYD_MACB_AIFS_CTL1, 0x00280028); + zyd_write32(sc, ZYD_MACB_AIFS_CTL2, 0x008C003C); + zyd_write32(sc, ZYD_MACB_TXOP, 0x01800824); + } + + zyd_write32(sc, ZYD_MAC_SNIFFER, 0x00000000); + zyd_write32(sc, ZYD_MAC_RXFILTER, 0x00000000); + zyd_write32(sc, ZYD_MAC_GHTBL, 0x00000000); + zyd_write32(sc, ZYD_MAC_GHTBH, 0x80000000); + zyd_write32(sc, ZYD_MAC_MISC, 0x000000a4); + zyd_write32(sc, ZYD_CR_ADDA_PWR_DWN, 0x0000007f); + zyd_write32(sc, ZYD_MAC_BCNCFG, 0x00f00401); + zyd_write32(sc, ZYD_MAC_PHY_DELAY2, 0x00000000); + zyd_write32(sc, ZYD_MAC_ACK_EXT, 0x00000080); + zyd_write32(sc, ZYD_CR_ADDA_PWR_DWN, 0x00000000); + zyd_write32(sc, ZYD_MAC_SIFS_ACK_TIME, 0x00000100); + zyd_write32(sc, ZYD_MAC_DIFS_EIFS_SIFS, 0x0547c032); + zyd_write32(sc, ZYD_CR_RX_PE_DELAY, 0x00000070); + zyd_write32(sc, ZYD_CR_PS_CTRL, 0x10000000); + zyd_write32(sc, ZYD_MAC_RTSCTSRATE, 0x02030203); + zyd_write32(sc, ZYD_MAC_RX_THRESHOLD, 0x000c0640); + zyd_write32(sc, ZYD_MAC_BACKOFF_PROTECT, 0x00000114); + + /* RF chip init */ + zyd_lock_phy(sc); + error = (*rf->init)(rf); + zyd_unlock_phy(sc); + if (error != 0) { + device_printf(sc->sc_dev, + "radio initialization failed, error %d\n", error); + goto fail; + } + + /* init beacon interval to 100ms */ + if ((error = zyd_set_beacon_interval(sc, 100)) != 0) + goto fail; + +fail: return error; +} + +static int +zyd_read_eeprom(struct zyd_softc *sc) +{ + struct ieee80211com *ic = &sc->sc_ic; + uint32_t tmp; + uint16_t val; + int i; + + /* read MAC address */ + (void)zyd_read32(sc, ZYD_EEPROM_MAC_ADDR_P1, &tmp); + ic->ic_myaddr[0] = tmp & 0xff; + ic->ic_myaddr[1] = tmp >> 8; + ic->ic_myaddr[2] = tmp >> 16; + ic->ic_myaddr[3] = tmp >> 24; + (void)zyd_read32(sc, ZYD_EEPROM_MAC_ADDR_P2, &tmp); + ic->ic_myaddr[4] = tmp & 0xff; + ic->ic_myaddr[5] = tmp >> 8; + + (void)zyd_read32(sc, ZYD_EEPROM_POD, &tmp); + sc->rf_rev = tmp & 0x0f; + sc->pa_rev = (tmp >> 16) & 0x0f; + + /* read regulatory domain (currently unused) */ + (void)zyd_read32(sc, ZYD_EEPROM_SUBID, &tmp); + sc->regdomain = tmp >> 16; + DPRINTF(("regulatory domain %x\n", sc->regdomain)); + + /* read Tx power calibration tables */ + for (i = 0; i < 7; i++) { + (void)zyd_read16(sc, ZYD_EEPROM_PWR_CAL + i, &val); + sc->pwr_cal[i * 2] = val >> 8; + sc->pwr_cal[i * 2 + 1] = val & 0xff; + + (void)zyd_read16(sc, ZYD_EEPROM_PWR_INT + i, &val); + sc->pwr_int[i * 2] = val >> 8; + sc->pwr_int[i * 2 + 1] = val & 0xff; + + (void)zyd_read16(sc, ZYD_EEPROM_36M_CAL + i, &val); + sc->ofdm36_cal[i * 2] = val >> 8; + sc->ofdm36_cal[i * 2 + 1] = val & 0xff; + + (void)zyd_read16(sc, ZYD_EEPROM_48M_CAL + i, &val); + sc->ofdm48_cal[i * 2] = val >> 8; + sc->ofdm48_cal[i * 2 + 1] = val & 0xff; + + (void)zyd_read16(sc, ZYD_EEPROM_54M_CAL + i, &val); + sc->ofdm54_cal[i * 2] = val >> 8; + sc->ofdm54_cal[i * 2 + 1] = val & 0xff; + } + return 0; +} + +static int +zyd_set_macaddr(struct zyd_softc *sc, const uint8_t *addr) +{ + uint32_t tmp; + + tmp = addr[3] << 24 | addr[2] << 16 | addr[1] << 8 | addr[0]; + (void)zyd_write32(sc, ZYD_MAC_MACADRL, tmp); + + tmp = addr[5] << 8 | addr[4]; + (void)zyd_write32(sc, ZYD_MAC_MACADRH, tmp); + + return 0; +} + +static int +zyd_set_bssid(struct zyd_softc *sc, const uint8_t *addr) +{ + uint32_t tmp; + + tmp = addr[3] << 24 | addr[2] << 16 | addr[1] << 8 | addr[0]; + (void)zyd_write32(sc, ZYD_MAC_BSSADRL, tmp); + + tmp = addr[5] << 8 | addr[4]; + (void)zyd_write32(sc, ZYD_MAC_BSSADRH, tmp); + + return 0; +} + +static int +zyd_switch_radio(struct zyd_softc *sc, int on) +{ + struct zyd_rf *rf = &sc->sc_rf; + int error; + + zyd_lock_phy(sc); + error = (*rf->switch_radio)(rf, on); + zyd_unlock_phy(sc); + + return error; +} + +static void +zyd_set_led(struct zyd_softc *sc, int which, int on) +{ + uint32_t tmp; + + (void)zyd_read32(sc, ZYD_MAC_TX_PE_CONTROL, &tmp); + tmp &= ~which; + if (on) + tmp |= which; + (void)zyd_write32(sc, ZYD_MAC_TX_PE_CONTROL, tmp); +} + +static int +zyd_set_rxfilter(struct zyd_softc *sc) +{ + uint32_t rxfilter; + + switch (sc->sc_ic.ic_opmode) { + case IEEE80211_M_STA: + rxfilter = ZYD_FILTER_BSS; + break; + case IEEE80211_M_IBSS: + case IEEE80211_M_HOSTAP: + rxfilter = ZYD_FILTER_HOSTAP; + break; + case IEEE80211_M_MONITOR: + rxfilter = ZYD_FILTER_MONITOR; + break; + default: + /* should not get there */ + return EINVAL; + } + return zyd_write32(sc, ZYD_MAC_RXFILTER, rxfilter); +} + +static void +zyd_set_chan(struct zyd_softc *sc, struct ieee80211_channel *c) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct zyd_rf *rf = &sc->sc_rf; + u_int chan; + + chan = ieee80211_chan2ieee(ic, c); + if (chan == 0 || chan == IEEE80211_CHAN_ANY) { + /* XXX should NEVER happen */ + device_printf(sc->sc_dev, + "%s: invalid channel %x\n", __func__, chan); + return; + } + + zyd_lock_phy(sc); + + (*rf->set_channel)(rf, chan); + + /* update Tx power */ + (void)zyd_write32(sc, ZYD_CR31, sc->pwr_int[chan - 1]); + (void)zyd_write32(sc, ZYD_CR68, sc->pwr_cal[chan - 1]); + + if (sc->mac_rev == ZYD_ZD1211B) { + (void)zyd_write32(sc, ZYD_CR67, sc->ofdm36_cal[chan - 1]); + (void)zyd_write32(sc, ZYD_CR66, sc->ofdm48_cal[chan - 1]); + (void)zyd_write32(sc, ZYD_CR65, sc->ofdm54_cal[chan - 1]); + + (void)zyd_write32(sc, ZYD_CR69, 0x28); + (void)zyd_write32(sc, ZYD_CR69, 0x2a); + } + + zyd_unlock_phy(sc); + + sc->sc_rxtap.wr_chan_freq = sc->sc_txtap.wt_chan_freq = + htole16(c->ic_freq); + sc->sc_rxtap.wr_chan_flags = sc->sc_txtap.wt_chan_flags = + htole16(c->ic_flags); +} + +static int +zyd_set_beacon_interval(struct zyd_softc *sc, int bintval) +{ + /* XXX this is probably broken.. */ + (void)zyd_write32(sc, ZYD_CR_ATIM_WND_PERIOD, bintval - 2); + (void)zyd_write32(sc, ZYD_CR_PRE_TBTT, bintval - 1); + (void)zyd_write32(sc, ZYD_CR_BCN_INTERVAL, bintval); + + return 0; +} + +static uint8_t +zyd_plcp_signal(int rate) +{ + switch (rate) { + /* CCK rates (returned values are device-dependent) */ + case 2: return 0x0; + case 4: return 0x1; + case 11: return 0x2; + case 22: return 0x3; + + /* OFDM rates (cf IEEE Std 802.11a-1999, pp. 14 Table 80) */ + case 12: return 0xb; + case 18: return 0xf; + case 24: return 0xa; + case 36: return 0xe; + case 48: return 0x9; + case 72: return 0xd; + case 96: return 0x8; + case 108: return 0xc; + + /* unsupported rates (should not get there) */ + default: return 0xff; + } +} + +static void +zyd_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) +{ + struct zyd_softc *sc = (struct zyd_softc *)priv; + struct zyd_cmd *cmd; + uint32_t datalen; + + if (status != USBD_NORMAL_COMPLETION) { + if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) + return; + + if (status == USBD_STALLED) { + usbd_clear_endpoint_stall_async( + sc->zyd_ep[ZYD_ENDPT_IIN]); + } + return; + } + + cmd = (struct zyd_cmd *)sc->ibuf; + + if (le16toh(cmd->code) == ZYD_NOTIF_RETRYSTATUS) { + struct zyd_notif_retry *retry = + (struct zyd_notif_retry *)cmd->data; + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = sc->sc_ifp; + struct ieee80211_node *ni; + + DPRINTF(("retry intr: rate=0x%x addr=%s count=%d (0x%x)\n", + le16toh(retry->rate), ether_sprintf(retry->macaddr), + le16toh(retry->count) & 0xff, le16toh(retry->count))); + + /* + * Find the node to which the packet was sent and update its + * retry statistics. In BSS mode, this node is the AP we're + * associated to so no lookup is actually needed. + */ + if (ic->ic_opmode != IEEE80211_M_STA) { + ni = ieee80211_find_node(&ic->ic_sta, retry->macaddr); + if (ni == NULL) + return; /* just ignore */ + } else + ni = ic->ic_bss; + + ((struct zyd_node *)ni)->amn.amn_retrycnt++; + + if (le16toh(retry->count) & 0x100) + ifp->if_oerrors++; /* too many retries */ + } else if (le16toh(cmd->code) == ZYD_NOTIF_IORD) { + struct rq *rqp; + + if (le16toh(*(uint16_t *)cmd->data) == ZYD_CR_INTERRUPT) + return; /* HMAC interrupt */ + + usbd_get_xfer_status(xfer, NULL, NULL, &datalen, NULL); + datalen -= sizeof(cmd->code); + datalen -= 2; /* XXX: padding? */ + + STAILQ_FOREACH(rqp, &sc->sc_rqh, rq) { + int i; + + if (sizeof(struct zyd_pair) * rqp->len != datalen) + continue; + for (i = 0; i < rqp->len; i++) { + if (*(((const uint16_t *)rqp->idata) + i) != + (((struct zyd_pair *)cmd->data) + i)->reg) + break; + } + if (i != rqp->len) + continue; + + /* copy answer into caller-supplied buffer */ + bcopy(cmd->data, rqp->odata, + sizeof(struct zyd_pair) * rqp->len); + wakeup(rqp->odata); /* wakeup caller */ + + return; + } + return; /* unexpected IORD notification */ + } else { + device_printf(sc->sc_dev, "unknown notification %x\n", + le16toh(cmd->code)); + } +} + +static __inline uint8_t +zyd_plcp2ieee(int signal, int isofdm) +{ + if (isofdm) { + static const uint8_t ofdmrates[16] = + { 0, 0, 0, 0, 0, 0, 0, 96, 48, 24, 12, 108, 72, 36, 18 }; + return ofdmrates[signal & 0xf]; + } else { + static const uint8_t cckrates[16] = + { 0, 0, 0, 0, 4, 0, 0, 11, 0, 0, 2, 0, 0, 0, 22, 0 }; + return cckrates[signal & 0xf]; + } +} + +static void +zyd_rx_data(struct zyd_softc *sc, const uint8_t *buf, uint16_t len) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = sc->sc_ifp; + struct ieee80211_node *ni; + const struct zyd_plcphdr *plcp; + const struct zyd_rx_stat *stat; + struct mbuf *m; + int rlen; + + if (len < ZYD_MIN_FRAGSZ) { + DPRINTF(("%s: frame too short (length=%d)\n", + device_get_nameunit(sc->sc_dev), len)); + ifp->if_ierrors++; + return; + } + + plcp = (const struct zyd_plcphdr *)buf; + stat = (const struct zyd_rx_stat *) + (buf + len - sizeof(struct zyd_rx_stat)); + + if (stat->flags & ZYD_RX_ERROR) { + DPRINTF(("%s: RX status indicated error (%x)\n", + device_get_nameunit(sc->sc_dev), stat->flags)); + ifp->if_ierrors++; + return; + } + + /* compute actual frame length */ + rlen = len - sizeof(struct zyd_plcphdr) - + sizeof(struct zyd_rx_stat) - IEEE80211_CRC_LEN; + + /* allocate a mbuf to store the frame */ + if (rlen > MHLEN) + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + else + m = m_gethdr(M_DONTWAIT, MT_DATA); + if (m == NULL) { + DPRINTF(("%s: could not allocate rx mbuf\n", + device_get_nameunit(sc->sc_dev))); + ifp->if_ierrors++; + return; + } + m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.len = m->m_len = rlen; + bcopy((const uint8_t *)(plcp + 1), mtod(m, uint8_t *), rlen); + + if (bpf_peers_present(sc->sc_drvbpf)) { + struct zyd_rx_radiotap_header *tap = &sc->sc_rxtap; + + tap->wr_flags = 0; + if (stat->flags & (ZYD_RX_BADCRC32|ZYD_RX_BADCRC32)) + tap->wr_flags |= IEEE80211_RADIOTAP_F_BADFCS; + /* XXX toss, no way to express errors */ + if (stat->flags & ZYD_RX_DECRYPTERR) + tap->wr_flags |= IEEE80211_RADIOTAP_F_BADFCS; + tap->wr_rate = + zyd_plcp2ieee(plcp->signal, stat->flags & ZYD_RX_OFDM); + tap->wr_antsignal = stat->rssi + -95; + tap->wr_antnoise = -95; /* XXX */ + + bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m); + } + + ni = ieee80211_find_rxnode(ic, mtod(m, struct ieee80211_frame_min *)); + ieee80211_input(ic, m, ni, + stat->rssi > 63 ? 127 : 2 * stat->rssi, -95/*XXX*/, 0); + + /* node is no longer needed */ + ieee80211_free_node(ni); +} + +static void +zyd_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) +{ + struct zyd_rx_data *data = priv; + struct zyd_softc *sc = data->sc; + struct ifnet *ifp = sc->sc_ifp; + const struct zyd_rx_desc *desc; + int len; + + if (status != USBD_NORMAL_COMPLETION) { + if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) + return; + + if (status == USBD_STALLED) + usbd_clear_endpoint_stall(sc->zyd_ep[ZYD_ENDPT_BIN]); + + goto skip; + } + usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL); + + if (len < ZYD_MIN_RXBUFSZ) { + DPRINTFN(3, ("%s: xfer too short (length=%d)\n", + device_get_nameunit(sc->sc_dev), len)); + ifp->if_ierrors++; /* XXX not really errors */ + goto skip; + } + + desc = (const struct zyd_rx_desc *) + (data->buf + len - sizeof(struct zyd_rx_desc)); + + if (UGETW(desc->tag) == ZYD_TAG_MULTIFRAME) { + const uint8_t *p = data->buf, *end = p + len; + int i; + + DPRINTFN(3, ("received multi-frame transfer\n")); + + for (i = 0; i < ZYD_MAX_RXFRAMECNT; i++) { + const uint16_t len16 = UGETW(desc->len[i]); + + if (len16 == 0 || p + len16 > end) + break; + + zyd_rx_data(sc, p, len16); + /* next frame is aligned on a 32-bit boundary */ + p += (len16 + 3) & ~3; + } + } else { + DPRINTFN(3, ("received single-frame transfer\n")); + + zyd_rx_data(sc, data->buf, len); + } + +skip: /* setup a new transfer */ + usbd_setup_xfer(xfer, sc->zyd_ep[ZYD_ENDPT_BIN], data, NULL, + ZYX_MAX_RXBUFSZ, USBD_NO_COPY | USBD_SHORT_XFER_OK, + USBD_NO_TIMEOUT, zyd_rxeof); + (void)usbd_transfer(xfer); +} + +static int +zyd_tx_mgt(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = sc->sc_ifp; + struct zyd_tx_desc *desc; + struct zyd_tx_data *data; + struct ieee80211_frame *wh; + int xferlen, totlen, rate; + uint16_t pktlen; + usbd_status error; + + data = &sc->tx_data[0]; + desc = (struct zyd_tx_desc *)data->buf; + + rate = IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan) ? 12 : 2; + + data->ni = ni; + data->m = m0; + + wh = mtod(m0, struct ieee80211_frame *); + + xferlen = sizeof(struct zyd_tx_desc) + m0->m_pkthdr.len; + totlen = m0->m_pkthdr.len + IEEE80211_CRC_LEN; + + /* fill Tx descriptor */ + desc->len = htole16(totlen); + + desc->flags = ZYD_TX_FLAG_BACKOFF; + if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { + /* multicast frames are not sent at OFDM rates in 802.11b/g */ + if (totlen > ic->ic_rtsthreshold) { + desc->flags |= ZYD_TX_FLAG_RTS; + } else if (ZYD_RATE_IS_OFDM(rate) && + (ic->ic_flags & IEEE80211_F_USEPROT)) { + if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) + desc->flags |= ZYD_TX_FLAG_CTS_TO_SELF; + else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) + desc->flags |= ZYD_TX_FLAG_RTS; + } + } else + desc->flags |= ZYD_TX_FLAG_MULTICAST; + + if ((wh->i_fc[0] & + (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == + (IEEE80211_FC0_TYPE_CTL | IEEE80211_FC0_SUBTYPE_PS_POLL)) + desc->flags |= ZYD_TX_FLAG_TYPE(ZYD_TX_TYPE_PS_POLL); + + desc->phy = zyd_plcp_signal(rate); + if (ZYD_RATE_IS_OFDM(rate)) { + desc->phy |= ZYD_TX_PHY_OFDM; + if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) + desc->phy |= ZYD_TX_PHY_5GHZ; + } else if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) + desc->phy |= ZYD_TX_PHY_SHPREAMBLE; + + /* actual transmit length (XXX why +10?) */ + pktlen = sizeof(struct zyd_tx_desc) + 10; + if (sc->mac_rev == ZYD_ZD1211) + pktlen += totlen; + desc->pktlen = htole16(pktlen); + + desc->plcp_length = (16 * totlen + rate - 1) / rate; + desc->plcp_service = 0; + if (rate == 22) { + const int remainder = (16 * totlen) % 22; + if (remainder != 0 && remainder < 7) + desc->plcp_service |= ZYD_PLCP_LENGEXT; + } + + if (bpf_peers_present(sc->sc_drvbpf)) { + struct zyd_tx_radiotap_header *tap = &sc->sc_txtap; + + tap->wt_flags = 0; + tap->wt_rate = rate; + + bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m0); + } + + m_copydata(m0, 0, m0->m_pkthdr.len, + data->buf + sizeof(struct zyd_tx_desc)); + + DPRINTFN(10, ("%s: sending mgt frame len=%zu rate=%u xferlen=%u\n", + device_get_nameunit(sc->sc_dev), (size_t)m0->m_pkthdr.len, + rate, xferlen)); + + usbd_setup_xfer(data->xfer, sc->zyd_ep[ZYD_ENDPT_BOUT], data, + data->buf, xferlen, USBD_FORCE_SHORT_XFER | USBD_NO_COPY, + ZYD_TX_TIMEOUT, zyd_txeof); + error = usbd_transfer(data->xfer); + if (error != USBD_IN_PROGRESS && error != 0) { + ifp->if_oerrors++; + return EIO; + } + sc->tx_queued++; + + return 0; +} + +static void +zyd_txeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) +{ + struct zyd_tx_data *data = priv; + struct zyd_softc *sc = data->sc; + struct ifnet *ifp = sc->sc_ifp; + struct ieee80211_node *ni; + struct mbuf *m; + + if (status != USBD_NORMAL_COMPLETION) { + if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) + return; + + device_printf(sc->sc_dev, "could not transmit buffer: %s\n", + usbd_errstr(status)); + + if (status == USBD_STALLED) { + usbd_clear_endpoint_stall_async( + sc->zyd_ep[ZYD_ENDPT_BOUT]); + } + ifp->if_oerrors++; + return; + } + + ni = data->ni; + /* update rate control statistics */ + ((struct zyd_node *)ni)->amn.amn_txcnt++; + + /* + * Do any tx complete callback. Note this must + * be done before releasing the node reference. + */ + m = data->m; + if (m != NULL && m->m_flags & M_TXCB) { + ieee80211_process_callback(ni, m, 0); /* XXX status? */ + m_freem(m); + data->m = NULL; + } + + ieee80211_free_node(ni); + data->ni = NULL; + + sc->tx_queued--; + ifp->if_opackets++; + + sc->tx_timer = 0; + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + zyd_start(ifp); +} + +static int +zyd_tx_data(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) +{ + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = sc->sc_ifp; + struct zyd_tx_desc *desc; + struct zyd_tx_data *data; + struct ieee80211_frame *wh; + struct ieee80211_key *k; + int xferlen, totlen, rate; + uint16_t pktlen; + usbd_status error; + + wh = mtod(m0, struct ieee80211_frame *); + data = &sc->tx_data[0]; + desc = (struct zyd_tx_desc *)data->buf; + + desc->flags = ZYD_TX_FLAG_BACKOFF; + if (IEEE80211_IS_MULTICAST(wh->i_addr1)) { + rate = ic->ic_mcast_rate; + desc->flags |= ZYD_TX_FLAG_MULTICAST; + } else if (ic->ic_fixed_rate != IEEE80211_FIXED_RATE_NONE) + rate = ic->ic_bss->ni_rates.rs_rates[ic->ic_fixed_rate]; + else + rate = ni->ni_rates.rs_rates[ni->ni_txrate]; + rate &= IEEE80211_RATE_VAL; + + if (wh->i_fc[1] & IEEE80211_FC1_WEP) { + k = ieee80211_crypto_encap(ic, ni, m0); + if (k == NULL) { + m_freem(m0); + return ENOBUFS; + } + + /* packet header may have moved, reset our local pointer */ + wh = mtod(m0, struct ieee80211_frame *); + } + + data->ni = ni; + data->m = NULL; + + xferlen = sizeof(struct zyd_tx_desc) + m0->m_pkthdr.len; + totlen = m0->m_pkthdr.len + IEEE80211_CRC_LEN; + + /* fill Tx descriptor */ + desc->len = htole16(totlen); + + if (!IEEE80211_IS_MULTICAST(wh->i_addr1)) { + /* multicast frames are not sent at OFDM rates in 802.11b/g */ + if (totlen > ic->ic_rtsthreshold) { + desc->flags |= ZYD_TX_FLAG_RTS; + } else if (ZYD_RATE_IS_OFDM(rate) && + (ic->ic_flags & IEEE80211_F_USEPROT)) { + if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) + desc->flags |= ZYD_TX_FLAG_CTS_TO_SELF; + else if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) + desc->flags |= ZYD_TX_FLAG_RTS; + } + } + + if ((wh->i_fc[0] & + (IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK)) == + (IEEE80211_FC0_TYPE_CTL | IEEE80211_FC0_SUBTYPE_PS_POLL)) + desc->flags |= ZYD_TX_FLAG_TYPE(ZYD_TX_TYPE_PS_POLL); + + desc->phy = zyd_plcp_signal(rate); + if (ZYD_RATE_IS_OFDM(rate)) { + desc->phy |= ZYD_TX_PHY_OFDM; + if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) + desc->phy |= ZYD_TX_PHY_5GHZ; + } else if (rate != 2 && (ic->ic_flags & IEEE80211_F_SHPREAMBLE)) + desc->phy |= ZYD_TX_PHY_SHPREAMBLE; + + /* actual transmit length (XXX why +10?) */ + pktlen = sizeof(struct zyd_tx_desc) + 10; + if (sc->mac_rev == ZYD_ZD1211) + pktlen += totlen; + desc->pktlen = htole16(pktlen); + + desc->plcp_length = (16 * totlen + rate - 1) / rate; + desc->plcp_service = 0; + if (rate == 22) { + const int remainder = (16 * totlen) % 22; + if (remainder != 0 && remainder < 7) + desc->plcp_service |= ZYD_PLCP_LENGEXT; + } + + if (bpf_peers_present(sc->sc_drvbpf)) { + struct zyd_tx_radiotap_header *tap = &sc->sc_txtap; + + tap->wt_flags = 0; + tap->wt_rate = rate; + tap->wt_chan_freq = htole16(ic->ic_curchan->ic_freq); + tap->wt_chan_flags = htole16(ic->ic_curchan->ic_flags); + + bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m0); + } + + m_copydata(m0, 0, m0->m_pkthdr.len, + data->buf + sizeof(struct zyd_tx_desc)); + + DPRINTFN(10, ("%s: sending data frame len=%zu rate=%u xferlen=%u\n", + device_get_nameunit(sc->sc_dev), (size_t)m0->m_pkthdr.len, + rate, xferlen)); + + m_freem(m0); /* mbuf no longer needed */ + + usbd_setup_xfer(data->xfer, sc->zyd_ep[ZYD_ENDPT_BOUT], data, + data->buf, xferlen, USBD_FORCE_SHORT_XFER | USBD_NO_COPY, + ZYD_TX_TIMEOUT, zyd_txeof); + error = usbd_transfer(data->xfer); + if (error != USBD_IN_PROGRESS && error != 0) { + ifp->if_oerrors++; + return EIO; + } + sc->tx_queued++; + + return 0; +} + +static void +zyd_start(struct ifnet *ifp) +{ + struct zyd_softc *sc = ifp->if_softc; + struct ieee80211com *ic = &sc->sc_ic; + struct ether_header *eh; + struct ieee80211_node *ni; + struct mbuf *m0; + + for (;;) { + IF_POLL(&ic->ic_mgtq, m0); + if (m0 != NULL) { + if (sc->tx_queued >= ZYD_TX_LIST_CNT) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + break; + } + IF_DEQUEUE(&ic->ic_mgtq, m0); + + ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; + m0->m_pkthdr.rcvif = NULL; + if (bpf_peers_present(ic->ic_rawbpf)) + bpf_mtap(ic->ic_rawbpf, m0); + if (zyd_tx_mgt(sc, m0, ni) != 0) + break; + } else { + if (ic->ic_state != IEEE80211_S_RUN) + break; + IFQ_POLL(&ifp->if_snd, m0); + if (m0 == NULL) + break; + if (sc->tx_queued >= ZYD_TX_LIST_CNT) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + break; + } + IFQ_DEQUEUE(&ifp->if_snd, m0); + + if (m0->m_len < sizeof(struct ether_header) && + !(m0 = m_pullup(m0, sizeof(struct ether_header)))) + continue; + + eh = mtod(m0, struct ether_header *); + ni = ieee80211_find_txnode(ic, eh->ether_dhost); + if (ni == NULL) { + m_freem(m0); + continue; + } + if (bpf_peers_present(ifp->if_bpf)) + bpf_mtap(ifp->if_bpf, m0); + if ((m0 = ieee80211_encap(ic, m0, ni)) == NULL) { + ieee80211_free_node(ni); + ifp->if_oerrors++; + continue; + } + if (bpf_peers_present(ic->ic_rawbpf)) + bpf_mtap(ic->ic_rawbpf, m0); + if (zyd_tx_data(sc, m0, ni) != 0) { + ieee80211_free_node(ni); + ifp->if_oerrors++; + break; + } + } + + sc->tx_timer = 5; + callout_reset(&sc->sc_watchdog_ch, hz, zyd_watchdog, sc); + } +} + +static void +zyd_watchdog(void *arg) +{ + struct zyd_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = ic->ic_ifp; + + if (sc->tx_timer > 0) { + if (--sc->tx_timer == 0) { + device_printf(sc->sc_dev, "device timeout\n"); + /* zyd_init(ifp); XXX needs a process context ? */ + ifp->if_oerrors++; + return; + } + callout_reset(&sc->sc_watchdog_ch, hz, zyd_watchdog, sc); + } +} + +static int +zyd_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +{ + struct zyd_softc *sc = ifp->if_softc; + struct ieee80211com *ic = &sc->sc_ic; + int error = 0; + + ZYD_LOCK(sc); + + switch (cmd) { + case SIOCSIFFLAGS: + if (ifp->if_flags & IFF_UP) { + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) + zyd_init(sc); + } else { + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + zyd_stop(sc, 1); + } + break; + + default: + error = ieee80211_ioctl(ic, cmd, data); + } + + if (error == ENETRESET) { + if ((ifp->if_flags & IFF_UP) == IFF_UP && + (ifp->if_drv_flags & IFF_DRV_RUNNING) == IFF_DRV_RUNNING) + zyd_init(sc); + error = 0; + } + + ZYD_UNLOCK(sc); + + return error; +} + +static void +zyd_init(void *priv) +{ + struct zyd_softc *sc = priv; + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = ic->ic_ifp; + int i, error; + + zyd_stop(sc, 0); + + IEEE80211_ADDR_COPY(ic->ic_myaddr, IF_LLADDR(ifp)); + DPRINTF(("setting MAC address to %s\n", ether_sprintf(ic->ic_myaddr))); + error = zyd_set_macaddr(sc, ic->ic_myaddr); + if (error != 0) + return; + + /* we'll do software WEP decryption for now */ + DPRINTF(("setting encryption type\n")); + error = zyd_write32(sc, ZYD_MAC_ENCRYPTION_TYPE, ZYD_ENC_SNIFFER); + if (error != 0) + return; + + /* promiscuous mode */ + (void)zyd_write32(sc, ZYD_MAC_SNIFFER, + (ic->ic_opmode == IEEE80211_M_MONITOR) ? 1 : 0); + + (void)zyd_set_rxfilter(sc); + + /* switch radio transmitter ON */ + (void)zyd_switch_radio(sc, 1); + + /* XXX wrong, can't set here */ + /* set basic rates */ + if (ic->ic_curmode == IEEE80211_MODE_11B) + (void)zyd_write32(sc, ZYD_MAC_BAS_RATE, 0x0003); + else if (ic->ic_curmode == IEEE80211_MODE_11A) + (void)zyd_write32(sc, ZYD_MAC_BAS_RATE, 0x1500); + else /* assumes 802.11b/g */ + (void)zyd_write32(sc, ZYD_MAC_BAS_RATE, 0x000f); + + /* set mandatory rates */ + if (ic->ic_curmode == IEEE80211_MODE_11B) + (void)zyd_write32(sc, ZYD_MAC_MAN_RATE, 0x000f); + else if (ic->ic_curmode == IEEE80211_MODE_11A) + (void)zyd_write32(sc, ZYD_MAC_MAN_RATE, 0x1500); + else /* assumes 802.11b/g */ + (void)zyd_write32(sc, ZYD_MAC_MAN_RATE, 0x150f); + + /* set default BSS channel */ + zyd_set_chan(sc, ic->ic_curchan); + + /* enable interrupts */ + (void)zyd_write32(sc, ZYD_CR_INTERRUPT, ZYD_HWINT_MASK); + + /* + * Allocate Tx and Rx xfer queues. + */ + if ((error = zyd_alloc_tx_list(sc)) != 0) { + device_printf(sc->sc_dev, "could not allocate Tx list\n"); + goto fail; + } + if ((error = zyd_alloc_rx_list(sc)) != 0) { + device_printf(sc->sc_dev, "could not allocate Rx list\n"); + goto fail; + } + + /* + * Start up the receive pipe. + */ + for (i = 0; i < ZYD_RX_LIST_CNT; i++) { + struct zyd_rx_data *data = &sc->rx_data[i]; + + usbd_setup_xfer(data->xfer, sc->zyd_ep[ZYD_ENDPT_BIN], data, + NULL, ZYX_MAX_RXBUFSZ, USBD_NO_COPY | USBD_SHORT_XFER_OK, + USBD_NO_TIMEOUT, zyd_rxeof); + error = usbd_transfer(data->xfer); + if (error != USBD_IN_PROGRESS && error != 0) { + device_printf(sc->sc_dev, + "could not queue Rx transfer\n"); + goto fail; + } + } + + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + ifp->if_drv_flags |= IFF_DRV_RUNNING; + + if (ic->ic_opmode != IEEE80211_M_MONITOR) { + if (ic->ic_roaming != IEEE80211_ROAMING_MANUAL) + ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); + } else + ieee80211_new_state(ic, IEEE80211_S_RUN, -1); + + return; + +fail: zyd_stop(sc, 1); + return; +} + +static void +zyd_stop(struct zyd_softc *sc, int disable) +{ + struct ifnet *ifp = sc->sc_ifp; + struct ieee80211com *ic = &sc->sc_ic; + + ieee80211_new_state(ic, IEEE80211_S_INIT, -1); /* free all nodes */ + + sc->tx_timer = 0; + ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); + + /* switch radio transmitter OFF */ + (void)zyd_switch_radio(sc, 0); + + /* disable Rx */ + (void)zyd_write32(sc, ZYD_MAC_RXFILTER, 0); + + /* disable interrupts */ + (void)zyd_write32(sc, ZYD_CR_INTERRUPT, 0); + + usbd_abort_pipe(sc->zyd_ep[ZYD_ENDPT_BIN]); + usbd_abort_pipe(sc->zyd_ep[ZYD_ENDPT_BOUT]); + + zyd_free_rx_list(sc); + zyd_free_tx_list(sc); +} + +static int +zyd_loadfirmware(struct zyd_softc *sc, u_char *fw, size_t size) +{ + usb_device_request_t req; + uint16_t addr; + uint8_t stat; + + DPRINTF(("firmware size=%zu\n", size)); + + req.bmRequestType = UT_WRITE_VENDOR_DEVICE; + req.bRequest = ZYD_DOWNLOADREQ; + USETW(req.wIndex, 0); + + addr = ZYD_FIRMWARE_START_ADDR; + while (size > 0) { +#if 0 + const int mlen = min(size, 4096); +#else + /* + * XXXX: When the transfer size is 4096 bytes, it is not + * likely to be able to transfer it. + * The cause is port or machine or chip? + */ + const int mlen = min(size, 64); +#endif + + DPRINTF(("loading firmware block: len=%d, addr=0x%x\n", mlen, + addr)); + + USETW(req.wValue, addr); + USETW(req.wLength, mlen); + if (usbd_do_request(sc->sc_udev, &req, fw) != 0) + return EIO; + + addr += mlen / 2; + fw += mlen; + size -= mlen; + } + + /* check whether the upload succeeded */ + req.bmRequestType = UT_READ_VENDOR_DEVICE; + req.bRequest = ZYD_DOWNLOADSTS; + USETW(req.wValue, 0); + USETW(req.wIndex, 0); + USETW(req.wLength, sizeof(stat)); + if (usbd_do_request(sc->sc_udev, &req, &stat) != 0) + return EIO; + + return (stat & 0x80) ? EIO : 0; +} + +static void +zyd_iter_func(void *arg, struct ieee80211_node *ni) +{ + struct zyd_softc *sc = arg; + struct zyd_node *zn = (struct zyd_node *)ni; + + ieee80211_amrr_choose(&sc->amrr, ni, &zn->amn); +} + +static void +zyd_amrr_timeout(void *arg) +{ + struct zyd_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + + ZYD_LOCK(sc); + if (ic->ic_opmode == IEEE80211_M_STA) + zyd_iter_func(sc, ic->ic_bss); + else + ieee80211_iterate_nodes(&ic->ic_sta, zyd_iter_func, sc); + ZYD_UNLOCK(sc); + + callout_reset(&sc->sc_amrr_ch, hz, zyd_amrr_timeout, sc); +} + +static void +zyd_newassoc(struct ieee80211_node *ni, int isnew) +{ + struct zyd_softc *sc = ni->ni_ic->ic_ifp->if_softc; + int i; + + ieee80211_amrr_node_init(&sc->amrr, &((struct zyd_node *)ni)->amn); + + /* set rate to some reasonable initial value */ + for (i = ni->ni_rates.rs_nrates - 1; + i > 0 && (ni->ni_rates.rs_rates[i] & IEEE80211_RATE_VAL) > 72; + i--); + ni->ni_txrate = i; +} + +static void +zyd_scan_start(struct ieee80211com *ic) +{ + struct zyd_softc *sc = ic->ic_ifp->if_softc; + + usb_rem_task(sc->sc_udev, &sc->sc_scantask); + + /* do it in a process context */ + sc->sc_scan_action = ZYD_SCAN_START; + usb_add_task(sc->sc_udev, &sc->sc_scantask, USB_TASKQ_DRIVER); +} + +static void +zyd_scan_end(struct ieee80211com *ic) +{ + struct zyd_softc *sc = ic->ic_ifp->if_softc; + + usb_rem_task(sc->sc_udev, &sc->sc_scantask); + + /* do it in a process context */ + sc->sc_scan_action = ZYD_SCAN_END; + usb_add_task(sc->sc_udev, &sc->sc_scantask, USB_TASKQ_DRIVER); +} + +static void +zyd_set_channel(struct ieee80211com *ic) +{ + struct zyd_softc *sc = ic->ic_ifp->if_softc; + + usb_rem_task(sc->sc_udev, &sc->sc_scantask); + + /* do it in a process context */ + sc->sc_scan_action = ZYD_SET_CHANNEL; + usb_add_task(sc->sc_udev, &sc->sc_scantask, USB_TASKQ_DRIVER); +} + +static void +zyd_scantask(void *arg) +{ + struct zyd_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = ic->ic_ifp; + + ZYD_LOCK(sc); + + switch (sc->sc_scan_action) { + case ZYD_SCAN_START: + zyd_set_bssid(sc, ifp->if_broadcastaddr); + break; + + case ZYD_SCAN_END: + zyd_set_bssid(sc, ic->ic_bss->ni_bssid); + break; + + case ZYD_SET_CHANNEL: + mtx_lock(&Giant); + zyd_set_chan(sc, ic->ic_curchan); + mtx_unlock(&Giant); + break; + + default: + device_printf(sc->sc_dev, "unknown scan action %d\n", + sc->sc_scan_action); + break; + } + + ZYD_UNLOCK(sc); +} + +static device_method_t zyd_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, zyd_match), + DEVMETHOD(device_attach, zyd_attach), + DEVMETHOD(device_detach, zyd_detach), + + { 0, 0 } +}; + +static driver_t zyd_driver = { + "zyd", + zyd_methods, + sizeof(struct zyd_softc) +}; + +static devclass_t zyd_devclass; + +DRIVER_MODULE(zyd, uhub, zyd_driver, zyd_devclass, usbd_driver_load, 0); +MODULE_DEPEND(rum, wlan, 1, 1, 1); +MODULE_DEPEND(rum, wlan_amrr, 1, 1, 1); +MODULE_DEPEND(rum, usb, 1, 1, 1); diff --git a/sys/dev/usb/if_zydfw.h b/sys/dev/usb/if_zydfw.h new file mode 100644 index 0000000..5c05686 --- /dev/null +++ b/sys/dev/usb/if_zydfw.h @@ -0,0 +1,1185 @@ +/* + * Copyright (C) 2001, 2002, 2003,2004 ZyDAS Technology Corporation. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted provided + * that the following conditions are met: + * 1. Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistribution 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * 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$ */ + +uint8_t zd1211_firmware[] = { + 0x08, 0x91, 0xFF, 0xED, 0x09, 0x93, 0x1E, 0xEE, + 0xD1, 0x94, 0x11, 0xEE, 0x88, 0xD4, 0xD1, 0x96, + 0xD1, 0x98, 0x5C, 0x99, 0x5C, 0x99, 0x4C, 0x99, + 0x04, 0x9D, 0xD1, 0x98, 0xD1, 0x9A, 0x03, 0xEE, + 0xF4, 0x94, 0xD3, 0xD4, 0x41, 0x2A, 0x40, 0x4A, + 0x45, 0xBE, 0x88, 0x92, 0x41, 0x24, 0x40, 0x44, + 0x53, 0xBE, 0x40, 0xF0, 0x93, 0xEE, 0x41, 0xEE, + 0x98, 0x9A, 0xD4, 0xF7, 0x02, 0x00, 0x1F, 0xEC, + 0x00, 0x00, 0xB2, 0xF8, 0x4D, 0x00, 0xA1, 0xEC, + 0x00, 0x00, 0xA6, 0xF7, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xD8, + 0xA0, 0x90, 0x98, 0x9A, 0x98, 0x9A, 0xA0, 0xD8, + 0x40, 0xF0, 0xB4, 0xF0, 0xA0, 0x90, 0x98, 0x9A, + 0xA0, 0xD8, 0x40, 0xF0, 0x64, 0xEF, 0xA0, 0x90, + 0x98, 0x9A, 0xA0, 0xD8, 0x40, 0xF0, 0xF6, 0xF0, + 0xA0, 0x90, 0x98, 0x9A, 0xA0, 0xD8, 0x40, 0xF0, + 0xF7, 0xF6, 0xA0, 0x90, 0x98, 0x9A, 0xA0, 0xD8, + 0x40, 0xF0, 0xF8, 0xF5, 0xA0, 0x90, 0x98, 0x9A, + 0xA0, 0xD8, 0x40, 0xF0, 0xF1, 0xF0, 0xA0, 0x90, + 0x98, 0x9A, 0x98, 0x9A, 0xA0, 0xD8, 0x40, 0xF0, + 0x97, 0xF7, 0xA0, 0x90, 0x98, 0x9A, 0x88, 0xDA, + 0x08, 0x0B, 0x01, 0x00, 0x0D, 0x03, 0x03, 0x00, + 0x09, 0x05, 0x01, 0x00, 0xC2, 0x94, 0x42, 0x02, + 0xC1, 0x92, 0x03, 0x96, 0x1B, 0xD7, 0x2A, 0x86, + 0x1A, 0xD5, 0x2B, 0x86, 0x09, 0xA3, 0x00, 0x80, + 0x19, 0xD3, 0x2C, 0x86, 0x00, 0xEE, 0x0A, 0x65, + 0xC0, 0x7A, 0x02, 0x97, 0xC3, 0x92, 0x09, 0xB3, + 0xFE, 0xFF, 0xC2, 0xD2, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x42, 0x20, 0x08, 0x0B, 0x01, 0x00, + 0x0D, 0x03, 0x05, 0x00, 0x05, 0x94, 0xC5, 0xD4, + 0x09, 0x05, 0x01, 0x00, 0xC2, 0x94, 0x01, 0xD4, + 0x42, 0x02, 0xC1, 0x96, 0x0A, 0x65, 0xC0, 0x7A, + 0x02, 0x99, 0xC4, 0x92, 0x41, 0xA2, 0xC4, 0xD2, + 0xC5, 0x98, 0x1C, 0xD9, 0x2A, 0x86, 0x01, 0x98, + 0x1C, 0xD9, 0x2B, 0x86, 0x1B, 0xD7, 0x2C, 0x86, + 0x00, 0xEE, 0x09, 0xB3, 0xFE, 0xFF, 0xC2, 0xD2, + 0x42, 0x00, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x41, 0x20, 0x08, 0x0B, 0x01, 0x00, 0x40, 0xF0, + 0xE5, 0xEE, 0x11, 0x93, 0xD8, 0xF7, 0x41, 0x42, + 0x02, 0x5E, 0x0F, 0x9F, 0xAE, 0xEE, 0x40, 0xF1, + 0x40, 0x92, 0x19, 0xD3, 0xD8, 0xF7, 0xC5, 0x92, + 0x41, 0x92, 0x19, 0xD3, 0x00, 0x83, 0x40, 0x92, + 0x19, 0xD3, 0x00, 0x83, 0x0F, 0x9F, 0x95, 0xF8, + 0x0F, 0x9F, 0x99, 0xEE, 0x42, 0x42, 0x02, 0x5E, + 0x0F, 0x9F, 0x99, 0xEE, 0x40, 0x92, 0x19, 0xD3, + 0xD8, 0xF7, 0x09, 0x93, 0xC7, 0xF7, 0x19, 0xD3, + 0x91, 0xEC, 0x40, 0xF0, 0x5F, 0xF2, 0x09, 0x63, + 0x00, 0x80, 0x19, 0xD3, 0xF2, 0xBD, 0x0F, 0x9F, + 0x99, 0xEE, 0x41, 0x00, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x40, 0x92, + 0x19, 0xD3, 0x12, 0x95, 0x19, 0xD3, 0x10, 0x95, + 0x19, 0xD3, 0x02, 0x80, 0x19, 0xD3, 0x03, 0x82, + 0x09, 0x93, 0xC7, 0xF7, 0x19, 0xD3, 0x91, 0xEC, + 0x40, 0xF0, 0x5F, 0xF2, 0x40, 0xF0, 0xDE, 0xF3, + 0x11, 0x93, 0x04, 0xEC, 0x42, 0x42, 0x02, 0x5E, + 0x0F, 0x9F, 0xE3, 0xEE, 0x40, 0x92, 0x19, 0xD3, + 0x04, 0xEC, 0x40, 0xF0, 0x38, 0xF2, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, + 0x11, 0x93, 0x44, 0x96, 0x09, 0xB3, 0xFF, 0xFD, + 0x19, 0xD3, 0x44, 0x96, 0x40, 0xF0, 0x90, 0xF7, + 0x6E, 0x92, 0x19, 0xD3, 0x05, 0x84, 0x40, 0xF0, + 0xC4, 0xEE, 0x4B, 0x62, 0x0A, 0x95, 0x2E, 0xEE, + 0xD1, 0xD4, 0x0B, 0x97, 0x2B, 0xEE, 0xD1, 0xD6, + 0x0A, 0x95, 0x00, 0xEE, 0xD1, 0xD4, 0x0B, 0x97, + 0x2F, 0xEE, 0xD1, 0xD6, 0x0A, 0x95, 0x34, 0xEE, + 0xD1, 0xD4, 0x0B, 0x97, 0x39, 0xEE, 0xD1, 0xD6, + 0x0A, 0x95, 0x3E, 0xEE, 0xD1, 0xD4, 0x0B, 0x97, + 0x43, 0xEE, 0xD1, 0xD6, 0x0A, 0x95, 0x48, 0xEE, + 0xD1, 0xD4, 0x0B, 0x97, 0x4D, 0xEE, 0xD1, 0xD6, + 0x0A, 0x95, 0x4E, 0xEE, 0xC1, 0xD4, 0x0A, 0x65, + 0x00, 0x44, 0x02, 0x97, 0xC3, 0x92, 0x44, 0xA2, + 0xC2, 0xD2, 0x43, 0xF1, 0x09, 0x93, 0x01, 0x3F, + 0x19, 0xD3, 0xC0, 0x85, 0x11, 0x93, 0x44, 0x96, + 0x09, 0xB3, 0xFF, 0xFC, 0x19, 0xD3, 0x44, 0x96, + 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, + 0x01, 0x00, 0x0D, 0x03, 0x03, 0x00, 0x03, 0x96, + 0x41, 0x02, 0x03, 0x99, 0xC4, 0x94, 0x42, 0x04, + 0xC1, 0x04, 0xC2, 0x94, 0xC3, 0xD4, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, + 0x40, 0x92, 0x19, 0xD3, 0x94, 0xEC, 0x13, 0x97, + 0x95, 0xEC, 0x1B, 0xD7, 0x02, 0x80, 0x11, 0x93, + 0x99, 0xEC, 0x19, 0xD3, 0x7C, 0x96, 0x0B, 0x97, + 0xA0, 0x00, 0x1B, 0xD7, 0x6E, 0xEC, 0x0A, 0x65, + 0x0E, 0x42, 0x02, 0x97, 0xC3, 0x92, 0x09, 0xB3, + 0xFF, 0xBF, 0x11, 0xA3, 0x9A, 0xEC, 0xC2, 0xD2, + 0x0A, 0x65, 0xEB, 0x43, 0x02, 0x97, 0xC3, 0x92, + 0x09, 0xA3, 0xC0, 0x00, 0xC2, 0xD2, 0x0A, 0x65, + 0xE9, 0x43, 0x02, 0x97, 0xC3, 0x92, 0x09, 0xB3, + 0xBF, 0xFF, 0xC2, 0xD2, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x47, 0x20, 0x08, 0x0B, 0x01, 0x00, + 0x14, 0x99, 0x03, 0x80, 0x0C, 0xB3, 0x00, 0x10, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x97, 0xF0, + 0x11, 0x93, 0x9F, 0xEC, 0x41, 0x02, 0x19, 0xD3, + 0x9F, 0xEC, 0x11, 0x93, 0xD6, 0xF7, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0x84, 0xEF, 0x0A, 0x65, + 0xFE, 0x7F, 0x02, 0x97, 0xC3, 0x92, 0x09, 0xA3, + 0x00, 0x04, 0xC2, 0xD2, 0x0F, 0x9F, 0xB1, 0xF0, + 0x11, 0x93, 0x94, 0xEC, 0x02, 0xD2, 0x40, 0x42, + 0x02, 0x5E, 0x0F, 0x9F, 0xD0, 0xEF, 0x41, 0x92, + 0x19, 0xD3, 0x94, 0xEC, 0x19, 0xD3, 0x9F, 0xEC, + 0x12, 0x95, 0x02, 0x80, 0x1A, 0xD5, 0x95, 0xEC, + 0x13, 0x97, 0x7C, 0x96, 0x1B, 0xD7, 0x99, 0xEC, + 0x0A, 0x65, 0x0E, 0x42, 0x02, 0x97, 0xC3, 0x92, + 0x09, 0xB3, 0x00, 0x40, 0x19, 0xD3, 0x9A, 0xEC, + 0x09, 0x63, 0x00, 0x40, 0xC2, 0xD2, 0x02, 0x94, + 0x1A, 0xD5, 0x7C, 0x96, 0x0C, 0xB3, 0x00, 0x08, + 0x40, 0x42, 0x02, 0x5E, 0x0F, 0x9F, 0xB0, 0xEF, + 0x0C, 0xB3, 0xFF, 0x07, 0x0F, 0x9F, 0xB4, 0xEF, + 0x11, 0x93, 0x06, 0x80, 0x09, 0xB3, 0xFF, 0x07, + 0x09, 0x03, 0x00, 0xA0, 0x19, 0xD3, 0x97, 0xEC, + 0x40, 0x98, 0x0B, 0x97, 0x9C, 0xEC, 0x04, 0x95, + 0x03, 0x05, 0x14, 0x03, 0x97, 0xEC, 0x46, 0x02, + 0xC1, 0x92, 0xC2, 0xD2, 0x41, 0x08, 0x42, 0x48, + 0x02, 0x9E, 0x0F, 0x9F, 0xBB, 0xEF, 0x11, 0x93, + 0x97, 0xEC, 0xC1, 0x92, 0xC5, 0xD2, 0x5F, 0xB2, + 0x19, 0xD3, 0x9B, 0xEC, 0x0F, 0x9F, 0xD3, 0xEF, + 0x13, 0x97, 0x98, 0xEC, 0xC5, 0xD6, 0x11, 0x93, + 0x03, 0x80, 0x09, 0xB3, 0x00, 0x08, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0xE9, 0xEF, 0x11, 0x93, + 0xDC, 0xF7, 0x41, 0x02, 0x19, 0xD3, 0xDC, 0xF7, + 0x11, 0x93, 0xDB, 0xF7, 0x09, 0xA3, 0x00, 0x10, + 0x19, 0xD3, 0xDB, 0xF7, 0x40, 0x98, 0x1C, 0xD9, + 0x9B, 0xEC, 0x12, 0x95, 0x9B, 0xEC, 0x40, 0x44, + 0x02, 0x4E, 0x0F, 0x9F, 0x86, 0xF0, 0x0A, 0xB3, + 0x08, 0x00, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0x07, 0xF0, 0x0A, 0xB3, 0x07, 0x00, 0x09, 0x05, + 0xA9, 0xEC, 0xC2, 0x94, 0x01, 0xD4, 0x09, 0x03, + 0xA1, 0xEC, 0xC1, 0x92, 0x19, 0xD3, 0x9B, 0xEC, + 0xC5, 0x94, 0x0A, 0xB5, 0x00, 0xFF, 0x01, 0xA5, + 0xC5, 0xD4, 0x0F, 0x9F, 0x13, 0xF0, 0x0A, 0x05, + 0xFF, 0xFF, 0x0A, 0x03, 0xB1, 0xEC, 0xC1, 0x92, + 0x01, 0xD2, 0x1A, 0xD5, 0x9B, 0xEC, 0xC5, 0x96, + 0x0B, 0x07, 0xFF, 0xFF, 0xC5, 0xD6, 0x11, 0x93, + 0x97, 0xEC, 0xC5, 0x98, 0xC1, 0xD8, 0x11, 0x93, + 0x97, 0xEC, 0x09, 0x05, 0x0B, 0x00, 0x03, 0xD4, + 0xC2, 0x96, 0x06, 0xD6, 0x7B, 0x95, 0x7A, 0x95, + 0x4C, 0x02, 0xC1, 0x92, 0x59, 0x93, 0x59, 0x93, + 0x01, 0xA5, 0x01, 0x98, 0x0C, 0xF5, 0x7B, 0x93, + 0x09, 0x09, 0x01, 0x00, 0x06, 0x92, 0x09, 0xB3, + 0xFF, 0x00, 0x04, 0xD2, 0x5C, 0x93, 0x59, 0x93, + 0x04, 0x94, 0x01, 0xA5, 0x03, 0x96, 0xC3, 0xD4, + 0x11, 0x93, 0x97, 0xEC, 0x4C, 0x02, 0x05, 0xD2, + 0xC1, 0x92, 0x09, 0xB3, 0x00, 0xFF, 0x7C, 0x95, + 0x7A, 0x95, 0x02, 0xA3, 0x05, 0x98, 0xC4, 0xD2, + 0x12, 0x95, 0x97, 0xEC, 0x45, 0x04, 0x02, 0x97, + 0xC3, 0x92, 0x09, 0xA3, 0x00, 0x01, 0xC2, 0xD2, + 0x12, 0x95, 0x9B, 0xEC, 0x0A, 0xB3, 0x08, 0x00, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x5B, 0xF0, + 0x12, 0x95, 0x97, 0xEC, 0x4A, 0x04, 0x02, 0x99, + 0xC4, 0x92, 0x01, 0x98, 0x0C, 0xF3, 0x7B, 0x93, + 0x41, 0x02, 0x0F, 0x9F, 0x7C, 0xF0, 0x43, 0x44, + 0x02, 0x8E, 0x0F, 0x9F, 0x7D, 0xF0, 0x11, 0x93, + 0x97, 0xEC, 0x42, 0x02, 0x0A, 0x05, 0xFF, 0xFF, + 0xC1, 0xD4, 0x11, 0x93, 0x97, 0xEC, 0x4A, 0x02, + 0x12, 0x95, 0x60, 0x96, 0xC1, 0xD4, 0x12, 0x95, + 0x97, 0xEC, 0x4B, 0x04, 0x02, 0x97, 0xC3, 0x92, + 0x09, 0xB3, 0x1F, 0xFF, 0xC2, 0xD2, 0x12, 0x95, + 0x97, 0xEC, 0x4B, 0x04, 0x11, 0x93, 0x62, 0x96, + 0x41, 0x93, 0x59, 0x93, 0x02, 0x99, 0xC4, 0xA2, + 0xC2, 0xD2, 0xC5, 0x92, 0x19, 0xD3, 0x98, 0xEC, + 0x0A, 0x95, 0x0C, 0x02, 0x1A, 0xD5, 0x02, 0x80, + 0x0F, 0x9F, 0xB1, 0xF0, 0x09, 0x63, 0xFE, 0x7F, + 0x01, 0x97, 0xC3, 0x94, 0x0A, 0xA5, 0x00, 0x04, + 0xC1, 0xD4, 0x11, 0x93, 0x9F, 0xEC, 0x09, 0xA3, + 0x00, 0x01, 0x19, 0xD3, 0x9F, 0xEC, 0x40, 0xF0, + 0x39, 0xEF, 0x0F, 0x9F, 0xB1, 0xF0, 0x11, 0x93, + 0x94, 0xEC, 0x41, 0x42, 0x02, 0x5E, 0x0F, 0x9F, + 0xA6, 0xF0, 0x40, 0xF0, 0x39, 0xEF, 0x11, 0x93, + 0x95, 0xEC, 0x44, 0xB2, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0xB1, 0xF0, 0x48, 0x98, 0x1C, 0xD9, + 0x02, 0x80, 0x11, 0x93, 0x91, 0xEC, 0x41, 0x22, + 0x0A, 0x95, 0xB1, 0xF0, 0x88, 0xD4, 0x88, 0xDC, + 0x91, 0x9A, 0x47, 0x00, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x11, 0x93, + 0x04, 0x82, 0x48, 0xB2, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0xC8, 0xF0, 0x0A, 0x65, 0xFD, 0x7D, + 0x02, 0x97, 0xC3, 0x92, 0x09, 0xB3, 0xFF, 0xFE, + 0xC2, 0xD2, 0x41, 0x92, 0x19, 0xD3, 0xBF, 0xEC, + 0x11, 0x93, 0x04, 0x82, 0x43, 0xB2, 0x12, 0x95, + 0x03, 0x82, 0x02, 0xB3, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0xEF, 0xF0, 0x0A, 0xB3, 0x00, 0xFF, + 0x48, 0xA2, 0x19, 0xD3, 0x03, 0x82, 0x40, 0xF0, + 0xEB, 0xF3, 0x11, 0x93, 0xBF, 0xEC, 0x41, 0x42, + 0x02, 0x5E, 0x0F, 0x9F, 0xEF, 0xF0, 0x11, 0x93, + 0x07, 0x82, 0x11, 0x43, 0x03, 0xEC, 0x02, 0x0E, + 0x0F, 0x9F, 0xEF, 0xF0, 0x11, 0x93, 0x03, 0x82, + 0x09, 0xA3, 0x00, 0x01, 0x19, 0xD3, 0x03, 0x82, + 0x40, 0x96, 0x1B, 0xD7, 0xBF, 0xEC, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, + 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, + 0x01, 0x00, 0x11, 0x93, 0x20, 0xBC, 0xC8, 0xD2, + 0x40, 0xF0, 0x48, 0xF1, 0x41, 0x00, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x42, 0x20, 0x08, 0x0B, + 0x01, 0x00, 0x0D, 0x03, 0x05, 0x00, 0x05, 0x94, + 0x41, 0x02, 0xC1, 0x92, 0x01, 0x97, 0xC3, 0x96, + 0xC2, 0xD6, 0x0A, 0x45, 0x00, 0x95, 0x02, 0x5E, + 0x0F, 0x9F, 0x45, 0xF1, 0xC1, 0x92, 0x41, 0xB2, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x45, 0xF1, + 0x11, 0x93, 0xC0, 0xEC, 0x40, 0x42, 0x02, 0x5E, + 0x0F, 0x9F, 0x45, 0xF1, 0x41, 0x98, 0x1C, 0xD9, + 0xC0, 0xEC, 0x12, 0x95, 0x02, 0x80, 0x01, 0xD4, + 0x40, 0xF0, 0x56, 0xF2, 0x0B, 0x67, 0xFD, 0x7D, + 0x03, 0x99, 0xC4, 0x92, 0x0C, 0x99, 0x96, 0x03, + 0x1C, 0xD9, 0x06, 0x82, 0x41, 0x98, 0x1C, 0xD9, + 0x02, 0x82, 0x42, 0x98, 0x1C, 0xD9, 0x05, 0x82, + 0x0C, 0x69, 0x80, 0x7F, 0x1C, 0xD9, 0x00, 0xB0, + 0x09, 0xA3, 0x00, 0x01, 0xC3, 0xD2, 0x01, 0x94, + 0x0A, 0xB3, 0x04, 0x00, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0x43, 0xF1, 0x42, 0xA4, 0x1A, 0xD5, + 0x02, 0x80, 0x42, 0x00, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x42, 0x20, 0x08, 0x0B, 0x01, 0x00, + 0x05, 0x92, 0xC5, 0xD2, 0x60, 0xB2, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0x55, 0xF1, 0x40, 0xF0, + 0x35, 0xF7, 0xC5, 0x94, 0x0A, 0xB3, 0x10, 0x00, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x5E, 0xF1, + 0x40, 0xF0, 0x23, 0xF6, 0xC5, 0x96, 0x0B, 0xB3, + 0x40, 0x00, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0x67, 0xF1, 0x40, 0xF0, 0x5D, 0xF5, 0xC5, 0x94, + 0x0A, 0xB3, 0x01, 0x00, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0xC8, 0xF1, 0x13, 0x97, 0x21, 0xBC, + 0x01, 0xD6, 0x0B, 0xB3, 0x02, 0x00, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0x79, 0xF1, 0x40, 0xF0, + 0x62, 0xFB, 0x01, 0x94, 0x0A, 0xB3, 0x04, 0x00, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x82, 0xF1, + 0x40, 0xF0, 0x6C, 0xFB, 0x01, 0x96, 0x0B, 0xB3, + 0x01, 0x00, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0xA2, 0xF1, 0x40, 0xF0, 0xB0, 0xFA, 0x41, 0x92, + 0x19, 0xD3, 0xD5, 0xF7, 0x11, 0x93, 0x03, 0xEC, + 0x09, 0x43, 0x40, 0x00, 0x02, 0x5E, 0x0F, 0x9F, + 0x98, 0xF1, 0x40, 0x94, 0x1A, 0xD5, 0xD5, 0xF7, + 0x11, 0x93, 0x00, 0xEC, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0xAB, 0xF1, 0x40, 0xF0, 0x38, 0xF2, + 0x0F, 0x9F, 0xAB, 0xF1, 0x01, 0x96, 0x0B, 0xB3, + 0x08, 0x00, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0xAB, 0xF1, 0x40, 0xF0, 0x7C, 0xFB, 0x01, 0x94, + 0x0A, 0xB3, 0x10, 0x00, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0xB4, 0xF1, 0x40, 0xF0, 0x87, 0xFB, + 0x11, 0x93, 0x10, 0xEC, 0x42, 0x42, 0x02, 0x5E, + 0x0F, 0x9F, 0xBF, 0xF1, 0x44, 0x96, 0x1B, 0xD7, + 0x0B, 0xBC, 0x0F, 0x9F, 0xC5, 0xF1, 0x41, 0x42, + 0x02, 0x5E, 0x0F, 0x9F, 0xC5, 0xF1, 0x19, 0xD3, + 0x0B, 0xBC, 0x40, 0x92, 0x19, 0xD3, 0x10, 0xEC, + 0xC5, 0x94, 0x0A, 0xB3, 0x80, 0x00, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0x12, 0xF2, 0x13, 0x97, + 0x28, 0xBC, 0x01, 0xD6, 0x0B, 0xB3, 0x40, 0x00, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0xDA, 0xF1, + 0x40, 0xF0, 0x18, 0xF7, 0x01, 0x94, 0x0A, 0xB3, + 0x02, 0x00, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0xED, 0xF1, 0x40, 0xF0, 0xC4, 0xEE, 0x40, 0xF0, + 0x8F, 0xFB, 0x40, 0xF0, 0x1B, 0xF2, 0x40, 0x96, + 0x1B, 0xD7, 0x00, 0xEC, 0x41, 0x92, 0x19, 0xD3, + 0xD8, 0xF7, 0x01, 0x94, 0x0A, 0xB3, 0x04, 0x00, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x09, 0xF2, + 0x40, 0xF0, 0x9E, 0xFB, 0x09, 0x63, 0x00, 0x44, + 0x01, 0x97, 0xC3, 0x94, 0x48, 0xA4, 0xC1, 0xD4, + 0x00, 0xEE, 0x40, 0x92, 0x19, 0xD3, 0x12, 0x95, + 0x19, 0xD3, 0x10, 0x95, 0x19, 0xD3, 0x02, 0x80, + 0x19, 0xD3, 0x03, 0x82, 0x41, 0x92, 0x19, 0xD3, + 0xD8, 0xF7, 0x01, 0x94, 0x0A, 0xB3, 0x08, 0x00, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x12, 0xF2, + 0x40, 0xF0, 0xAE, 0xFB, 0x0A, 0x65, 0x00, 0x44, + 0x02, 0x97, 0xC3, 0x92, 0x44, 0xA2, 0xC2, 0xD2, + 0x42, 0x00, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x08, 0x0B, 0x01, 0x00, 0x09, 0x63, 0x00, 0x40, + 0x19, 0xD3, 0xF2, 0xBD, 0x0A, 0x65, 0xEA, 0x43, + 0x02, 0x97, 0xC3, 0x92, 0x44, 0xA2, 0xC2, 0xD2, + 0x0A, 0x65, 0xE9, 0x43, 0x02, 0x97, 0xC3, 0x92, + 0x09, 0xA3, 0x40, 0x00, 0xC2, 0xD2, 0x0A, 0x65, + 0xEB, 0x43, 0x02, 0x97, 0xC3, 0x92, 0x09, 0xA3, + 0xC0, 0x00, 0xC2, 0xD2, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x09, 0x63, + 0x00, 0x80, 0x19, 0xD3, 0xF2, 0xBD, 0x0A, 0x65, + 0xE8, 0x43, 0x02, 0x97, 0xC3, 0x92, 0x09, 0xA3, + 0xC0, 0x00, 0xC2, 0xD2, 0x0A, 0x65, 0xEB, 0x43, + 0x02, 0x97, 0xC3, 0x92, 0x09, 0xB3, 0xBF, 0xFF, + 0xC2, 0xD2, 0x0A, 0x65, 0xEA, 0x43, 0x02, 0x97, + 0xC3, 0x92, 0x09, 0xB3, 0xFB, 0xFF, 0xC2, 0xD2, + 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, + 0x01, 0x00, 0x09, 0x93, 0x00, 0x01, 0x19, 0xD3, + 0x02, 0x80, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x08, 0x0B, 0x01, 0x00, 0x09, 0x93, 0x00, 0x09, + 0x19, 0xD3, 0x02, 0x80, 0x40, 0xF0, 0x56, 0xF2, + 0x40, 0x92, 0x19, 0xD3, 0x94, 0xEC, 0xC8, 0xD2, + 0x09, 0x93, 0x91, 0xEC, 0xC8, 0xD2, 0x40, 0xF0, + 0x2A, 0xEF, 0x42, 0x00, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x40, 0xF0, + 0x3B, 0xF5, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0x85, 0xF2, 0x0A, 0x65, 0xFE, 0x7F, 0x02, 0x97, + 0xC3, 0x92, 0x44, 0xA2, 0xC2, 0xD2, 0x0F, 0x9F, + 0x92, 0xF2, 0x40, 0xF0, 0x94, 0xF2, 0x40, 0x42, + 0x02, 0x5E, 0x0F, 0x9F, 0x92, 0xF2, 0xC8, 0xD2, + 0x09, 0x93, 0x91, 0xEC, 0xC8, 0xD2, 0x40, 0xF0, + 0x2A, 0xEF, 0x42, 0x00, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x11, 0x93, + 0xF1, 0xBD, 0x19, 0xD3, 0xB6, 0xEC, 0x11, 0x93, + 0xB4, 0xEC, 0x40, 0x42, 0x02, 0x5E, 0x0F, 0x9F, + 0xAC, 0xF2, 0x09, 0x63, 0x00, 0x80, 0x01, 0x97, + 0xC3, 0x94, 0x0A, 0x07, 0x07, 0x00, 0xC1, 0xD6, + 0x0A, 0x05, 0x00, 0xA0, 0x1A, 0xD5, 0x96, 0xEC, + 0x11, 0x93, 0xB6, 0xEC, 0x19, 0xD3, 0x01, 0x80, + 0x0A, 0x65, 0xFE, 0x7F, 0x02, 0x97, 0xC3, 0x92, + 0x41, 0xA2, 0xC2, 0xD2, 0x40, 0x92, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x41, 0x20, 0x08, 0x0B, + 0x01, 0x00, 0x13, 0x97, 0xB4, 0xEC, 0x40, 0x46, + 0x02, 0x5E, 0x0F, 0x9F, 0x2C, 0xF3, 0x12, 0x95, + 0x96, 0xEC, 0x0A, 0x03, 0x07, 0x00, 0xC1, 0x92, + 0xC2, 0xD2, 0x11, 0x93, 0x96, 0xEC, 0x09, 0x05, + 0x01, 0x00, 0x48, 0x02, 0xC1, 0x92, 0xC2, 0xD2, + 0x11, 0x93, 0x96, 0xEC, 0x4E, 0x02, 0xC1, 0x94, + 0xC5, 0xD6, 0xC5, 0x92, 0x11, 0x07, 0x96, 0xEC, + 0x0B, 0x03, 0x0F, 0x00, 0xC1, 0x98, 0x46, 0x06, + 0x7A, 0x93, 0x79, 0x93, 0x5C, 0x95, 0x5A, 0x95, + 0x02, 0xA3, 0xC3, 0xD2, 0x04, 0x95, 0xC5, 0x96, + 0x41, 0x06, 0xC5, 0xD6, 0x42, 0x46, 0x02, 0x9E, + 0x0F, 0x9F, 0xD5, 0xF2, 0x11, 0x93, 0x96, 0xEC, + 0x09, 0x05, 0x05, 0x00, 0x41, 0x02, 0xC1, 0x92, + 0xC2, 0xD2, 0x11, 0x93, 0x96, 0xEC, 0xC1, 0x92, + 0x09, 0xB5, 0x1F, 0x00, 0x43, 0x44, 0x02, 0x8E, + 0x0F, 0x9F, 0x02, 0xF3, 0x40, 0x44, 0x02, 0x4E, + 0x0F, 0x9F, 0x03, 0xF3, 0x0A, 0x05, 0xFF, 0xFF, + 0x0F, 0x9F, 0x03, 0xF3, 0x43, 0x94, 0x11, 0x93, + 0x96, 0xEC, 0x42, 0x02, 0xC1, 0xD4, 0x11, 0x93, + 0x96, 0xEC, 0x49, 0x02, 0xC1, 0x92, 0x19, 0xD3, + 0xB4, 0xEC, 0x09, 0x05, 0xF2, 0xFF, 0x1A, 0xD5, + 0x92, 0xEC, 0x09, 0x43, 0xD0, 0x07, 0x02, 0x9E, + 0x0F, 0x9F, 0x2C, 0xF3, 0x11, 0x93, 0xDC, 0xF7, + 0x41, 0x02, 0x19, 0xD3, 0xDC, 0xF7, 0x11, 0x93, + 0xDB, 0xF7, 0x09, 0xA3, 0x40, 0x00, 0x19, 0xD3, + 0xDB, 0xF7, 0x09, 0x63, 0x00, 0x80, 0x01, 0x95, + 0xC2, 0x94, 0x1A, 0xD5, 0xB5, 0xEC, 0x40, 0x96, + 0x1B, 0xD7, 0xB4, 0xEC, 0x0F, 0x9F, 0x92, 0xF3, + 0x11, 0x93, 0x92, 0xEC, 0x12, 0x95, 0xB6, 0xEC, + 0x02, 0x43, 0x02, 0x8E, 0x0F, 0x9F, 0x7A, 0xF3, + 0x02, 0x0E, 0x0F, 0x9F, 0x4D, 0xF3, 0x11, 0x93, + 0xDC, 0xF7, 0x41, 0x02, 0x19, 0xD3, 0xDC, 0xF7, + 0x11, 0x93, 0xDB, 0xF7, 0x09, 0xA3, 0x80, 0x00, + 0x19, 0xD3, 0xDB, 0xF7, 0x09, 0x63, 0x00, 0x80, + 0x01, 0x95, 0xC2, 0x94, 0x1A, 0xD5, 0xB5, 0xEC, + 0x40, 0x96, 0x1B, 0xD7, 0xB4, 0xEC, 0x0F, 0x9F, + 0x92, 0xF3, 0x11, 0x93, 0x03, 0x80, 0x09, 0xB3, + 0x00, 0x40, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0x5F, 0xF3, 0x11, 0x93, 0xC0, 0xEC, 0x40, 0x42, + 0x02, 0x5E, 0x0F, 0x9F, 0x5F, 0xF3, 0x40, 0xF0, + 0xA6, 0xF3, 0x0F, 0x9F, 0x94, 0xF3, 0x41, 0x92, + 0xC8, 0xD2, 0x0A, 0x95, 0x91, 0xEC, 0xC8, 0xD4, + 0x40, 0xF0, 0x2A, 0xEF, 0x42, 0x00, 0x11, 0x93, + 0xC0, 0xEC, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0x72, 0xF3, 0x42, 0x96, 0x1B, 0xD7, 0xC0, 0xEC, + 0x0F, 0x9F, 0x94, 0xF3, 0x0A, 0x65, 0xFE, 0x7F, + 0x02, 0x97, 0xC3, 0x92, 0x42, 0xA2, 0xC2, 0xD2, + 0x0F, 0x9F, 0x94, 0xF3, 0x12, 0x45, 0x03, 0xEC, + 0x02, 0x4E, 0x0F, 0x9F, 0x8C, 0xF3, 0x11, 0x93, + 0xDC, 0xF7, 0x41, 0x02, 0x19, 0xD3, 0xDC, 0xF7, + 0x11, 0x93, 0xDB, 0xF7, 0x09, 0xA3, 0x00, 0x08, + 0x19, 0xD3, 0xDB, 0xF7, 0x1A, 0xD5, 0x92, 0xEC, + 0x11, 0x93, 0x92, 0xEC, 0x19, 0x25, 0x92, 0xEC, + 0x09, 0x63, 0x00, 0x80, 0x19, 0xD3, 0xF2, 0xBD, + 0x41, 0x00, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x08, 0x0B, 0x01, 0x00, 0x40, 0xF0, 0xA6, 0xF3, + 0x40, 0x92, 0xC8, 0xD2, 0x09, 0x93, 0x91, 0xEC, + 0xC8, 0xD2, 0x40, 0xF0, 0x2A, 0xEF, 0x42, 0x00, + 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, + 0x01, 0x00, 0x11, 0x93, 0xD7, 0xF7, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0xB6, 0xF3, 0x0A, 0x65, + 0xBC, 0x69, 0x02, 0x97, 0xC3, 0x92, 0x09, 0x83, + 0x00, 0x02, 0xC2, 0xD2, 0x11, 0x93, 0x03, 0x80, + 0x09, 0xB3, 0x00, 0x40, 0x40, 0x42, 0x02, 0x5E, + 0x0F, 0x9F, 0xC9, 0xF3, 0x11, 0x93, 0xDC, 0xF7, + 0x41, 0x02, 0x19, 0xD3, 0xDC, 0xF7, 0x11, 0x93, + 0xDB, 0xF7, 0x09, 0xA3, 0x00, 0x20, 0x19, 0xD3, + 0xDB, 0xF7, 0x11, 0x93, 0xB5, 0xEC, 0x19, 0xD3, + 0x04, 0x80, 0x12, 0x95, 0xB4, 0xEC, 0x1A, 0xD5, + 0x05, 0x80, 0x09, 0x63, 0x00, 0x80, 0x01, 0x97, + 0xC3, 0x96, 0x1B, 0xD7, 0xB5, 0xEC, 0x40, 0x94, + 0x1A, 0xD5, 0xB4, 0xEC, 0x19, 0xD3, 0xF2, 0xBD, + 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, + 0x01, 0x00, 0x09, 0x93, 0x96, 0x03, 0x19, 0xD3, + 0x06, 0x82, 0x09, 0x93, 0x00, 0x01, 0x19, 0xD3, + 0x03, 0x82, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x47, 0x20, 0x08, 0x0B, 0x01, 0x00, 0x11, 0x93, + 0x01, 0x82, 0xC5, 0xD2, 0x40, 0x94, 0x01, 0xD4, + 0x13, 0x97, 0xB8, 0xEC, 0x02, 0xD6, 0x03, 0x95, + 0x0C, 0x99, 0xBB, 0xEC, 0x04, 0x05, 0x13, 0x97, + 0x03, 0xEC, 0x01, 0x27, 0x02, 0x99, 0xC4, 0x92, + 0x03, 0x03, 0xC2, 0xD2, 0x14, 0x99, 0xBA, 0xEC, + 0x03, 0x09, 0x1C, 0xD9, 0xBA, 0xEC, 0x12, 0x95, + 0x04, 0x82, 0x0A, 0xB3, 0x02, 0x00, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0x29, 0xF5, 0x01, 0x92, + 0x03, 0xD2, 0x0A, 0xA3, 0x02, 0x00, 0x19, 0xD3, + 0x04, 0x82, 0x02, 0x96, 0x0B, 0x05, 0x01, 0x00, + 0x1A, 0xD5, 0xB8, 0xEC, 0xC5, 0x92, 0x43, 0x42, + 0x02, 0x9E, 0x0F, 0x9F, 0x37, 0xF4, 0x42, 0x44, + 0x02, 0x8E, 0x0F, 0x9F, 0x37, 0xF4, 0x11, 0x93, + 0xBF, 0xEC, 0x40, 0x42, 0x02, 0x5E, 0x0F, 0x9F, + 0x37, 0xF4, 0x0C, 0x49, 0xD3, 0x08, 0x02, 0x8E, + 0x0F, 0x9F, 0x37, 0xF4, 0x11, 0x63, 0x07, 0x82, + 0x11, 0xA3, 0x07, 0x82, 0x71, 0x93, 0x79, 0x93, + 0x79, 0x93, 0x79, 0x93, 0x03, 0xD2, 0xC5, 0x94, + 0x0A, 0xB5, 0xFC, 0xFF, 0x04, 0xD4, 0x03, 0x96, + 0x40, 0x46, 0x02, 0x5E, 0x0F, 0x9F, 0x46, 0xF4, + 0x11, 0x93, 0xB8, 0xEC, 0x41, 0x42, 0x02, 0x8E, + 0x0F, 0x9F, 0x4D, 0xF4, 0xC5, 0x98, 0x0C, 0x03, + 0xFF, 0xFF, 0x42, 0x42, 0x02, 0x8E, 0x0F, 0x9F, + 0x74, 0xF4, 0x0A, 0x95, 0xBB, 0xEC, 0x42, 0x92, + 0x19, 0xD3, 0xB9, 0xEC, 0xC5, 0x96, 0x43, 0x46, + 0x02, 0x9E, 0x0F, 0x9F, 0x66, 0xF4, 0x0B, 0x07, + 0xFC, 0xFF, 0xC5, 0xD6, 0xD2, 0x98, 0x1C, 0xD9, + 0xC8, 0xBC, 0xD2, 0x96, 0x1B, 0xD7, 0xCA, 0xBC, + 0x09, 0x03, 0xFF, 0xFF, 0x40, 0x42, 0x02, 0x5E, + 0x0F, 0x9F, 0x52, 0xF4, 0x19, 0xD3, 0xB9, 0xEC, + 0x40, 0x42, 0x02, 0x5E, 0x0F, 0x9F, 0x72, 0xF4, + 0x0A, 0x05, 0xFE, 0xFF, 0xCA, 0xD2, 0xC2, 0xD2, + 0x0F, 0x9F, 0x74, 0xF4, 0x1A, 0xD5, 0x93, 0xEC, + 0x03, 0x98, 0x40, 0x48, 0x02, 0x5E, 0x0F, 0x9F, + 0xA1, 0xF4, 0x11, 0x93, 0xB8, 0xEC, 0x41, 0x42, + 0x02, 0x9E, 0x0F, 0x9F, 0x84, 0xF4, 0x04, 0x94, + 0x48, 0x44, 0x02, 0x4E, 0x0F, 0x9F, 0x8F, 0xF4, + 0x41, 0x42, 0x02, 0x5E, 0x0F, 0x9F, 0xA1, 0xF4, + 0x11, 0x93, 0x04, 0x82, 0x41, 0xB2, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0xA1, 0xF4, 0x41, 0x96, + 0x01, 0xD6, 0x0A, 0x65, 0xBD, 0x43, 0x02, 0x99, + 0xC4, 0x92, 0x09, 0xA3, 0x80, 0x00, 0xC2, 0xD2, + 0x0A, 0x65, 0xE8, 0x43, 0x02, 0x97, 0xC3, 0x92, + 0x09, 0xB3, 0xBF, 0xFF, 0xC2, 0xD2, 0x0F, 0x9F, + 0xFA, 0xF4, 0xC5, 0x98, 0x43, 0x48, 0x02, 0x9E, + 0x0F, 0x9F, 0xFA, 0xF4, 0x4F, 0x96, 0x0C, 0xB3, + 0x01, 0x00, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0xAE, 0xF4, 0x47, 0x96, 0x11, 0x93, 0xB7, 0xEC, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0xD6, 0xF4, + 0x11, 0x93, 0xB8, 0xEC, 0x41, 0x42, 0x02, 0x5E, + 0x0F, 0x9F, 0xD6, 0xF4, 0x12, 0x95, 0x00, 0x82, + 0x0A, 0x05, 0xFF, 0xAF, 0x05, 0xD4, 0xC8, 0xD6, + 0xC8, 0xD2, 0x40, 0xF0, 0x7B, 0xF7, 0x42, 0x00, + 0x05, 0x96, 0xC3, 0x94, 0x01, 0xB5, 0x40, 0x44, + 0x02, 0x4E, 0x0F, 0x9F, 0xD6, 0xF4, 0x06, 0x98, + 0x50, 0x98, 0x1C, 0xD9, 0xA2, 0xBC, 0x40, 0x98, + 0x1C, 0xD9, 0xA2, 0xBC, 0x40, 0x92, 0x03, 0xD2, + 0x0F, 0x9F, 0xFF, 0xF4, 0x03, 0x94, 0x40, 0x44, + 0x02, 0x5E, 0x0F, 0x9F, 0xE3, 0xF4, 0x0A, 0x65, + 0x5E, 0x43, 0x02, 0x97, 0xC3, 0x92, 0x48, 0xA2, + 0xC2, 0xD2, 0x0F, 0x9F, 0xFF, 0xF4, 0x11, 0x93, + 0xB8, 0xEC, 0x0C, 0x99, 0xBB, 0xEC, 0x04, 0x03, + 0x04, 0x96, 0x13, 0x25, 0x03, 0xEC, 0xC1, 0xD4, + 0x11, 0x93, 0xBA, 0xEC, 0x19, 0x05, 0xBA, 0xEC, + 0x1B, 0xD7, 0x01, 0x82, 0x0A, 0x65, 0xFD, 0x7D, + 0x02, 0x99, 0xC4, 0x92, 0x43, 0xA2, 0xC2, 0xD2, + 0x41, 0x92, 0x01, 0xD2, 0x03, 0x94, 0x40, 0x44, + 0x02, 0x5E, 0x0F, 0x9F, 0x13, 0xF5, 0x11, 0x93, + 0xB9, 0xEC, 0x40, 0x42, 0x02, 0x5E, 0x0F, 0x9F, + 0x0B, 0xF5, 0x19, 0xD3, 0xB8, 0xEC, 0x19, 0xD3, + 0xBA, 0xEC, 0x19, 0xD3, 0xBB, 0xEC, 0x03, 0x96, + 0x40, 0x46, 0x02, 0x5E, 0x0F, 0x9F, 0x13, 0xF5, + 0x41, 0x98, 0x1C, 0xD9, 0xB7, 0xEC, 0x11, 0x93, + 0xBF, 0xEC, 0x41, 0x42, 0x02, 0x5E, 0x0F, 0x9F, + 0x24, 0xF5, 0x11, 0x93, 0x00, 0x82, 0x19, 0xD3, + 0x02, 0x82, 0x0A, 0x65, 0xFD, 0x7D, 0x02, 0x97, + 0xC3, 0x92, 0x09, 0xA3, 0x00, 0x01, 0xC2, 0xD2, + 0x40, 0x98, 0x1C, 0xD9, 0xBF, 0xEC, 0x0F, 0x9F, + 0x2C, 0xF5, 0x01, 0x92, 0x19, 0xD3, 0xB7, 0xEC, + 0x01, 0x94, 0x40, 0x44, 0x02, 0x5E, 0x0F, 0x9F, + 0x38, 0xF5, 0x0A, 0x65, 0xEA, 0x43, 0x02, 0x97, + 0xC3, 0x92, 0x09, 0xB3, 0xFB, 0xFF, 0xC2, 0xD2, + 0x47, 0x00, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x08, 0x0B, 0x01, 0x00, 0x12, 0x95, 0x03, 0x80, + 0x0A, 0xB3, 0x00, 0x40, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0x57, 0xF5, 0x0A, 0xB7, 0x00, 0x08, + 0x40, 0x46, 0x02, 0x5E, 0x0F, 0x9F, 0x5A, 0xF5, + 0x11, 0x93, 0x03, 0xEC, 0x41, 0x02, 0x09, 0xB3, + 0xFE, 0xFF, 0x12, 0x95, 0x07, 0x80, 0x01, 0x45, + 0x02, 0x8E, 0x0F, 0x9F, 0x5A, 0xF5, 0x41, 0x92, + 0x0F, 0x9F, 0x5B, 0xF5, 0x40, 0x92, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x41, 0x20, 0x08, 0x0B, + 0x01, 0x00, 0x0A, 0x65, 0xE9, 0x43, 0x02, 0x97, + 0xC3, 0x92, 0x09, 0xA3, 0x40, 0x00, 0xC2, 0xD2, + 0x13, 0x97, 0x6E, 0xEC, 0x0B, 0x47, 0xA0, 0x00, + 0x02, 0x5E, 0x0F, 0x9F, 0x86, 0xF5, 0x09, 0x63, + 0x08, 0x43, 0x0A, 0x65, 0xFF, 0x5F, 0x01, 0x99, + 0xC4, 0xD4, 0x0A, 0x95, 0x9B, 0xEC, 0xD2, 0x96, + 0x1B, 0xD7, 0xFA, 0xBC, 0xD2, 0x96, 0xC4, 0xD6, + 0xD2, 0x98, 0x1C, 0xD9, 0xFA, 0xBC, 0xD2, 0x96, + 0xC1, 0xD6, 0xC2, 0x94, 0x1A, 0xD5, 0xFA, 0xBC, + 0x0F, 0x9F, 0xC4, 0xF5, 0x0C, 0x69, 0xFF, 0x6F, + 0x1C, 0xD9, 0xF8, 0xBC, 0x0B, 0x47, 0x10, 0x95, + 0x02, 0x5E, 0x0F, 0x9F, 0x9E, 0xF5, 0x0A, 0x95, + 0x6F, 0xEC, 0x09, 0x63, 0x06, 0x43, 0x01, 0x99, + 0xC4, 0xD6, 0xD2, 0x96, 0x1B, 0xD7, 0xF8, 0xBC, + 0x0C, 0x69, 0xEE, 0x6A, 0xC1, 0xD8, 0xC2, 0x94, + 0x1A, 0xD5, 0xF8, 0xBC, 0x40, 0x92, 0xC5, 0xD2, + 0x11, 0x43, 0xC1, 0xEC, 0x02, 0x0E, 0x0F, 0x9F, + 0xC1, 0xF5, 0xC5, 0x94, 0x0A, 0x03, 0x71, 0xEC, + 0xC1, 0x94, 0x1A, 0xD5, 0xFA, 0xBC, 0x11, 0x93, + 0xC0, 0xEC, 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0xB3, 0xF5, 0x0A, 0x95, 0x6F, 0xEC, 0xC8, 0xD4, + 0x40, 0xF0, 0x9C, 0xF7, 0x19, 0xD3, 0xF8, 0xBC, + 0x41, 0x00, 0xC5, 0x96, 0x41, 0x06, 0xC5, 0xD6, + 0x13, 0x47, 0xC1, 0xEC, 0x02, 0x1E, 0x0F, 0x9F, + 0xA5, 0xF5, 0x40, 0x98, 0x1C, 0xD9, 0xFA, 0xBC, + 0x40, 0x92, 0x19, 0xD3, 0x6E, 0xEC, 0x19, 0xD3, + 0xC1, 0xEC, 0x0A, 0x65, 0x52, 0x43, 0x02, 0x97, + 0xC3, 0x92, 0x48, 0xA2, 0xC2, 0xD2, 0x0A, 0x65, + 0xEB, 0x43, 0x02, 0x99, 0xC4, 0x92, 0x09, 0xB3, + 0xBF, 0xFF, 0xC2, 0xD2, 0x41, 0x00, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x43, 0x20, 0x08, 0x0B, + 0x01, 0x00, 0x06, 0x92, 0x01, 0xD2, 0x0A, 0x65, + 0xF0, 0x6A, 0x0B, 0x97, 0x6F, 0xEC, 0x02, 0x99, + 0xC4, 0x98, 0xD3, 0xD8, 0x02, 0xD6, 0x0A, 0x03, + 0x02, 0x00, 0x01, 0x97, 0xC3, 0x98, 0x02, 0x96, + 0xC3, 0xD8, 0x01, 0x96, 0xC1, 0xD6, 0x1A, 0xD5, + 0x6E, 0xEC, 0xC5, 0x98, 0x14, 0x99, 0x6F, 0xEC, + 0xC2, 0xD8, 0x43, 0x00, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x40, 0x92, + 0xC8, 0xD2, 0x40, 0xF0, 0xD9, 0xF5, 0x41, 0x00, + 0x11, 0x93, 0xC0, 0xEC, 0x40, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0x13, 0xF6, 0x42, 0x42, 0x02, 0x5E, + 0x0F, 0x9F, 0x10, 0xF6, 0x0A, 0x65, 0xFE, 0x7F, + 0x02, 0x97, 0xC3, 0x92, 0x42, 0xA2, 0xC2, 0xD2, + 0x40, 0x92, 0x19, 0xD3, 0xC0, 0xEC, 0x0A, 0x65, + 0xEB, 0x43, 0x02, 0x97, 0xC3, 0x92, 0x09, 0xA3, + 0xC0, 0x00, 0xC2, 0xD2, 0x0A, 0x65, 0xE9, 0x43, + 0x02, 0x97, 0xC3, 0x92, 0x09, 0xB3, 0xBF, 0xFF, + 0xC2, 0xD2, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x63, 0x20, 0x08, 0x0B, 0x01, 0x00, 0x11, 0x93, + 0xAF, 0xBC, 0x47, 0xB2, 0x59, 0x95, 0x5A, 0x95, + 0x12, 0xA5, 0xBF, 0xBC, 0x0A, 0xB3, 0x01, 0x00, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x35, 0xF6, + 0x41, 0x04, 0x05, 0x93, 0x40, 0x96, 0x20, 0xD6, + 0x62, 0x97, 0x0F, 0x9F, 0x44, 0xF6, 0x14, 0x99, + 0xFC, 0xBC, 0xD1, 0xD8, 0x14, 0x99, 0xFE, 0xBC, + 0xD1, 0xD8, 0x20, 0x98, 0x42, 0x08, 0x20, 0xD8, + 0x20, 0x98, 0x03, 0x49, 0x02, 0x1E, 0x0F, 0x9F, + 0x3B, 0xF6, 0xC5, 0x92, 0x62, 0x42, 0x02, 0x4E, + 0x0F, 0x9F, 0x5D, 0xF6, 0x02, 0x8E, 0x0F, 0x9F, + 0x57, 0xF6, 0x61, 0x42, 0x02, 0x4E, 0x0F, 0x9F, + 0x81, 0xF6, 0x0F, 0x9F, 0xAE, 0xF6, 0x63, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0xA4, 0xF6, 0x0F, 0x9F, + 0xAE, 0xF6, 0x0D, 0x03, 0x01, 0x00, 0x0C, 0x99, + 0x71, 0xEC, 0x0B, 0x05, 0xFF, 0xFF, 0x40, 0x96, + 0x0F, 0x9F, 0x6A, 0xF6, 0xD1, 0x96, 0xD4, 0xD6, + 0x20, 0x96, 0x41, 0x06, 0x20, 0xD6, 0x02, 0x47, + 0x02, 0x1E, 0x0F, 0x9F, 0x66, 0xF6, 0x1A, 0xD5, + 0xC1, 0xEC, 0x0A, 0x65, 0xEB, 0x43, 0x02, 0x99, + 0xC4, 0x92, 0x09, 0xA3, 0xC0, 0x00, 0xC2, 0xD2, + 0x0A, 0x65, 0xE9, 0x43, 0x02, 0x97, 0xC3, 0x92, + 0x09, 0xB3, 0xBF, 0xFF, 0xC2, 0xD2, 0x0F, 0x9F, + 0xAE, 0xF6, 0x0A, 0x03, 0xFE, 0xFF, 0x61, 0x95, + 0x40, 0x98, 0x20, 0xD8, 0x02, 0x49, 0x02, 0x0E, + 0x0F, 0x9F, 0xAE, 0xF6, 0x0D, 0x03, 0x01, 0x00, + 0x21, 0xD2, 0x20, 0x92, 0x05, 0x03, 0x42, 0x02, + 0xC8, 0xD2, 0x21, 0x96, 0xC3, 0x92, 0x42, 0x06, + 0x21, 0xD6, 0xC8, 0xD2, 0x22, 0xD4, 0x40, 0xF0, + 0x01, 0xF1, 0x42, 0x00, 0x20, 0x98, 0x42, 0x08, + 0x20, 0xD8, 0x22, 0x94, 0x02, 0x49, 0x02, 0x1E, + 0x0F, 0x9F, 0x8D, 0xF6, 0x0F, 0x9F, 0xAE, 0xF6, + 0x0D, 0x03, 0x03, 0x00, 0xC8, 0xD2, 0x02, 0x92, + 0xC8, 0xD2, 0x01, 0x96, 0xC8, 0xD6, 0x40, 0xF0, + 0xB1, 0xF6, 0x43, 0x00, 0x63, 0x00, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x45, 0x20, 0x08, 0x0B, + 0x01, 0x00, 0x0D, 0x03, 0x08, 0x00, 0x08, 0x94, + 0xC5, 0xD4, 0x09, 0x05, 0x01, 0x00, 0xC2, 0x94, + 0x03, 0xD4, 0x42, 0x02, 0xC1, 0x92, 0x01, 0xD2, + 0x02, 0x97, 0xC5, 0x94, 0x0A, 0x83, 0xFF, 0xFF, + 0x11, 0xB3, 0x2C, 0x93, 0x09, 0xB3, 0xFB, 0xFF, + 0x19, 0xD3, 0x2C, 0x93, 0x03, 0x92, 0x40, 0x42, + 0x02, 0x4E, 0x0F, 0x9F, 0xE4, 0xF6, 0x01, 0x94, + 0xD2, 0x92, 0x19, 0xD3, 0x2C, 0x93, 0x01, 0xD4, + 0x02, 0x94, 0x12, 0x95, 0x2C, 0x93, 0x44, 0xA4, + 0x1A, 0xD5, 0x2C, 0x93, 0x0A, 0xB5, 0xFB, 0xFF, + 0x1A, 0xD5, 0x2C, 0x93, 0x0B, 0x07, 0xFF, 0xFF, + 0x40, 0x46, 0x02, 0x5E, 0x0F, 0x9F, 0xCF, 0xF6, + 0x09, 0x63, 0xD4, 0x6C, 0x01, 0x95, 0xC2, 0x96, + 0xC5, 0x94, 0x02, 0xA7, 0xC1, 0xD6, 0x03, 0x92, + 0x54, 0x42, 0x02, 0x5E, 0x0F, 0x9F, 0xF4, 0xF6, + 0x0A, 0x83, 0xFF, 0xFF, 0x1B, 0xB3, 0x2C, 0x93, + 0x45, 0x00, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x08, 0x0B, 0x01, 0x00, 0x09, 0x63, 0x00, 0x40, + 0x19, 0xD3, 0xF2, 0xBD, 0x40, 0xF0, 0x3B, 0xF5, + 0x40, 0x42, 0x02, 0x5E, 0x0F, 0x9F, 0x08, 0xF7, + 0x40, 0xF0, 0x94, 0xF2, 0x0F, 0x9F, 0x16, 0xF7, + 0x40, 0x96, 0xC8, 0xD6, 0x09, 0x93, 0x91, 0xEC, + 0xC8, 0xD2, 0x40, 0xF0, 0x2A, 0xEF, 0x0A, 0x65, + 0xFE, 0x7F, 0x02, 0x97, 0xC3, 0x92, 0x44, 0xA2, + 0xC2, 0xD2, 0x42, 0x00, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x0A, 0x65, + 0xE8, 0x43, 0x02, 0x97, 0xC3, 0x92, 0x09, 0xA3, + 0x40, 0x00, 0xC2, 0xD2, 0x0A, 0x65, 0xEA, 0x43, + 0x02, 0x97, 0xC3, 0x92, 0x09, 0xB3, 0xFB, 0xFF, + 0xC2, 0xD2, 0x40, 0x92, 0x19, 0xD3, 0x2D, 0xBC, + 0x0A, 0x65, 0xD8, 0x43, 0x02, 0x97, 0xC3, 0x92, + 0x09, 0xB3, 0xBF, 0xFF, 0xC2, 0xD2, 0x88, 0x98, + 0x90, 0x9A, 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, + 0x09, 0x63, 0xEA, 0x43, 0x01, 0x97, 0xC3, 0x94, + 0x44, 0xA4, 0xC1, 0xD4, 0x11, 0x93, 0xB9, 0xEC, + 0x40, 0x42, 0x02, 0x4E, 0x0F, 0x9F, 0x6F, 0xF7, + 0x12, 0x95, 0x93, 0xEC, 0x0B, 0x67, 0x36, 0x43, + 0xD2, 0x98, 0x1C, 0xD9, 0xC8, 0xBC, 0xD2, 0x98, + 0x03, 0x93, 0xC1, 0xD8, 0x11, 0x93, 0xB9, 0xEC, + 0x09, 0x03, 0xFF, 0xFF, 0x19, 0xD3, 0xB9, 0xEC, + 0x40, 0x42, 0x02, 0x5E, 0x0F, 0x9F, 0x48, 0xF7, + 0x19, 0xD3, 0xB8, 0xEC, 0x19, 0xD3, 0xBA, 0xEC, + 0x0A, 0x05, 0xFE, 0xFF, 0xCA, 0xD2, 0xCA, 0xD2, + 0xC2, 0xD2, 0x0A, 0x65, 0x5E, 0x43, 0x02, 0x97, + 0xC3, 0x92, 0x48, 0xA2, 0xC2, 0xD2, 0x0A, 0x65, + 0xEA, 0x43, 0x02, 0x99, 0xC4, 0x92, 0x09, 0xB3, + 0xFB, 0xFF, 0x0F, 0x9F, 0x78, 0xF7, 0x11, 0x93, + 0x03, 0xEC, 0x19, 0xD3, 0x01, 0x82, 0x0A, 0x65, + 0xFD, 0x7D, 0x02, 0x97, 0xC3, 0x92, 0x43, 0xA2, + 0xC2, 0xD2, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x08, 0x0B, 0x01, 0x00, 0x03, 0x92, 0x04, 0x96, + 0x0D, 0x5E, 0x50, 0x46, 0x02, 0x0E, 0x40, 0x92, + 0x09, 0xEE, 0x44, 0x46, 0x04, 0x0E, 0x59, 0x93, + 0x44, 0x26, 0x04, 0x5E, 0x46, 0xEE, 0x41, 0x93, + 0x41, 0x26, 0x43, 0x4E, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x40, 0xF0, + 0xB1, 0xFE, 0x88, 0x98, 0x90, 0x9A, 0x88, 0xDA, + 0x08, 0x0B, 0x01, 0x00, 0x88, 0x98, 0x90, 0x9A, + 0x88, 0xDA, 0x08, 0x0B, 0x01, 0x00, 0x03, 0x94, + 0x1A, 0xD5, 0xA3, 0xF7, 0x11, 0x93, 0x00, 0x90, + 0x88, 0x98, 0x90, 0x9A, 0x1D, 0x00, 0x1A, 0x00, + 0x03, 0x00, 0x03, 0x00, 0x18, 0x00, 0x19, 0x00, + 0x1A, 0x00, 0x1B, 0x00, 0x16, 0x00, 0x21, 0x00, + 0x12, 0x00, 0x09, 0x00, 0x13, 0x00, 0x19, 0x00, + 0x19, 0x00, 0x19, 0x00, 0x21, 0x00, 0x2D, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x69, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x5F, 0xF2, 0xCD, 0xF7, 0x00, 0x00, 0x74, 0xF2, + 0xCD, 0xF7, 0x00, 0x00, 0xB9, 0xF2, 0xCA, 0xF7, + 0xD1, 0xF7, 0x00, 0x00, 0x97, 0xF3, 0xCD, 0xF7, + 0x05, 0x46, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +uint8_t zd1211b_firmware[] = { + 0x08, 0x91, 0xff, 0xed, 0x09, 0x93, 0x1e, 0xee, 0xd1, 0x94, + 0x11, 0xee, 0x88, 0xd4, 0xd1, 0x96, 0xd1, 0x98, 0x5c, 0x99, + 0x5c, 0x99, 0x4c, 0x99, 0x04, 0x9d, 0xd1, 0x98, 0xd1, 0x9a, + 0x03, 0xee, 0xf4, 0x94, 0xd3, 0xd4, 0x41, 0x2a, 0x40, 0x4a, + 0x45, 0xbe, 0x88, 0x92, 0x41, 0x24, 0x40, 0x44, 0x53, 0xbe, + 0x40, 0xf0, 0x8e, 0xee, 0x41, 0xee, 0x98, 0x9a, 0xc9, 0xf7, + 0x02, 0x00, 0x1f, 0xec, 0x00, 0x00, 0xb2, 0xf8, 0x4d, 0x00, + 0xa1, 0xec, 0x00, 0x00, 0x9b, 0xf7, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xd8, 0xa0, 0x90, + 0x98, 0x9a, 0x98, 0x9a, 0xa0, 0xd8, 0x40, 0xf0, 0xbc, 0xf0, + 0xa0, 0x90, 0x98, 0x9a, 0xa0, 0xd8, 0x40, 0xf0, 0x6c, 0xef, + 0xa0, 0x90, 0x98, 0x9a, 0xa0, 0xd8, 0x40, 0xf0, 0xf9, 0xf0, + 0xa0, 0x90, 0x98, 0x9a, 0xa0, 0xd8, 0x40, 0xf0, 0xec, 0xf6, + 0xa0, 0x90, 0x98, 0x9a, 0xa0, 0xd8, 0x40, 0xf0, 0xed, 0xf5, + 0xa0, 0x90, 0x98, 0x9a, 0x98, 0x9a, 0xa0, 0xd8, 0x40, 0xf0, + 0x8c, 0xf7, 0xa0, 0x90, 0x98, 0x9a, 0x88, 0xda, 0x08, 0x0b, + 0x01, 0x00, 0x0d, 0x03, 0x03, 0x00, 0x09, 0x05, 0x01, 0x00, + 0xc2, 0x94, 0x42, 0x02, 0xc1, 0x92, 0x03, 0x96, 0x1b, 0xd7, + 0x2a, 0x86, 0x1a, 0xd5, 0x2b, 0x86, 0x09, 0xa3, 0x00, 0x80, + 0x19, 0xd3, 0x2c, 0x86, 0x00, 0xee, 0x0a, 0x65, 0xc0, 0x7a, + 0x02, 0x97, 0xc3, 0x92, 0x09, 0xb3, 0xfe, 0xff, 0xc2, 0xd2, + 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x42, 0x20, 0x08, 0x0b, + 0x01, 0x00, 0x0d, 0x03, 0x05, 0x00, 0x05, 0x94, 0xc5, 0xd4, + 0x09, 0x05, 0x01, 0x00, 0xc2, 0x94, 0x01, 0xd4, 0x42, 0x02, + 0xc1, 0x96, 0x0a, 0x65, 0xc0, 0x7a, 0x02, 0x99, 0xc4, 0x92, + 0x41, 0xa2, 0xc4, 0xd2, 0xc5, 0x98, 0x1c, 0xd9, 0x2a, 0x86, + 0x01, 0x98, 0x1c, 0xd9, 0x2b, 0x86, 0x1b, 0xd7, 0x2c, 0x86, + 0x00, 0xee, 0x09, 0xb3, 0xfe, 0xff, 0xc2, 0xd2, 0x42, 0x00, + 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x41, 0x20, 0x08, 0x0b, + 0x01, 0x00, 0x40, 0xf0, 0xed, 0xee, 0x11, 0x93, 0xcd, 0xf7, + 0x41, 0x42, 0x02, 0x5e, 0x0f, 0x9f, 0xa9, 0xee, 0x40, 0xf1, + 0x40, 0x92, 0x19, 0xd3, 0xcd, 0xf7, 0xc5, 0x92, 0x41, 0x92, + 0x19, 0xd3, 0x00, 0x83, 0x40, 0x92, 0x19, 0xd3, 0x00, 0x83, + 0x0f, 0x9f, 0x95, 0xf8, 0x0f, 0x9f, 0x94, 0xee, 0x42, 0x42, + 0x02, 0x5e, 0x0f, 0x9f, 0xbc, 0xee, 0x40, 0x92, 0x19, 0xd3, + 0xcd, 0xf7, 0x09, 0x93, 0xbc, 0xf7, 0x19, 0xd3, 0x91, 0xec, + 0x40, 0xf0, 0x5f, 0xf2, 0x09, 0x63, 0x00, 0x80, 0x19, 0xd3, + 0xf2, 0xbd, 0x0f, 0x9f, 0x94, 0xee, 0x43, 0x42, 0x02, 0x5e, + 0x0f, 0x9f, 0x94, 0xee, 0x09, 0x93, 0x0b, 0x01, 0x19, 0xd3, + 0x03, 0x82, 0x40, 0x92, 0x19, 0xd3, 0xcd, 0xf7, 0x0f, 0x9f, + 0x94, 0xee, 0x41, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x08, 0x0b, 0x01, 0x00, 0x40, 0x92, 0x19, 0xd3, 0x12, 0x95, + 0x19, 0xd3, 0x10, 0x95, 0x19, 0xd3, 0x02, 0x80, 0x19, 0xd3, + 0x03, 0x82, 0x09, 0x93, 0xbc, 0xf7, 0x19, 0xd3, 0x91, 0xec, + 0x40, 0xf0, 0x5f, 0xf2, 0x40, 0xf0, 0xcd, 0xf3, 0x11, 0x93, + 0x04, 0xec, 0x42, 0x42, 0x02, 0x5e, 0x0f, 0x9f, 0xeb, 0xee, + 0x40, 0x92, 0x19, 0xd3, 0x04, 0xec, 0x40, 0xf0, 0x38, 0xf2, + 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, + 0x11, 0x93, 0x44, 0x96, 0x09, 0xb3, 0xff, 0xfd, 0x19, 0xd3, + 0x44, 0x96, 0x40, 0xf0, 0x85, 0xf7, 0x6e, 0x92, 0x19, 0xd3, + 0x05, 0x84, 0x40, 0xf0, 0xcc, 0xee, 0x4b, 0x62, 0x0a, 0x95, + 0x2e, 0xee, 0xd1, 0xd4, 0x0b, 0x97, 0x2b, 0xee, 0xd1, 0xd6, + 0x0a, 0x95, 0x00, 0xee, 0xd1, 0xd4, 0x0b, 0x97, 0x2f, 0xee, + 0xd1, 0xd6, 0x0a, 0x95, 0x34, 0xee, 0xd1, 0xd4, 0x0b, 0x97, + 0x39, 0xee, 0xd1, 0xd6, 0x0a, 0x95, 0x3e, 0xee, 0xd1, 0xd4, + 0x0b, 0x97, 0x43, 0xee, 0xd1, 0xd6, 0x0a, 0x95, 0x2e, 0xee, + 0xd1, 0xd4, 0x0b, 0x97, 0x48, 0xee, 0xd1, 0xd6, 0x0a, 0x95, + 0x49, 0xee, 0xc1, 0xd4, 0x0a, 0x65, 0x00, 0x44, 0x02, 0x97, + 0xc3, 0x92, 0x44, 0xa2, 0xc2, 0xd2, 0x43, 0xf1, 0x09, 0x93, + 0x01, 0x3f, 0x19, 0xd3, 0xc0, 0x85, 0x11, 0x93, 0x44, 0x96, + 0x09, 0xb3, 0xff, 0xfc, 0x19, 0xd3, 0x44, 0x96, 0x88, 0x98, + 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x0d, 0x03, + 0x03, 0x00, 0x03, 0x96, 0x41, 0x02, 0x03, 0x99, 0xc4, 0x94, + 0x42, 0x04, 0xc1, 0x04, 0xc2, 0x94, 0xc3, 0xd4, 0x88, 0x98, + 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x40, 0x92, + 0x19, 0xd3, 0x94, 0xec, 0x13, 0x97, 0x95, 0xec, 0x1b, 0xd7, + 0x02, 0x80, 0x11, 0x93, 0x99, 0xec, 0x19, 0xd3, 0x7c, 0x96, + 0x0b, 0x97, 0xa0, 0x00, 0x1b, 0xd7, 0x6e, 0xec, 0x0a, 0x65, + 0x0e, 0x42, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xb3, 0xff, 0xbf, + 0x11, 0xa3, 0x9a, 0xec, 0xc2, 0xd2, 0x0a, 0x65, 0xeb, 0x43, + 0x02, 0x97, 0xc3, 0x92, 0x09, 0xa3, 0xc0, 0x00, 0xc2, 0xd2, + 0x0a, 0x65, 0xe9, 0x43, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xb3, + 0xbf, 0xff, 0xc2, 0xd2, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x47, 0x20, 0x08, 0x0b, 0x01, 0x00, 0x14, 0x99, 0x03, 0x80, + 0x0c, 0xb3, 0x00, 0x10, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, + 0x9f, 0xf0, 0x11, 0x93, 0x9f, 0xec, 0x41, 0x02, 0x19, 0xd3, + 0x9f, 0xec, 0x11, 0x93, 0xcb, 0xf7, 0x40, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0x8c, 0xef, 0x0a, 0x65, 0xfe, 0x7f, 0x02, 0x97, + 0xc3, 0x92, 0x09, 0xa3, 0x00, 0x04, 0xc2, 0xd2, 0x0f, 0x9f, + 0xb9, 0xf0, 0x11, 0x93, 0x94, 0xec, 0x02, 0xd2, 0x40, 0x42, + 0x02, 0x5e, 0x0f, 0x9f, 0xd8, 0xef, 0x41, 0x92, 0x19, 0xd3, + 0x94, 0xec, 0x19, 0xd3, 0x9f, 0xec, 0x12, 0x95, 0x02, 0x80, + 0x1a, 0xd5, 0x95, 0xec, 0x13, 0x97, 0x7c, 0x96, 0x1b, 0xd7, + 0x99, 0xec, 0x0a, 0x65, 0x0e, 0x42, 0x02, 0x97, 0xc3, 0x92, + 0x09, 0xb3, 0x00, 0x40, 0x19, 0xd3, 0x9a, 0xec, 0x09, 0x63, + 0x00, 0x40, 0xc2, 0xd2, 0x02, 0x94, 0x1a, 0xd5, 0x7c, 0x96, + 0x0c, 0xb3, 0x00, 0x08, 0x40, 0x42, 0x02, 0x5e, 0x0f, 0x9f, + 0xb8, 0xef, 0x0c, 0xb3, 0xff, 0x07, 0x0f, 0x9f, 0xbc, 0xef, + 0x11, 0x93, 0x06, 0x80, 0x09, 0xb3, 0xff, 0x07, 0x09, 0x03, + 0x00, 0xa0, 0x19, 0xd3, 0x97, 0xec, 0x40, 0x98, 0x0b, 0x97, + 0x9c, 0xec, 0x04, 0x95, 0x03, 0x05, 0x14, 0x03, 0x97, 0xec, + 0x46, 0x02, 0xc1, 0x92, 0xc2, 0xd2, 0x41, 0x08, 0x42, 0x48, + 0x02, 0x9e, 0x0f, 0x9f, 0xc3, 0xef, 0x11, 0x93, 0x97, 0xec, + 0xc1, 0x92, 0xc5, 0xd2, 0x5f, 0xb2, 0x19, 0xd3, 0x9b, 0xec, + 0x0f, 0x9f, 0xdb, 0xef, 0x13, 0x97, 0x98, 0xec, 0xc5, 0xd6, + 0x11, 0x93, 0x03, 0x80, 0x09, 0xb3, 0x00, 0x08, 0x40, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0xf1, 0xef, 0x11, 0x93, 0xd1, 0xf7, + 0x41, 0x02, 0x19, 0xd3, 0xd1, 0xf7, 0x11, 0x93, 0xd0, 0xf7, + 0x09, 0xa3, 0x00, 0x10, 0x19, 0xd3, 0xd0, 0xf7, 0x40, 0x98, + 0x1c, 0xd9, 0x9b, 0xec, 0x12, 0x95, 0x9b, 0xec, 0x40, 0x44, + 0x02, 0x4e, 0x0f, 0x9f, 0x8e, 0xf0, 0x0a, 0xb3, 0x08, 0x00, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x0f, 0xf0, 0x0a, 0xb3, + 0x07, 0x00, 0x09, 0x05, 0xa9, 0xec, 0xc2, 0x94, 0x01, 0xd4, + 0x09, 0x03, 0xa1, 0xec, 0xc1, 0x92, 0x19, 0xd3, 0x9b, 0xec, + 0xc5, 0x94, 0x0a, 0xb5, 0x00, 0xff, 0x01, 0xa5, 0xc5, 0xd4, + 0x0f, 0x9f, 0x1b, 0xf0, 0x0a, 0x05, 0xff, 0xff, 0x0a, 0x03, + 0xb1, 0xec, 0xc1, 0x92, 0x01, 0xd2, 0x1a, 0xd5, 0x9b, 0xec, + 0xc5, 0x96, 0x0b, 0x07, 0xff, 0xff, 0xc5, 0xd6, 0x11, 0x93, + 0x97, 0xec, 0xc5, 0x98, 0xc1, 0xd8, 0x11, 0x93, 0x97, 0xec, + 0x09, 0x05, 0x0b, 0x00, 0x03, 0xd4, 0xc2, 0x96, 0x06, 0xd6, + 0x7b, 0x95, 0x7a, 0x95, 0x4c, 0x02, 0xc1, 0x92, 0x59, 0x93, + 0x59, 0x93, 0x01, 0xa5, 0x01, 0x98, 0x0c, 0xf5, 0x7b, 0x93, + 0x09, 0x09, 0x01, 0x00, 0x06, 0x92, 0x09, 0xb3, 0xff, 0x00, + 0x04, 0xd2, 0x5c, 0x93, 0x59, 0x93, 0x04, 0x94, 0x01, 0xa5, + 0x03, 0x96, 0xc3, 0xd4, 0x11, 0x93, 0x97, 0xec, 0x4c, 0x02, + 0x05, 0xd2, 0xc1, 0x92, 0x09, 0xb3, 0x00, 0xff, 0x7c, 0x95, + 0x7a, 0x95, 0x02, 0xa3, 0x05, 0x98, 0xc4, 0xd2, 0x12, 0x95, + 0x97, 0xec, 0x45, 0x04, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xa3, + 0x00, 0x01, 0xc2, 0xd2, 0x12, 0x95, 0x9b, 0xec, 0x0a, 0xb3, + 0x08, 0x00, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x63, 0xf0, + 0x12, 0x95, 0x97, 0xec, 0x4a, 0x04, 0x02, 0x99, 0xc4, 0x92, + 0x01, 0x98, 0x0c, 0xf3, 0x7b, 0x93, 0x41, 0x02, 0x0f, 0x9f, + 0x84, 0xf0, 0x43, 0x44, 0x02, 0x8e, 0x0f, 0x9f, 0x85, 0xf0, + 0x11, 0x93, 0x97, 0xec, 0x42, 0x02, 0x0a, 0x05, 0xff, 0xff, + 0xc1, 0xd4, 0x11, 0x93, 0x97, 0xec, 0x4a, 0x02, 0x12, 0x95, + 0x60, 0x96, 0xc1, 0xd4, 0x12, 0x95, 0x97, 0xec, 0x4b, 0x04, + 0x02, 0x97, 0xc3, 0x92, 0x09, 0xb3, 0x1f, 0xff, 0xc2, 0xd2, + 0x12, 0x95, 0x97, 0xec, 0x4b, 0x04, 0x11, 0x93, 0x62, 0x96, + 0x41, 0x93, 0x59, 0x93, 0x02, 0x99, 0xc4, 0xa2, 0xc2, 0xd2, + 0xc5, 0x92, 0x19, 0xd3, 0x98, 0xec, 0x0a, 0x95, 0x0c, 0x02, + 0x1a, 0xd5, 0x02, 0x80, 0x0f, 0x9f, 0xb9, 0xf0, 0x09, 0x63, + 0xfe, 0x7f, 0x01, 0x97, 0xc3, 0x94, 0x0a, 0xa5, 0x00, 0x04, + 0xc1, 0xd4, 0x11, 0x93, 0x9f, 0xec, 0x09, 0xa3, 0x00, 0x01, + 0x19, 0xd3, 0x9f, 0xec, 0x40, 0xf0, 0x41, 0xef, 0x0f, 0x9f, + 0xb9, 0xf0, 0x11, 0x93, 0x94, 0xec, 0x41, 0x42, 0x02, 0x5e, + 0x0f, 0x9f, 0xae, 0xf0, 0x40, 0xf0, 0x41, 0xef, 0x11, 0x93, + 0x95, 0xec, 0x44, 0xb2, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, + 0xb9, 0xf0, 0x48, 0x98, 0x1c, 0xd9, 0x02, 0x80, 0x11, 0x93, + 0x91, 0xec, 0x41, 0x22, 0x0a, 0x95, 0xb9, 0xf0, 0x88, 0xd4, + 0x88, 0xdc, 0x91, 0x9a, 0x47, 0x00, 0x88, 0x98, 0x90, 0x9a, + 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x11, 0x93, 0x04, 0x82, + 0x48, 0xb2, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0xd0, 0xf0, + 0x0a, 0x65, 0xfd, 0x7d, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xb3, + 0xff, 0xfe, 0xc2, 0xd2, 0x41, 0x92, 0x19, 0xd3, 0xbf, 0xec, + 0x11, 0x93, 0x04, 0x82, 0x43, 0xb2, 0x12, 0x95, 0x03, 0x82, + 0x02, 0xb3, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0xf7, 0xf0, + 0x0a, 0xb3, 0x00, 0xff, 0x48, 0xa2, 0x19, 0xd3, 0x03, 0x82, + 0x40, 0xf0, 0xda, 0xf3, 0x11, 0x93, 0xbf, 0xec, 0x41, 0x42, + 0x02, 0x5e, 0x0f, 0x9f, 0xf7, 0xf0, 0x11, 0x93, 0x07, 0x82, + 0x11, 0x43, 0x03, 0xec, 0x02, 0x0e, 0x0f, 0x9f, 0xf7, 0xf0, + 0x11, 0x93, 0x03, 0x82, 0x09, 0xa3, 0x00, 0x01, 0x19, 0xd3, + 0x03, 0x82, 0x40, 0x96, 0x1b, 0xd7, 0xbf, 0xec, 0x88, 0x98, + 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x11, 0x93, + 0x20, 0xbc, 0xc8, 0xd2, 0x40, 0xf0, 0x4b, 0xf1, 0x41, 0x00, + 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x42, 0x20, 0x08, 0x0b, + 0x01, 0x00, 0x0d, 0x03, 0x05, 0x00, 0x05, 0x94, 0x41, 0x02, + 0xc1, 0x92, 0x01, 0x97, 0xc3, 0x96, 0xc2, 0xd6, 0x0a, 0x45, + 0x00, 0x95, 0x02, 0x5e, 0x0f, 0x9f, 0x48, 0xf1, 0xc1, 0x92, + 0x41, 0xb2, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x48, 0xf1, + 0x11, 0x93, 0xc0, 0xec, 0x40, 0x42, 0x02, 0x5e, 0x0f, 0x9f, + 0x48, 0xf1, 0x41, 0x98, 0x1c, 0xd9, 0xc0, 0xec, 0x12, 0x95, + 0x02, 0x80, 0x01, 0xd4, 0x40, 0xf0, 0x56, 0xf2, 0x0b, 0x67, + 0xfd, 0x7d, 0x03, 0x99, 0xc4, 0x92, 0x0c, 0x99, 0x96, 0x03, + 0x1c, 0xd9, 0x06, 0x82, 0x41, 0x98, 0x1c, 0xd9, 0x02, 0x82, + 0x42, 0x98, 0x1c, 0xd9, 0x05, 0x82, 0x0c, 0x69, 0x80, 0x7f, + 0x1c, 0xd9, 0x00, 0xb0, 0x09, 0xa3, 0x00, 0x01, 0xc3, 0xd2, + 0x01, 0x94, 0x0a, 0xb3, 0x04, 0x00, 0x40, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0x46, 0xf1, 0x42, 0xa4, 0x1a, 0xd5, 0x02, 0x80, + 0x42, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x42, 0x20, + 0x08, 0x0b, 0x01, 0x00, 0x05, 0x92, 0xc5, 0xd2, 0x60, 0xb2, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x58, 0xf1, 0x40, 0xf0, + 0x2a, 0xf7, 0xc5, 0x94, 0x0a, 0xb3, 0x10, 0x00, 0x40, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0x61, 0xf1, 0x40, 0xf0, 0x18, 0xf6, + 0xc5, 0x96, 0x0b, 0xb3, 0x40, 0x00, 0x40, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0x6a, 0xf1, 0x40, 0xf0, 0x52, 0xf5, 0xc5, 0x94, + 0x0a, 0xb3, 0x01, 0x00, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, + 0xcb, 0xf1, 0x13, 0x97, 0x21, 0xbc, 0x01, 0xd6, 0x0b, 0xb3, + 0x02, 0x00, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x7c, 0xf1, + 0x40, 0xf0, 0x62, 0xfb, 0x01, 0x94, 0x0a, 0xb3, 0x04, 0x00, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x85, 0xf1, 0x40, 0xf0, + 0x6c, 0xfb, 0x01, 0x96, 0x0b, 0xb3, 0x01, 0x00, 0x40, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0xa5, 0xf1, 0x40, 0xf0, 0xb0, 0xfa, + 0x41, 0x92, 0x19, 0xd3, 0xca, 0xf7, 0x11, 0x93, 0x03, 0xec, + 0x09, 0x43, 0x40, 0x00, 0x02, 0x5e, 0x0f, 0x9f, 0x9b, 0xf1, + 0x40, 0x94, 0x1a, 0xd5, 0xca, 0xf7, 0x11, 0x93, 0x00, 0xec, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0xae, 0xf1, 0x40, 0xf0, + 0x38, 0xf2, 0x0f, 0x9f, 0xae, 0xf1, 0x01, 0x96, 0x0b, 0xb3, + 0x08, 0x00, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0xae, 0xf1, + 0x40, 0xf0, 0x7c, 0xfb, 0x01, 0x94, 0x0a, 0xb3, 0x10, 0x00, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0xb7, 0xf1, 0x40, 0xf0, + 0x87, 0xfb, 0x11, 0x93, 0x10, 0xec, 0x42, 0x42, 0x02, 0x5e, + 0x0f, 0x9f, 0xc2, 0xf1, 0x44, 0x96, 0x1b, 0xd7, 0x0b, 0xbc, + 0x0f, 0x9f, 0xc8, 0xf1, 0x41, 0x42, 0x02, 0x5e, 0x0f, 0x9f, + 0xc8, 0xf1, 0x19, 0xd3, 0x0b, 0xbc, 0x40, 0x92, 0x19, 0xd3, + 0x10, 0xec, 0xc5, 0x94, 0x0a, 0xb3, 0x80, 0x00, 0x40, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0x12, 0xf2, 0x13, 0x97, 0x28, 0xbc, + 0x01, 0xd6, 0x0b, 0xb3, 0x40, 0x00, 0x40, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0xdd, 0xf1, 0x40, 0xf0, 0x0d, 0xf7, 0x01, 0x94, + 0x0a, 0xb3, 0x02, 0x00, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, + 0xed, 0xf1, 0x40, 0xf0, 0xcc, 0xee, 0x40, 0xf0, 0x8f, 0xfb, + 0x40, 0xf0, 0x1b, 0xf2, 0x40, 0x96, 0x1b, 0xd7, 0x00, 0xec, + 0x01, 0x94, 0x0a, 0xb3, 0x04, 0x00, 0x40, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0x09, 0xf2, 0x40, 0xf0, 0x9e, 0xfb, 0x09, 0x63, + 0x00, 0x44, 0x01, 0x97, 0xc3, 0x94, 0x48, 0xa4, 0xc1, 0xd4, + 0x00, 0xee, 0x40, 0x92, 0x19, 0xd3, 0x12, 0x95, 0x19, 0xd3, + 0x10, 0x95, 0x19, 0xd3, 0x02, 0x80, 0x19, 0xd3, 0x03, 0x82, + 0x43, 0x92, 0x19, 0xd3, 0xcd, 0xf7, 0x01, 0x94, 0x0a, 0xb3, + 0x08, 0x00, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x12, 0xf2, + 0x40, 0xf0, 0xae, 0xfb, 0x0a, 0x65, 0x00, 0x44, 0x02, 0x97, + 0xc3, 0x92, 0x44, 0xa2, 0xc2, 0xd2, 0x42, 0x00, 0x88, 0x98, + 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x09, 0x63, + 0x00, 0x40, 0x19, 0xd3, 0xf2, 0xbd, 0x0a, 0x65, 0xea, 0x43, + 0x02, 0x97, 0xc3, 0x92, 0x44, 0xa2, 0xc2, 0xd2, 0x0a, 0x65, + 0xe9, 0x43, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xa3, 0x40, 0x00, + 0xc2, 0xd2, 0x0a, 0x65, 0xeb, 0x43, 0x02, 0x97, 0xc3, 0x92, + 0x09, 0xa3, 0xc0, 0x00, 0xc2, 0xd2, 0x88, 0x98, 0x90, 0x9a, + 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x09, 0x63, 0x00, 0x80, + 0x19, 0xd3, 0xf2, 0xbd, 0x0a, 0x65, 0xe8, 0x43, 0x02, 0x97, + 0xc3, 0x92, 0x09, 0xa3, 0xc0, 0x00, 0xc2, 0xd2, 0x0a, 0x65, + 0xeb, 0x43, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xb3, 0xbf, 0xff, + 0xc2, 0xd2, 0x0a, 0x65, 0xea, 0x43, 0x02, 0x97, 0xc3, 0x92, + 0x09, 0xb3, 0xfb, 0xff, 0xc2, 0xd2, 0x88, 0x98, 0x90, 0x9a, + 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x09, 0x93, 0x00, 0x01, + 0x19, 0xd3, 0x02, 0x80, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x08, 0x0b, 0x01, 0x00, 0x09, 0x93, 0x00, 0x09, 0x19, 0xd3, + 0x02, 0x80, 0x40, 0xf0, 0x56, 0xf2, 0x40, 0x92, 0x19, 0xd3, + 0x94, 0xec, 0xc8, 0xd2, 0x09, 0x93, 0x91, 0xec, 0xc8, 0xd2, + 0x40, 0xf0, 0x32, 0xef, 0x42, 0x00, 0x88, 0x98, 0x90, 0x9a, + 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x40, 0xf0, 0x30, 0xf5, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x85, 0xf2, 0x0a, 0x65, + 0xfe, 0x7f, 0x02, 0x97, 0xc3, 0x92, 0x44, 0xa2, 0xc2, 0xd2, + 0x0f, 0x9f, 0x92, 0xf2, 0x40, 0xf0, 0x94, 0xf2, 0x40, 0x42, + 0x02, 0x5e, 0x0f, 0x9f, 0x92, 0xf2, 0xc8, 0xd2, 0x09, 0x93, + 0x91, 0xec, 0xc8, 0xd2, 0x40, 0xf0, 0x32, 0xef, 0x42, 0x00, + 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, + 0x11, 0x93, 0xf1, 0xbd, 0x19, 0xd3, 0xb6, 0xec, 0x11, 0x93, + 0xb4, 0xec, 0x40, 0x42, 0x02, 0x5e, 0x0f, 0x9f, 0xac, 0xf2, + 0x09, 0x63, 0x00, 0x80, 0x01, 0x97, 0xc3, 0x94, 0x0a, 0x07, + 0x07, 0x00, 0xc1, 0xd6, 0x0a, 0x05, 0x00, 0xa0, 0x1a, 0xd5, + 0x96, 0xec, 0x11, 0x93, 0xb6, 0xec, 0x19, 0xd3, 0x01, 0x80, + 0x0a, 0x65, 0xfe, 0x7f, 0x02, 0x97, 0xc3, 0x92, 0x41, 0xa2, + 0xc2, 0xd2, 0x40, 0x92, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x41, 0x20, 0x08, 0x0b, 0x01, 0x00, 0x13, 0x97, 0xb4, 0xec, + 0x40, 0x46, 0x02, 0x5e, 0x0f, 0x9f, 0x1b, 0xf3, 0x12, 0x95, + 0x96, 0xec, 0x0a, 0x03, 0x07, 0x00, 0xc1, 0x92, 0xc2, 0xd2, + 0x11, 0x93, 0x96, 0xec, 0x09, 0x05, 0x01, 0x00, 0x48, 0x02, + 0xc1, 0x92, 0xc2, 0xd2, 0x11, 0x93, 0x96, 0xec, 0x4e, 0x02, + 0xc1, 0x94, 0xc5, 0xd6, 0xc5, 0x92, 0x11, 0x07, 0x96, 0xec, + 0x0b, 0x03, 0x0f, 0x00, 0xc1, 0x98, 0x46, 0x06, 0x7a, 0x93, + 0x79, 0x93, 0x5c, 0x95, 0x5a, 0x95, 0x02, 0xa3, 0xc3, 0xd2, + 0x04, 0x95, 0xc5, 0x96, 0x41, 0x06, 0xc5, 0xd6, 0x42, 0x46, + 0x02, 0x9e, 0x0f, 0x9f, 0xd5, 0xf2, 0x11, 0x93, 0x96, 0xec, + 0x09, 0x05, 0x05, 0x00, 0x41, 0x02, 0xc1, 0x92, 0xc2, 0xd2, + 0x11, 0x93, 0x96, 0xec, 0xc1, 0x92, 0x09, 0xb5, 0x1f, 0x00, + 0x43, 0x44, 0x02, 0x8e, 0x0f, 0x9f, 0x02, 0xf3, 0x40, 0x44, + 0x02, 0x4e, 0x0f, 0x9f, 0x03, 0xf3, 0x0a, 0x05, 0xff, 0xff, + 0x0f, 0x9f, 0x03, 0xf3, 0x43, 0x94, 0x11, 0x93, 0x96, 0xec, + 0x42, 0x02, 0xc1, 0xd4, 0x13, 0x97, 0x96, 0xec, 0x03, 0x93, + 0xd1, 0x94, 0x7a, 0x95, 0x7a, 0x95, 0xc1, 0x92, 0x59, 0x93, + 0x59, 0x93, 0x01, 0x05, 0x49, 0x06, 0xc3, 0x92, 0x7f, 0xb2, + 0x01, 0x05, 0x1a, 0xd5, 0xb4, 0xec, 0x0a, 0x05, 0xf2, 0xff, + 0x1a, 0xd5, 0x92, 0xec, 0x11, 0x93, 0x92, 0xec, 0x12, 0x95, + 0xb6, 0xec, 0x02, 0x43, 0x02, 0x8e, 0x0f, 0x9f, 0x69, 0xf3, + 0x02, 0x0e, 0x0f, 0x9f, 0x3c, 0xf3, 0x11, 0x93, 0xd1, 0xf7, + 0x41, 0x02, 0x19, 0xd3, 0xd1, 0xf7, 0x11, 0x93, 0xd0, 0xf7, + 0x09, 0xa3, 0x80, 0x00, 0x19, 0xd3, 0xd0, 0xf7, 0x09, 0x63, + 0x00, 0x80, 0x01, 0x95, 0xc2, 0x94, 0x1a, 0xd5, 0xb5, 0xec, + 0x40, 0x96, 0x1b, 0xd7, 0xb4, 0xec, 0x0f, 0x9f, 0x81, 0xf3, + 0x11, 0x93, 0x03, 0x80, 0x09, 0xb3, 0x00, 0x40, 0x40, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0x4e, 0xf3, 0x11, 0x93, 0xc0, 0xec, + 0x40, 0x42, 0x02, 0x5e, 0x0f, 0x9f, 0x4e, 0xf3, 0x40, 0xf0, + 0x95, 0xf3, 0x0f, 0x9f, 0x83, 0xf3, 0x41, 0x92, 0xc8, 0xd2, + 0x0a, 0x95, 0x91, 0xec, 0xc8, 0xd4, 0x40, 0xf0, 0x32, 0xef, + 0x42, 0x00, 0x11, 0x93, 0xc0, 0xec, 0x40, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0x61, 0xf3, 0x42, 0x96, 0x1b, 0xd7, 0xc0, 0xec, + 0x0f, 0x9f, 0x83, 0xf3, 0x0a, 0x65, 0xfe, 0x7f, 0x02, 0x97, + 0xc3, 0x92, 0x42, 0xa2, 0xc2, 0xd2, 0x0f, 0x9f, 0x83, 0xf3, + 0x12, 0x45, 0x03, 0xec, 0x02, 0x4e, 0x0f, 0x9f, 0x7b, 0xf3, + 0x11, 0x93, 0xd1, 0xf7, 0x41, 0x02, 0x19, 0xd3, 0xd1, 0xf7, + 0x11, 0x93, 0xd0, 0xf7, 0x09, 0xa3, 0x00, 0x08, 0x19, 0xd3, + 0xd0, 0xf7, 0x1a, 0xd5, 0x92, 0xec, 0x11, 0x93, 0x92, 0xec, + 0x19, 0x25, 0x92, 0xec, 0x09, 0x63, 0x00, 0x80, 0x19, 0xd3, + 0xf2, 0xbd, 0x41, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x08, 0x0b, 0x01, 0x00, 0x40, 0xf0, 0x95, 0xf3, 0x40, 0x92, + 0xc8, 0xd2, 0x09, 0x93, 0x91, 0xec, 0xc8, 0xd2, 0x40, 0xf0, + 0x32, 0xef, 0x42, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x08, 0x0b, 0x01, 0x00, 0x11, 0x93, 0xcc, 0xf7, 0x40, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0xa5, 0xf3, 0x0a, 0x65, 0xbc, 0x69, + 0x02, 0x97, 0xc3, 0x92, 0x09, 0x83, 0x00, 0x02, 0xc2, 0xd2, + 0x11, 0x93, 0x03, 0x80, 0x09, 0xb3, 0x00, 0x40, 0x40, 0x42, + 0x02, 0x5e, 0x0f, 0x9f, 0xb8, 0xf3, 0x11, 0x93, 0xd1, 0xf7, + 0x41, 0x02, 0x19, 0xd3, 0xd1, 0xf7, 0x11, 0x93, 0xd0, 0xf7, + 0x09, 0xa3, 0x00, 0x20, 0x19, 0xd3, 0xd0, 0xf7, 0x11, 0x93, + 0xb5, 0xec, 0x19, 0xd3, 0x04, 0x80, 0x12, 0x95, 0xb4, 0xec, + 0x1a, 0xd5, 0x05, 0x80, 0x09, 0x63, 0x00, 0x80, 0x01, 0x97, + 0xc3, 0x96, 0x1b, 0xd7, 0xb5, 0xec, 0x40, 0x94, 0x1a, 0xd5, + 0xb4, 0xec, 0x19, 0xd3, 0xf2, 0xbd, 0x88, 0x98, 0x90, 0x9a, + 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x09, 0x93, 0x96, 0x03, + 0x19, 0xd3, 0x06, 0x82, 0x09, 0x93, 0x00, 0x01, 0x19, 0xd3, + 0x03, 0x82, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x47, 0x20, + 0x08, 0x0b, 0x01, 0x00, 0x11, 0x93, 0x01, 0x82, 0xc5, 0xd2, + 0x40, 0x94, 0x01, 0xd4, 0x13, 0x97, 0xb8, 0xec, 0x02, 0xd6, + 0x03, 0x95, 0x0c, 0x99, 0xbb, 0xec, 0x04, 0x05, 0x13, 0x97, + 0x03, 0xec, 0x01, 0x27, 0x02, 0x99, 0xc4, 0x92, 0x03, 0x03, + 0xc2, 0xd2, 0x14, 0x99, 0xba, 0xec, 0x03, 0x09, 0x1c, 0xd9, + 0xba, 0xec, 0x12, 0x95, 0x04, 0x82, 0x0a, 0xb3, 0x02, 0x00, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x1e, 0xf5, 0x01, 0x92, + 0x03, 0xd2, 0x0a, 0xa3, 0x02, 0x00, 0x19, 0xd3, 0x04, 0x82, + 0x02, 0x96, 0x0b, 0x05, 0x01, 0x00, 0x1a, 0xd5, 0xb8, 0xec, + 0xc5, 0x92, 0x43, 0x42, 0x02, 0x9e, 0x0f, 0x9f, 0x26, 0xf4, + 0x42, 0x44, 0x02, 0x8e, 0x0f, 0x9f, 0x26, 0xf4, 0x11, 0x93, + 0xbf, 0xec, 0x40, 0x42, 0x02, 0x5e, 0x0f, 0x9f, 0x26, 0xf4, + 0x0c, 0x49, 0xd3, 0x08, 0x02, 0x8e, 0x0f, 0x9f, 0x26, 0xf4, + 0x11, 0x63, 0x07, 0x82, 0x11, 0xa3, 0x07, 0x82, 0x71, 0x93, + 0x79, 0x93, 0x79, 0x93, 0x79, 0x93, 0x03, 0xd2, 0xc5, 0x94, + 0x0a, 0xb5, 0xfc, 0xff, 0x04, 0xd4, 0x03, 0x96, 0x40, 0x46, + 0x02, 0x5e, 0x0f, 0x9f, 0x35, 0xf4, 0x11, 0x93, 0xb8, 0xec, + 0x41, 0x42, 0x02, 0x8e, 0x0f, 0x9f, 0x3c, 0xf4, 0xc5, 0x98, + 0x0c, 0x03, 0xff, 0xff, 0x42, 0x42, 0x02, 0x8e, 0x0f, 0x9f, + 0x63, 0xf4, 0x0a, 0x95, 0xbb, 0xec, 0x42, 0x92, 0x19, 0xd3, + 0xb9, 0xec, 0xc5, 0x96, 0x43, 0x46, 0x02, 0x9e, 0x0f, 0x9f, + 0x55, 0xf4, 0x0b, 0x07, 0xfc, 0xff, 0xc5, 0xd6, 0xd2, 0x98, + 0x1c, 0xd9, 0xc8, 0xbc, 0xd2, 0x96, 0x1b, 0xd7, 0xca, 0xbc, + 0x09, 0x03, 0xff, 0xff, 0x40, 0x42, 0x02, 0x5e, 0x0f, 0x9f, + 0x41, 0xf4, 0x19, 0xd3, 0xb9, 0xec, 0x40, 0x42, 0x02, 0x5e, + 0x0f, 0x9f, 0x61, 0xf4, 0x0a, 0x05, 0xfe, 0xff, 0xca, 0xd2, + 0xc2, 0xd2, 0x0f, 0x9f, 0x63, 0xf4, 0x1a, 0xd5, 0x93, 0xec, + 0x03, 0x98, 0x40, 0x48, 0x02, 0x5e, 0x0f, 0x9f, 0x90, 0xf4, + 0x11, 0x93, 0xb8, 0xec, 0x41, 0x42, 0x02, 0x9e, 0x0f, 0x9f, + 0x73, 0xf4, 0x04, 0x94, 0x48, 0x44, 0x02, 0x4e, 0x0f, 0x9f, + 0x7e, 0xf4, 0x41, 0x42, 0x02, 0x5e, 0x0f, 0x9f, 0x90, 0xf4, + 0x11, 0x93, 0x04, 0x82, 0x41, 0xb2, 0x40, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0x90, 0xf4, 0x41, 0x96, 0x01, 0xd6, 0x0a, 0x65, + 0xbd, 0x43, 0x02, 0x99, 0xc4, 0x92, 0x09, 0xa3, 0x80, 0x00, + 0xc2, 0xd2, 0x0a, 0x65, 0xe8, 0x43, 0x02, 0x97, 0xc3, 0x92, + 0x09, 0xb3, 0xbf, 0xff, 0xc2, 0xd2, 0x0f, 0x9f, 0xef, 0xf4, + 0xc5, 0x98, 0x43, 0x48, 0x02, 0x9e, 0x0f, 0x9f, 0xef, 0xf4, + 0x4f, 0x96, 0x0c, 0xb3, 0x01, 0x00, 0x40, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0x9d, 0xf4, 0x47, 0x96, 0x11, 0x93, 0xb7, 0xec, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0xcb, 0xf4, 0x11, 0x93, + 0xb8, 0xec, 0x41, 0x42, 0x02, 0x5e, 0x0f, 0x9f, 0xcb, 0xf4, + 0x12, 0x95, 0x00, 0x82, 0x0a, 0x05, 0xff, 0xaf, 0x05, 0xd4, + 0xc8, 0xd6, 0xc8, 0xd2, 0x40, 0xf0, 0x70, 0xf7, 0x42, 0x00, + 0x05, 0x96, 0xc3, 0x94, 0x01, 0xb5, 0x40, 0x44, 0x02, 0x5e, + 0x0f, 0x9f, 0xc0, 0xf4, 0x11, 0x93, 0xba, 0xec, 0x4d, 0x42, + 0x02, 0x8e, 0x0f, 0x9f, 0xcb, 0xf4, 0x06, 0x98, 0x50, 0x98, + 0x1c, 0xd9, 0xa2, 0xbc, 0x40, 0x98, 0x1c, 0xd9, 0xa2, 0xbc, + 0x40, 0x92, 0x03, 0xd2, 0x0f, 0x9f, 0xf4, 0xf4, 0x03, 0x94, + 0x40, 0x44, 0x02, 0x5e, 0x0f, 0x9f, 0xd8, 0xf4, 0x0a, 0x65, + 0x5e, 0x43, 0x02, 0x97, 0xc3, 0x92, 0x48, 0xa2, 0xc2, 0xd2, + 0x0f, 0x9f, 0xf4, 0xf4, 0x11, 0x93, 0xb8, 0xec, 0x0c, 0x99, + 0xbb, 0xec, 0x04, 0x03, 0x04, 0x96, 0x13, 0x25, 0x03, 0xec, + 0xc1, 0xd4, 0x11, 0x93, 0xba, 0xec, 0x19, 0x05, 0xba, 0xec, + 0x1b, 0xd7, 0x01, 0x82, 0x0a, 0x65, 0xfd, 0x7d, 0x02, 0x99, + 0xc4, 0x92, 0x43, 0xa2, 0xc2, 0xd2, 0x41, 0x92, 0x01, 0xd2, + 0x03, 0x94, 0x40, 0x44, 0x02, 0x5e, 0x0f, 0x9f, 0x08, 0xf5, + 0x11, 0x93, 0xb9, 0xec, 0x40, 0x42, 0x02, 0x5e, 0x0f, 0x9f, + 0x00, 0xf5, 0x19, 0xd3, 0xb8, 0xec, 0x19, 0xd3, 0xba, 0xec, + 0x19, 0xd3, 0xbb, 0xec, 0x03, 0x96, 0x40, 0x46, 0x02, 0x5e, + 0x0f, 0x9f, 0x08, 0xf5, 0x41, 0x98, 0x1c, 0xd9, 0xb7, 0xec, + 0x11, 0x93, 0xbf, 0xec, 0x41, 0x42, 0x02, 0x5e, 0x0f, 0x9f, + 0x19, 0xf5, 0x11, 0x93, 0x00, 0x82, 0x19, 0xd3, 0x02, 0x82, + 0x0a, 0x65, 0xfd, 0x7d, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xa3, + 0x00, 0x01, 0xc2, 0xd2, 0x40, 0x98, 0x1c, 0xd9, 0xbf, 0xec, + 0x0f, 0x9f, 0x21, 0xf5, 0x01, 0x92, 0x19, 0xd3, 0xb7, 0xec, + 0x01, 0x94, 0x40, 0x44, 0x02, 0x5e, 0x0f, 0x9f, 0x2d, 0xf5, + 0x0a, 0x65, 0xea, 0x43, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xb3, + 0xfb, 0xff, 0xc2, 0xd2, 0x47, 0x00, 0x88, 0x98, 0x90, 0x9a, + 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x12, 0x95, 0x03, 0x80, + 0x0a, 0xb3, 0x00, 0x40, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, + 0x4c, 0xf5, 0x0a, 0xb7, 0x00, 0x08, 0x40, 0x46, 0x02, 0x5e, + 0x0f, 0x9f, 0x4f, 0xf5, 0x11, 0x93, 0x03, 0xec, 0x41, 0x02, + 0x09, 0xb3, 0xfe, 0xff, 0x12, 0x95, 0x07, 0x80, 0x01, 0x45, + 0x02, 0x8e, 0x0f, 0x9f, 0x4f, 0xf5, 0x41, 0x92, 0x0f, 0x9f, + 0x50, 0xf5, 0x40, 0x92, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x41, 0x20, 0x08, 0x0b, 0x01, 0x00, 0x0a, 0x65, 0xe9, 0x43, + 0x02, 0x97, 0xc3, 0x92, 0x09, 0xa3, 0x40, 0x00, 0xc2, 0xd2, + 0x13, 0x97, 0x6e, 0xec, 0x0b, 0x47, 0xa0, 0x00, 0x02, 0x5e, + 0x0f, 0x9f, 0x7b, 0xf5, 0x09, 0x63, 0x08, 0x43, 0x0a, 0x65, + 0xff, 0x5f, 0x01, 0x99, 0xc4, 0xd4, 0x0a, 0x95, 0x9b, 0xec, + 0xd2, 0x96, 0x1b, 0xd7, 0xfa, 0xbc, 0xd2, 0x96, 0xc4, 0xd6, + 0xd2, 0x98, 0x1c, 0xd9, 0xfa, 0xbc, 0xd2, 0x96, 0xc1, 0xd6, + 0xc2, 0x94, 0x1a, 0xd5, 0xfa, 0xbc, 0x0f, 0x9f, 0xb9, 0xf5, + 0x0c, 0x69, 0xff, 0x6f, 0x1c, 0xd9, 0xf8, 0xbc, 0x0b, 0x47, + 0x10, 0x95, 0x02, 0x5e, 0x0f, 0x9f, 0x93, 0xf5, 0x0a, 0x95, + 0x6f, 0xec, 0x09, 0x63, 0x06, 0x43, 0x01, 0x99, 0xc4, 0xd6, + 0xd2, 0x96, 0x1b, 0xd7, 0xf8, 0xbc, 0x0c, 0x69, 0xee, 0x6a, + 0xc1, 0xd8, 0xc2, 0x94, 0x1a, 0xd5, 0xf8, 0xbc, 0x40, 0x92, + 0xc5, 0xd2, 0x11, 0x43, 0xc1, 0xec, 0x02, 0x0e, 0x0f, 0x9f, + 0xb6, 0xf5, 0xc5, 0x94, 0x0a, 0x03, 0x71, 0xec, 0xc1, 0x94, + 0x1a, 0xd5, 0xfa, 0xbc, 0x11, 0x93, 0xc0, 0xec, 0x40, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0xa8, 0xf5, 0x0a, 0x95, 0x6f, 0xec, + 0xc8, 0xd4, 0x40, 0xf0, 0x91, 0xf7, 0x19, 0xd3, 0xf8, 0xbc, + 0x41, 0x00, 0xc5, 0x96, 0x41, 0x06, 0xc5, 0xd6, 0x13, 0x47, + 0xc1, 0xec, 0x02, 0x1e, 0x0f, 0x9f, 0x9a, 0xf5, 0x40, 0x98, + 0x1c, 0xd9, 0xfa, 0xbc, 0x40, 0x92, 0x19, 0xd3, 0x6e, 0xec, + 0x19, 0xd3, 0xc1, 0xec, 0x0a, 0x65, 0x52, 0x43, 0x02, 0x97, + 0xc3, 0x92, 0x48, 0xa2, 0xc2, 0xd2, 0x0a, 0x65, 0xeb, 0x43, + 0x02, 0x99, 0xc4, 0x92, 0x09, 0xb3, 0xbf, 0xff, 0xc2, 0xd2, + 0x41, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x43, 0x20, + 0x08, 0x0b, 0x01, 0x00, 0x06, 0x92, 0x01, 0xd2, 0x0a, 0x65, + 0xf0, 0x6a, 0x0b, 0x97, 0x6f, 0xec, 0x02, 0x99, 0xc4, 0x98, + 0xd3, 0xd8, 0x02, 0xd6, 0x0a, 0x03, 0x02, 0x00, 0x01, 0x97, + 0xc3, 0x98, 0x02, 0x96, 0xc3, 0xd8, 0x01, 0x96, 0xc1, 0xd6, + 0x1a, 0xd5, 0x6e, 0xec, 0xc5, 0x98, 0x14, 0x99, 0x6f, 0xec, + 0xc2, 0xd8, 0x43, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x08, 0x0b, 0x01, 0x00, 0x40, 0x92, 0xc8, 0xd2, 0x40, 0xf0, + 0xce, 0xf5, 0x41, 0x00, 0x11, 0x93, 0xc0, 0xec, 0x40, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0x08, 0xf6, 0x42, 0x42, 0x02, 0x5e, + 0x0f, 0x9f, 0x05, 0xf6, 0x0a, 0x65, 0xfe, 0x7f, 0x02, 0x97, + 0xc3, 0x92, 0x42, 0xa2, 0xc2, 0xd2, 0x40, 0x92, 0x19, 0xd3, + 0xc0, 0xec, 0x0a, 0x65, 0xeb, 0x43, 0x02, 0x97, 0xc3, 0x92, + 0x09, 0xa3, 0xc0, 0x00, 0xc2, 0xd2, 0x0a, 0x65, 0xe9, 0x43, + 0x02, 0x97, 0xc3, 0x92, 0x09, 0xb3, 0xbf, 0xff, 0xc2, 0xd2, + 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x63, 0x20, 0x08, 0x0b, + 0x01, 0x00, 0x11, 0x93, 0xaf, 0xbc, 0x47, 0xb2, 0x59, 0x95, + 0x5a, 0x95, 0x12, 0xa5, 0xbf, 0xbc, 0x0a, 0xb3, 0x01, 0x00, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x2a, 0xf6, 0x41, 0x04, + 0x05, 0x93, 0x40, 0x96, 0x20, 0xd6, 0x62, 0x97, 0x0f, 0x9f, + 0x39, 0xf6, 0x14, 0x99, 0xfc, 0xbc, 0xd1, 0xd8, 0x14, 0x99, + 0xfe, 0xbc, 0xd1, 0xd8, 0x20, 0x98, 0x42, 0x08, 0x20, 0xd8, + 0x20, 0x98, 0x03, 0x49, 0x02, 0x1e, 0x0f, 0x9f, 0x30, 0xf6, + 0xc5, 0x92, 0x62, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0x52, 0xf6, + 0x02, 0x8e, 0x0f, 0x9f, 0x4c, 0xf6, 0x61, 0x42, 0x02, 0x4e, + 0x0f, 0x9f, 0x76, 0xf6, 0x0f, 0x9f, 0xa3, 0xf6, 0x63, 0x42, + 0x02, 0x4e, 0x0f, 0x9f, 0x99, 0xf6, 0x0f, 0x9f, 0xa3, 0xf6, + 0x0d, 0x03, 0x01, 0x00, 0x0c, 0x99, 0x71, 0xec, 0x0b, 0x05, + 0xff, 0xff, 0x40, 0x96, 0x0f, 0x9f, 0x5f, 0xf6, 0xd1, 0x96, + 0xd4, 0xd6, 0x20, 0x96, 0x41, 0x06, 0x20, 0xd6, 0x02, 0x47, + 0x02, 0x1e, 0x0f, 0x9f, 0x5b, 0xf6, 0x1a, 0xd5, 0xc1, 0xec, + 0x0a, 0x65, 0xeb, 0x43, 0x02, 0x99, 0xc4, 0x92, 0x09, 0xa3, + 0xc0, 0x00, 0xc2, 0xd2, 0x0a, 0x65, 0xe9, 0x43, 0x02, 0x97, + 0xc3, 0x92, 0x09, 0xb3, 0xbf, 0xff, 0xc2, 0xd2, 0x0f, 0x9f, + 0xa3, 0xf6, 0x0a, 0x03, 0xfe, 0xff, 0x61, 0x95, 0x40, 0x98, + 0x20, 0xd8, 0x02, 0x49, 0x02, 0x0e, 0x0f, 0x9f, 0xa3, 0xf6, + 0x0d, 0x03, 0x01, 0x00, 0x21, 0xd2, 0x20, 0x92, 0x05, 0x03, + 0x42, 0x02, 0xc8, 0xd2, 0x21, 0x96, 0xc3, 0x92, 0x42, 0x06, + 0x21, 0xd6, 0xc8, 0xd2, 0x22, 0xd4, 0x40, 0xf0, 0x04, 0xf1, + 0x42, 0x00, 0x20, 0x98, 0x42, 0x08, 0x20, 0xd8, 0x22, 0x94, + 0x02, 0x49, 0x02, 0x1e, 0x0f, 0x9f, 0x82, 0xf6, 0x0f, 0x9f, + 0xa3, 0xf6, 0x0d, 0x03, 0x03, 0x00, 0xc8, 0xd2, 0x02, 0x92, + 0xc8, 0xd2, 0x01, 0x96, 0xc8, 0xd6, 0x40, 0xf0, 0xa6, 0xf6, + 0x43, 0x00, 0x63, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x45, 0x20, 0x08, 0x0b, 0x01, 0x00, 0x0d, 0x03, 0x08, 0x00, + 0x08, 0x94, 0xc5, 0xd4, 0x09, 0x05, 0x01, 0x00, 0xc2, 0x94, + 0x03, 0xd4, 0x42, 0x02, 0xc1, 0x92, 0x01, 0xd2, 0x02, 0x97, + 0xc5, 0x94, 0x0a, 0x83, 0xff, 0xff, 0x11, 0xb3, 0x2c, 0x93, + 0x09, 0xb3, 0xfb, 0xff, 0x19, 0xd3, 0x2c, 0x93, 0x03, 0x92, + 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, 0xd9, 0xf6, 0x01, 0x94, + 0xd2, 0x92, 0x19, 0xd3, 0x2c, 0x93, 0x01, 0xd4, 0x02, 0x94, + 0x12, 0x95, 0x2c, 0x93, 0x44, 0xa4, 0x1a, 0xd5, 0x2c, 0x93, + 0x0a, 0xb5, 0xfb, 0xff, 0x1a, 0xd5, 0x2c, 0x93, 0x0b, 0x07, + 0xff, 0xff, 0x40, 0x46, 0x02, 0x5e, 0x0f, 0x9f, 0xc4, 0xf6, + 0x09, 0x63, 0xd4, 0x6c, 0x01, 0x95, 0xc2, 0x96, 0xc5, 0x94, + 0x02, 0xa7, 0xc1, 0xd6, 0x03, 0x92, 0x54, 0x42, 0x02, 0x5e, + 0x0f, 0x9f, 0xe9, 0xf6, 0x0a, 0x83, 0xff, 0xff, 0x1b, 0xb3, + 0x2c, 0x93, 0x45, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x08, 0x0b, 0x01, 0x00, 0x09, 0x63, 0x00, 0x40, 0x19, 0xd3, + 0xf2, 0xbd, 0x40, 0xf0, 0x30, 0xf5, 0x40, 0x42, 0x02, 0x5e, + 0x0f, 0x9f, 0xfd, 0xf6, 0x40, 0xf0, 0x94, 0xf2, 0x0f, 0x9f, + 0x0b, 0xf7, 0x40, 0x96, 0xc8, 0xd6, 0x09, 0x93, 0x91, 0xec, + 0xc8, 0xd2, 0x40, 0xf0, 0x32, 0xef, 0x0a, 0x65, 0xfe, 0x7f, + 0x02, 0x97, 0xc3, 0x92, 0x44, 0xa2, 0xc2, 0xd2, 0x42, 0x00, + 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, + 0x0a, 0x65, 0xe8, 0x43, 0x02, 0x97, 0xc3, 0x92, 0x09, 0xa3, + 0x40, 0x00, 0xc2, 0xd2, 0x0a, 0x65, 0xea, 0x43, 0x02, 0x97, + 0xc3, 0x92, 0x09, 0xb3, 0xfb, 0xff, 0xc2, 0xd2, 0x40, 0x92, + 0x19, 0xd3, 0x2d, 0xbc, 0x0a, 0x65, 0xd8, 0x43, 0x02, 0x97, + 0xc3, 0x92, 0x09, 0xb3, 0xbf, 0xff, 0xc2, 0xd2, 0x88, 0x98, + 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x09, 0x63, + 0xea, 0x43, 0x01, 0x97, 0xc3, 0x94, 0x44, 0xa4, 0xc1, 0xd4, + 0x11, 0x93, 0xb9, 0xec, 0x40, 0x42, 0x02, 0x4e, 0x0f, 0x9f, + 0x64, 0xf7, 0x12, 0x95, 0x93, 0xec, 0x0b, 0x67, 0x36, 0x43, + 0xd2, 0x98, 0x1c, 0xd9, 0xc8, 0xbc, 0xd2, 0x98, 0x03, 0x93, + 0xc1, 0xd8, 0x11, 0x93, 0xb9, 0xec, 0x09, 0x03, 0xff, 0xff, + 0x19, 0xd3, 0xb9, 0xec, 0x40, 0x42, 0x02, 0x5e, 0x0f, 0x9f, + 0x3d, 0xf7, 0x19, 0xd3, 0xb8, 0xec, 0x19, 0xd3, 0xba, 0xec, + 0x0a, 0x05, 0xfe, 0xff, 0xca, 0xd2, 0xca, 0xd2, 0xc2, 0xd2, + 0x0a, 0x65, 0x5e, 0x43, 0x02, 0x97, 0xc3, 0x92, 0x48, 0xa2, + 0xc2, 0xd2, 0x0a, 0x65, 0xea, 0x43, 0x02, 0x99, 0xc4, 0x92, + 0x09, 0xb3, 0xfb, 0xff, 0x0f, 0x9f, 0x6d, 0xf7, 0x11, 0x93, + 0x03, 0xec, 0x19, 0xd3, 0x01, 0x82, 0x0a, 0x65, 0xfd, 0x7d, + 0x02, 0x97, 0xc3, 0x92, 0x43, 0xa2, 0xc2, 0xd2, 0x88, 0x98, + 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, 0x03, 0x92, + 0x04, 0x96, 0x0d, 0x5e, 0x50, 0x46, 0x02, 0x0e, 0x40, 0x92, + 0x09, 0xee, 0x44, 0x46, 0x04, 0x0e, 0x59, 0x93, 0x44, 0x26, + 0x04, 0x5e, 0x46, 0xee, 0x41, 0x93, 0x41, 0x26, 0x43, 0x4e, + 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, 0x08, 0x0b, 0x01, 0x00, + 0x40, 0xf0, 0xb1, 0xfe, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x08, 0x0b, 0x01, 0x00, 0x88, 0x98, 0x90, 0x9a, 0x88, 0xda, + 0x08, 0x0b, 0x01, 0x00, 0x03, 0x94, 0x1a, 0xd5, 0x98, 0xf7, + 0x11, 0x93, 0x00, 0x90, 0x88, 0x98, 0x90, 0x9a, 0x1d, 0x00, + 0x1a, 0x00, 0x03, 0x00, 0x03, 0x00, 0x18, 0x00, 0x19, 0x00, + 0x1a, 0x00, 0x1b, 0x00, 0x16, 0x00, 0x21, 0x00, 0x12, 0x00, + 0x09, 0x00, 0x13, 0x00, 0x19, 0x00, 0x19, 0x00, 0x19, 0x00, + 0x21, 0x00, 0x2d, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x69, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0xf2, 0xc2, 0xf7, + 0x00, 0x00, 0x74, 0xf2, 0xc2, 0xf7, 0x00, 0x00, 0xb9, 0xf2, + 0xbf, 0xf7, 0xc6, 0xf7, 0x00, 0x00, 0x86, 0xf3, 0xc2, 0xf7, + 0x25, 0x47, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; diff --git a/sys/dev/usb/if_zydreg.h b/sys/dev/usb/if_zydreg.h new file mode 100644 index 0000000..05e92f2 --- /dev/null +++ b/sys/dev/usb/if_zydreg.h @@ -0,0 +1,1246 @@ +/* $OpenBSD: if_zydreg.h,v 1.19 2006/11/30 19:28:07 damien Exp $ */ +/* $NetBSD: if_zydreg.h,v 1.2 2007/06/16 11:18:45 kiyohara Exp $ */ +/* $FreeBSD$ */ + +/*- + * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> + * Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * ZyDAS ZD1211/ZD1211B USB WLAN driver. + */ + +#define ZYD_CR_GPI_EN 0x9418 +#define ZYD_CR_RADIO_PD 0x942c +#define ZYD_CR_RF2948_PD 0x942c +#define ZYD_CR_EN_PS_MANUAL_AGC 0x943c +#define ZYD_CR_CONFIG_PHILIPS 0x9440 +#define ZYD_CR_I2C_WRITE 0x9444 +#define ZYD_CR_SA2400_SER_RP 0x9448 +#define ZYD_CR_RADIO_PE 0x9458 +#define ZYD_CR_RST_BUS_MASTER 0x945c +#define ZYD_CR_RFCFG 0x9464 +#define ZYD_CR_HSTSCHG 0x946c +#define ZYD_CR_PHY_ON 0x9474 +#define ZYD_CR_RX_DELAY 0x9478 +#define ZYD_CR_RX_PE_DELAY 0x947c +#define ZYD_CR_GPIO_1 0x9490 +#define ZYD_CR_GPIO_2 0x9494 +#define ZYD_CR_EnZYD_CRyBufMux 0x94a8 +#define ZYD_CR_PS_CTRL 0x9500 +#define ZYD_CR_ADDA_PWR_DWN 0x9504 +#define ZYD_CR_ADDA_MBIAS_WT 0x9508 +#define ZYD_CR_INTERRUPT 0x9510 +#define ZYD_CR_MAC_PS_STATE 0x950c +#define ZYD_CR_ATIM_WND_PERIOD 0x951c +#define ZYD_CR_BCN_INTERVAL 0x9520 +#define ZYD_CR_PRE_TBTT 0x9524 + +/* + * MAC registers. + */ +#define ZYD_MAC_MACADRL 0x9610 /* MAC address (low) */ +#define ZYD_MAC_MACADRH 0x9614 /* MAC address (high) */ +#define ZYD_MAC_BSSADRL 0x9618 /* BSS address (low) */ +#define ZYD_MAC_BSSADRH 0x961c /* BSS address (high) */ +#define ZYD_MAC_BCNCFG 0x9620 /* BCN configuration */ +#define ZYD_MAC_GHTBL 0x9624 /* Group hash table (low) */ +#define ZYD_MAC_GHTBH 0x9628 /* Group hash table (high) */ +#define ZYD_MAC_RX_TIMEOUT 0x962c /* Rx timeout value */ +#define ZYD_MAC_BAS_RATE 0x9630 /* Basic rate setting */ +#define ZYD_MAC_MAN_RATE 0x9634 /* Mandatory rate setting */ +#define ZYD_MAC_RTSCTSRATE 0x9638 /* RTS CTS rate */ +#define ZYD_MAC_BACKOFF_PROTECT 0x963c /* Backoff protection */ +#define ZYD_MAC_RX_THRESHOLD 0x9640 /* Rx threshold */ +#define ZYD_MAC_TX_PE_CONTROL 0x9644 /* Tx_PE control */ +#define ZYD_MAC_AFTER_PNP 0x9648 /* After PnP */ +#define ZYD_MAC_RX_PE_DELAY 0x964c /* Rx_pe delay */ +#define ZYD_MAC_RX_ADDR2_L 0x9650 /* RX address2 (low) */ +#define ZYD_MAC_RX_ADDR2_H 0x9654 /* RX address2 (high) */ +#define ZYD_MAC_SIFS_ACK_TIME 0x9658 /* Dynamic SIFS ack time */ +#define ZYD_MAC_PHY_DELAY 0x9660 /* PHY delay */ +#define ZYD_MAC_PHY_DELAY2 0x966c /* PHY delay */ +#define ZYD_MAC_BCNFIFO 0x9670 /* Beacon FIFO I/O port */ +#define ZYD_MAC_SNIFFER 0x9674 /* Sniffer on/off */ +#define ZYD_MAC_ENCRYPTION_TYPE 0x9678 /* Encryption type */ +#define ZYD_MAC_RETRY 0x967c /* Retry time */ +#define ZYD_MAC_MISC 0x9680 /* Misc */ +#define ZYD_MAC_STMACHINESTAT 0x9684 /* State machine status */ +#define ZYD_MAC_TX_UNDERRUN_CNT 0x9688 /* TX underrun counter */ +#define ZYD_MAC_RXFILTER 0x968c /* Send to host settings */ +#define ZYD_MAC_ACK_EXT 0x9690 /* Acknowledge extension */ +#define ZYD_MAC_BCNFIFOST 0x9694 /* BCN FIFO set and status */ +#define ZYD_MAC_DIFS_EIFS_SIFS 0x9698 /* DIFS, EIFS & SIFS settings */ +#define ZYD_MAC_RX_TIMEOUT_CNT 0x969c /* RX timeout count */ +#define ZYD_MAC_RX_TOTAL_FRAME 0x96a0 /* RX total frame count */ +#define ZYD_MAC_RX_CRC32_CNT 0x96a4 /* RX CRC32 frame count */ +#define ZYD_MAC_RX_CRC16_CNT 0x96a8 /* RX CRC16 frame count */ +#define ZYD_MAC_RX_UDEC 0x96ac /* RX unicast decr. error count */ +#define ZYD_MAC_RX_OVERRUN_CNT 0x96b0 /* RX FIFO overrun count */ +#define ZYD_MAC_RX_MDEC 0x96bc /* RX multicast decr. err. cnt. */ +#define ZYD_MAC_NAV_TCR 0x96c4 /* NAV timer count read */ +#define ZYD_MAC_BACKOFF_ST_RD 0x96c8 /* Backoff status read */ +#define ZYD_MAC_DM_RETRY_CNT_RD 0x96cc /* DM retry count read */ +#define ZYD_MAC_RX_ACR 0x96d0 /* RX arbitration count read */ +#define ZYD_MAC_TX_CCR 0x96d4 /* Tx complete count read */ +#define ZYD_MAC_TCB_ADDR 0x96e8 /* Current PCI process TCP addr */ +#define ZYD_MAC_RCB_ADDR 0x96ec /* Next RCB address */ +#define ZYD_MAC_CONT_WIN_LIMIT 0x96f0 /* Contention window limit */ +#define ZYD_MAC_TX_PKT 0x96f4 /* Tx total packet count read */ +#define ZYD_MAC_DL_CTRL 0x96f8 /* Download control */ +#define ZYD_MACB_TXPWR_CTL1 0x9b00 +#define ZYD_MACB_TXPWR_CTL2 0x9b04 +#define ZYD_MACB_TXPWR_CTL3 0x9b08 +#define ZYD_MACB_TXPWR_CTL4 0x9b0c +#define ZYD_MACB_AIFS_CTL1 0x9b10 +#define ZYD_MACB_AIFS_CTL2 0x9b14 +#define ZYD_MACB_TXOP 0x9b20 +#define ZYD_MACB_MAX_RETRY 0x9b28 + +/* + * Miscellanous registers. + */ +#define ZYD_FIRMWARE_START_ADDR 0xee00 +#define ZYD_FIRMWARE_BASE_ADDR 0xee1d /* Firmware base address */ + +/* + * EEPROM registers. + */ +#define ZYD_EEPROM_START_HEAD 0xf800 /* EEPROM start */ +#define ZYD_EEPROM_SUBID 0xf817 +#define ZYD_EEPROM_POD 0xf819 +#define ZYD_EEPROM_MAC_ADDR_P1 0xf81b /* Part 1 of the MAC address */ +#define ZYD_EEPROM_MAC_ADDR_P2 0xf81d /* Part 2 of the MAC address */ +#define ZYD_EEPROM_PWR_CAL 0xf81f /* Calibration */ +#define ZYD_EEPROM_PWR_INT 0xf827 /* Calibration */ +#define ZYD_EEPROM_ALLOWEDCHAN 0xf82f /* Allowed CH mask, 1 bit each */ +#define ZYD_EEPROM_PHY_REG 0xf831 /* PHY registers */ +#define ZYD_EEPROM_DEVICE_VER 0xf837 /* Device version */ +#define ZYD_EEPROM_36M_CAL 0xf83f /* Calibration */ +#define ZYD_EEPROM_11A_INT 0xf847 /* Interpolation */ +#define ZYD_EEPROM_48M_CAL 0xf84f /* Calibration */ +#define ZYD_EEPROM_48M_INT 0xf857 /* Interpolation */ +#define ZYD_EEPROM_54M_CAL 0xf85f /* Calibration */ +#define ZYD_EEPROM_54M_INT 0xf867 /* Interpolation */ + +/* + * Firmware registers offsets (relative to fwbase). + */ +#define ZYD_FW_FIRMWARE_REV 0x0000 /* Firmware version */ +#define ZYD_FW_USB_SPEED 0x0001 /* USB speed (!=0 if highspeed) */ +#define ZYD_FW_FIX_TX_RATE 0x0002 /* Fixed TX rate */ +#define ZYD_FW_LINK_STATUS 0x0003 +#define ZYD_FW_SOFT_RESET 0x0004 +#define ZYD_FW_FLASH_CHK 0x0005 + +/* possible flags for register ZYD_FW_LINK_STATUS */ +#define ZYD_LED1 (1 << 8) +#define ZYD_LED2 (1 << 9) + +/* + * RF IDs. + */ +#define ZYD_RF_UW2451 0x2 /* not supported yet */ +#define ZYD_RF_UCHIP 0x3 /* not supported yet */ +#define ZYD_RF_AL2230 0x4 +#define ZYD_RF_AL7230B 0x5 +#define ZYD_RF_THETA 0x6 /* not supported yet */ +#define ZYD_RF_AL2210 0x7 +#define ZYD_RF_MAXIM_NEW 0x8 +#define ZYD_RF_GCT 0x9 +#define ZYD_RF_PV2000 0xa /* not supported yet */ +#define ZYD_RF_RALINK 0xb /* not supported yet */ +#define ZYD_RF_INTERSIL 0xc /* not supported yet */ +#define ZYD_RF_RFMD 0xd +#define ZYD_RF_MAXIM_NEW2 0xe +#define ZYD_RF_PHILIPS 0xf /* not supported yet */ + +/* + * PHY registers (8 bits, not documented). + */ +#define ZYD_CR0 0x9000 +#define ZYD_CR1 0x9004 +#define ZYD_CR2 0x9008 +#define ZYD_CR3 0x900c +#define ZYD_CR5 0x9010 +#define ZYD_CR6 0x9014 +#define ZYD_CR7 0x9018 +#define ZYD_CR8 0x901c +#define ZYD_CR4 0x9020 +#define ZYD_CR9 0x9024 +#define ZYD_CR10 0x9028 +#define ZYD_CR11 0x902c +#define ZYD_CR12 0x9030 +#define ZYD_CR13 0x9034 +#define ZYD_CR14 0x9038 +#define ZYD_CR15 0x903c +#define ZYD_CR16 0x9040 +#define ZYD_CR17 0x9044 +#define ZYD_CR18 0x9048 +#define ZYD_CR19 0x904c +#define ZYD_CR20 0x9050 +#define ZYD_CR21 0x9054 +#define ZYD_CR22 0x9058 +#define ZYD_CR23 0x905c +#define ZYD_CR24 0x9060 +#define ZYD_CR25 0x9064 +#define ZYD_CR26 0x9068 +#define ZYD_CR27 0x906c +#define ZYD_CR28 0x9070 +#define ZYD_CR29 0x9074 +#define ZYD_CR30 0x9078 +#define ZYD_CR31 0x907c +#define ZYD_CR32 0x9080 +#define ZYD_CR33 0x9084 +#define ZYD_CR34 0x9088 +#define ZYD_CR35 0x908c +#define ZYD_CR36 0x9090 +#define ZYD_CR37 0x9094 +#define ZYD_CR38 0x9098 +#define ZYD_CR39 0x909c +#define ZYD_CR40 0x90a0 +#define ZYD_CR41 0x90a4 +#define ZYD_CR42 0x90a8 +#define ZYD_CR43 0x90ac +#define ZYD_CR44 0x90b0 +#define ZYD_CR45 0x90b4 +#define ZYD_CR46 0x90b8 +#define ZYD_CR47 0x90bc +#define ZYD_CR48 0x90c0 +#define ZYD_CR49 0x90c4 +#define ZYD_CR50 0x90c8 +#define ZYD_CR51 0x90cc +#define ZYD_CR52 0x90d0 +#define ZYD_CR53 0x90d4 +#define ZYD_CR54 0x90d8 +#define ZYD_CR55 0x90dc +#define ZYD_CR56 0x90e0 +#define ZYD_CR57 0x90e4 +#define ZYD_CR58 0x90e8 +#define ZYD_CR59 0x90ec +#define ZYD_CR60 0x90f0 +#define ZYD_CR61 0x90f4 +#define ZYD_CR62 0x90f8 +#define ZYD_CR63 0x90fc +#define ZYD_CR64 0x9100 +#define ZYD_CR65 0x9104 +#define ZYD_CR66 0x9108 +#define ZYD_CR67 0x910c +#define ZYD_CR68 0x9110 +#define ZYD_CR69 0x9114 +#define ZYD_CR70 0x9118 +#define ZYD_CR71 0x911c +#define ZYD_CR72 0x9120 +#define ZYD_CR73 0x9124 +#define ZYD_CR74 0x9128 +#define ZYD_CR75 0x912c +#define ZYD_CR76 0x9130 +#define ZYD_CR77 0x9134 +#define ZYD_CR78 0x9138 +#define ZYD_CR79 0x913c +#define ZYD_CR80 0x9140 +#define ZYD_CR81 0x9144 +#define ZYD_CR82 0x9148 +#define ZYD_CR83 0x914c +#define ZYD_CR84 0x9150 +#define ZYD_CR85 0x9154 +#define ZYD_CR86 0x9158 +#define ZYD_CR87 0x915c +#define ZYD_CR88 0x9160 +#define ZYD_CR89 0x9164 +#define ZYD_CR90 0x9168 +#define ZYD_CR91 0x916c +#define ZYD_CR92 0x9170 +#define ZYD_CR93 0x9174 +#define ZYD_CR94 0x9178 +#define ZYD_CR95 0x917c +#define ZYD_CR96 0x9180 +#define ZYD_CR97 0x9184 +#define ZYD_CR98 0x9188 +#define ZYD_CR99 0x918c +#define ZYD_CR100 0x9190 +#define ZYD_CR101 0x9194 +#define ZYD_CR102 0x9198 +#define ZYD_CR103 0x919c +#define ZYD_CR104 0x91a0 +#define ZYD_CR105 0x91a4 +#define ZYD_CR106 0x91a8 +#define ZYD_CR107 0x91ac +#define ZYD_CR108 0x91b0 +#define ZYD_CR109 0x91b4 +#define ZYD_CR110 0x91b8 +#define ZYD_CR111 0x91bc +#define ZYD_CR112 0x91c0 +#define ZYD_CR113 0x91c4 +#define ZYD_CR114 0x91c8 +#define ZYD_CR115 0x91cc +#define ZYD_CR116 0x91d0 +#define ZYD_CR117 0x91d4 +#define ZYD_CR118 0x91d8 +#define ZYD_CR119 0x91dc +#define ZYD_CR120 0x91e0 +#define ZYD_CR121 0x91e4 +#define ZYD_CR122 0x91e8 +#define ZYD_CR123 0x91ec +#define ZYD_CR124 0x91f0 +#define ZYD_CR125 0x91f4 +#define ZYD_CR126 0x91f8 +#define ZYD_CR127 0x91fc +#define ZYD_CR128 0x9200 +#define ZYD_CR129 0x9204 +#define ZYD_CR130 0x9208 +#define ZYD_CR131 0x920c +#define ZYD_CR132 0x9210 +#define ZYD_CR133 0x9214 +#define ZYD_CR134 0x9218 +#define ZYD_CR135 0x921c +#define ZYD_CR136 0x9220 +#define ZYD_CR137 0x9224 +#define ZYD_CR138 0x9228 +#define ZYD_CR139 0x922c +#define ZYD_CR140 0x9230 +#define ZYD_CR141 0x9234 +#define ZYD_CR142 0x9238 +#define ZYD_CR143 0x923c +#define ZYD_CR144 0x9240 +#define ZYD_CR145 0x9244 +#define ZYD_CR146 0x9248 +#define ZYD_CR147 0x924c +#define ZYD_CR148 0x9250 +#define ZYD_CR149 0x9254 +#define ZYD_CR150 0x9258 +#define ZYD_CR151 0x925c +#define ZYD_CR152 0x9260 +#define ZYD_CR153 0x9264 +#define ZYD_CR154 0x9268 +#define ZYD_CR155 0x926c +#define ZYD_CR156 0x9270 +#define ZYD_CR157 0x9274 +#define ZYD_CR158 0x9278 +#define ZYD_CR159 0x927c +#define ZYD_CR160 0x9280 +#define ZYD_CR161 0x9284 +#define ZYD_CR162 0x9288 +#define ZYD_CR163 0x928c +#define ZYD_CR164 0x9290 +#define ZYD_CR165 0x9294 +#define ZYD_CR166 0x9298 +#define ZYD_CR167 0x929c +#define ZYD_CR168 0x92a0 +#define ZYD_CR169 0x92a4 +#define ZYD_CR170 0x92a8 +#define ZYD_CR171 0x92ac +#define ZYD_CR172 0x92b0 +#define ZYD_CR173 0x92b4 +#define ZYD_CR174 0x92b8 +#define ZYD_CR175 0x92bc +#define ZYD_CR176 0x92c0 +#define ZYD_CR177 0x92c4 +#define ZYD_CR178 0x92c8 +#define ZYD_CR179 0x92cc +#define ZYD_CR180 0x92d0 +#define ZYD_CR181 0x92d4 +#define ZYD_CR182 0x92d8 +#define ZYD_CR183 0x92dc +#define ZYD_CR184 0x92e0 +#define ZYD_CR185 0x92e4 +#define ZYD_CR186 0x92e8 +#define ZYD_CR187 0x92ec +#define ZYD_CR188 0x92f0 +#define ZYD_CR189 0x92f4 +#define ZYD_CR190 0x92f8 +#define ZYD_CR191 0x92fc +#define ZYD_CR192 0x9300 +#define ZYD_CR193 0x9304 +#define ZYD_CR194 0x9308 +#define ZYD_CR195 0x930c +#define ZYD_CR196 0x9310 +#define ZYD_CR197 0x9314 +#define ZYD_CR198 0x9318 +#define ZYD_CR199 0x931c +#define ZYD_CR200 0x9320 +#define ZYD_CR201 0x9324 +#define ZYD_CR202 0x9328 +#define ZYD_CR203 0x932c +#define ZYD_CR204 0x9330 +#define ZYD_CR205 0x9334 +#define ZYD_CR206 0x9338 +#define ZYD_CR207 0x933c +#define ZYD_CR208 0x9340 +#define ZYD_CR209 0x9344 +#define ZYD_CR210 0x9348 +#define ZYD_CR211 0x934c +#define ZYD_CR212 0x9350 +#define ZYD_CR213 0x9354 +#define ZYD_CR214 0x9358 +#define ZYD_CR215 0x935c +#define ZYD_CR216 0x9360 +#define ZYD_CR217 0x9364 +#define ZYD_CR218 0x9368 +#define ZYD_CR219 0x936c +#define ZYD_CR220 0x9370 +#define ZYD_CR221 0x9374 +#define ZYD_CR222 0x9378 +#define ZYD_CR223 0x937c +#define ZYD_CR224 0x9380 +#define ZYD_CR225 0x9384 +#define ZYD_CR226 0x9388 +#define ZYD_CR227 0x938c +#define ZYD_CR228 0x9390 +#define ZYD_CR229 0x9394 +#define ZYD_CR230 0x9398 +#define ZYD_CR231 0x939c +#define ZYD_CR232 0x93a0 +#define ZYD_CR233 0x93a4 +#define ZYD_CR234 0x93a8 +#define ZYD_CR235 0x93ac +#define ZYD_CR236 0x93b0 +#define ZYD_CR240 0x93c0 +#define ZYD_CR241 0x93c4 +#define ZYD_CR242 0x93c8 +#define ZYD_CR243 0x93cc +#define ZYD_CR244 0x93d0 +#define ZYD_CR245 0x93d4 +#define ZYD_CR251 0x93ec +#define ZYD_CR252 0x93f0 +#define ZYD_CR253 0x93f4 +#define ZYD_CR254 0x93f8 +#define ZYD_CR255 0x93fc + +/* copied nearly verbatim from the Linux driver rewrite */ +#define ZYD_DEF_PHY \ +{ \ + { ZYD_CR0, 0x0a }, { ZYD_CR1, 0x06 }, { ZYD_CR2, 0x26 }, \ + { ZYD_CR3, 0x38 }, { ZYD_CR4, 0x80 }, { ZYD_CR9, 0xa0 }, \ + { ZYD_CR10, 0x81 }, { ZYD_CR11, 0x00 }, { ZYD_CR12, 0x7f }, \ + { ZYD_CR13, 0x8c }, { ZYD_CR14, 0x80 }, { ZYD_CR15, 0x3d }, \ + { ZYD_CR16, 0x20 }, { ZYD_CR17, 0x1e }, { ZYD_CR18, 0x0a }, \ + { ZYD_CR19, 0x48 }, { ZYD_CR20, 0x0c }, { ZYD_CR21, 0x0c }, \ + { ZYD_CR22, 0x23 }, { ZYD_CR23, 0x90 }, { ZYD_CR24, 0x14 }, \ + { ZYD_CR25, 0x40 }, { ZYD_CR26, 0x10 }, { ZYD_CR27, 0x19 }, \ + { ZYD_CR28, 0x7f }, { ZYD_CR29, 0x80 }, { ZYD_CR30, 0x4b }, \ + { ZYD_CR31, 0x60 }, { ZYD_CR32, 0x43 }, { ZYD_CR33, 0x08 }, \ + { ZYD_CR34, 0x06 }, { ZYD_CR35, 0x0a }, { ZYD_CR36, 0x00 }, \ + { ZYD_CR37, 0x00 }, { ZYD_CR38, 0x38 }, { ZYD_CR39, 0x0c }, \ + { ZYD_CR40, 0x84 }, { ZYD_CR41, 0x2a }, { ZYD_CR42, 0x80 }, \ + { ZYD_CR43, 0x10 }, { ZYD_CR44, 0x12 }, { ZYD_CR46, 0xff }, \ + { ZYD_CR47, 0x08 }, { ZYD_CR48, 0x26 }, { ZYD_CR49, 0x5b }, \ + { ZYD_CR64, 0xd0 }, { ZYD_CR65, 0x04 }, { ZYD_CR66, 0x58 }, \ + { ZYD_CR67, 0xc9 }, { ZYD_CR68, 0x88 }, { ZYD_CR69, 0x41 }, \ + { ZYD_CR70, 0x23 }, { ZYD_CR71, 0x10 }, { ZYD_CR72, 0xff }, \ + { ZYD_CR73, 0x32 }, { ZYD_CR74, 0x30 }, { ZYD_CR75, 0x65 }, \ + { ZYD_CR76, 0x41 }, { ZYD_CR77, 0x1b }, { ZYD_CR78, 0x30 }, \ + { ZYD_CR79, 0x68 }, { ZYD_CR80, 0x64 }, { ZYD_CR81, 0x64 }, \ + { ZYD_CR82, 0x00 }, { ZYD_CR83, 0x00 }, { ZYD_CR84, 0x00 }, \ + { ZYD_CR85, 0x02 }, { ZYD_CR86, 0x00 }, { ZYD_CR87, 0x00 }, \ + { ZYD_CR88, 0xff }, { ZYD_CR89, 0xfc }, { ZYD_CR90, 0x00 }, \ + { ZYD_CR91, 0x00 }, { ZYD_CR92, 0x00 }, { ZYD_CR93, 0x08 }, \ + { ZYD_CR94, 0x00 }, { ZYD_CR95, 0x00 }, { ZYD_CR96, 0xff }, \ + { ZYD_CR97, 0xe7 }, { ZYD_CR98, 0x00 }, { ZYD_CR99, 0x00 }, \ + { ZYD_CR100, 0x00 }, { ZYD_CR101, 0xae }, { ZYD_CR102, 0x02 }, \ + { ZYD_CR103, 0x00 }, { ZYD_CR104, 0x03 }, { ZYD_CR105, 0x65 }, \ + { ZYD_CR106, 0x04 }, { ZYD_CR107, 0x00 }, { ZYD_CR108, 0x0a }, \ + { ZYD_CR109, 0xaa }, { ZYD_CR110, 0xaa }, { ZYD_CR111, 0x25 }, \ + { ZYD_CR112, 0x25 }, { ZYD_CR113, 0x00 }, { ZYD_CR119, 0x1e }, \ + { ZYD_CR125, 0x90 }, { ZYD_CR126, 0x00 }, { ZYD_CR127, 0x00 }, \ + { ZYD_CR5, 0x00 }, { ZYD_CR6, 0x00 }, { ZYD_CR7, 0x00 }, \ + { ZYD_CR8, 0x00 }, { ZYD_CR9, 0x20 }, { ZYD_CR12, 0xf0 }, \ + { ZYD_CR20, 0x0e }, { ZYD_CR21, 0x0e }, { ZYD_CR27, 0x10 }, \ + { ZYD_CR44, 0x33 }, { ZYD_CR47, 0x30 }, { ZYD_CR83, 0x24 }, \ + { ZYD_CR84, 0x04 }, { ZYD_CR85, 0x00 }, { ZYD_CR86, 0x0C }, \ + { ZYD_CR87, 0x12 }, { ZYD_CR88, 0x0C }, { ZYD_CR89, 0x00 }, \ + { ZYD_CR90, 0x10 }, { ZYD_CR91, 0x08 }, { ZYD_CR93, 0x00 }, \ + { ZYD_CR94, 0x01 }, { ZYD_CR95, 0x00 }, { ZYD_CR96, 0x50 }, \ + { ZYD_CR97, 0x37 }, { ZYD_CR98, 0x35 }, { ZYD_CR101, 0x13 }, \ + { ZYD_CR102, 0x27 }, { ZYD_CR103, 0x27 }, { ZYD_CR104, 0x18 }, \ + { ZYD_CR105, 0x12 }, { ZYD_CR109, 0x27 }, { ZYD_CR110, 0x27 }, \ + { ZYD_CR111, 0x27 }, { ZYD_CR112, 0x27 }, { ZYD_CR113, 0x27 }, \ + { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x26 }, { ZYD_CR116, 0x24 }, \ + { ZYD_CR117, 0xfc }, { ZYD_CR118, 0xfa }, { ZYD_CR120, 0x4f }, \ + { ZYD_CR123, 0x27 }, { ZYD_CR125, 0xaa }, { ZYD_CR127, 0x03 }, \ + { ZYD_CR128, 0x14 }, { ZYD_CR129, 0x12 }, { ZYD_CR130, 0x10 }, \ + { ZYD_CR131, 0x0C }, { ZYD_CR136, 0xdf }, { ZYD_CR137, 0x40 }, \ + { ZYD_CR138, 0xa0 }, { ZYD_CR139, 0xb0 }, { ZYD_CR140, 0x99 }, \ + { ZYD_CR141, 0x82 }, { ZYD_CR142, 0x54 }, { ZYD_CR143, 0x1c }, \ + { ZYD_CR144, 0x6c }, { ZYD_CR147, 0x07 }, { ZYD_CR148, 0x4c }, \ + { ZYD_CR149, 0x50 }, { ZYD_CR150, 0x0e }, { ZYD_CR151, 0x18 }, \ + { ZYD_CR160, 0xfe }, { ZYD_CR161, 0xee }, { ZYD_CR162, 0xaa }, \ + { ZYD_CR163, 0xfa }, { ZYD_CR164, 0xfa }, { ZYD_CR165, 0xea }, \ + { ZYD_CR166, 0xbe }, { ZYD_CR167, 0xbe }, { ZYD_CR168, 0x6a }, \ + { ZYD_CR169, 0xba }, { ZYD_CR170, 0xba }, { ZYD_CR171, 0xba }, \ + { ZYD_CR204, 0x7d }, { ZYD_CR203, 0x30 }, \ + { 0, 0 } \ +} + +#define ZYD_DEF_PHYB \ +{ \ + { ZYD_CR0, 0x14 }, { ZYD_CR1, 0x06 }, { ZYD_CR2, 0x26 }, \ + { ZYD_CR3, 0x38 }, { ZYD_CR4, 0x80 }, { ZYD_CR9, 0xe0 }, \ + { ZYD_CR10, 0x81 }, { ZYD_CR11, 0x00 }, { ZYD_CR12, 0xf0 }, \ + { ZYD_CR13, 0x8c }, { ZYD_CR14, 0x80 }, { ZYD_CR15, 0x3d }, \ + { ZYD_CR16, 0x20 }, { ZYD_CR17, 0x1e }, { ZYD_CR18, 0x0a }, \ + { ZYD_CR19, 0x48 }, { ZYD_CR20, 0x10 }, { ZYD_CR21, 0x0e }, \ + { ZYD_CR22, 0x23 }, { ZYD_CR23, 0x90 }, { ZYD_CR24, 0x14 }, \ + { ZYD_CR25, 0x40 }, { ZYD_CR26, 0x10 }, { ZYD_CR27, 0x10 }, \ + { ZYD_CR28, 0x7f }, { ZYD_CR29, 0x80 }, { ZYD_CR30, 0x4b }, \ + { ZYD_CR31, 0x60 }, { ZYD_CR32, 0x43 }, { ZYD_CR33, 0x08 }, \ + { ZYD_CR34, 0x06 }, { ZYD_CR35, 0x0a }, { ZYD_CR36, 0x00 }, \ + { ZYD_CR37, 0x00 }, { ZYD_CR38, 0x38 }, { ZYD_CR39, 0x0c }, \ + { ZYD_CR40, 0x84 }, { ZYD_CR41, 0x2a }, { ZYD_CR42, 0x80 }, \ + { ZYD_CR43, 0x10 }, { ZYD_CR44, 0x33 }, { ZYD_CR46, 0xff }, \ + { ZYD_CR47, 0x1E }, { ZYD_CR48, 0x26 }, { ZYD_CR49, 0x5b }, \ + { ZYD_CR64, 0xd0 }, { ZYD_CR65, 0x04 }, { ZYD_CR66, 0x58 }, \ + { ZYD_CR67, 0xc9 }, { ZYD_CR68, 0x88 }, { ZYD_CR69, 0x41 }, \ + { ZYD_CR70, 0x23 }, { ZYD_CR71, 0x10 }, { ZYD_CR72, 0xff }, \ + { ZYD_CR73, 0x32 }, { ZYD_CR74, 0x30 }, { ZYD_CR75, 0x65 }, \ + { ZYD_CR76, 0x41 }, { ZYD_CR77, 0x1b }, { ZYD_CR78, 0x30 }, \ + { ZYD_CR79, 0xf0 }, { ZYD_CR80, 0x64 }, { ZYD_CR81, 0x64 }, \ + { ZYD_CR82, 0x00 }, { ZYD_CR83, 0x24 }, { ZYD_CR84, 0x04 }, \ + { ZYD_CR85, 0x00 }, { ZYD_CR86, 0x0c }, { ZYD_CR87, 0x12 }, \ + { ZYD_CR88, 0x0c }, { ZYD_CR89, 0x00 }, { ZYD_CR90, 0x58 }, \ + { ZYD_CR91, 0x04 }, { ZYD_CR92, 0x00 }, { ZYD_CR93, 0x00 }, \ + { ZYD_CR94, 0x01 }, { ZYD_CR95, 0x20 }, { ZYD_CR96, 0x50 }, \ + { ZYD_CR97, 0x37 }, { ZYD_CR98, 0x35 }, { ZYD_CR99, 0x00 }, \ + { ZYD_CR100, 0x01 }, { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, \ + { ZYD_CR103, 0x27 }, { ZYD_CR104, 0x18 }, { ZYD_CR105, 0x12 }, \ + { ZYD_CR106, 0x04 }, { ZYD_CR107, 0x00 }, { ZYD_CR108, 0x0a }, \ + { ZYD_CR109, 0x27 }, { ZYD_CR110, 0x27 }, { ZYD_CR111, 0x27 }, \ + { ZYD_CR112, 0x27 }, { ZYD_CR113, 0x27 }, { ZYD_CR114, 0x27 }, \ + { ZYD_CR115, 0x26 }, { ZYD_CR116, 0x24 }, { ZYD_CR117, 0xfc }, \ + { ZYD_CR118, 0xfa }, { ZYD_CR119, 0x1e }, { ZYD_CR125, 0x90 }, \ + { ZYD_CR126, 0x00 }, { ZYD_CR127, 0x00 }, { ZYD_CR128, 0x14 }, \ + { ZYD_CR129, 0x12 }, { ZYD_CR130, 0x10 }, { ZYD_CR131, 0x0c }, \ + { ZYD_CR136, 0xdf }, { ZYD_CR137, 0xa0 }, { ZYD_CR138, 0xa8 }, \ + { ZYD_CR139, 0xb4 }, { ZYD_CR140, 0x98 }, { ZYD_CR141, 0x82 }, \ + { ZYD_CR142, 0x53 }, { ZYD_CR143, 0x1c }, { ZYD_CR144, 0x6c }, \ + { ZYD_CR147, 0x07 }, { ZYD_CR148, 0x40 }, { ZYD_CR149, 0x40 }, \ + { ZYD_CR150, 0x14 }, { ZYD_CR151, 0x18 }, { ZYD_CR159, 0x70 }, \ + { ZYD_CR160, 0xfe }, { ZYD_CR161, 0xee }, { ZYD_CR162, 0xaa }, \ + { ZYD_CR163, 0xfa }, { ZYD_CR164, 0xfa }, { ZYD_CR165, 0xea }, \ + { ZYD_CR166, 0xbe }, { ZYD_CR167, 0xbe }, { ZYD_CR168, 0x6a }, \ + { ZYD_CR169, 0xba }, { ZYD_CR170, 0xba }, { ZYD_CR171, 0xba }, \ + { ZYD_CR204, 0x7d }, { ZYD_CR203, 0x30 }, \ + { 0, 0 } \ +} + +#define ZYD_RFMD_PHY \ +{ \ + { ZYD_CR2, 0x1e }, { ZYD_CR9, 0x20 }, { ZYD_CR10, 0x89 }, \ + { ZYD_CR11, 0x00 }, { ZYD_CR15, 0xd0 }, { ZYD_CR17, 0x68 }, \ + { ZYD_CR19, 0x4a }, { ZYD_CR20, 0x0c }, { ZYD_CR21, 0x0e }, \ + { ZYD_CR23, 0x48 }, { ZYD_CR24, 0x14 }, { ZYD_CR26, 0x90 }, \ + { ZYD_CR27, 0x30 }, { ZYD_CR29, 0x20 }, { ZYD_CR31, 0xb2 }, \ + { ZYD_CR32, 0x43 }, { ZYD_CR33, 0x28 }, { ZYD_CR38, 0x30 }, \ + { ZYD_CR34, 0x0f }, { ZYD_CR35, 0xf0 }, { ZYD_CR41, 0x2a }, \ + { ZYD_CR46, 0x7f }, { ZYD_CR47, 0x1e }, { ZYD_CR51, 0xc5 }, \ + { ZYD_CR52, 0xc5 }, { ZYD_CR53, 0xc5 }, { ZYD_CR79, 0x58 }, \ + { ZYD_CR80, 0x30 }, { ZYD_CR81, 0x30 }, { ZYD_CR82, 0x00 }, \ + { ZYD_CR83, 0x24 }, { ZYD_CR84, 0x04 }, { ZYD_CR85, 0x00 }, \ + { ZYD_CR86, 0x10 }, { ZYD_CR87, 0x2a }, { ZYD_CR88, 0x10 }, \ + { ZYD_CR89, 0x24 }, { ZYD_CR90, 0x18 }, { ZYD_CR91, 0x00 }, \ + { ZYD_CR92, 0x0a }, { ZYD_CR93, 0x00 }, { ZYD_CR94, 0x01 }, \ + { ZYD_CR95, 0x00 }, { ZYD_CR96, 0x40 }, { ZYD_CR97, 0x37 }, \ + { ZYD_CR98, 0x05 }, { ZYD_CR99, 0x28 }, { ZYD_CR100, 0x00 }, \ + { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, { ZYD_CR103, 0x27 }, \ + { ZYD_CR104, 0x18 }, { ZYD_CR105, 0x12 }, { ZYD_CR106, 0x1a }, \ + { ZYD_CR107, 0x24 }, { ZYD_CR108, 0x0a }, { ZYD_CR109, 0x13 }, \ + { ZYD_CR110, 0x2f }, { ZYD_CR111, 0x27 }, { ZYD_CR112, 0x27 }, \ + { ZYD_CR113, 0x27 }, { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x40 }, \ + { ZYD_CR116, 0x40 }, { ZYD_CR117, 0xf0 }, { ZYD_CR118, 0xf0 }, \ + { ZYD_CR119, 0x16 }, { ZYD_CR122, 0x00 }, { ZYD_CR127, 0x03 }, \ + { ZYD_CR131, 0x08 }, { ZYD_CR138, 0x28 }, { ZYD_CR148, 0x44 }, \ + { ZYD_CR150, 0x10 }, { ZYD_CR169, 0xbb }, { ZYD_CR170, 0xbb } \ +} + +#define ZYD_RFMD_RF \ +{ \ + 0x000007, 0x07dd43, 0x080959, 0x0e6666, 0x116a57, 0x17dd43, \ + 0x1819f9, 0x1e6666, 0x214554, 0x25e7fa, 0x27fffa, 0x294128, \ + 0x2c0000, 0x300000, 0x340000, 0x381e0f, 0x6c180f \ +} + +#define ZYD_RFMD_CHANTABLE \ +{ \ + { 0x181979, 0x1e6666 }, \ + { 0x181989, 0x1e6666 }, \ + { 0x181999, 0x1e6666 }, \ + { 0x1819a9, 0x1e6666 }, \ + { 0x1819b9, 0x1e6666 }, \ + { 0x1819c9, 0x1e6666 }, \ + { 0x1819d9, 0x1e6666 }, \ + { 0x1819e9, 0x1e6666 }, \ + { 0x1819f9, 0x1e6666 }, \ + { 0x181a09, 0x1e6666 }, \ + { 0x181a19, 0x1e6666 }, \ + { 0x181a29, 0x1e6666 }, \ + { 0x181a39, 0x1e6666 }, \ + { 0x181a60, 0x1c0000 } \ +} + + + +#define ZYD_AL2230_PHY \ +{ \ + { ZYD_CR15, 0x20 }, { ZYD_CR23, 0x40 }, { ZYD_CR24, 0x20 }, \ + { ZYD_CR26, 0x11 }, { ZYD_CR28, 0x3e }, { ZYD_CR29, 0x00 }, \ + { ZYD_CR44, 0x33 }, { ZYD_CR106, 0x2a }, { ZYD_CR107, 0x1a }, \ + { ZYD_CR109, 0x09 }, { ZYD_CR110, 0x27 }, { ZYD_CR111, 0x2b }, \ + { ZYD_CR112, 0x2b }, { ZYD_CR119, 0x0a }, { ZYD_CR10, 0x89 }, \ + { ZYD_CR17, 0x28 }, { ZYD_CR26, 0x93 }, { ZYD_CR34, 0x30 }, \ + { ZYD_CR35, 0x3e }, { ZYD_CR41, 0x24 }, { ZYD_CR44, 0x32 }, \ + { ZYD_CR46, 0x96 }, { ZYD_CR47, 0x1e }, { ZYD_CR79, 0x58 }, \ + { ZYD_CR80, 0x30 }, { ZYD_CR81, 0x30 }, { ZYD_CR87, 0x0a }, \ + { ZYD_CR89, 0x04 }, { ZYD_CR92, 0x0a }, { ZYD_CR99, 0x28 }, \ + { ZYD_CR100, 0x00 }, { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, \ + { ZYD_CR106, 0x24 }, { ZYD_CR107, 0x2a }, { ZYD_CR109, 0x09 }, \ + { ZYD_CR110, 0x13 }, { ZYD_CR111, 0x1f }, { ZYD_CR112, 0x1f }, \ + { ZYD_CR113, 0x27 }, { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x24 }, \ + { ZYD_CR116, 0x24 }, { ZYD_CR117, 0xf4 }, { ZYD_CR118, 0xfc }, \ + { ZYD_CR119, 0x10 }, { ZYD_CR120, 0x4f }, { ZYD_CR121, 0x77 }, \ + { ZYD_CR122, 0xe0 }, { ZYD_CR137, 0x88 }, { ZYD_CR252, 0xff }, \ + { ZYD_CR253, 0xff }, { ZYD_CR251, 0x2f }, { ZYD_CR251, 0x3f }, \ + { ZYD_CR138, 0x28 }, { ZYD_CR203, 0x06 } \ +} + +#define ZYD_AL2230_PHY_B \ +{ \ + { ZYD_CR10, 0x89 }, { ZYD_CR15, 0x20 }, { ZYD_CR17, 0x2b }, \ + { ZYD_CR23, 0x40 }, { ZYD_CR24, 0x20 }, { ZYD_CR26, 0x93 }, \ + { ZYD_CR28, 0x3e }, { ZYD_CR29, 0x00 }, { ZYD_CR33, 0x28 }, \ + { ZYD_CR34, 0x30 }, { ZYD_CR35, 0x3e }, { ZYD_CR41, 0x24 }, \ + { ZYD_CR44, 0x32 }, { ZYD_CR46, 0x99 }, { ZYD_CR47, 0x1e }, \ + { ZYD_CR48, 0x00 }, { ZYD_CR49, 0x00 }, { ZYD_CR51, 0x01 }, \ + { ZYD_CR52, 0x80 }, { ZYD_CR53, 0x7e }, { ZYD_CR65, 0x00 }, \ + { ZYD_CR66, 0x00 }, { ZYD_CR67, 0x00 }, { ZYD_CR68, 0x00 }, \ + { ZYD_CR69, 0x28 }, { ZYD_CR79, 0x58 }, { ZYD_CR80, 0x30 }, \ + { ZYD_CR81, 0x30 }, { ZYD_CR87, 0x0a }, { ZYD_CR89, 0x04 }, \ + { ZYD_CR91, 0x00 }, { ZYD_CR92, 0x0a }, { ZYD_CR98, 0x8d }, \ + { ZYD_CR99, 0x00 }, { ZYD_CR101, 0x13 }, { ZYD_CR106, 0x24 }, \ + { ZYD_CR107, 0x2a }, { ZYD_CR109, 0x13 }, { ZYD_CR110, 0x1f }, \ + { ZYD_CR111, 0x1f }, { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x26 }, \ + { ZYD_CR116, 0x24 }, { ZYD_CR117, 0xfa }, { ZYD_CR118, 0xfa }, \ + { ZYD_CR119, 0x10 }, { ZYD_CR120, 0x4f }, { ZYD_CR121, 0x6c }, \ + { ZYD_CR122, 0xfc }, { ZYD_CR123, 0x57 }, { ZYD_CR125, 0xad }, \ + { ZYD_CR126, 0x6c }, { ZYD_CR127, 0x03 }, { ZYD_CR137, 0x50 }, \ + { ZYD_CR138, 0xa8 }, { ZYD_CR144, 0xac }, { ZYD_CR150, 0x0d }, \ + { ZYD_CR252, 0x00 }, { ZYD_CR253, 0x00 } \ +} + +#define ZYD_AL2230_RF \ +{ \ + 0x03f790, 0x033331, 0x00000d, 0x0b3331, 0x03b812, 0x00fff3, \ + 0x000da4, 0x0f4dc5, 0x0805b6, 0x011687, 0x000688, 0x0403b9, \ + 0x00dbba, 0x00099b, 0x0bdffc, 0x00000d, 0x00500f, 0x00d00f, \ + 0x004c0f, 0x00540f, 0x00700f, 0x00500f \ +} + +#define ZYD_AL2230_RF_B \ +{ \ + 0x03f790, 0x033331, 0x00000d, 0x0b3331, 0x03b812, 0x00fff3, \ + 0x0005a4, 0x0f4dc5, 0x0805b6, 0x0146c7, 0x000688, 0x0403b9, \ + 0x00dbba, 0x00099b, 0x0bdffc, 0x00000d, 0x00580f \ +} + +#define ZYD_AL2230_CHANTABLE \ +{ \ + { 0x03f790, 0x033331, 0x00000d }, \ + { 0x03f790, 0x0b3331, 0x00000d }, \ + { 0x03e790, 0x033331, 0x00000d }, \ + { 0x03e790, 0x0b3331, 0x00000d }, \ + { 0x03f7a0, 0x033331, 0x00000d }, \ + { 0x03f7a0, 0x0b3331, 0x00000d }, \ + { 0x03e7a0, 0x033331, 0x00000d }, \ + { 0x03e7a0, 0x0b3331, 0x00000d }, \ + { 0x03f7b0, 0x033331, 0x00000d }, \ + { 0x03f7b0, 0x0b3331, 0x00000d }, \ + { 0x03e7b0, 0x033331, 0x00000d }, \ + { 0x03e7b0, 0x0b3331, 0x00000d }, \ + { 0x03f7c0, 0x033331, 0x00000d }, \ + { 0x03e7c0, 0x066661, 0x00000d } \ +} + + + +#define ZYD_AL7230B_PHY_1 \ +{ \ + { ZYD_CR240, 0x57 }, { ZYD_CR15, 0x20 }, { ZYD_CR23, 0x40 }, \ + { ZYD_CR24, 0x20 }, { ZYD_CR26, 0x11 }, { ZYD_CR28, 0x3e }, \ + { ZYD_CR29, 0x00 }, { ZYD_CR44, 0x33 }, { ZYD_CR106, 0x22 }, \ + { ZYD_CR107, 0x1a }, { ZYD_CR109, 0x09 }, { ZYD_CR110, 0x27 }, \ + { ZYD_CR111, 0x2b }, { ZYD_CR112, 0x2b }, { ZYD_CR119, 0x0a }, \ + { ZYD_CR122, 0xfc }, { ZYD_CR10, 0x89 }, { ZYD_CR17, 0x28 }, \ + { ZYD_CR26, 0x93 }, { ZYD_CR34, 0x30 }, { ZYD_CR35, 0x3e }, \ + { ZYD_CR41, 0x24 }, { ZYD_CR44, 0x32 }, { ZYD_CR46, 0x96 }, \ + { ZYD_CR47, 0x1e }, { ZYD_CR79, 0x58 }, { ZYD_CR80, 0x30 }, \ + { ZYD_CR81, 0x30 }, { ZYD_CR87, 0x0a }, { ZYD_CR89, 0x04 }, \ + { ZYD_CR92, 0x0a }, { ZYD_CR99, 0x28 }, { ZYD_CR100, 0x02 }, \ + { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, { ZYD_CR106, 0x22 }, \ + { ZYD_CR107, 0x3f }, { ZYD_CR109, 0x09 }, { ZYD_CR110, 0x1f }, \ + { ZYD_CR111, 0x1f }, { ZYD_CR112, 0x1f }, { ZYD_CR113, 0x27 }, \ + { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x24 }, { ZYD_CR116, 0x3f }, \ + { ZYD_CR117, 0xfa }, { ZYD_CR118, 0xfc }, { ZYD_CR119, 0x10 }, \ + { ZYD_CR120, 0x4f }, { ZYD_CR121, 0x77 }, { ZYD_CR137, 0x88 }, \ + { ZYD_CR138, 0xa8 }, { ZYD_CR252, 0x34 }, { ZYD_CR253, 0x34 }, \ + { ZYD_CR251, 0x2f } \ +} + +#define ZYD_AL7230B_PHY_2 \ +{ \ + { ZYD_CR251, 0x3f }, { ZYD_CR128, 0x14 }, { ZYD_CR129, 0x12 }, \ + { ZYD_CR130, 0x10 }, { ZYD_CR38, 0x38 }, { ZYD_CR136, 0xdf } \ +} + +#define ZYD_AL7230B_PHY_3 \ +{ \ + { ZYD_CR203, 0x06 }, { ZYD_CR240, 0x80 } \ +} + +#define ZYD_AL7230B_RF_1 \ +{ \ + 0x09ec04, 0x8cccc8, 0x4ff821, 0xc5fbfc, 0x21ebfe, 0xafd401, \ + 0x6cf56a, 0xe04073, 0x193d76, 0x9dd844, 0x500007, 0xd8c010, \ + 0x3c9000, 0xbfffff, 0x700000, 0xf15d58 \ +} + +#define ZYD_AL7230B_RF_2 \ +{ \ + 0xf15d59, 0xf15d5c, 0xf15d58 \ +} + +#define ZYD_AL7230B_RF_SETCHANNEL \ +{ \ + 0x4ff821, 0xc5fbfc, 0x21ebfe, 0xafd401, 0x6cf56a, 0xe04073, \ + 0x193d76, 0x9dd844, 0x500007, 0xd8c010, 0x3c9000, 0xf15d58 \ +} + +#define ZYD_AL7230B_CHANTABLE \ +{ \ + { 0x09ec00, 0x8cccc8 }, \ + { 0x09ec00, 0x8cccd8 }, \ + { 0x09ec00, 0x8cccc0 }, \ + { 0x09ec00, 0x8cccd0 }, \ + { 0x05ec00, 0x8cccc8 }, \ + { 0x05ec00, 0x8cccd8 }, \ + { 0x05ec00, 0x8cccc0 }, \ + { 0x05ec00, 0x8cccd0 }, \ + { 0x0dec00, 0x8cccc8 }, \ + { 0x0dec00, 0x8cccd8 }, \ + { 0x0dec00, 0x8cccc0 }, \ + { 0x0dec00, 0x8cccd0 }, \ + { 0x03ec00, 0x8cccc8 }, \ + { 0x03ec00, 0x866660 } \ +} + + + +#define ZYD_AL2210_PHY \ +{ \ + { ZYD_CR9, 0xe0 }, { ZYD_CR10, 0x91 }, { ZYD_CR12, 0x90 }, \ + { ZYD_CR15, 0xd0 }, { ZYD_CR16, 0x40 }, { ZYD_CR17, 0x58 }, \ + { ZYD_CR18, 0x04 }, { ZYD_CR23, 0x66 }, { ZYD_CR24, 0x14 }, \ + { ZYD_CR26, 0x90 }, { ZYD_CR31, 0x80 }, { ZYD_CR34, 0x06 }, \ + { ZYD_CR35, 0x3e }, { ZYD_CR38, 0x38 }, { ZYD_CR46, 0x90 }, \ + { ZYD_CR47, 0x1e }, { ZYD_CR64, 0x64 }, { ZYD_CR79, 0xb5 }, \ + { ZYD_CR80, 0x38 }, { ZYD_CR81, 0x30 }, { ZYD_CR113, 0xc0 }, \ + { ZYD_CR127, 0x03 } \ +} + +#define ZYD_AL2210_RF \ +{ \ + 0x2396c0, 0x00fcb1, 0x358132, 0x0108b3, 0xc77804, 0x456415, \ + 0xff2226, 0x806667, 0x7860f8, 0xbb01c9, 0x00000a, 0x00000b \ +} + +#define ZYD_AL2210_CHANTABLE \ +{ \ + 0x0196c0, 0x019710, 0x019760, 0x0197b0, 0x019800, 0x019850, \ + 0x0198a0, 0x0198f0, 0x019940, 0x019990, 0x0199e0, 0x019a30, \ + 0x019a80, 0x019b40 \ +} + + + +#define ZYD_GCT_PHY \ +{ \ + { ZYD_CR47, 0x1e }, { ZYD_CR15, 0xdc }, { ZYD_CR113, 0xc0 }, \ + { ZYD_CR20, 0x0c }, { ZYD_CR17, 0x65 }, { ZYD_CR34, 0x04 }, \ + { ZYD_CR35, 0x35 }, { ZYD_CR24, 0x20 }, { ZYD_CR9, 0xe0 }, \ + { ZYD_CR127, 0x02 }, { ZYD_CR10, 0x91 }, { ZYD_CR23, 0x7f }, \ + { ZYD_CR27, 0x10 }, { ZYD_CR28, 0x7a }, { ZYD_CR79, 0xb5 }, \ + { ZYD_CR64, 0x80 }, { ZYD_CR33, 0x28 }, { ZYD_CR38, 0x30 } \ +} + +#define ZYD_GCT_RF \ +{ \ + 0x1f0000, 0x1f0000, 0x1f0200, 0x1f0600, 0x1f8600, 0x1f8600, \ + 0x002050, 0x1f8000, 0x1f8200, 0x1f8600, 0x1c0000, 0x10c458, \ + 0x088e92, 0x187b82, 0x0401b4, 0x140816, 0x0c7000, 0x1c0000, \ + 0x02ccae, 0x128023, 0x0a0000, 0x1a0000, 0x06e380, 0x16cb94, \ + 0x0e1740, 0x014980, 0x116240, 0x090000, 0x192304, 0x05112f, \ + 0x0d54a8, 0x0f8000, 0x1c0008, 0x1c0000, 0x1a0000, 0x1c0008, \ + 0x150000, 0x0c7000, 0x150800, 0x150000 \ +} + +#define ZYD_GCT_CHANTABLE \ +{ \ + 0x1a0000, 0x1a8000, 0x1a4000, 0x1ac000, 0x1a2000, 0x1aa000, \ + 0x1a6000, 0x1ae000, 0x1a1000, 0x1a9000, 0x1a5000, 0x1ad000, \ + 0x1a3000, 0x1ab000 \ +} + + + +#define ZYD_MAXIM_PHY \ +{ \ + { ZYD_CR23, 0x40 }, { ZYD_CR15, 0x20 }, { ZYD_CR28, 0x3e }, \ + { ZYD_CR29, 0x00 }, { ZYD_CR26, 0x11 }, { ZYD_CR44, 0x33 }, \ + { ZYD_CR106, 0x2a }, { ZYD_CR107, 0x1a }, { ZYD_CR109, 0x2b }, \ + { ZYD_CR110, 0x2b }, { ZYD_CR111, 0x2b }, { ZYD_CR112, 0x2b }, \ + { ZYD_CR10, 0x89 }, { ZYD_CR17, 0x20 }, { ZYD_CR26, 0x93 }, \ + { ZYD_CR34, 0x30 }, { ZYD_CR35, 0x40 }, { ZYD_CR41, 0x24 }, \ + { ZYD_CR44, 0x32 }, { ZYD_CR46, 0x90 }, { ZYD_CR89, 0x18 }, \ + { ZYD_CR92, 0x0a }, { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, \ + { ZYD_CR106, 0x20 }, { ZYD_CR107, 0x24 }, { ZYD_CR109, 0x09 }, \ + { ZYD_CR110, 0x13 }, { ZYD_CR111, 0x13 }, { ZYD_CR112, 0x13 }, \ + { ZYD_CR113, 0x27 }, { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x24 }, \ + { ZYD_CR116, 0x24 }, { ZYD_CR117, 0xf4 }, { ZYD_CR118, 0xfa }, \ + { ZYD_CR120, 0x4f }, { ZYD_CR121, 0x77 }, { ZYD_CR122, 0xfe }, \ + { ZYD_CR10, 0x89 }, { ZYD_CR17, 0x20 }, { ZYD_CR26, 0x93 }, \ + { ZYD_CR34, 0x30 }, { ZYD_CR35, 0x40 }, { ZYD_CR41, 0x24 }, \ + { ZYD_CR44, 0x32 }, { ZYD_CR46, 0x90 }, { ZYD_CR89, 0x18 }, \ + { ZYD_CR92, 0x0a }, { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, \ + { ZYD_CR106, 0x20 }, { ZYD_CR107, 0x24 }, { ZYD_CR109, 0x13 }, \ + { ZYD_CR110, 0x27 }, { ZYD_CR111, 0x27 }, { ZYD_CR112, 0x13 }, \ + { ZYD_CR113, 0x27 }, { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x24 }, \ + { ZYD_CR116, 0x24 }, { ZYD_CR117, 0xf4 }, { ZYD_CR118, 0x00 }, \ + { ZYD_CR120, 0x4f }, { ZYD_CR121, 0x06 }, { ZYD_CR122, 0xfe }, \ + { ZYD_CR150, 0x0d } \ +} + +#define ZYD_MAXIM_RF \ +{ \ + 0x00ccd4, 0x030a03, 0x000400, 0x000ca1, 0x010072, 0x018645, \ + 0x004006, 0x0000a7, 0x008258, 0x003fc9, 0x00040a, 0x00000b, \ + 0x00026c \ +} + +#define ZYD_MAXIM_CHANTABLE \ +{ \ + { 0x0ccd4, 0x30a03 }, \ + { 0x22224, 0x00a13 }, \ + { 0x37774, 0x10a13 }, \ + { 0x0ccd4, 0x30a13 }, \ + { 0x22224, 0x00a23 }, \ + { 0x37774, 0x10a23 }, \ + { 0x0ccd4, 0x30a23 }, \ + { 0x22224, 0x00a33 }, \ + { 0x37774, 0x10a33 }, \ + { 0x0ccd4, 0x30a33 }, \ + { 0x22224, 0x00a43 }, \ + { 0x37774, 0x10a43 }, \ + { 0x0ccd4, 0x30a43 }, \ + { 0x199a4, 0x20a53 } \ +} + + + +#define ZYD_MAXIM2_PHY \ +{ \ + { ZYD_CR23, 0x40 }, { ZYD_CR15, 0x20 }, { ZYD_CR28, 0x3e }, \ + { ZYD_CR29, 0x00 }, { ZYD_CR26, 0x11 }, { ZYD_CR44, 0x33 }, \ + { ZYD_CR106, 0x2a }, { ZYD_CR107, 0x1a }, { ZYD_CR109, 0x2b }, \ + { ZYD_CR110, 0x2b }, { ZYD_CR111, 0x2b }, { ZYD_CR112, 0x2b }, \ + { ZYD_CR10, 0x89 }, { ZYD_CR17, 0x20 }, { ZYD_CR26, 0x93 }, \ + { ZYD_CR34, 0x30 }, { ZYD_CR35, 0x40 }, { ZYD_CR41, 0x24 }, \ + { ZYD_CR44, 0x32 }, { ZYD_CR46, 0x90 }, { ZYD_CR89, 0x18 }, \ + { ZYD_CR92, 0x0a }, { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, \ + { ZYD_CR106, 0x20 }, { ZYD_CR107, 0x24 }, { ZYD_CR109, 0x09 }, \ + { ZYD_CR110, 0x13 }, { ZYD_CR111, 0x13 }, { ZYD_CR112, 0x13 }, \ + { ZYD_CR113, 0x27 }, { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x24 }, \ + { ZYD_CR116, 0x24 }, { ZYD_CR117, 0xf4 }, { ZYD_CR118, 0xfa }, \ + { ZYD_CR120, 0x4f }, { ZYD_CR121, 0x77 }, { ZYD_CR122, 0xfe }, \ + { ZYD_CR10, 0x89 }, { ZYD_CR17, 0x20 }, { ZYD_CR26, 0x93 }, \ + { ZYD_CR34, 0x30 }, { ZYD_CR35, 0x40 }, { ZYD_CR41, 0x24 }, \ + { ZYD_CR44, 0x32 }, { ZYD_CR46, 0x90 }, { ZYD_CR79, 0x58 }, \ + { ZYD_CR80, 0x30 }, { ZYD_CR81, 0x30 }, { ZYD_CR89, 0x18 }, \ + { ZYD_CR92, 0x0a }, { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, \ + { ZYD_CR106, 0x20 }, { ZYD_CR107, 0x24 }, { ZYD_CR109, 0x09 }, \ + { ZYD_CR110, 0x13 }, { ZYD_CR111, 0x13 }, { ZYD_CR112, 0x13 }, \ + { ZYD_CR113, 0x27 }, { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x24 }, \ + { ZYD_CR116, 0x24 }, { ZYD_CR117, 0xf4 }, { ZYD_CR118, 0x00 }, \ + { ZYD_CR120, 0x4f }, { ZYD_CR121, 0x06 }, { ZYD_CR122, 0xfe } \ +} + +#define ZYD_MAXIM2_RF \ +{ \ + 0x33334, 0x10a03, 0x00400, 0x00ca1, 0x10072, 0x18645, 0x04006, \ + 0x000a7, 0x08258, 0x03fc9, 0x0040a, 0x0000b, 0x0026c \ +} + +#define ZYD_MAXIM2_CHANTABLE_F \ +{ \ + 0x33334, 0x08884, 0x1ddd4, 0x33334, 0x08884, 0x1ddd4, 0x33334, \ + 0x08884, 0x1ddd4, 0x33334, 0x08884, 0x1ddd4, 0x33334, 0x26664 \ +} + +#define ZYD_MAXIM2_CHANTABLE \ +{ \ + { 0x33334, 0x10a03 }, \ + { 0x08884, 0x20a13 }, \ + { 0x1ddd4, 0x30a13 }, \ + { 0x33334, 0x10a13 }, \ + { 0x08884, 0x20a23 }, \ + { 0x1ddd4, 0x30a23 }, \ + { 0x33334, 0x10a23 }, \ + { 0x08884, 0x20a33 }, \ + { 0x1ddd4, 0x30a33 }, \ + { 0x33334, 0x10a33 }, \ + { 0x08884, 0x20a43 }, \ + { 0x1ddd4, 0x30a43 }, \ + { 0x33334, 0x10a43 }, \ + { 0x26664, 0x20a53 } \ +} + +/* + * Control pipe requests. + */ +#define ZYD_DOWNLOADREQ 0x30 +#define ZYD_DOWNLOADSTS 0x31 + +/* possible values for register ZYD_CR_INTERRUPT */ +#define ZYD_HWINT_MASK 0x004f0000 + +/* possible values for register ZYD_MAC_MISC */ +#define ZYD_UNLOCK_PHY_REGS 0x80 + +/* possible values for register ZYD_MAC_ENCRYPTION_TYPE */ +#define ZYD_ENC_SNIFFER 8 + +/* flags for register ZYD_MAC_RXFILTER */ +#define ZYD_FILTER_ASS_REQ (1 << 0) +#define ZYD_FILTER_ASS_RSP (1 << 1) +#define ZYD_FILTER_REASS_REQ (1 << 2) +#define ZYD_FILTER_REASS_RSP (1 << 3) +#define ZYD_FILTER_PRB_REQ (1 << 4) +#define ZYD_FILTER_PRB_RSP (1 << 5) +#define ZYD_FILTER_BCN (1 << 8) +#define ZYD_FILTER_ATIM (1 << 9) +#define ZYD_FILTER_DEASS (1 << 10) +#define ZYD_FILTER_AUTH (1 << 11) +#define ZYD_FILTER_DEAUTH (1 << 12) +#define ZYD_FILTER_PS_POLL (1 << 26) +#define ZYD_FILTER_RTS (1 << 27) +#define ZYD_FILTER_CTS (1 << 28) +#define ZYD_FILTER_ACK (1 << 29) +#define ZYD_FILTER_CFE (1 << 30) +#define ZYD_FILTER_CFE_A (1 << 31) + +/* helpers for register ZYD_MAC_RXFILTER */ +#define ZYD_FILTER_MONITOR 0xffffffff +#define ZYD_FILTER_BSS \ + (ZYD_FILTER_ASS_RSP | ZYD_FILTER_REASS_RSP | \ + ZYD_FILTER_PRB_RSP | ZYD_FILTER_BCN | ZYD_FILTER_DEASS | \ + ZYD_FILTER_AUTH | ZYD_FILTER_DEAUTH) +#define ZYD_FILTER_HOSTAP \ + (ZYD_FILTER_ASS_REQ | ZYD_FILTER_REASS_REQ | \ + ZYD_FILTER_PRB_REQ | ZYD_FILTER_DEASS | ZYD_FILTER_AUTH | \ + ZYD_FILTER_DEAUTH | ZYD_FILTER_PS_POLL) + +struct zyd_tx_desc { + uint8_t phy; +#define ZYD_TX_PHY_SIGNAL(x) ((x) & 0xf) +#define ZYD_TX_PHY_OFDM (1 << 4) +#define ZYD_TX_PHY_SHPREAMBLE (1 << 5) /* CCK */ +#define ZYD_TX_PHY_5GHZ (1 << 5) /* OFDM */ + + uint16_t len; + uint8_t flags; +#define ZYD_TX_FLAG_BACKOFF (1 << 0) +#define ZYD_TX_FLAG_MULTICAST (1 << 1) +#define ZYD_TX_FLAG_TYPE(x) (((x) & 0x3) << 2) +#define ZYD_TX_TYPE_DATA 0 +#define ZYD_TX_TYPE_PS_POLL 1 +#define ZYD_TX_TYPE_MGMT 2 +#define ZYD_TX_TYPE_CTL 3 +#define ZYD_TX_FLAG_WAKEUP (1 << 4) +#define ZYD_TX_FLAG_RTS (1 << 5) +#define ZYD_TX_FLAG_ENCRYPT (1 << 6) +#define ZYD_TX_FLAG_CTS_TO_SELF (1 << 7) + + uint16_t pktlen; + uint16_t plcp_length; + uint8_t plcp_service; +#define ZYD_PLCP_LENGEXT 0x80 + + uint16_t nextlen; +} __packed; + +struct zyd_plcphdr { + uint8_t signal; + uint8_t reserved[2]; + uint16_t service; /* unaligned! */ +} __packed; + +struct zyd_rx_stat { + uint8_t signal_cck; + uint8_t rssi; + uint8_t signal_ofdm; + uint8_t cipher; +#define ZYD_RX_CIPHER_WEP64 1 +#define ZYD_RX_CIPHER_TKIP 2 +#define ZYD_RX_CIPHER_AES 4 +#define ZYD_RX_CIPHER_WEP128 5 +#define ZYD_RX_CIPHER_WEP256 6 +#define ZYD_RX_CIPHER_WEP \ + (ZYD_RX_CIPHER_WEP64 | ZYD_RX_CIPHER_WEP128 | ZYD_RX_CIPHER_WEP256) + + uint8_t flags; +#define ZYD_RX_OFDM (1 << 0) +#define ZYD_RX_TIMEOUT (1 << 1) +#define ZYD_RX_OVERRUN (1 << 2) +#define ZYD_RX_DECRYPTERR (1 << 3) +#define ZYD_RX_BADCRC32 (1 << 4) +#define ZYD_RX_NOT2ME (1 << 5) +#define ZYD_RX_BADCRC16 (1 << 6) +#define ZYD_RX_ERROR (1 << 7) +} __packed; + +/* this structure may be unaligned */ +struct zyd_rx_desc { +#define ZYD_MAX_RXFRAMECNT 3 + uWord len[ZYD_MAX_RXFRAMECNT]; + uWord tag; +#define ZYD_TAG_MULTIFRAME 0x697e +} __packed; + +/* I2C bus alike */ +struct zyd_rfwrite { + uint16_t code; + uint16_t width; + uint16_t bit[32]; +#define ZYD_RF_IF_LE (1 << 1) +#define ZYD_RF_CLK (1 << 2) +#define ZYD_RF_DATA (1 << 3) +} __packed; + +struct zyd_cmd { + uint16_t code; +#define ZYD_CMD_IOWR 0x0021 /* write HMAC or PHY register */ +#define ZYD_CMD_IORD 0x0022 /* read HMAC or PHY register */ +#define ZYD_CMD_RFCFG 0x0023 /* write RF register */ +#define ZYD_NOTIF_IORD 0x9001 /* response for ZYD_CMD_IORD */ +#define ZYD_NOTIF_MACINTR 0x9001 /* interrupt notification */ +#define ZYD_NOTIF_RETRYSTATUS 0xa001 /* Tx retry notification */ + + uint8_t data[64]; +} __packed; + +/* structure for command ZYD_CMD_IOWR */ +struct zyd_pair { + uint16_t reg; +/* helpers macros to read/write 32-bit registers */ +#define ZYD_REG32_LO(reg) (reg) +#define ZYD_REG32_HI(reg) \ + ((reg) + ((((reg) & 0xf000) == 0x9000) ? 2 : 1)) + + uint16_t val; +} __packed; + +/* structure for notification ZYD_NOTIF_RETRYSTATUS */ +struct zyd_notif_retry { + uint16_t rate; + uint8_t macaddr[IEEE80211_ADDR_LEN]; + uint16_t count; +} __packed; + + +#define ZYD_RX_LIST_CNT 1 +#define ZYD_TX_LIST_CNT 1 + +#define ZYD_CONFIG_NO 1 +#define ZYD_IFACE_INDEX 0 + +#define ZYD_INTR_TIMEOUT 1000 +#define ZYD_TX_TIMEOUT 10000 + +#define ZYD_MAX_TXBUFSZ \ + (sizeof(struct zyd_tx_desc) + MCLBYTES) + +#define ZYD_MIN_FRAGSZ \ + (sizeof(struct zyd_plcphdr) + IEEE80211_MIN_LEN + \ + sizeof(struct zyd_rx_stat)) +#define ZYD_MIN_RXBUFSZ ZYD_MIN_FRAGSZ +#define ZYX_MAX_RXBUFSZ \ + (sizeof(struct zyd_plcphdr) + MCLBYTES + sizeof(struct zyd_rx_desc)) + +#define ZYD_CMD_FLAG_READ (1 << 0) + +/* quickly determine if a given rate is CCK or OFDM */ +#define ZYD_RATE_IS_OFDM(rate) ((rate) >= 12 && (rate) != 22) + +struct zyd_phy_pair { + uint16_t reg; + uint8_t val; +}; + +struct zyd_mac_pair { + uint16_t reg; + uint32_t val; +}; + +struct zyd_tx_data { + struct zyd_softc *sc; + usbd_xfer_handle xfer; + uint8_t *buf; + struct ieee80211_node *ni; + struct mbuf *m; +}; + +struct zyd_rx_data { + struct zyd_softc *sc; + usbd_xfer_handle xfer; + const uint8_t *buf; +}; + +struct zyd_node { + struct ieee80211_node ni; /* must be the first */ + struct ieee80211_amrr_node amn; +}; + +struct zyd_rx_radiotap_header { + struct ieee80211_radiotap_header wr_ihdr; + uint8_t wr_flags; + uint8_t wr_rate; + uint16_t wr_chan_freq; + uint16_t wr_chan_flags; + int8_t wr_antsignal; + int8_t wr_antnoise; +} __packed; + +#define ZYD_RX_RADIOTAP_PRESENT \ + ((1 << IEEE80211_RADIOTAP_FLAGS) | \ + (1 << IEEE80211_RADIOTAP_RATE) | \ + (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ + (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \ + (1 << IEEE80211_RADIOTAP_CHANNEL)) + +struct zyd_tx_radiotap_header { + struct ieee80211_radiotap_header wt_ihdr; + uint8_t wt_flags; + uint8_t wt_rate; + uint16_t wt_chan_freq; + uint16_t wt_chan_flags; +} __packed; + +#define ZYD_TX_RADIOTAP_PRESENT \ + ((1 << IEEE80211_RADIOTAP_FLAGS) | \ + (1 << IEEE80211_RADIOTAP_RATE) | \ + (1 << IEEE80211_RADIOTAP_CHANNEL)) + +struct zyd_softc; /* forward declaration */ + +struct zyd_rf { + /* RF methods */ + int (*init)(struct zyd_rf *); + int (*switch_radio)(struct zyd_rf *, int); + int (*set_channel)(struct zyd_rf *, uint8_t); + + /* RF attributes */ + struct zyd_softc *rf_sc; /* back-pointer */ + int width; +}; + +struct rq { + const uint16_t *idata; + struct zyd_pair *odata; + int len; + STAILQ_ENTRY(rq) rq; +}; + +struct zyd_softc { + device_t sc_dev; + struct ifnet *sc_ifp; + struct ieee80211com sc_ic; + int (*sc_newstate)(struct ieee80211com *, + enum ieee80211_state, int); + struct zyd_rf sc_rf; + + struct usb_task sc_task; + struct usb_task sc_scantask; + int sc_scan_action; +#define ZYD_SCAN_START 0 +#define ZYD_SCAN_END 1 +#define ZYD_SET_CHANNEL 2 + usbd_device_handle sc_udev; + usbd_interface_handle sc_iface; + int sc_flags; +#define ZD1211_FWLOADED (1 << 0) + + + enum ieee80211_state sc_state; + int sc_arg; + + struct mtx sc_mtx; + struct callout sc_amrr_ch; + struct callout sc_watchdog_ch; + + struct ieee80211_amrr amrr; + + STAILQ_HEAD(rqh, rq) sc_rqh; + + uint16_t fwbase; + uint8_t regdomain; + uint8_t mac_rev; + uint16_t fw_rev; + uint8_t rf_rev; + uint8_t pa_rev; + uint8_t pwr_cal[14]; + uint8_t pwr_int[14]; + uint8_t ofdm36_cal[14]; + uint8_t ofdm48_cal[14]; + uint8_t ofdm54_cal[14]; + +#define ZYD_ENDPT_BOUT 0 +#define ZYD_ENDPT_BIN 1 +#define ZYD_ENDPT_IIN 2 +#define ZYD_ENDPT_IOUT 3 +#define ZYD_ENDPT_CNT 4 + usbd_pipe_handle zyd_ep[ZYD_ENDPT_CNT]; + uint8_t *ibuf; + + struct zyd_rx_data rx_data[ZYD_RX_LIST_CNT]; + struct zyd_tx_data tx_data[ZYD_TX_LIST_CNT]; + int tx_queued; + + int tx_timer; + + struct bpf_if *sc_drvbpf; + + struct zyd_rx_radiotap_header sc_rxtap; + int sc_rxtap_len; + + struct zyd_tx_radiotap_header sc_txtap; + int sc_txtap_len; +}; + +#if 0 +#define ZYD_LOCK(sc) mtx_lock(&(sc)->sc_mtx) +#define ZYD_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) +#else +#define ZYD_LOCK(sc) do { ((sc) = (sc)); mtx_lock(&Giant); } while (0) +#define ZYD_UNLOCK(sc) mtx_unlock(&Giant) +#endif + |