svn commit: r185377 - in projects/ath_hal: . ar5210 ar5211 ar5212 ar5312 ar5416 linux public

Sam Leffler sam at FreeBSD.org
Thu Nov 27 16:03:42 PST 2008


Author: sam
Date: Fri Nov 28 00:03:41 2008
New Revision: 185377
URL: http://svn.freebsd.org/changeset/base/185377

Log:
  virgin import of ath hal

Added:
  projects/ath_hal/
  projects/ath_hal/COPYRIGHT
  projects/ath_hal/Makefile   (contents, props changed)
  projects/ath_hal/README
  projects/ath_hal/ah.c   (contents, props changed)
  projects/ath_hal/ah.h   (contents, props changed)
  projects/ath_hal/ah_debug.h   (contents, props changed)
  projects/ath_hal/ah_decode.h   (contents, props changed)
  projects/ath_hal/ah_desc.h   (contents, props changed)
  projects/ath_hal/ah_devid.h   (contents, props changed)
  projects/ath_hal/ah_eeprom.h   (contents, props changed)
  projects/ath_hal/ah_eeprom_v14.c   (contents, props changed)
  projects/ath_hal/ah_eeprom_v14.h   (contents, props changed)
  projects/ath_hal/ah_eeprom_v3.c   (contents, props changed)
  projects/ath_hal/ah_eeprom_v3.h   (contents, props changed)
  projects/ath_hal/ah_internal.h   (contents, props changed)
  projects/ath_hal/ah_regdomain.c   (contents, props changed)
  projects/ath_hal/ah_soc.h   (contents, props changed)
  projects/ath_hal/ar5210/
  projects/ath_hal/ar5210/ar5210.h   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_attach.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_beacon.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_interrupts.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_keycache.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_misc.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_phy.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_power.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_recv.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_reset.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210_xmit.c   (contents, props changed)
  projects/ath_hal/ar5210/ar5210desc.h   (contents, props changed)
  projects/ath_hal/ar5210/ar5210phy.h   (contents, props changed)
  projects/ath_hal/ar5210/ar5210reg.h   (contents, props changed)
  projects/ath_hal/ar5210/ar5k_0007.ini
  projects/ath_hal/ar5211/
  projects/ath_hal/ar5211/ar5211.h   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_attach.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_beacon.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_interrupts.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_keycache.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_misc.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_phy.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_power.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_recv.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_reset.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211_xmit.c   (contents, props changed)
  projects/ath_hal/ar5211/ar5211desc.h   (contents, props changed)
  projects/ath_hal/ar5211/ar5211phy.h   (contents, props changed)
  projects/ath_hal/ar5211/ar5211reg.h   (contents, props changed)
  projects/ath_hal/ar5211/boss.ini   (contents, props changed)
  projects/ath_hal/ar5212/
  projects/ath_hal/ar5212/ar2316.c   (contents, props changed)
  projects/ath_hal/ar5212/ar2317.c   (contents, props changed)
  projects/ath_hal/ar5212/ar2413.c   (contents, props changed)
  projects/ath_hal/ar5212/ar2425.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5111.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5112.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212.h   (contents, props changed)
  projects/ath_hal/ar5212/ar5212.ini
  projects/ath_hal/ar5212/ar5212_ani.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_attach.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_beacon.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_eeprom.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_gpio.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_interrupts.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_keycache.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_misc.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_phy.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_power.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_recv.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_reset.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212_xmit.c   (contents, props changed)
  projects/ath_hal/ar5212/ar5212desc.h   (contents, props changed)
  projects/ath_hal/ar5212/ar5212phy.h   (contents, props changed)
  projects/ath_hal/ar5212/ar5212reg.h   (contents, props changed)
  projects/ath_hal/ar5212/ar5311reg.h   (contents, props changed)
  projects/ath_hal/ar5212/ar5413.c   (contents, props changed)
  projects/ath_hal/ar5312/
  projects/ath_hal/ar5312/ar5312.h   (contents, props changed)
  projects/ath_hal/ar5312/ar5312_attach.c   (contents, props changed)
  projects/ath_hal/ar5312/ar5312_eeprom.c   (contents, props changed)
  projects/ath_hal/ar5312/ar5312_gpio.c   (contents, props changed)
  projects/ath_hal/ar5312/ar5312_interrupts.c   (contents, props changed)
  projects/ath_hal/ar5312/ar5312_misc.c   (contents, props changed)
  projects/ath_hal/ar5312/ar5312_power.c   (contents, props changed)
  projects/ath_hal/ar5312/ar5312_reset.c   (contents, props changed)
  projects/ath_hal/ar5312/ar5312phy.h   (contents, props changed)
  projects/ath_hal/ar5312/ar5312reg.h   (contents, props changed)
  projects/ath_hal/ar5312/ar5315_gpio.c   (contents, props changed)
  projects/ath_hal/ar5416/
  projects/ath_hal/ar5416/ar2133.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416.h   (contents, props changed)
  projects/ath_hal/ar5416/ar5416.ini
  projects/ath_hal/ar5416/ar5416_attach.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_beacon.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_eeprom.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_gpio.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_interrupts.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_keycache.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_misc.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_phy.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_power.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_recv.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_reset.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416_xmit.c   (contents, props changed)
  projects/ath_hal/ar5416/ar5416desc.h   (contents, props changed)
  projects/ath_hal/ar5416/ar5416phy.h   (contents, props changed)
  projects/ath_hal/ar5416/ar5416reg.h   (contents, props changed)
  projects/ath_hal/ar5416/ar9160.ini   (contents, props changed)
  projects/ath_hal/ar5416/ar9160_attach.c   (contents, props changed)
  projects/ath_hal/linux/
  projects/ath_hal/linux/Makefile   (contents, props changed)
  projects/ath_hal/linux/Makefile.inc   (contents, props changed)
  projects/ath_hal/linux/ah_osdep.c   (contents, props changed)
  projects/ath_hal/linux/ah_osdep.h   (contents, props changed)
  projects/ath_hal/public/
  projects/ath_hal/public/alpha-elf.inc
  projects/ath_hal/public/ap30.inc
  projects/ath_hal/public/ap43.inc
  projects/ath_hal/public/ap51.inc
  projects/ath_hal/public/ap61.inc
  projects/ath_hal/public/arm9-le-thumb-elf.inc
  projects/ath_hal/public/armv4-be-elf.inc
  projects/ath_hal/public/armv4-le-elf.inc
  projects/ath_hal/public/i386-elf.inc
  projects/ath_hal/public/mips-be-elf.inc
  projects/ath_hal/public/mips-le-elf.inc
  projects/ath_hal/public/mips1-be-elf.inc
  projects/ath_hal/public/mips1-le-elf.inc
  projects/ath_hal/public/mipsisa32-be-elf.inc
  projects/ath_hal/public/mipsisa32-le-elf.inc
  projects/ath_hal/public/powerpc-be-eabi.inc
  projects/ath_hal/public/powerpc-be-elf.inc
  projects/ath_hal/public/powerpc-le-eabi.inc
  projects/ath_hal/public/sh4-le-elf.inc
  projects/ath_hal/public/sparc-be-elf.inc
  projects/ath_hal/public/sparc64-be-elf.inc
  projects/ath_hal/public/wackelf.c   (contents, props changed)
  projects/ath_hal/public/wisoc.inc
  projects/ath_hal/public/x86_64-elf.inc
  projects/ath_hal/public/xscale-be-elf.inc
  projects/ath_hal/public/xscale-le-elf.inc
  projects/ath_hal/version.h   (contents, props changed)

