⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ah_os.c.svn-base

📁 最新之atheros芯片driver source code, 基于linux操作系统,內含atheros芯片HAL全部代码
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
/*- * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer, *    without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any *    redistribution must be conditioned upon including a substantially *    similar Disclaimer requirement for further binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names *    of any contributors may be used to endorse or promote products derived *    from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * NO WARRANTY * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. * * $Id$ */#include "opt_ah.h"#ifndef EXPORT_SYMTAB#define	EXPORT_SYMTAB#endif /* EXPORT_SYMTAB *//* Don't use virtualized timer in Linux 2.6.20+ */#define USE_REAL_TIME_DELAY#ifndef AUTOCONF_INCLUDED#include <linux/config.h>#endif /* AUTOCONF_INCLUDED */#include <linux/version.h>#include <linux/module.h>#include <linux/init.h>#include <linux/kernel.h>#include <linux/slab.h>#include <linux/delay.h>#include <linux/sched.h>#include <linux/sysctl.h>#include <linux/proc_fs.h>#include <asm/io.h>#include <ah.h>#include <ah_os.h>#ifdef AH_DEBUGint ath_hal_debug = 0;EXPORT_SYMBOL(ath_hal_debug);#endif /* AH_DEBUG */#define		MSG_MAXLEN	161#define REGOP_NONE  0#define REGOP_READ  1#define REGOP_WRITE 2int	ath_hal_dma_beacon_response_time = 2;	/* in TUs */int	ath_hal_sw_beacon_response_time = 10;	/* in TUs */int	ath_hal_additional_swba_backoff = 0;	/* in TUs */struct ath_hal *_ath_hal_attach(u_int16_t devid, HAL_SOFTC sc,		HAL_BUS_TAG t, HAL_BUS_HANDLE h, HAL_STATUS *s){	struct ath_hal *ah = ath_hal_attach(devid, sc, t, h, s);	if (ah)#ifndef __MOD_INC_USE_COUNT		if (!try_module_get(THIS_MODULE)) {			printk(KERN_WARNING "%s: try_module_get failed\n",					__func__);			_ath_hal_detach(ah);			return NULL;		}#else /* __MOD_INC_USE_COUNT */		MOD_INC_USE_COUNT;#endif /* __MOD_INC_USE_COUNT */	return ah;}void_ath_hal_detach(struct ath_hal *ah){	(*ah->ah_detach)(ah);#ifndef __MOD_INC_USE_COUNT	module_put(THIS_MODULE);#else /* __MOD_INC_USE_COUNT */	MOD_DEC_USE_COUNT;#endif /* __MOD_INC_USE_COUNT */}/* * Print/log message support. */#ifdef AH_ASSERTvoid __ahdeclath_hal_assert_failed(const char *filename, int lineno, const char *msg){	printk(KERN_ERR "Atheros HAL assertion failure: %s: line %u: %s\n",		filename, lineno, msg);	panic("ath_hal_assert");}#endif /* AH_ASSERT *//* Store the current function name (should be called by wrapper functions) * useful for debugging and figuring out, which hal function sets which  * registers */const char *ath_hal_func = NULL;const char *ath_hal_device = NULL;EXPORT_SYMBOL(ath_hal_func);EXPORT_SYMBOL(ath_hal_device);#ifdef AH_DEBUG_ALQ/* * ALQ register tracing support. * * Setting hw.ath.hal.alq=1 enables tracing of all register reads and * writes to the file /var/log/ath_hal.log.  The file format is a simple * fixed-size array of records.  When done logging set hw.ath.hal.alq=0 * and then decode the file with the ardecode program (that is part of the * HAL).  If you start+stop tracing the data will be appended to an * existing file. * * NB: doesn't handle multiple devices properly; only one DEVICE record *     is emitted and the different devices are not identified. */#include "alq.h"static	struct alq *ath_hal_alq = NULL;static	u_int ath_hal_alq_lost;		/* count of lost records */static	const char *ath_hal_logfile = "/var/log/ath_hal.log";static	u_int ath_hal_alq_qsize = 8 * 1024;static intath_hal_setlogging(int enable){	int error;	if (enable) {		if (!capable(CAP_NET_ADMIN))			return -EPERM;		error = alq_open(&ath_hal_alq, ath_hal_logfile,				MSG_MAXLEN, ath_hal_alq_qsize, (enable == 1 ? 0x7fffffff : enable));		ath_hal_alq_lost = 0;		printk(KERN_INFO "ath_hal: logging to %s %s\n", ath_hal_logfile,			error == 0 ? "enabled" : "could not be setup");	} else {		if (ath_hal_alq)			alq_close(ath_hal_alq);		ath_hal_alq = NULL;		printk(KERN_INFO "ath_hal: logging disabled\n");		error = 0;	}	return error;}/* * Deal with the sysctl handler api changing. */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)#define	AH_SYSCTL_ARGS_DECL \	ctl_table *ctl, int write, struct file *filp, void *buffer, \		size_t *lenp#define	AH_SYSCTL_ARGS		ctl, write, filp, buffer, lenp#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8) */#define	AH_SYSCTL_ARGS_DECL \	ctl_table *ctl, int write, struct file *filp, void *buffer,\		size_t *lenp, loff_t *ppos#define	AH_SYSCTL_ARGS		ctl, write, filp, buffer, lenp, ppos#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,8) */static intsysctl_hw_ath_hal_log(AH_SYSCTL_ARGS_DECL){	int error, enable;	ctl->data = &enable;	ctl->maxlen = sizeof(enable);	enable = (ath_hal_alq != NULL);	error = proc_dointvec(AH_SYSCTL_ARGS);	if (error || !write)		return error;	else		return ath_hal_setlogging(enable);}static inline voidath_hal_logvprintf(struct ath_hal *ah, const char *fmt, va_list ap){	struct ale *ale;	if (!ath_hal_alq) {		ath_hal_alq_lost++;		return;	}	ale = alq_get(ath_hal_alq, ALQ_NOWAIT);	if (!ale) {		ath_hal_alq_lost++;		return;	}	memset(ale->ae_data, 0, MSG_MAXLEN);	vsnprintf(ale->ae_data, MSG_MAXLEN, fmt, ap);	alq_post(ath_hal_alq, ale);}void __ahdecl ath_hal_logprintf(struct ath_hal *ah, const char *fmt, ...){	va_list ap;	va_start(ap, fmt);	ath_hal_logvprintf(ah, fmt, ap);	va_end(ap);}EXPORT_SYMBOL(ath_hal_logprintf);#endif /* AH_DEBUG_ALQ */static inline void_hal_vprintf(struct ath_hal *ah, HAL_BOOL prefer_alq, const char *fmt, va_list ap){	char buf[MSG_MAXLEN];#ifdef AH_DEBUG_ALQ	if (prefer_alq && ath_hal_alq) {		ath_hal_logvprintf(ah, fmt, ap);		return;	}#endif /* AH_DEBUG_ALQ */	vsnprintf(buf, sizeof(buf), fmt, ap);	printk("%s", buf);}void __ahdecl ath_hal_printf(struct ath_hal *ah, HAL_BOOL prefer_alq, const char *fmt, ...){	va_list ap;	va_start(ap, fmt);	_hal_vprintf(ah, prefer_alq, fmt, ap);	va_end(ap);}EXPORT_SYMBOL(ath_hal_printf);/* Lookup a friendly name for a register address (for any we have nicknames * for). Names were taken from openhal ar5212regs.h. Return AH_TRUE if the * name is a known ar5212 register, and AH_FALSE otherwise. */HAL_BOOLath_hal_lookup_register_name(struct ath_hal *ah, char *buf, int buflen, 		u_int32_t address) {	const char *static_label = NULL;	memset(buf, 0, buflen);#if 0 /* Enable once for each new board/magic type */	printk("MAGIC: %x\n", ah->ah_magic);#endif	if (ah->ah_magic == 0x19541014 /* AR5212 compatible HAL magic */ ) {		/* Handle Static Register Labels (unique stuff we know about) */		switch (address) {		case 0x0008: static_label = "AR5K_CR"; break;		case 0x000c: static_label = "AR5K_RXDP"; break;		case 0x0014: static_label = "AR5K_CFG"; break;		case 0x0024: static_label = "AR5K_IER"; break;		case 0x0030: static_label = "AR5K_TXCFG"; break;		case 0x0034: static_label = "AR5K_RXCFG"; break;		case 0x0040: static_label = "AR5K_MIBC"; break;		case 0x0044: static_label = "AR5K_TOPS"; break;		case 0x0048: static_label = "AR5K_RXNOFRM"; break;		case 0x004c: static_label = "AR5K_TXNOFRM"; break;		case 0x0050: static_label = "AR5K_RPGTO"; break;		case 0x0054: static_label = "AR5K_RFCNT"; break;		case 0x0058: static_label = "AR5K_MISC"; break;		case 0x0080: static_label = "AR5K_PISR"; break;		case 0x0084: static_label = "AR5K_SISR0"; break;		case 0x0088: static_label = "AR5K_SISR1"; break;		case 0x008c: static_label = "AR5K_SISR2"; break;		case 0x0090: static_label = "AR5K_SISR3"; break;		case 0x0094: static_label = "AR5K_SISR4"; break;		case 0x00a0: static_label = "AR5K_PIMR"; break;		case 0x00a4: static_label = "AR5K_SIMR0"; break;		case 0x00a8: static_label = "AR5K_SIMR1"; break;		case 0x00ac: static_label = "AR5K_SIMR2"; break;		case 0x00b0: static_label = "AR5K_SIMR3"; break;		case 0x00b4: static_label = "AR5K_SIMR4"; break;		case 0x00c0: static_label = "AR5K_RAC_PISR"; break;		case 0x00c4: static_label = "AR5K_RAC_SISR0"; break;		case 0x00c8: static_label = "AR5K_RAC_SISR1"; break;		case 0x00cc: static_label = "AR5K_RAC_SISR2"; break;		case 0x00d0: static_label = "AR5K_RAC_SISR3"; break;		case 0x00d4: static_label = "AR5K_RAC_SISR4"; break;		case 0x0400: static_label = "AR5K_DCM_ADDR"; break;		case 0x0404: static_label = "AR5K_DCM_DATA"; break;		case 0x0420: static_label = "AR5K_DCCFG"; break;		case 0x0600: static_label = "AR5K_CCFG"; break;		case 0x0604: static_label = "AR5K_CCFG_CUP"; break;		case 0x0610: static_label = "AR5K_CPC0"; break;		case 0x0614: static_label = "AR5K_CPC1"; break;		case 0x0618: static_label = "AR5K_CPC2"; break;		case 0x061c: static_label = "AR5K_CPC3"; break;		case 0x0620: static_label = "AR5K_CPCORN"; break;		case 0x0840: static_label = "AR5K_QCU_TXE"; break;		case 0x0880: static_label = "AR5K_QCU_TXD"; break;		case 0x0940: static_label = "AR5K_QCU_ONESHOTARM_SET"; break;		case 0x0980: static_label = "AR5K_QCU_ONESHOTARM_CLEAR"; break;		case 0xa200: static_label = "AR5K_PHY_MODE"; break;		case 0x0a40: static_label = "AR5K_QCU_RDYTIMESHDN"; break;		case 0x0b00: static_label = "AR5K_QCU_CBB_SELECT"; break;		case 0x0b04: static_label = "AR5K_QCU_CBB_ADDR"; break;		case 0x0b08: static_label = "AR5K_QCU_CBCFG"; break;		case 0x1030: static_label = "AR5K_DCU_GBL_IFS_SIFS"; break;		case 0x1038: static_label = "AR5K_DCU_TX_FILTER"; break;		case 0x1070: static_label = "AR5K_DCU_GBL_IFS_SLOT"; break;		case 0x10b0: static_label = "AR5K_DCU_GBL_IFS_EIFS"; break;		case 0x10f0: static_label = "AR5K_DCU_GBL_IFS_MISC"; break;		case 0x1230: static_label = "AR5K_DCU_FP"; break;		case 0x1270: static_label = "AR5K_DCU_TXP"; break;		case 0x143c: static_label = "AR5K_DCU_TX_FILTER_CLR"; break;		case 0x147c: static_label = "AR5K_DCU_TX_FILTER_SET"; break;		case 0x4000: static_label = "AR5K_RESET_CTL"; break;		case 0x4004: static_label = "AR5K_SLEEP_CTL"; break;		case 0x4008: static_label = "AR5K_INTPEND"; break;		case 0x400c: static_label = "AR5K_SFR"; break;		case 0x4010: static_label = "AR5K_PCICFG"; break;		case 0x4014: static_label = "AR5K_GPIOCR"; break;		case 0x4018: static_label = "AR5K_GPIODO"; break;		case 0x401c: static_label = "AR5K_GPIODI"; break;		case 0x4020: static_label = "AR5K_SREV"; break;		case 0x6000: static_label = "AR5K_EEPROM_BASE"; break;		case 0x6004: static_label = "AR5K_EEPROM_DATA_5211"; break;		case 0x6008: static_label = "AR5K_EEPROM_CMD"; break;		case 0x600c: static_label = "AR5K_EEPROM_STAT_5211"; break;		case 0x6010: static_label = "AR5K_EEPROM_CFG"; break;		case 0x8000: static_label = "AR5K_STA_ID0"; break;		case 0x8004: static_label = "AR5K_STA_ID1"; break;		case 0x8008: static_label = "AR5K_BSS_ID0"; break;		case 0x800c: static_label = "AR5K_BSS_ID1"; break;		case 0x8010: static_label = "AR5K_SLOT_TIME"; break;		case 0x8014: static_label = "AR5K_TIME_OUT"; break;		case 0x8018: static_label = "AR5K_RSSI_THR"; break;		case 0x801c: static_label = "AR5K_USEC_5211"; break;		case 0x8020: static_label = "AR5K_BEACON_5211"; break;		case 0x8024: static_label = "AR5K_CFP_PERIOD_5211"; break;		case 0x8028: static_label = "AR5K_TIMER0_5211"; break;		case 0x802c: static_label = "AR5K_TIMER1_5211"; break;		case 0x8030: static_label = "AR5K_TIMER2_5211"; break;		case 0x8034: static_label = "AR5K_TIMER3_5211"; break;		case 0x8038: static_label = "AR5K_CFP_DUR_5211"; break;		case 0x803c: static_label = "AR5K_RX_FILTER_5211"; break;		case 0x8040: static_label = "AR5K_MCAST_FILTER0_5211"; break;		case 0x8044: static_label = "AR5K_MCAST_FILTER1_5211"; break;		case 0x8048: static_label = "AR5K_DIAG_SW_5211"; break;		case 0x804c: static_label = "AR5K_TSF_L32_5211"; break;		case 0x8050: static_label = "AR5K_TSF_U32_5211"; break;		case 0x8054: static_label = "AR5K_ADDAC_TEST"; break;		case 0x8058: static_label = "AR5K_DEFAULT_ANTENNA"; break;		case 0x8080: static_label = "AR5K_LAST_TSTP"; break;		case 0x8084: static_label = "AR5K_NAV_5211"; break;		case 0x8088: static_label = "AR5K_RTS_OK_5211"; break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -