为什么ISA不需要request_mem_region [英] Why ISA doesn't need request_mem_region
问题描述
我正在阅读第9章LDD3的源代码.还有一个名为silly的ISA驱动程序示例.
I'm reading the source code of LDD3 Chapter 9. And there's an example for ISA driver named silly.
以下是模块的初始化.我不明白的是,为什么在第282行调用ioremap()之前没有调用"request_mem_region()"
The following is initialization for the module. What I don't understand is why there's no call for "request_mem_region()" before invocation for ioremap() in line 282
268 int silly_init(void)
269 {
270 int result = register_chrdev(silly_major, "silly", &silly_fops);
271 if (result < 0) {
272 printk(KERN_INFO "silly: can't get major number\n");
273 return result;
274 }
275 if (silly_major == 0)
276 silly_major = result; /* dynamic */
277 /*
278 * Set up our I/O range.
279 */
280
281 /* this line appears in silly_init */
282 io_base = ioremap(ISA_BASE, ISA_MAX - ISA_BASE);
283 return 0;
284 }
推荐答案
此特定驱动程序允许访问0xA0000..0x100000范围内的所有内存.
This particular driver allows accesses to all the memory in the range 0xA0000..0x100000.
如果实际上有此范围内的任何设备,则可能其他驱动程序已经保留了一些内存,因此如果 silly
试图调用 request_mem_region
,它将失败,或者有必要在加载 silly
之前先卸载其他驱动程序.
If there actually are any devices in this range, then it is likely that some other driver already has reserved some of that memory, so if silly
were try to call request_mem_region
, it would fail, or it would be necessary to unload that other driver before loading silly
.
在PC上,此范围包含图形卡的内存和系统BIOS:
On a PC, this range contains memory of the graphics card, and the system BIOS:
$ cat /proc/iomem
...
000a0000-000bffff : PCI Bus 0000:00
000c0000-000cedff : Video ROM
000d0000-000dffff : PCI Bus 0000:00
000e4000-000fffff : reserved
000f0000-000fffff : System ROM
...
通常不可能卸载图形驱动程序(因为它不是模块),并且会阻止您看到 silly
驱动程序的工作以及ROM内存范围由内核本身保留,无法释放.
Unloading the graphics driver often is not possible (because it's not a module), and would prevent you from seeing what the silly
driver does, and the ROM memory ranges are reserved by the kernel itself and cannot be freed.
TL; DR:不调用 request_mem_region
是 silly
驱动程序的一个特殊问题.任何真实"驱动程序都需要调用它.
TL;DR: Not calling request_mem_region
is a particular quirk of the silly
driver.
Any 'real' driver would be required to call it.
这篇关于为什么ISA不需要request_mem_region的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!