免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2808 | 回复: 1
打印 上一主题 下一主题

[求助]cs8900a网卡驱动中的io的初始化问题? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-09-04 20:04 |只看该作者 |倒序浏览
请教下面的io和irq是怎样赋值的,在哪儿赋值?谢谢哈!
#ifdef MODULE
static struct net_device *dev_cs89x0;
/*
* Support the 'debug' module parm even if we're compiled for non-debug to
* avoid breaking someone's startup scripts
*/
static int io;
static int irq;

static int debug;
static char media[8];
static int duplex=-1;
static int use_dma;   /* These generate unused var warnings if ALLOW_DMA = 0 */
static int dma;
static int dmasize=16;   /* or 64 */
module_param(io, int, 0);
module_param(irq, int, 0);

module_param(debug, int, 0);
module_param_string(media, media, sizeof(media), 0);
module_param(duplex, int, 0);
module_param(dma , int, 0);
module_param(dmasize , int, 0);
module_param(use_dma , int, 0);
MODULE_PARM_DESC(io, "cs89x0 I/O base address");
MODULE_PARM_DESC(irq, "cs89x0 IRQ number");

#if DEBUGGING
MODULE_PARM_DESC(debug, "cs89x0 debug level (0-6)");
#else
MODULE_PARM_DESC(debug, "(ignored)");
#endif
MODULE_PARM_DESC(media, "Set cs89x0 adapter(s) media type(s) (rj45,bnc,aui)");
/* No other value than -1 for duplex seems to be currently interpreted */
MODULE_PARM_DESC(duplex, "(ignored)");
#if ALLOW_DMA
MODULE_PARM_DESC(dma , "cs89x0 ISA DMA channel; ignored if use_dma=0");
MODULE_PARM_DESC(dmasize , "cs89x0 DMA size in kB (16,64); ignored if use_dma=0");
MODULE_PARM_DESC(use_dma , "cs89x0 using DMA (0-1)");
#else
MODULE_PARM_DESC(dma , "(ignored)");
MODULE_PARM_DESC(dmasize , "(ignored)");
MODULE_PARM_DESC(use_dma , "(ignored)");
#endif
MODULE_AUTHOR("Mike Cruse, Russwll Nelson <nelson@crynwr.com>, Andrew Morton <andrewm@uow.edu.au>");
MODULE_LICENSE("GPL");

/*
* media=t             - specify media type
   or media=2
   or media=aui
   or medai=auto
* duplex=0            - specify forced half/full/autonegotiate duplex
* debug=#             - debug level

* Default Chip Configuration:
  * DMA Burst = enabled
  * IOCHRDY Enabled = enabled
    * UseSA = enabled
    * CS8900 defaults to half-duplex if not specified on command-line
    * CS8920 defaults to autoneg if not specified on command-line
    * Use reset defaults for other config parameters
* Assumptions:
  * media type specified is supported (circuitry is present)
  * if memory address is > 1MB, then required mem decode hw is present
  * if 10B-2, then agent other than driver will enable DC/DC converter
    (hw or software util)

*/
int
init_module(void)
{
struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
struct net_local *lp;
int ret = 0;
#if DEBUGGING
net_debug = debug;
#else
debug = 0;
#endif
if (!dev)
  return -ENOMEM;
dev->irq = irq;
dev->base_addr = io;

lp = netdev_priv(dev);
#if ALLOW_DMA
if (use_dma) {
  lp->use_dma = use_dma;
  lp->dma = dma;
  lp->dmasize = dmasize;
}
#endif
spin_lock_init(&lp->lock);
        /* boy, they'd better get these right */
        if (!strcmp(media, "rj45"))
  lp->adapter_cnf = A_CNF_MEDIA_10B_T | A_CNF_10B_T;
else if (!strcmp(media, "aui"))
  lp->adapter_cnf = A_CNF_MEDIA_AUI   | A_CNF_AUI;
else if (!strcmp(media, "bnc"))
  lp->adapter_cnf = A_CNF_MEDIA_10B_2 | A_CNF_10B_2;
else
  lp->adapter_cnf = A_CNF_MEDIA_10B_T | A_CNF_10B_T;
        if (duplex==-1)
  lp->auto_neg_cnf = AUTO_NEG_ENABLE;
       if (io == 0) {
                printk(KERN_ERR "cs89x0.c: Module autoprobing not allowed.\n");
                printk(KERN_ERR "cs89x0.c: Append io=0xNNN\n");
                ret = -EPERM;
  goto out;
        } else if (io <= 0x1ff) {
  ret = -ENXIO;
  goto out;
}

#if ALLOW_DMA
if (use_dma && dmasize != 16 && dmasize != 64) {
  printk(KERN_ERR "cs89x0.c: dma size must be either 16K or 64K, not %dK\n", dmasize);
  ret = -EPERM;
  goto out;
}
#endif
ret = cs89x0_probe1(dev, io, 1);
if (ret)
  goto out;
dev_cs89x0 = dev;
return 0;
out:
free_netdev(dev);
return ret;
}

论坛徽章:
0
2 [报告]
发表于 2008-09-12 09:54 |只看该作者
我觉得应该是加在模块的时候传进来的吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP