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

📄 rt_linux.h

📁 ralink最新rt3070 usb wifi 无线网卡驱动程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ************************************************************************* * Ralink Tech Inc. * 5F., No.36, Taiyuan St., Jhubei City, * Hsinchu County 302, * Taiwan, R.O.C. * * (c) Copyright 2002-2007, Ralink Technology, Inc. * * This program is free software; you can redistribute it and/or modify  *  * it under the terms of the GNU General Public License as published by  *  * the Free Software Foundation; either version 2 of the License, or     *  * (at your option) any later version.                                   *  *                                                                       *  * This program is distributed in the hope that it will be useful,       *  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *  * GNU General Public License for more details.                          *  *                                                                       *  * You should have received a copy of the GNU General Public License     *  * along with this program; if not, write to the                         *  * Free Software Foundation, Inc.,                                       *  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *  *                                                                       *  ************************************************************************* */ /***********************************************************************//*                                                                     *//*   Program:    rt_linux.c                                            *//*   Created:    4/21/2006 1:17:38 PM                                  *//*   Author:     Wu Xi-Kun                                             *//*   Comments:   `description`                                         *//*                                                                     *//*---------------------------------------------------------------------*//*                                                                     *//* History:                                                            *//*    Revision 1.1 4/21/2006 1:17:38 PM  xsikun                        *//*    Initial revision                                                 *//*                                                                     *//***********************************************************************/#include "rtmp_type.h"#include <linux/module.h>#include <linux/version.h>#include <linux/kernel.h>#include <linux/spinlock.h>#include <linux/init.h>#include <linux/string.h>#include <linux/timer.h>#include <linux/errno.h>#include <linux/slab.h>#include <linux/interrupt.h>#include <linux/pci.h>#include <linux/netdevice.h>#include <linux/etherdevice.h>#include <linux/skbuff.h>#include <linux/ethtool.h>#include <linux/wireless.h>#include <linux/proc_fs.h>#include <linux/delay.h>#include <linux/if_arp.h>#include <linux/ctype.h>#include <linux/vmalloc.h>#include <linux/wireless.h>#include <net/iw_handler.h>// load firmware#define __KERNEL_SYSCALLS__#include <linux/unistd.h>#include <asm/uaccess.h>#define MEM_ALLOC_FLAG      (GFP_ATOMIC) //(GFP_DMA | GFP_ATOMIC)#ifndef IFNAMSIZ#define IFNAMSIZ 16#endif//#define CONFIG_CKIP_SUPPORT#undef __inline#define __inline	   static inline typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_dev);// add by kathy#ifdef CONFIG_STA_SUPPORT#ifdef RT2870#define STA_PROFILE_PATH			"/etc/Wireless/RT2870STA/RT2870STA.dat"#define STA_RT2870_IMAGE_FILE_NAME  "/etc/Wireless/RT2870STA/rt2870.bin"#define STA_NIC_DEVICE_NAME			"RT2870STA"#define STA_DRIVER_VERSION			"2.0.1.0"#ifdef MULTIPLE_CARD_SUPPORT#define CARD_INFO_PATH			"/etc/Wireless/RT2870STA/RT2870STACard.dat"#endif // MULTIPLE_CARD_SUPPORT //#endif // RT2870 //#endif // CONFIG_STA_SUPPORT //#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)#define RTMP_TIME_AFTER(a,b)		\	(typecheck(unsigned long, (unsigned long)a) && \	 typecheck(unsigned long, (unsigned long)b) && \	 ((long)(b) - (long)(a) < 0))#define RTMP_TIME_AFTER_EQ(a,b)	\	(typecheck(unsigned long, (unsigned long)a) && \	 typecheck(unsigned long, (unsigned long)b) && \	 ((long)(a) - (long)(b) >= 0))#define RTMP_TIME_BEFORE(a,b)	RTMP_TIME_AFTER_EQ(b,a)#else#define RTMP_TIME_AFTER(a,b) time_after(a, b)#endif#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)#define RT_MOD_INC_USE_COUNT() \	if (!try_module_get(THIS_MODULE)) \	{ \		DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __FUNCTION__)); \		return -1; \	}#define RT_MOD_DEC_USE_COUNT() module_put(THIS_MODULE);#else#define RT_MOD_INC_USE_COUNT()	MOD_INC_USE_COUNT;#define RT_MOD_DEC_USE_COUNT() MOD_DEC_USE_COUNT;#endif#define OS_HZ			HZ#define ETH_LENGTH_OF_ADDRESS	6#define IN#define OUT#define NDIS_STATUS                             INT#define NDIS_STATUS_SUCCESS                     0x00#define NDIS_STATUS_FAILURE                     0x01#define NDIS_STATUS_INVALID_DATA				0x02#define NDIS_STATUS_RESOURCES                   0x03#define MIN_NET_DEVICE_FOR_AID			0x00		//0x00~0x3f#define MIN_NET_DEVICE_FOR_MBSSID		0x00		//0x00,0x10,0x20,0x30#define MIN_NET_DEVICE_FOR_WDS			0x10		//0x40,0x50,0x60,0x70#define MIN_NET_DEVICE_FOR_APCLI		0x20#define MIN_NET_DEVICE_FOR_MESH			0x30#ifdef CONFIG_STA_SUPPORT#define MIN_NET_DEVICE_FOR_DLS			0x40#endif // CONFIG_STA_SUPPORT //#ifdef CONFIG_STA_SUPPORT#define NDIS_PACKET_TYPE_DIRECTED		0#define NDIS_PACKET_TYPE_MULTICAST		1#define NDIS_PACKET_TYPE_BROADCAST		2#define NDIS_PACKET_TYPE_ALL_MULTICAST	3#endif // CONFIG_STA_SUPPORT //struct os_lock  {	spinlock_t		lock;	unsigned long  	flags;};struct os_cookie {#ifdef RT2870	struct usb_device		*pUsb_Dev;	pid_t					MLMEThr_pid;	pid_t					RTUSBCmdThr_pid;	pid_t					TimerQThr_pid;#endif // RT2870 //	struct tasklet_struct 	rx_done_task;	struct tasklet_struct 	mgmt_dma_done_task;	struct tasklet_struct 	ac0_dma_done_task;	struct tasklet_struct 	ac1_dma_done_task;	struct tasklet_struct 	ac2_dma_done_task;	struct tasklet_struct 	ac3_dma_done_task;	struct tasklet_struct 	hcca_dma_done_task;	struct tasklet_struct	tbtt_task;#ifdef RT2870	struct tasklet_struct	null_frame_complete_task;	struct tasklet_struct	rts_frame_complete_task;	struct tasklet_struct	pspoll_frame_complete_task;#endif // RT2870 //	unsigned long			apd_pid; //802.1x daemon pid	INT						ioctl_if_type;	INT 					ioctl_if;};	typedef struct _VIRTUAL_ADAPTER{	struct net_device		*RtmpDev;	struct net_device		*VirtualDev;} VIRTUAL_ADAPTER, PVIRTUAL_ADAPTER;#undef  ASSERT#define ASSERT(x)                                                               \{                                                                               \    if (!(x))                                                                   \    {                                                                           \        printk(KERN_WARNING __FILE__ ":%d assert " #x "failed\n", __LINE__);    \    }                                                                           \}	typedef struct os_cookie	* POS_COOKIE;	typedef struct pci_dev 		* PPCI_DEV;	typedef struct net_device	* PNET_DEV;typedef void				* PNDIS_PACKET;typedef char				NDIS_PACKET;typedef PNDIS_PACKET		* PPNDIS_PACKET;typedef	dma_addr_t			NDIS_PHYSICAL_ADDRESS;typedef	dma_addr_t			* PNDIS_PHYSICAL_ADDRESS;//typedef struct timer_list	RALINK_TIMER_STRUCT;//typedef struct timer_list	* PRALINK_TIMER_STRUCT;//typedef struct os_lock		NDIS_SPIN_LOCK;typedef spinlock_t			NDIS_SPIN_LOCK;typedef struct timer_list	NDIS_MINIPORT_TIMER;typedef void				* NDIS_HANDLE;typedef char 				* PNDIS_BUFFER;void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen);dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, int sd_idx, int direction);void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, int direction);////////////////////////////////////////// MOVE TO rtmp.h ?/////////////////////////////////////////#define PKTSRC_NDIS             0x7f#define PKTSRC_DRIVER           0x0f#define PRINT_MAC(addr)	\	addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]#define RT2860_PCI_DEVICE_ID		0x0601#ifdef RT2870#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (ULONG)0#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir)#endif // RT2870 //#define BEACON_FRAME_DMA_CACHE_WBACK(_ptr, _size)	\	dma_cache_wback(_ptr, _size)//////////////////////////////////////////////////////////////////////////////////////#define NdisMIndicateStatus(_w, _x, _y, _z)typedef struct timer_list	RTMP_OS_TIMER;	#ifdef RT2870/* ----------------- Timer Related MARCO ---------------*/// In RT2870, we have a lot of timer functions and will read/write register, it's //	not allowed in Linux USB sub-system to do it ( because of sleep issue when submit //  to ctrl pipe). So we need a wrapper function to take care it.typedef VOID (*RT2870_TIMER_HANDLE)(	IN  PVOID   SystemSpecific1, 	IN  PVOID   FunctionContext, 	IN  PVOID   SystemSpecific2, 	IN  PVOID   SystemSpecific3);#endif // RT2870 //typedef struct  _RALINK_TIMER_STRUCT    {    RTMP_OS_TIMER		TimerObj;       // Ndis Timer object	BOOLEAN				Valid;			// Set to True when call RTMPInitTimer    BOOLEAN             State;          // True if timer cancelled    BOOLEAN	      		PeriodicType;	// True if timer is periodic timer     BOOLEAN             Repeat;         // True if periodic timer    ULONG               TimerValue;     // Timer value in milliseconds	ULONG				cookie;			// os specific object#ifdef RT2870	RT2870_TIMER_HANDLE	handle;	void				*pAd;#endif // RT2870 //}   RALINK_TIMER_STRUCT, *PRALINK_TIMER_STRUCT;#ifdef RT2870typedef enum _RT2870_KERNEL_THREAD_STATUS_{	RT2870_THREAD_UNKNOWN = 0,	RT2870_THREAD_INITED = 1,	RT2870_THREAD_RUNNING = 2,	RT2870_THREAD_STOPED = 4,}RT2870_KERNEL_THREAD_STATUS;#define RT2870_THREAD_CAN_DO_INSERT		(RT2870_THREAD_INITED |RT2870_THREAD_RUNNING)typedef struct _RT2870_TIMER_ENTRY_{	RALINK_TIMER_STRUCT 			*pRaTimer;	struct _RT2870_TIMER_ENTRY_ 	*pNext;}RT2870_TIMER_ENTRY;#define TIMER_QUEUE_SIZE_MAX	128typedef struct _RT2870_TIMER_QUEUE_{	unsigned int		status;	//wait_queue_head_t 	timerWaitQ;	//atomic_t			count;	UCHAR				*pTimerQPoll;	RT2870_TIMER_ENTRY	*pQPollFreeList;	RT2870_TIMER_ENTRY 	*pQHead;	RT2870_TIMER_ENTRY 	*pQTail;}RT2870_TIMER_QUEUE;#endif // RT2870 ////#define DBG	1////  MACRO for debugging information//#ifdef DBGextern ULONG    RTDebugLevel;#define DBGPRINT_RAW(Level, Fmt)    \{                                   \    if (Level <= RTDebugLevel)      \    {                               \        printk Fmt;               \    }                               \}#define DBGPRINT(Level, Fmt)    DBGPRINT_RAW(Level, Fmt)#define DBGPRINT_ERR(Fmt)           \{                                   \    printk("ERROR!!! ");          \    printk Fmt;                  \}#define DBGPRINT_S(Status, Fmt)		\{									\	printk Fmt;					\}			#else#define DBGPRINT(Level, Fmt)#define DBGPRINT_RAW(Level, Fmt)#define DBGPRINT_S(Status, Fmt)#define DBGPRINT_ERR(Fmt)#endif////  spin_lock enhanced for Nested spin lock//#define NdisAllocateSpinLock(__lock)      \{                                       \    spin_lock_init((spinlock_t *)(__lock));               \}#define NdisFreeSpinLock(lock)          \{                                       \}#define RTMP_SEM_LOCK(__lock)					\{												\	spin_lock_bh((spinlock_t *)(__lock));				\}#define RTMP_SEM_UNLOCK(__lock)					\{												\	spin_unlock_bh((spinlock_t *)(__lock));				\}// sample, use semaphore lock to replace IRQ lock, 2007/11/15#define RTMP_IRQ_LOCK(__lock, __irqflags)			\{													\	__irqflags = 0;									\	spin_lock_bh((spinlock_t *)(__lock));			\	pAd->irq_disabled |= 1; \}#define RTMP_IRQ_UNLOCK(__lock, __irqflag)			\{													\	pAd->irq_disabled &= 0; \	spin_unlock_bh((spinlock_t *)(__lock));			\}#define RTMP_INT_LOCK(__lock, __irqflags)			\{													\	spin_lock_irqsave((spinlock_t *)__lock, __irqflags);	\}#define RTMP_INT_UNLOCK(__lock, __irqflag)			\{													\	spin_unlock_irqrestore((spinlock_t *)(__lock), ((unsigned long)__irqflag));	\}#ifdef RT2870#define RTMP_IO_READ32(_A, _R, _pV)								\	RTUSBReadMACRegister(_A, _R, _pV)#define RTMP_IO_READ8(_A, _R, _pV)								\{																\}#define RTMP_IO_WRITE32(_A, _R, _V)								\	RTUSBWriteMACRegister(_A, _R, _V)#define RTMP_IO_WRITE8(_A, _R, _V)								\{																\	USHORT	_Val = _V;											\	RTUSBSingleWrite(_A, _R, _Val);								\}#define RTMP_IO_WRITE16(_A, _R, _V)								\{																\	RTUSBSingleWrite(_A, _R, _V);								\

⌨️ 快捷键说明

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