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

📄 prism2_cs.c

📁 uClinux2.6上兼容PRISM2.0芯片组的USB设备驱动程序.
💻 C
📖 第 1 页 / 共 3 页
字号:
#define WLAN_HOSTIF WLAN_PCMCIA#include "hfa384x.c"#include "prism2mgmt.c"#include "prism2mib.c"#include "prism2sta.c"#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21) )#if (WLAN_CPU_FAMILY == WLAN_Ix86)#ifndef CONFIG_ISA#warning "You may need to enable ISA support in your kernel."#endif#endif#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) )static u_int	irq_mask = 0xdeb8;		/* Interrupt mask */static int	irq_list[4] = { -1 };		/* Interrupt list */#endifstatic u_int	prism2_ignorevcc=0;		/* Boolean, if set, we						 * ignore what the Vcc						 * is set to and what the CIS						 * says.						 */#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) )#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,8))static int numlist = 4;module_param_array(irq_list, int, numlist, 0444);#elsemodule_param_array(irq_list, int, NULL, 0444);#endifmodule_param( irq_mask, int, 0644);#endifstatic dev_link_t	*dev_list = NULL;	/* head of instance list */dev_link_t	*prism2sta_attach(void);static void	prism2sta_detach(dev_link_t *link);static void	prism2sta_config(dev_link_t *link);static void	prism2sta_release(u_long arg);static int 	prism2sta_event (event_t event, int priority, event_callback_args_t *args);#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68))/*----------------------------------------------------------------* cs_error** Utility function to print card services error messages.** Arguments:*	handle	client handle identifying this CS client*	func	CS function number that generated the error*	ret	CS function return code** Returns: *	nothing* Side effects:** Call context:*	process thread*	interrupt----------------------------------------------------------------*/static void cs_error(client_handle_t handle, int func, int ret){#if (defined(CS_RELEASE_CODE) && (CS_RELEASE_CODE < 0x2911))	CardServices(ReportError, dev_info, (void *)func, (void *)ret);#else	error_info_t err = { func, ret };	pcmcia_report_error(handle, &err);#endif}#else // kernel_version#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)static struct pcmcia_device_id prism2_cs_ids[] = {	PCMCIA_DEVICE_PROD_ID12("INTERSIL",  "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), // Intersil PRISM2 Reference Design 11Mb/s 802.11b WLAN Card	PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), // Compaq WL100/200 11Mb/s 802.11b WLAN Card	PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), // Compaq iPaq HNW-100 11Mb/s 802.11b WLAN Card	PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), // Samsung SWL2000-N 11Mb/s 802.11b WLAN Card	PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), // Z-Com XI300 11Mb/s 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID12("ZoomAir 11Mbps High",  "Rate wireless Networking", 0x273fe3db, 0x32a1eaee), // ZoomAir 4100 11Mb/s 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID123("Instant Wireless ",  " Network PC CARD",  "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0), // Linksys WPC11 11Mbps 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID123("Addtron",  "AWP-100 Wireless PCMCIA",  "Version 01.02", 0xe6ec52ce, 0x8649af2, 0x4b74baa0), // Addtron AWP-100 11Mbps 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID123("D",  "Link DWL-650 11Mbps WLAN Card",  "Version 01.02", 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), // D-Link DWL-650 11Mbps 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID123("SMC",  "SMC2632W",  "Version 01.02", 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0), // SMC 2632W 11Mbps 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID1234("Intersil",  "PRISM 2_5 PCMCIA ADAPTER",  "ISL37300P",  "Eval-RevA", 0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e), // BroMax Freeport 11Mbps 802.11b WLAN Card (Prism 2.5)	PCMCIA_DEVICE_PROD_ID123("U.S. Robotics",  "IEEE 802.11b PC-CARD",  "Version 01.02", 0xc7b8df9d, 0x1700d087, 0x4b74baa0), // U.S. Robotics IEEE 802.11b PC-CARD	PCMCIA_DEVICE_PROD_ID12("Digital Data Communications",  "WPC-0100", 0xfdd73470, 0xe0b6f146), // Level-One WPC-0100	PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), // Bromax OEM 11Mbps 802.11b WLAN Card (Prism 2.5)	PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), // Bromax OEM 11Mbps 802.11b WLAN Card (Prism 3)	PCMCIA_DEVICE_PROD_ID12("corega K.K.",  "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), // corega K.K. Wireless LAN PCC-11	PCMCIA_DEVICE_PROD_ID12("corega K.K.",  "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), // corega K.K. Wireless LAN PCCA-11	PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0008), // CONTEC FLEXSCAN/FX-DDS110-PCC	PCMCIA_DEVICE_PROD_ID12("PLANEX",  "GeoWave/GW-NS110", 0x209f40ab, 0x46263178), // PLANEX GeoWave/GW-NS110	PCMCIA_DEVICE_PROD_ID123("OEM",  "PRISM2 IEEE 802.11 PC-Card",  "Version 01.02", 0xfea54c90, 0x48f2bdd6, 0x4b74baa0), // Ambicom WL1100 11Mbps 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID123("LeArtery",  "SYNCBYAIR 11Mbps Wireless LAN PC Card",  "Version 01.02", 0x7e3b326a, 0x49893e92, 0x4b74baa0), // LeArtery SYNCBYAIR 11Mbps 802.11b WLAN CardPCMCIA_DEVICE_MANF_CARD(0x01ff, 0x0008), // Intermec MobileLAN 11Mbps 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID123("NETGEAR MA401 Wireless PC",  "Card",  "Version 01.00", 0xa37434e9, 0x9762e8f1, 0xa57adb8c), // NETGEAR MA401 11Mbps 802.11 WLAN Card	PCMCIA_DEVICE_PROD_ID1234("Intersil",  "PRISM Freedom PCMCIA Adapter",  "ISL37100P",  "Eval-RevA", 0x4b801a17, 0xf222ec2d, 0x630d52b2, 0xc23adc0e), // Intersil PRISM Freedom 11mbps 802.11 WLAN Card	PCMCIA_DEVICE_PROD_ID123("OTC",  "Wireless AirEZY 2411-PCC WLAN Card",  "Version 01.02", 0x4ac44287, 0x235a6bed, 0x4b74baa0), // OTC Wireless AirEZY 2411-PCC 11Mbps 802.11 WLAN Card	PCMCIA_DEVICE_PROD_ID1234("802.11",  "11Mbps Wireless LAN Card",  "v08C1",  ""   , 0xb67a610e, 0x655aa7b7, 0x264b451a, 0x0), // Dynalink L11HDT 11Mbps 802.11 WLAN Card	PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), // Dynalink L11HDT 11Mbps 802.11 WLAN Card	PCMCIA_DEVICE_PROD_ID12("PROXIM",  "RangeLAN-DS/LAN PC CARD", 0xc6536a5e, 0x3f35797d), // PROXIM RangeLAN-DS/LAN PC CARD	PCMCIA_DEVICE_PROD_ID1234("ACTIONTEC",  "PRISM Wireless LAN PC Card",  "0381",  "RevA", 0x393089da, 0xa71e69d5, 0x90471fa9, 0x57a66194), // ACTIONTEC PRISM Wireless LAN PC Card	PCMCIA_DEVICE_MANF_CARD(0x1668, 0x0101), // ACTIONTEC PRISM Wireless LAN PC Card	PCMCIA_DEVICE_PROD_ID12("3Com",  "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3), // 3Com AirConnect 3CRWE737A	PCMCIA_DEVICE_PROD_ID12("3Com",  "3CRWE777A AirConnect Wireless LAN PCI Card"  , 0x41240e5b, 0xafc7c33e), // 3Com AirConnect 3CRWE777A	PCMCIA_DEVICE_PROD_ID12("ASUS",  "802_11b_PC_CARD_25", 0x78fc06ee, 0xdb9aa842), // ASUS WL-100 802.11b WLAN  PC Card	PCMCIA_DEVICE_PROD_ID12("ASUS",  "802_11B_CF_CARD_25", 0x78fc06ee, 0x45a50c1e), // ASUS WL-110 802.11b WLAN CF Card	PCMCIA_DEVICE_PROD_ID12("BUFFALO",  "WLI-CF-S11G", 0x2decece3, 0x82067c18), // BUFFALO WLI-CF-S11G 802.11b WLAN Card	PCMCIA_DEVICE_PROD_ID1234("The Linksys Group, Inc.", "Wireless Network CF Card", "ISL37300P", "RevA", 0xa5f472c2, 0x9c05598d, 0xc9049a39, 0x57a66194), // Linksys WCF11 11Mbps 802.11b WLAN Card (Prism 2.5)	PCMCIA_DEVICE_PROD_ID1234("Linksys",  "Wireless CompactFlash Card",  "",  "", 0x733cc81, 0xc52f395, 0x0, 0x0), // Linksys WCF12 11Mbps 802.11b WLAN Card (Prism 3)	PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), // Linksys WCF12 11Mbps 802.11b WLAN Card (Prism 3)	PCMCIA_DEVICE_PROD_ID1234("NETGEAR MA401RA Wireless PC",  "Card",  "ISL37300P",  "Eval-RevA", 0x306467f, 0x9762e8f1, 0xc9049a39, 0xc23adc0e), // NETGEAR MA401RA 11Mbps 802.11 WLAN Card	PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), // D-Link DCF-660W  11Mbps 802.11b WLAN Card	PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), // Microsoft Wireless Notebook Adapter MN-520	PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0002), // AnyPoint(TM) Wireless II PC Card	PCMCIA_DEVICE_PROD_ID1234("D",  "Link DRC-650 11Mbps WLAN Card",  "Version 01.02",  "" , 0x71b18589, 0xf144e3ac, 0x4b74baa0, 0x0), // D-Link DRC-650 802.11b WLAN Card	PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), // Adaptec AWN-8030	PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7110), // D-Link DWL-650 rev P 802.11b WLAN card	// PCMCIA_DEVICE_PROD_ID1234("D-Link",  "DWL-650 Wireless PC Card RevP",  "ISL37101P-10",  "A3", 0x1a424a1c, 0x6ea57632, 0xdd97a26b, 0x56b21f52), // D-Link DWL-650 rev P 802.11b WLAN card	PCMCIA_DEVICE_PROD_ID123("INTERSIL",   "I-GATE 11M PC Card / PC Card plus",  "Version 01.02", 0x74c5e40d, 0x8304ff77, 0x4b74baa0), // I-Gate 11M PC Card	PCMCIA_DEVICE_PROD_ID1234("BENQ",  "AWL100 PCMCIA ADAPTER",  "ISL37300P",  "Eval-RevA", 0x35dadc74, 0x1f7fedb, 0xc9049a39, 0xc23adc0e), // benQ AWL100 802.11b WLAN Card	PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), // benQ AWL100 802.11b WLAN Card	// PCMCIA_DEVICE_PROD_ID1("INTERSIL", 0x74c5e40d), // Intersil Prism 2 card	// PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), // Intersil Prism 2 card	PCMCIA_DEVICE_NULL};MODULE_DEVICE_TABLE(pcmcia, prism2_cs_ids);#endifstatic struct pcmcia_driver prism2_cs_driver = {	.drv = { 		.name = "prism2_cs",	},	.attach = prism2sta_attach,	.detach = prism2sta_detach,	.owner = THIS_MODULE,#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12)	.id_table = prism2_cs_ids,	.event = prism2sta_event,#endif};#endif /* kernel_version *//*----------------------------------------------------------------* prism2sta_attach** Half of the attach/detach pair.  Creates and registers a device* instance with Card Services.  In this case, it also creates the* wlandev structure and device private structure.  These are * linked to the device instance via its priv member.** Arguments:*	none** Returns: *	A valid ptr to dev_link_t on success, NULL otherwise** Side effects:*	** Call context:*	process thread (insmod/init_module/register_pccard_driver)----------------------------------------------------------------*/dev_link_t *prism2sta_attach(void){	client_reg_t		client_reg;	int			result;	dev_link_t		*link = NULL;	wlandevice_t		*wlandev = NULL;	hfa384x_t		*hw = NULL;	DBFENTER;	/* Alloc our structures */	link =		kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);	if (!link || ((wlandev = create_wlan()) == NULL)) {		WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info);		result = -EIO;		goto failed;	}	hw = wlandev->priv;	/* Clear all the structs */	memset(link, 0, sizeof(struct dev_link_t));	if ( wlan_setup(wlandev) != 0 ) {		WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info);		result = -EIO;		goto failed;	}	/* Initialize the hw struct for now */	hfa384x_create(hw, 0, 0, NULL);	hw->wlandev = wlandev;	/* Initialize the device private data stucture. */	hw->cs_link = link;	/* Initialize the PC card device object. */#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))	init_timer(&link->release);	link->release.function = &prism2sta_release;	link->release.data = (u_long)link;#endif	link->conf.IntType = INT_MEMORY_AND_IO;	link->priv = wlandev;#if (defined(CS_RELEASE_CODE) && (CS_RELEASE_CODE < 0x2911))	link->irq.Instance = wlandev;#endif	/* Link in to the list of devices managed by this driver */	link->next = dev_list;	dev_list = link;		/* Register with Card Services */	client_reg.dev_info = &dev_info;#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) )	client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) )	client_reg.EventMask =		CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |		CS_EVENT_RESET_REQUEST |		CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |		CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;	client_reg.event_handler = &prism2sta_event;#endif	client_reg.Version = 0x0210;	client_reg.event_callback_args.client_data = link;	result = pcmcia_register_client(&link->handle, &client_reg);	if (result != 0) {		cs_error(link->handle, RegisterClient, result);		prism2sta_detach(link);		return NULL;	}	goto done; failed:	if (link)	kfree(link);	if (wlandev)	kfree(wlandev);	if (hw)		kfree(hw);	link = NULL; done:	DBFEXIT;	return link;}/*----------------------------------------------------------------* prism2sta_detach** Remove one of the device instances managed by this driver.*   Search the list for the given instance, *   check our flags for a waiting timer'd release call*   call release*   Deregister the instance with Card Services*   (netdevice) unregister the network device.*   unlink the instance from the list*   free the link, priv, and priv->priv memory* Note: the dev_list variable is a driver scoped static used to*	maintain a list of device instances managed by this*	driver.** Arguments:*	link	ptr to the instance to detach** Returns: *	nothing** Side effects:*	the link structure is gone, the netdevice is gone** Call context:*	Might be interrupt, don't block.----------------------------------------------------------------*/void prism2sta_detach(dev_link_t *link){	dev_link_t		**linkp;	wlandevice_t		*wlandev;	hfa384x_t		*hw;	DBFENTER;	/* Locate prev device structure */	for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) {		if (*linkp == link) break;	}	if (*linkp != NULL) {#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))		unsigned long	flags;		/* Get rid of any timer'd release call */		save_flags(flags);		cli();#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))		if (link->state & DEV_RELEASE_PENDING) {			del_timer_sync(&link->release);			link->state &= ~DEV_RELEASE_PENDING;		}#endif#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))		restore_flags(flags);#endif		/* If link says we're still config'd, call release */		if (link->state & DEV_CONFIG) {			prism2sta_release((u_long)link);			if (link->state & DEV_STALE_CONFIG) {				link->state |= DEV_STALE_LINK;				return;			}		}				/* Tell Card Services we're not around any more */		if (link->handle) {			pcmcia_deregister_client(link->handle);		}			/* Unlink device structure, free bits */

⌨️ 快捷键说明

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