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

📄 hostap_cs.c

📁 linux内核源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		       "(%d)\n", res);		return;	}	mdelay(10);	reg.Action = CS_WRITE;	reg.Offset = CISREG_COR;	reg.Value = old_cor & ~COR_SOFT_RESET;	res = pcmcia_access_configuration_register(hw_priv->link,						   &reg);	if (res != CS_SUCCESS) {		printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "		       "(%d)\n", res);		return;	}	mdelay(10);}static struct prism2_helper_functions prism2_pccard_funcs ={	.card_present	= prism2_pccard_card_present,	.cor_sreset	= prism2_pccard_cor_sreset,	.genesis_reset	= prism2_pccard_genesis_reset,	.hw_type	= HOSTAP_HW_PCCARD,};/* allocate local data and register with CardServices * initialize dev_link structure, but do not configure the card yet */static int hostap_cs_probe(struct pcmcia_device *p_dev){	int ret;	PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);	p_dev->conf.IntType = INT_MEMORY_AND_IO;	ret = prism2_config(p_dev);	if (ret) {		PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");	}	return ret;}static void prism2_detach(struct pcmcia_device *link){	PDEBUG(DEBUG_FLOW, "prism2_detach\n");	prism2_release((u_long)link);	/* release net devices */	if (link->priv) {		struct hostap_cs_priv *hw_priv;		struct net_device *dev;		struct hostap_interface *iface;		dev = link->priv;		iface = netdev_priv(dev);		hw_priv = iface->local->hw_priv;		prism2_free_local_data(dev);		kfree(hw_priv);	}}#define CS_CHECK(fn, ret) \do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)#define CFG_CHECK2(fn, retf) \do { int ret = (retf); \if (ret != 0) { \	PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \	cs_error(link, fn, ret); \	goto next_entry; \} \} while (0)/* run after a CARD_INSERTION event is received to configure the PCMCIA * socket and make the device available to the system */static int prism2_config(struct pcmcia_device *link){	struct net_device *dev;	struct hostap_interface *iface;	local_info_t *local;	int ret = 1;	tuple_t tuple;	cisparse_t *parse;	int last_fn, last_ret;	u_char buf[64];	config_info_t conf;	cistpl_cftable_entry_t dflt = { 0 };	struct hostap_cs_priv *hw_priv;	PDEBUG(DEBUG_FLOW, "prism2_config()\n");	parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);	hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);	if (parse == NULL || hw_priv == NULL) {		ret = -ENOMEM;		goto failed;	}	tuple.Attributes = 0;	tuple.TupleData = buf;	tuple.TupleDataMax = sizeof(buf);	tuple.TupleOffset = 0;	CS_CHECK(GetConfigurationInfo,		 pcmcia_get_configuration_info(link, &conf));	/* Look for an appropriate configuration table entry in the CIS */	tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;	CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));	for (;;) {		cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);		CFG_CHECK2(GetTupleData,			   pcmcia_get_tuple_data(link, &tuple));		CFG_CHECK2(ParseTuple,			   pcmcia_parse_tuple(link, &tuple, parse));		if (cfg->flags & CISTPL_CFTABLE_DEFAULT)			dflt = *cfg;		if (cfg->index == 0)			goto next_entry;		link->conf.ConfigIndex = cfg->index;		PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "		       "(default 0x%02X)\n", cfg->index, dflt.index);		/* Does this card need audio output? */		if (cfg->flags & CISTPL_CFTABLE_AUDIO) {			link->conf.Attributes |= CONF_ENABLE_SPKR;			link->conf.Status = CCSR_AUDIO_ENA;		}		/* Use power settings for Vcc and Vpp if present */		/*  Note that the CIS values need to be rescaled */		if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {			if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /			    10000 && !ignore_cis_vcc) {				PDEBUG(DEBUG_EXTRA, "  Vcc mismatch - skipping"				       " this entry\n");				goto next_entry;			}		} else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {			if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] /			    10000 && !ignore_cis_vcc) {				PDEBUG(DEBUG_EXTRA, "  Vcc (default) mismatch "				       "- skipping this entry\n");				goto next_entry;			}		}		if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))			link->conf.Vpp =				cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;		else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))			link->conf.Vpp =				dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;		/* Do we need to allocate an interrupt? */		if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)			link->conf.Attributes |= CONF_ENABLE_IRQ;		else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) {			/* At least Compaq WL200 does not have IRQInfo1 set,			 * but it does not work without interrupts.. */			printk("Config has no IRQ info, but trying to enable "			       "IRQ anyway..\n");			link->conf.Attributes |= CONF_ENABLE_IRQ;		}		/* IO window settings */		PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "		       "dflt.io.nwin=%d\n",		       cfg->io.nwin, dflt.io.nwin);		link->io.NumPorts1 = link->io.NumPorts2 = 0;		if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {			cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;			link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;			PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "			       "io.base=0x%04x, len=%d\n", io->flags,			       io->win[0].base, io->win[0].len);			if (!(io->flags & CISTPL_IO_8BIT))				link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;			if (!(io->flags & CISTPL_IO_16BIT))				link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;			link->io.IOAddrLines = io->flags &				CISTPL_IO_LINES_MASK;			link->io.BasePort1 = io->win[0].base;			link->io.NumPorts1 = io->win[0].len;			if (io->nwin > 1) {				link->io.Attributes2 = link->io.Attributes1;				link->io.BasePort2 = io->win[1].base;				link->io.NumPorts2 = io->win[1].len;			}		}		/* This reserves IO space but doesn't actually enable it */		CFG_CHECK2(RequestIO,			   pcmcia_request_io(link, &link->io));		/* This configuration table entry is OK */		break;	next_entry:		CS_CHECK(GetNextTuple,			 pcmcia_get_next_tuple(link, &tuple));	}	/* Need to allocate net_device before requesting IRQ handler */	dev = prism2_init_local_data(&prism2_pccard_funcs, 0,				     &handle_to_dev(link));	if (dev == NULL)		goto failed;	link->priv = dev;	iface = netdev_priv(dev);	local = iface->local;	local->hw_priv = hw_priv;	hw_priv->link = link;	strcpy(hw_priv->node.dev_name, dev->name);	link->dev_node = &hw_priv->node;	/*	 * Allocate an interrupt line.  Note that this does not assign a	 * handler to the interrupt, unless the 'Handler' member of the	 * irq structure is initialized.	 */	if (link->conf.Attributes & CONF_ENABLE_IRQ) {		link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;		link->irq.IRQInfo1 = IRQ_LEVEL_ID;		link->irq.Handler = prism2_interrupt;		link->irq.Instance = dev;		CS_CHECK(RequestIRQ,			 pcmcia_request_irq(link, &link->irq));	}	/*	 * This actually configures the PCMCIA socket -- setting up	 * the I/O windows and the interrupt mapping, and putting the	 * card and host interface into "Memory and IO" mode.	 */	CS_CHECK(RequestConfiguration,		 pcmcia_request_configuration(link, &link->conf));	dev->irq = link->irq.AssignedIRQ;	dev->base_addr = link->io.BasePort1;	/* Finally, report what we've done */	printk(KERN_INFO "%s: index 0x%02x: ",	       dev_info, link->conf.ConfigIndex);	if (link->conf.Vpp)		printk(", Vpp %d.%d", link->conf.Vpp / 10,		       link->conf.Vpp % 10);	if (link->conf.Attributes & CONF_ENABLE_IRQ)		printk(", irq %d", link->irq.AssignedIRQ);	if (link->io.NumPorts1)		printk(", io 0x%04x-0x%04x", link->io.BasePort1,		       link->io.BasePort1+link->io.NumPorts1-1);	if (link->io.NumPorts2)		printk(" & 0x%04x-0x%04x", link->io.BasePort2,		       link->io.BasePort2+link->io.NumPorts2-1);	printk("\n");	local->shutdown = 0;	sandisk_enable_wireless(dev);	ret = prism2_hw_config(dev, 1);	if (!ret) {		ret = hostap_hw_ready(dev);		if (ret == 0 && local->ddev)			strcpy(hw_priv->node.dev_name, local->ddev->name);	}	kfree(parse);	return ret; cs_failed:	cs_error(link, last_fn, last_ret); failed:	kfree(parse);	kfree(hw_priv);	prism2_release((u_long)link);	return ret;}static void prism2_release(u_long arg){	struct pcmcia_device *link = (struct pcmcia_device *)arg;	PDEBUG(DEBUG_FLOW, "prism2_release\n");	if (link->priv) {		struct net_device *dev = link->priv;		struct hostap_interface *iface;		iface = netdev_priv(dev);		prism2_hw_shutdown(dev, 0);		iface->local->shutdown = 1;	}	pcmcia_disable_device(link);	PDEBUG(DEBUG_FLOW, "release - done\n");}static int hostap_cs_suspend(struct pcmcia_device *link){	struct net_device *dev = (struct net_device *) link->priv;	int dev_open = 0;	struct hostap_interface *iface = NULL;	if (dev)		iface = netdev_priv(dev);	PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);	if (iface && iface->local)		dev_open = iface->local->num_dev_open > 0;	if (dev_open) {		netif_stop_queue(dev);		netif_device_detach(dev);	}	prism2_suspend(dev);	return 0;}static int hostap_cs_resume(struct pcmcia_device *link){	struct net_device *dev = (struct net_device *) link->priv;	int dev_open = 0;	struct hostap_interface *iface = NULL;	if (dev)		iface = netdev_priv(dev);	PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);	if (iface && iface->local)		dev_open = iface->local->num_dev_open > 0;	prism2_hw_shutdown(dev, 1);	prism2_hw_config(dev, dev_open ? 0 : 1);	if (dev_open) {		netif_device_attach(dev);		netif_start_queue(dev);	}	return 0;}static struct pcmcia_device_id hostap_cs_ids[] = {	PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100),	PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),	PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777),	PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000),	PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),	PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3301),	PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002),	PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b),	PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612),	PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613),	PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002),	PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002),	PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),	PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),	PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),/*	PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),    conflict with pcnet_cs */	PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),	PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),	PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),	PCMCIA_DEVICE_MANF_CARD(0x0126, 0x0002),	PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0xd601, 0x0005, "ADLINK 345 CF",					 0x2d858104),	PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "INTERSIL",					 0x74c5e40d),	PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "Intersil",					 0x4b801a17),	PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus",				    0x7a954bd9, 0x74be00c6),	PCMCIA_DEVICE_PROD_ID1234(		"Intersil", "PRISM 2_5 PCMCIA ADAPTER",	"ISL37300P",		"Eval-RevA",		0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e),	/* D-Link DWL-650 Rev. P1; manfid 0x000b, 0x7110 */	PCMCIA_DEVICE_PROD_ID1234(		"D-Link", "DWL-650 Wireless PC Card RevP", "ISL37101P-10",		"A3",		0x1a424a1c, 0x6ea57632, 0xdd97a26b, 0x56b21f52),	PCMCIA_DEVICE_PROD_ID123(		"Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02",		0xe6ec52ce, 0x08649af2, 0x4b74baa0),	PCMCIA_DEVICE_PROD_ID123(		"D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02",		0x71b18589, 0xb6f1b0ab, 0x4b74baa0),	PCMCIA_DEVICE_PROD_ID123(		"Instant Wireless ", " Network PC CARD", "Version 01.02",		0x11d901af, 0x6e9bd926, 0x4b74baa0),	PCMCIA_DEVICE_PROD_ID123(		"SMC", "SMC2632W", "Version 01.02",		0xc4f8b18b, 0x474a1f2a, 0x4b74baa0),	PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 				0x2decece3, 0x82067c18),	PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card",				0x54f7c49c, 0x15a75e5b),	PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE",				0x74c5e40d, 0xdb472a18),	PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card",				0x0733cc81, 0x0c52f395),	PCMCIA_DEVICE_PROD_ID12(		"ZoomAir 11Mbps High", "Rate wireless Networking",		0x273fe3db, 0x32a1eaee),	PCMCIA_DEVICE_PROD_ID123(		"Pretec", "CompactWLAN Card 802.11b", "2.5",		0x1cadd3e5, 0xe697636c, 0x7a5bfcf1),	PCMCIA_DEVICE_PROD_ID123(		"U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02",		0xc7b8df9d, 0x1700d087, 0x4b74baa0),	PCMCIA_DEVICE_PROD_ID123(		"Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio",		"Ver. 1.00",		0x5cd01705, 0x4271660f, 0x9d08ee12),	PCMCIA_DEVICE_PROD_ID123(		"corega", "WL PCCL-11", "ISL37300P",		0xa21501a, 0x59868926, 0xc9049a39),	PCMCIA_DEVICE_PROD_ID1234(		"The Linksys Group, Inc.", "Wireless Network CF Card", "ISL37300P",		"RevA",		0xa5f472c2, 0x9c05598d, 0xc9049a39, 0x57a66194),	PCMCIA_DEVICE_NULL};MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);static struct pcmcia_driver hostap_driver = {	.drv		= {		.name	= "hostap_cs",	},	.probe		= hostap_cs_probe,	.remove		= prism2_detach,	.owner		= THIS_MODULE,	.id_table	= hostap_cs_ids,	.suspend	= hostap_cs_suspend,	.resume		= hostap_cs_resume,};static int __init init_prism2_pccard(void){	return pcmcia_register_driver(&hostap_driver);}static void __exit exit_prism2_pccard(void){	pcmcia_unregister_driver(&hostap_driver);}module_init(init_prism2_pccard);module_exit(exit_prism2_pccard);

⌨️ 快捷键说明

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