void __iomem *map_base=0; # __iomem is useless, just for scalability and flexibility.
#if 1
printk(KERN_ERR "ioremap start\n");
map_base = ioremap_nocache(0x(physical address of registers base address), 0x1000(分配大小));
printk(KERN_ERR "ioremap base: 0x%lx\n",(unsigned long)map_base);
writel(0x1234, map_base+0x(your register's offset));
printk(KERN_ERR "0x%x\n", readl(map_base+0x(your registers offset)));
#endif
# the following is the original code in the adapter probe function, attention dont use the upper code in the irq(interruption request function)
if ((adapter->flags & FLAG_HAS_FLASH) &&
(pci_resource_flags(pdev, 1) & IORESOURCE_MEM) &&
(hw->mac.type < e1000_pch_spt)) {
flash_start = pci_resource_start(pdev, 1);
flash_len = pci_resource_len(pdev, 1);
adapter->hw.flash_address = ioremap(flash_start, flash_len);
if (!adapter->hw.flash_address)
goto err_flashmap;
}
如何在内核中读写仅提供物理地址的寄存器 ioremap
最新推荐文章于 2022-12-07 09:01:26 发布