阅读:1498回复:1
pci驱动,问题..
我在linux下写了一个pci卡的驱动, 代码如下:
resource_begin = pci_resource_start(dev, 0); resource_end = pci_resource_end(dev, 0); printk(\"resource_begin = 0x%x\\n\", resource_begin); printk(\"resource_end = 0x%x\\n\", resource_end); resource_flag = pci_resource_flags(dev, 0); if(resource_flag == IORESOURCE_IO) { printk(\"resource is io\\n\"); } else if(resource_flag == IORESOURCE_MEM) { printk(\"resource is mem\\n\"); } if(pci_enable_device(dev)) { printk(\"enable_device fail\"); return -EBUSY; } else printk(\"enable_device success\"); /*if(check_mem_region(resource_begin, 0x3ff)) { printk(\"drivername: memory already in use\\n\"); return -EBUSY; }*/ request_mem_region(resource_begin, 0x3ff, \"scull\"); printk(\"result = 0x%x\\n\", result); printk(\"result = 0x%x\\n\", result); resource_virtual_address =(long)ioremap_nocache(resource_begin, sz); printk(\"resource_virtual_address = 0x%x\\n\", resource_virtual_address); printk(\"result = 0x%x\\n\", result); long test = resource_virtual_address + 0x120; writel(0x028f , test); printk(\"resource_virtual_address = 0x%x\\n\", resource_virtual_address+0x120); iounmap((void *)resource_virtual_address); release_mem_region(resource_begin, 0x3ff); return 0; /* 模块初始化 * 主要是,执行writel(0x028f, test)后,应该led灯亮,但是,我这里没有成功,而且,我用 check_mem_region函数时返回也是失败的,我在windows下写了个驱动试了一下,硬件没有问题, 而且我得到的基地址也正确,我的设备资源是mem的,我想问一下,为什么,我会写不进去, 怎么写,多谢了..... |
|
沙发#
发布于:2005-02-24 21:43
ioremap_nocache(resource_begin, sz)
这个函数调用sz为多少,应该为pci_resource_len()或者为resource_begin-resource_end [编辑 - 2/24/05 by baaniaw] |
|