Added: projects/ath_hal/COPYRIGHT
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ath_hal/COPYRIGHT	Fri Nov 28 00:03:41 2008	(r185377)
@@ -0,0 +1,18 @@
+All files are under this license where not stated.
+
+/*
+ * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
+ * Copyright (c) 2002-2008 Atheros Communications, Inc.
+ *
+ * Permission to use, copy, modify, and/or 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.
+ */

Added: projects/ath_hal/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ath_hal/Makefile	Fri Nov 28 00:03:41 2008	(r185377)
@@ -0,0 +1,101 @@
+#
+# Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
+# Copyright (c) 2002-2008 Atheros Communications, Inc.
+#
+# Permission to use, copy, modify, and/or 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.
+#
+# $Id: Makefile,v 1.6 2008/11/10 01:23:57 sam Exp $
+#
+
+nop:
+
+#
+# Release-related support.
+#
+FILES=	COPYRIGHT README \
+	ah.h ah_desc.h ah_devid.h ah_soc.h version.h \
+	public/[a-z]*.inc public/*.hal.o.uu public/*.opt_ah.h \
+	public/wackelf.c \
+	${NULL}
+#
+# Tag the tree and build a release tarball suitable for open
+# distribution (e.g. to sourceforge).  The tag is date-based.
+#
+release:
+	DATE=`date +'%Y%m%d'`; TAG="ATH_HAL_$${DATE}"; \
+	cvs tag -F $${TAG} ${FILES} && make rerelease TAG=$${TAG}
+
+#
+# Rebuild a release tarball using an existing tag.
+#
+rerelease:
+	if [ -z "${TAG}" ]; then \
+		echo "You must specify a TAG to do a re-release"; \
+		exit 1; \
+	fi; \
+	expr "${TAG}" : '^ATH_HAL_' || { \
+		echo "TAG must be of the form ATH_HAL_YYYYMMDD"; \
+		exit 1; \
+	}; \
+	DATE=`echo "${TAG}" | sed 's/^ATH_HAL_//'`; \
+	DIR="ath_hal-$${DATE}"; \
+	rm -rf $${DIR}; \
+	mkdir $${DIR} && \
+	cvs export -d $${DIR} -r ${TAG} hal && \
+	tar zcf $${DIR}.tgz --exclude=CVS $${DIR} && \
+	rm -rf $${DIR}
+
+#
+# Build a release-like tarball suitable for open distribution
+# using the current contents of the local directory.  This is
+# useful for distributing private changes that are not committed
+# to cvs.  Note that this should not be used to construct
+# distributions as there is no cvs history or tag to use in
+# tracking issues.
+#
+tarball:
+	DATE=`date +'%Y%m%d'`; DIR="ath_hal-$${DATE}"; \
+	ln -s . $${DIR}; \
+	TARFILES=`for i in ${FILES}; do echo $${DIR}/$$i; done`; \
+	tar zcf $${DIR}.tgz --exclude=CVS $${TARFILES}; \
+	rm -f $${DIR};
+
+#
+# Build a source distribution. Be sure to
+# first tag the source files using src_tag then follow this with
+# src_release to construct the tarball.  Tags and filenames are
+# constructed from the contents of version.h (as opposed to the
+# current date) so be sure this file is up to date prior to rolling
+# a release.  Note that a source release does NOT include the
+# pre-built binary hal files; it is assumed the recipient can/will
+# do this themselves.
+#
+
+# tag the source code according to the current version
+src_tag:
+	TAG=`awk '/ATH_HAL_VERSION/ \
+		{ gsub("\\"","",$$3); \
+		  gsub("[-.]", "_", $$3); print "v" $$3; }' version.h`; \
+		cvs tag ${TAGOPTS} $${TAG}; \
+	cvs tag -d $${TAG} */*.uu */*opt_ah.h
+# create a tarball of the source for the current tagged version
+src_release:
+	TAG=`awk '/ATH_HAL_VERSION/ \
+		{ gsub("\\"","",$$3); \
+		  gsub("[-.]", "_", $$3); print "v" $$3; }' version.h`; \
+	DIR=`awk '/ATH_HAL_VERSION/ \
+		{ gsub("\\"","",$$3); print "hal-" $$3; }' version.h`; \
+	rm -rf $${DIR}; mkdir $${DIR}; \
+	cvs export -d $${DIR} -r $${TAG} hal; \
+	tar zcf $${DIR}.tgz --exclude=CVS $${DIR}; \
+	rm -rf $${DIR};

Added: projects/ath_hal/README
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ath_hal/README	Fri Nov 28 00:03:41 2008	(r185377)
@@ -0,0 +1,47 @@
+$Id: README,v 1.1.1.1 2008/08/20 04:41:19 sam Exp $
+
+Atheros Hardware Access Layer (HAL)
+===================================
+
+Read the file COPYRIGHT for the complete copyright.
+
+This code manages much of the chip-specific operation of the Atheros
+driver.
+
+Atheros Hardware
+================
+There are many generations of Atheros 802.11 wireless devices that
+are typically referred to by their programming model:
+
+5210	supports 11a only
+5211	supports both 11a and 11b
+5212	supports 11a, 11b, and 11g
+
+These parts have been incorporated in a variety of retail products
+including cardbus cards and mini-pci cards.  In addition many laptop
+vendors use Atheros mini-pci cards for their builtin wireless
+support.
+
+The Atheros PCI vendor id is 0x168c.  The file ah_devid.h lists most
+known PCI device id's but is not exhaustive.  Some vendors program
+their own vendor and/or device id's to aid in BIOS-locking mini-pci
+cards in laptops.
+
+Atheros SoC Hardware
+====================
+In addition to the cardbus/pci devices Atheros makes System on Chip
+(SoC) parts that integrate a MIPS cpu core and one or more MAC and
+radio parts. Support for these parts is necessarily built
+for the embedded MIPS processor where the code is to be run.
+
+Caveats
+=======
+The binary hal builds provided here include no floating point and
+are operating system-independent.  However due to toolchain
+peculiarities the .o files may be wrongly rejected by development
+tools.  If that happens it may be possible to patch the file header
+so that the native toolchain will accept the files.  In particular
+this has been observed for various Linux MIPS installations for the
+SoC parts.  If you have issues consult the associated .inc file in
+the public directory; it explains exactly how the binary file was
+created (e.g. toolchain and compilation options).

Added: projects/ath_hal/ah.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/ath_hal/ah.c	Fri Nov 28 00:03:41 2008	(r185377)
@@ -0,0 +1,1029 @@
+/*
+ * Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
+ * Copyright (c) 2002-2008 Atheros Communications, Inc.
+ *
+ * Permission to use, copy, modify, and/or 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.
+ *
+ * $Id: ah.c,v 1.13 2008/11/10 04:08:00 sam Exp $
+ */
+#include "opt_ah.h"
+
+#include "ah.h"
+#include "ah_internal.h"
+#include "ah_devid.h"
+
+#ifdef AH_SUPPORT_AR5210
+extern	struct ath_hal *ar5210Attach(uint16_t, HAL_SOFTC,
+	HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*);
+#endif
+#ifdef AH_SUPPORT_AR5211
+extern	struct ath_hal *ar5211Attach(uint16_t, HAL_SOFTC,
+	HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*);
+#endif
+#ifdef AH_SUPPORT_AR5212
+extern	struct ath_hal *ar5212Attach(uint16_t, HAL_SOFTC,
+	HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*);
+#endif
+#ifdef AH_SUPPORT_AR5312
+extern	struct ath_hal *ar5312Attach(uint16_t, HAL_SOFTC,
+	HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*);
+#endif
+#ifdef AH_SUPPORT_AR5416
+extern	struct ath_hal *ar5416Attach(uint16_t, HAL_SOFTC,
+	HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*);
+#endif
+#ifdef AH_SUPPORT_AR9160
+extern	struct ath_hal *ar9160Attach(uint16_t, HAL_SOFTC,
+	HAL_BUS_TAG, HAL_BUS_HANDLE, HAL_STATUS*);
+#endif
+
+#include "version.h"
+char ath_hal_version[] = ATH_HAL_VERSION;
+const char* ath_hal_buildopts[] = {
+#ifdef AH_SUPPORT_AR5210
+	"AR5210",
+#endif
+#ifdef AH_SUPPORT_AR5211
+	"AR5211",
+#endif
+#ifdef AH_SUPPORT_AR5212
+	"AR5212",
+#endif
+#ifdef AH_SUPPORT_AR5312
+	"AR5312",
+#endif
+#ifdef AH_SUPPORT_AR5416
+	"AR5416",
+#endif
+#ifdef AH_SUPPORT_AR9180
+	"AR9180",
+#endif
+#ifdef AH_SUPPORT_5111
+	"RF5111",
+#endif
+#ifdef AH_SUPPORT_5112
+	"RF5112",
+#endif
+#ifdef AH_SUPPORT_2413
+	"RF2413",
+#endif
+#ifdef AH_SUPPORT_5413
+	"RF5413",
+#endif
+#ifdef AH_SUPPORT_2316
+	"RF2316",
+#endif
+#ifdef AH_SUPPORT_2317
+	"RF2317",
+#endif
+#ifdef AH_SUPPORT_2133
+	"RF2133",
+#endif
+#ifdef AH_SUPPORT_2425
+	"RF2425",
+#endif
+#ifdef AH_SUPPORT_2417
+	"RF2417",
+#endif
+#ifdef AH_DEBUG
+	"DEBUG",
+#endif
+#ifdef AH_ASSERT
+	"ASSERT",
+#endif
+#ifdef AH_DEBUG_ALQ
+	"DEBUG_ALQ",
+#endif
+#ifdef AH_REGOPS_FUNC
+	"REGOPS_FUNC",
+#endif
+#ifdef AH_PRIVATE_DIAG
+	"PRIVATE_DIAG",
+#endif
+#ifdef AH_DEBUG_COUNTRY
+	"DEBUG_COUNTRY",
+#endif
+#ifdef AH_NEED_DESC_SWAP
+	"TX_DESC_SWAP",
+#endif
+#ifdef AH_DISABLE_WME
+	"DISABLE_WME",
+#endif
+#ifdef AH_SUPPORT_11D
+	"11D",
+#endif
+	AH_NULL
+};
+
+static const char*
+ath_hal_devname(uint16_t devid)
+{
+	switch (devid) {
+	case AR5210_PROD:
+	case AR5210_DEFAULT:
+		return "Atheros 5210";
+
+	case AR5211_DEVID:
+	case AR5311_DEVID:
+	case AR5211_DEFAULT:
+		return "Atheros 5211";
+	case AR5211_FPGA11B:
+		return "Atheros 5211 (FPGA)";
+
+	case AR5212_FPGA:
+		return "Atheros 5212 (FPGA)";
+	case AR5212_AR5312_REV2:
+	case AR5212_AR5312_REV7:
+		return "Atheros 5312 WiSoC";
+	case AR5212_AR2315_REV6:
+	case AR5212_AR2315_REV7:
+		return "Atheros 2315 WiSoC";
+	case AR5212_AR2317_REV1:
+		return "Atheros 2317 WiSoC";
+	case AR5212_AR2313_REV8:
+		return "Atheros 2313 WiSoC";
+	case AR5212_DEVID:
+	case AR5212_DEVID_IBM:
+	case AR5212_DEFAULT:
+		return "Atheros 5212";
+	case AR5212_AR2413:
+		return "Atheros 2413";
+	case AR5212_AR2417:
+		return "Atheros 2417";
+	case AR5212_AR5413:
+		return "Atheros 5413";
+	case AR5212_AR5424:
+		return "Atheros 5424/2424";
+	case AR5416_DEVID_PCI:
+	case AR5416_DEVID_PCIE:
+		return "Atheros 5416";
+	case AR9160_DEVID_PCI:
+		return "Atheros 9160";
+	}
+	return AH_NULL;
+}
+
+const char*
+ath_hal_probe(uint16_t vendorid, uint16_t devid)
+{
+	return (vendorid == ATHEROS_VENDOR_ID ||
+		vendorid == ATHEROS_3COM_VENDOR_ID ||
+		vendorid == ATHEROS_3COM2_VENDOR_ID ?
+			ath_hal_devname(devid) : 0);
+}
+
+/*
+ * Attach detects device chip revisions, initializes the hwLayer
+ * function list, reads EEPROM information,
+ * selects reset vectors, and performs a short self test.
+ * Any failures will return an error that should cause a hardware
+ * disable.
+ */
+struct ath_hal*
+ath_hal_attach(uint16_t devid, HAL_SOFTC sc,
+	HAL_BUS_TAG st, HAL_BUS_HANDLE sh, HAL_STATUS *error)
+{
+	struct ath_hal *ah=AH_NULL;
+
+	switch (devid) {
+#ifdef AH_SUPPORT_AR5210
+	case AR5210_AP:
+	case AR5210_PROD:
+	case AR5210_DEFAULT:
+		ah = ar5210Attach(devid, sc, st, sh, error);
+		break;
+#endif
+#ifdef AH_SUPPORT_AR5211
+	case AR5211_DEVID:
+	case AR5311_DEVID:
+	case AR5211_FPGA11B:
+	case AR5211_DEFAULT:
+		ah = ar5211Attach(devid, sc, st, sh, error);
+		break;
+#endif
+#ifdef AH_SUPPORT_AR5212
+	case AR5212_DEVID_IBM:
+	case AR5212_AR2413:
+	case AR5212_AR2417:
+	case AR5212_AR5413:
+	case AR5212_AR5424:
+	case AR5212_DEVID_FF19: /* XXX PCI Express extra */
+		devid = AR5212_DEVID;
+		/* fall thru... */
+	case AR5212_DEVID:
+	case AR5212_FPGA:
+	case AR5212_DEFAULT:
+		ah = ar5212Attach(devid, sc, st, sh, error);
+		break;
+#endif
+#ifdef AH_SUPPORT_AR5312
+	case AR5212_AR5312_REV2:
+	case AR5212_AR5312_REV7:
+	case AR5212_AR2313_REV8:
+	case AR5212_AR2315_REV6:
+	case AR5212_AR2315_REV7:
+	case AR5212_AR2317_REV1:
+		ah = ar5312Attach(devid, sc, st, sh, error);
+		break;
+#endif
+#ifdef AH_SUPPORT_AR5416
+	case AR5416_DEVID_PCI:
+	case AR5416_DEVID_PCIE:
+		ah = ar5416Attach(devid, sc, st, sh, error);
+		break;
+#endif
+#ifdef AH_SUPPORT_AR9160
+	case AR9160_DEVID_PCI:
+		ah = ar9160Attach(devid, sc, st, sh, error);
+		break;
+#endif
+	default:
+		ah = AH_NULL;
+		*error = HAL_ENXIO;
+		break;
+	}
+	if (ah != AH_NULL) {
+		/* copy back private state to public area */
+		ah->ah_devid = AH_PRIVATE(ah)->ah_devid;
+		ah->ah_subvendorid = AH_PRIVATE(ah)->ah_subvendorid;
+		ah->ah_macVersion = AH_PRIVATE(ah)->ah_macVersion;
+		ah->ah_macRev = AH_PRIVATE(ah)->ah_macRev;
+		ah->ah_phyRev = AH_PRIVATE(ah)->ah_phyRev;
+		ah->ah_analog5GhzRev = AH_PRIVATE(ah)->ah_analog5GhzRev;
+		ah->ah_analog2GhzRev = AH_PRIVATE(ah)->ah_analog2GhzRev;
+	}
+	return ah;
+}
+
+/*
+ * Poll the register looking for a specific value.
+ */
+HAL_BOOL
+ath_hal_wait(struct ath_hal *ah, u_int reg, uint32_t mask, uint32_t val)
+{
+#define	AH_TIMEOUT	1000
+	int i;
+
+	for (i = 0; i < AH_TIMEOUT; i++) {
+		if ((OS_REG_READ(ah, reg) & mask) == val)
+			return AH_TRUE;
+		OS_DELAY(10);
+	}
+	HALDEBUG(ah, HAL_DEBUG_REGIO | HAL_DEBUG_PHYIO,
+	    "%s: timeout on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n",
+	    __func__, reg, OS_REG_READ(ah, reg), mask, val);
+	return AH_FALSE;
+#undef AH_TIMEOUT
+}
+
+/*
+ * Reverse the bits starting at the low bit for a value of
+ * bit_count in size
+ */
+uint32_t
+ath_hal_reverseBits(uint32_t val, uint32_t n)
+{
+	uint32_t retval;
+	int i;
+
+	for (i = 0, retval = 0; i < n; i++) {
+		retval = (retval << 1) | (val & 1);
+		val >>= 1;
+	}
+	return retval;
+}
+
+/*
+ * Compute the time to transmit a frame of length frameLen bytes
+ * using the specified rate, phy, and short preamble setting.
+ */
+uint16_t
+ath_hal_computetxtime(struct ath_hal *ah,
+	const HAL_RATE_TABLE *rates, uint32_t frameLen, uint16_t rateix,
+	HAL_BOOL shortPreamble)
+{
+	uint32_t bitsPerSymbol, numBits, numSymbols, phyTime, txTime;
+	uint32_t kbps;
+
+	kbps = rates->info[rateix].rateKbps;
+	/*
+	 * index can be invalid duting dynamic Turbo transitions. 
+	 */
+	if(kbps == 0) return 0;
+	switch (rates->info[rateix].phy) {
+
+	case IEEE80211_T_CCK:
+#define CCK_SIFS_TIME        10
+#define CCK_PREAMBLE_BITS   144
+#define CCK_PLCP_BITS        48
+		phyTime		= CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
+		if (shortPreamble && rates->info[rateix].shortPreamble)
+			phyTime >>= 1;
+		numBits		= frameLen << 3;
+		txTime		= CCK_SIFS_TIME + phyTime
+				+ ((numBits * 1000)/kbps);
+		break;
+#undef CCK_SIFS_TIME
+#undef CCK_PREAMBLE_BITS
+#undef CCK_PLCP_BITS
+
+	case IEEE80211_T_OFDM:
+#define OFDM_SIFS_TIME        16
+#define OFDM_PREAMBLE_TIME    20
+#define OFDM_PLCP_BITS        22
+#define OFDM_SYMBOL_TIME       4
+
+#define OFDM_SIFS_TIME_HALF	32
+#define OFDM_PREAMBLE_TIME_HALF	40
+#define OFDM_PLCP_BITS_HALF	22
+#define OFDM_SYMBOL_TIME_HALF	8
+
+#define OFDM_SIFS_TIME_QUARTER 		64
+#define OFDM_PREAMBLE_TIME_QUARTER	80
+#define OFDM_PLCP_BITS_QUARTER		22
+#define OFDM_SYMBOL_TIME_QUARTER	16
+
+		if (AH_PRIVATE(ah)->ah_curchan && 
+			IS_CHAN_QUARTER_RATE(AH_PRIVATE(ah)->ah_curchan)) {
+			bitsPerSymbol	= (kbps * OFDM_SYMBOL_TIME_QUARTER) / 1000;
+			HALASSERT(bitsPerSymbol != 0);
+
+			numBits		= OFDM_PLCP_BITS + (frameLen << 3);
+			numSymbols	= howmany(numBits, bitsPerSymbol);
+			txTime		= OFDM_SIFS_TIME_QUARTER 
+						+ OFDM_PREAMBLE_TIME_QUARTER
+					+ (numSymbols * OFDM_SYMBOL_TIME_QUARTER);
+		} else if (AH_PRIVATE(ah)->ah_curchan &&
+				IS_CHAN_HALF_RATE(AH_PRIVATE(ah)->ah_curchan)) {
+			bitsPerSymbol	= (kbps * OFDM_SYMBOL_TIME_HALF) / 1000;
+			HALASSERT(bitsPerSymbol != 0);
+
+			numBits		= OFDM_PLCP_BITS + (frameLen << 3);
+			numSymbols	= howmany(numBits, bitsPerSymbol);
+			txTime		= OFDM_SIFS_TIME_HALF + 
+						OFDM_PREAMBLE_TIME_HALF
+					+ (numSymbols * OFDM_SYMBOL_TIME_HALF);
+		} else { /* full rate channel */
+			bitsPerSymbol	= (kbps * OFDM_SYMBOL_TIME) / 1000;
+			HALASSERT(bitsPerSymbol != 0);
+
+			numBits		= OFDM_PLCP_BITS + (frameLen << 3);
+			numSymbols	= howmany(numBits, bitsPerSymbol);
+			txTime		= OFDM_SIFS_TIME + OFDM_PREAMBLE_TIME
+					+ (numSymbols * OFDM_SYMBOL_TIME);
+		}
+		break;
+
+#undef OFDM_SIFS_TIME
+#undef OFDM_PREAMBLE_TIME
+#undef OFDM_PLCP_BITS
+#undef OFDM_SYMBOL_TIME
+
+	case IEEE80211_T_TURBO:
+#define TURBO_SIFS_TIME         8
+#define TURBO_PREAMBLE_TIME    14
+#define TURBO_PLCP_BITS        22
+#define TURBO_SYMBOL_TIME       4
+		/* we still save OFDM rates in kbps - so double them */
+		bitsPerSymbol = ((kbps << 1) * TURBO_SYMBOL_TIME) / 1000;
+		HALASSERT(bitsPerSymbol != 0);
+
+		numBits       = TURBO_PLCP_BITS + (frameLen << 3);
+		numSymbols    = howmany(numBits, bitsPerSymbol);
+		txTime        = TURBO_SIFS_TIME + TURBO_PREAMBLE_TIME
+			      + (numSymbols * TURBO_SYMBOL_TIME);
+		break;
+#undef TURBO_SIFS_TIME
+#undef TURBO_PREAMBLE_TIME
+#undef TURBO_PLCP_BITS
+#undef TURBO_SYMBOL_TIME
+
+	default:
+		HALDEBUG(ah, HAL_DEBUG_PHYIO,
+		    "%s: unknown phy %u (rate ix %u)\n",
+		    __func__, rates->info[rateix].phy, rateix);
+		txTime = 0;
+		break;
+	}
+	return txTime;
+}
+
+static __inline int
+mappsb(u_int freq, u_int flags)
+{
+	return ((freq * 10) + (((freq % 5) == 2) ? 5 : 0) - 49400) / 5;
+}
+
+/*
+ * Convert GHz frequency to IEEE channel number.
+ */
+int
+ath_hal_mhz2ieee(struct ath_hal *ah, u_int freq, u_int flags)
+{
+	if (flags & CHANNEL_2GHZ) {	/* 2GHz band */
+		if (freq == 2484)
+			return 14;
+		if (freq < 2484) {
+			return ((int)freq - 2407) / 5;
+		} else
+			return 15 + ((freq - 2512) / 20);
+	} else if (flags & CHANNEL_5GHZ) {/* 5Ghz band */
+		if (ath_hal_ispublicsafetysku(ah) &&
+		    IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) {
+			return mappsb(freq, flags);
+		} else if ((flags & CHANNEL_A) && (freq <= 5000)) {
+			return (freq - 4000) / 5;
+		} else {
+			return (freq - 5000) / 5;
+		}
+	} else {			/* either, guess */
+		if (freq == 2484)
+			return 14;
+		if (freq < 2484) {
+			return ((int)freq - 2407) / 5;
+		}
+		if (freq < 5000) {
+			if (ath_hal_ispublicsafetysku(ah) &&
+			    IS_CHAN_IN_PUBLIC_SAFETY_BAND(freq)) {
+				return mappsb(freq, flags);
+			} else if (freq > 4900) {
+				return (freq - 4000) / 5;
+			} else {
+				return 15 + ((freq - 2512) / 20);
+			}
+		}
+		return (freq - 5000) / 5;
+	}
+}
+
+typedef enum {
+	WIRELESS_MODE_11a   = 0,
+	WIRELESS_MODE_TURBO = 1,
+	WIRELESS_MODE_11b   = 2,
+	WIRELESS_MODE_11g   = 3,
+	WIRELESS_MODE_108g  = 4,
+
+	WIRELESS_MODE_MAX
+} WIRELESS_MODE;
+
+static WIRELESS_MODE
+ath_hal_chan2wmode(struct ath_hal *ah, const HAL_CHANNEL *chan)
+{
+	if (IS_CHAN_CCK(chan))
+		return WIRELESS_MODE_11b;
+	if (IS_CHAN_G(chan))
+		return WIRELESS_MODE_11g;
+	if (IS_CHAN_108G(chan))
+		return WIRELESS_MODE_108g;
+	if (IS_CHAN_TURBO(chan))
+		return WIRELESS_MODE_TURBO;
+	return WIRELESS_MODE_11a;
+}
+
+/*
+ * Convert between microseconds and core system clocks.
+ */
+                                     /* 11a Turbo  11b  11g  108g */
+static const uint8_t CLOCK_RATE[]  = { 40,  80,   22,  44,   88  };
+
+u_int
+ath_hal_mac_clks(struct ath_hal *ah, u_int usecs)
+{
+	const HAL_CHANNEL *c = (const HAL_CHANNEL *) AH_PRIVATE(ah)->ah_curchan;
+	u_int clks;
+
+	/* NB: ah_curchan may be null when called attach time */
+	if (c != AH_NULL) {
+		clks = usecs * CLOCK_RATE[ath_hal_chan2wmode(ah, c)];
+		if (IS_CHAN_HT40(c))
+			clks <<= 1;
+		else if (IS_CHAN_HALF_RATE(c))
+			clks >>= 1;
+		else if (IS_CHAN_QUARTER_RATE(c))
+			clks >>= 2;
+	} else
+		clks = usecs * CLOCK_RATE[WIRELESS_MODE_11b];
+	return clks;
+}
+
+u_int
+ath_hal_mac_usec(struct ath_hal *ah, u_int clks)
+{
+	const HAL_CHANNEL *c = (const HAL_CHANNEL *) AH_PRIVATE(ah)->ah_curchan;
+	u_int usec;
+
+	/* NB: ah_curchan may be null when called attach time */
+	if (c != AH_NULL) {
+		usec = clks / CLOCK_RATE[ath_hal_chan2wmode(ah, c)];
+		if (IS_CHAN_HT40(c))
+			usec >>= 1;
+		else if (IS_CHAN_HALF_RATE(c))
+			usec <<= 1;
+		else if (IS_CHAN_QUARTER_RATE(c))
+			usec <<= 2;
+	} else
+		usec = clks / CLOCK_RATE[WIRELESS_MODE_11b];
+	return usec;
+}
+
+/*
+ * Setup a h/w rate table's reverse lookup table and
+ * fill in ack durations.  This routine is called for
+ * each rate table returned through the ah_getRateTable
+ * method.  The reverse lookup tables are assumed to be
+ * initialized to zero (or at least the first entry).
+ * We use this as a key that indicates whether or not
+ * we've previously setup the reverse lookup table.
+ *
+ * XXX not reentrant, but shouldn't matter
+ */
+void
+ath_hal_setupratetable(struct ath_hal *ah, HAL_RATE_TABLE *rt)
+{
+#define	N(a)	(sizeof(a)/sizeof(a[0]))
+	int i;
+
+	if (rt->rateCodeToIndex[0] != 0)	/* already setup */
+		return;
+	for (i = 0; i < N(rt->rateCodeToIndex); i++)
+		rt->rateCodeToIndex[i] = (uint8_t) -1;
+	for (i = 0; i < rt->rateCount; i++) {
+		uint8_t code = rt->info[i].rateCode;
+		uint8_t cix = rt->info[i].controlRate;
+
+		HALASSERT(code < N(rt->rateCodeToIndex));
+		rt->rateCodeToIndex[code] = i;
+		HALASSERT((code | rt->info[i].shortPreamble) <
+		    N(rt->rateCodeToIndex));
+		rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i;
+		/*
+		 * XXX for 11g the control rate to use for 5.5 and 11 Mb/s
+		 *     depends on whether they are marked as basic rates;
+		 *     the static tables are setup with an 11b-compatible
+		 *     2Mb/s rate which will work but is suboptimal
+		 */
+		rt->info[i].lpAckDuration = ath_hal_computetxtime(ah, rt,
+			WLAN_CTRL_FRAME_SIZE, cix, AH_FALSE);
+		rt->info[i].spAckDuration = ath_hal_computetxtime(ah, rt,
+			WLAN_CTRL_FRAME_SIZE, cix, AH_TRUE);
+	}
+#undef N
+}
+
+HAL_STATUS
+ath_hal_getcapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type,
+	uint32_t capability, uint32_t *result)
+{
+	const HAL_CAPABILITIES *pCap = &AH_PRIVATE(ah)->ah_caps;
+
+	switch (type) {
+	case HAL_CAP_REG_DMN:		/* regulatory domain */
+		*result = AH_PRIVATE(ah)->ah_currentRD;
+		return HAL_OK;
+	case HAL_CAP_CIPHER:		/* cipher handled in hardware */
+	case HAL_CAP_TKIP_MIC:		/* handle TKIP MIC in hardware */
+		return HAL_ENOTSUPP;
+	case HAL_CAP_TKIP_SPLIT:	/* hardware TKIP uses split keys */
+		return HAL_ENOTSUPP;
+	case HAL_CAP_PHYCOUNTERS:	/* hardware PHY error counters */
+		return pCap->halHwPhyCounterSupport ? HAL_OK : HAL_ENXIO;
+	case HAL_CAP_WME_TKIPMIC:   /* hardware can do TKIP MIC when WMM is turned on */
+		return HAL_ENOTSUPP;
+	case HAL_CAP_DIVERSITY:		/* hardware supports fast diversity */
+		return HAL_ENOTSUPP;
+	case HAL_CAP_KEYCACHE_SIZE:	/* hardware key cache size */
+		*result =  pCap->halKeyCacheSize;
+		return HAL_OK;
+	case HAL_CAP_NUM_TXQUEUES:	/* number of hardware tx queues */
+		*result = pCap->halTotalQueues;
+		return HAL_OK;
+	case HAL_CAP_VEOL:		/* hardware supports virtual EOL */
+		return pCap->halVEOLSupport ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_PSPOLL:		/* hardware PS-Poll support works */
+		return pCap->halPSPollBroken ? HAL_ENOTSUPP : HAL_OK;
+	case HAL_CAP_COMPRESSION:
+		return pCap->halCompressSupport ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_BURST:
+		return pCap->halBurstSupport ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_FASTFRAME:
+		return pCap->halFastFramesSupport ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_DIAG:		/* hardware diagnostic support */
+		*result = AH_PRIVATE(ah)->ah_diagreg;
+		return HAL_OK;
+	case HAL_CAP_TXPOW:		/* global tx power limit  */
+		switch (capability) {
+		case 0:			/* facility is supported */
+			return HAL_OK;
+		case 1:			/* current limit */
+			*result = AH_PRIVATE(ah)->ah_powerLimit;
+			return HAL_OK;
+		case 2:			/* current max tx power */
+			*result = AH_PRIVATE(ah)->ah_maxPowerLevel;
+			return HAL_OK;
+		case 3:			/* scale factor */
+			*result = AH_PRIVATE(ah)->ah_tpScale;
+			return HAL_OK;
+		}
+		return HAL_ENOTSUPP;
+	case HAL_CAP_BSSIDMASK:		/* hardware supports bssid mask */
+		return pCap->halBssIdMaskSupport ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_MCAST_KEYSRCH:	/* multicast frame keycache search */
+		return pCap->halMcastKeySrchSupport ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_TSF_ADJUST:	/* hardware has beacon tsf adjust */
+		return HAL_ENOTSUPP;
+	case HAL_CAP_CHAN_HALFRATE:
+		return pCap->halChanHalfRate ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_CHAN_QUARTERRATE:
+		return pCap->halChanQuarterRate ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_RFSILENT:		/* rfsilent support  */
+		switch (capability) {
+		case 0:			/* facility is supported */
+			return pCap->halRfSilentSupport ? HAL_OK : HAL_ENOTSUPP;
+		case 1:			/* current setting */
+			return AH_PRIVATE(ah)->ah_rfkillEnabled ?
+				HAL_OK : HAL_ENOTSUPP;
+		case 2:			/* rfsilent config */
+			*result = AH_PRIVATE(ah)->ah_rfsilent;
+			return HAL_OK;
+		}
+		return HAL_ENOTSUPP;
+	case HAL_CAP_11D:
+#ifdef AH_SUPPORT_11D
+		return HAL_OK;
+#else
+		return HAL_ENOTSUPP;
+#endif
+	case HAL_CAP_RXORN_FATAL:	/* HAL_INT_RXORN treated as fatal  */
+		return AH_PRIVATE(ah)->ah_rxornIsFatal ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_HT:
+		return pCap->halHTSupport ? HAL_OK : HAL_ENOTSUPP;
+	case HAL_CAP_TX_CHAINMASK:	/* mask of TX chains supported */
+		*result = pCap->halTxChainMask;
+		return HAL_OK;
+	case HAL_CAP_RX_CHAINMASK:	/* mask of RX chains supported */
+		*result = pCap->halRxChainMask;
+		return HAL_OK;
+	case HAL_CAP_RXTSTAMP_PREC:	/* rx desc tstamp precision (bits) */
+		*result = pCap->halTstampPrecision;
+		return HAL_OK;
+	default:
+		return HAL_EINVAL;
+	}
+}
+
+HAL_BOOL
+ath_hal_setcapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type,
+	uint32_t capability, uint32_t setting, HAL_STATUS *status)
+{
+
+	switch (type) {
+	case HAL_CAP_TXPOW:
+		switch (capability) {
+		case 3:
+			if (setting <= HAL_TP_SCALE_MIN) {
+				AH_PRIVATE(ah)->ah_tpScale = setting;
+				return AH_TRUE;
+			}
+			break;
+		}
+		break;
+	case HAL_CAP_RFSILENT:		/* rfsilent support  */
+		/*
+		 * NB: allow even if halRfSilentSupport is false
+		 *     in case the EEPROM is misprogrammed.
+		 */
+		switch (capability) {
+		case 1:			/* current setting */
+			AH_PRIVATE(ah)->ah_rfkillEnabled = (setting != 0);
+			return AH_TRUE;
+		case 2:			/* rfsilent config */
+			/* XXX better done per-chip for validation? */
+			AH_PRIVATE(ah)->ah_rfsilent = setting;
+			return AH_TRUE;
+		}
+		break;
+	case HAL_CAP_REG_DMN:		/* regulatory domain */
+		AH_PRIVATE(ah)->ah_currentRD = setting;
+		return AH_TRUE;
+	case HAL_CAP_RXORN_FATAL:	/* HAL_INT_RXORN treated as fatal  */
+		AH_PRIVATE(ah)->ah_rxornIsFatal = setting;
+		return AH_TRUE;
+	default:
+		break;
+	}
+	if (status)
+		*status = HAL_EINVAL;
+	return AH_FALSE;
+}
+
+/* 
+ * Common support for getDiagState method.
+ */
+
+static u_int
+ath_hal_getregdump(struct ath_hal *ah, const HAL_REGRANGE *regs,
+	void *dstbuf, int space)
+{
+	uint32_t *dp = dstbuf;
+	int i;
+
+	for (i = 0; space >= 2*sizeof(uint32_t); i++) {
+		u_int r = regs[i].start;
+		u_int e = regs[i].end;
+		*dp++ = (r<<16) | e;
+		space -= sizeof(uint32_t);
+		do {
+			*dp++ = OS_REG_READ(ah, r);
+			r += sizeof(uint32_t);
+			space -= sizeof(uint32_t);
+		} while (r <= e && space >= sizeof(uint32_t));
+	}
+	return (char *) dp - (char *) dstbuf;
+}
+
+HAL_BOOL
+ath_hal_getdiagstate(struct ath_hal *ah, int request,
+	const void *args, uint32_t argsize,
+	void **result, uint32_t *resultsize)
+{
+	switch (request) {
+	case HAL_DIAG_REVS:
+		*result = &AH_PRIVATE(ah)->ah_devid;
+		*resultsize = sizeof(HAL_REVS);
+		return AH_TRUE;
+	case HAL_DIAG_REGS:
+		*resultsize = ath_hal_getregdump(ah, args, *result,*resultsize);
+		return AH_TRUE;
+	case HAL_DIAG_FATALERR:
+		*result = &AH_PRIVATE(ah)->ah_fatalState[0];
+		*resultsize = sizeof(AH_PRIVATE(ah)->ah_fatalState);
+		return AH_TRUE;
+	case HAL_DIAG_EEREAD:
+		if (argsize != sizeof(uint16_t))
+			return AH_FALSE;
+		if (!ath_hal_eepromRead(ah, *(const uint16_t *)args, *result))
+			return AH_FALSE;
+		*resultsize = sizeof(uint16_t);
+		return AH_TRUE;
+#ifdef AH_PRIVATE_DIAG
+	case HAL_DIAG_SETKEY: {
+		const HAL_DIAG_KEYVAL *dk;
+
+		if (argsize != sizeof(HAL_DIAG_KEYVAL))
+			return AH_FALSE;
+		dk = (const HAL_DIAG_KEYVAL *)args;
+		return ah->ah_setKeyCacheEntry(ah, dk->dk_keyix,
+			&dk->dk_keyval, dk->dk_mac, dk->dk_xor);
+	}
+	case HAL_DIAG_RESETKEY:
+		if (argsize != sizeof(uint16_t))
+			return AH_FALSE;
+		return ah->ah_resetKeyCacheEntry(ah, *(const uint16_t *)args);
+#endif /* AH_PRIVATE_DIAG */
+	case HAL_DIAG_11NCOMPAT:
+		if (argsize == 0) {
+			*resultsize = sizeof(uint32_t);
+			*((uint32_t *)(*result)) =
+				AH_PRIVATE(ah)->ah_11nCompat;
+		} else if (argsize == sizeof(uint32_t)) {
+			AH_PRIVATE(ah)->ah_11nCompat = *(const uint32_t *)args;
+		} else
+			return AH_FALSE;
+		return AH_TRUE;
+	}
+	return AH_FALSE;
+}
+
+/*
+ * Set the properties of the tx queue with the parameters
+ * from qInfo.
+ */
+HAL_BOOL
+ath_hal_setTxQProps(struct ath_hal *ah,
+	HAL_TX_QUEUE_INFO *qi, const HAL_TXQ_INFO *qInfo)
+{
+	uint32_t cw;
+
+	if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {
+		HALDEBUG(ah, HAL_DEBUG_TXQUEUE,
+		    "%s: inactive queue\n", __func__);
+		return AH_FALSE;
+	}
+	/* XXX validate parameters */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list