>Is there any function for allocating of kernel address space (not
>memory but address space for device's memory) ? I studied the
>existing drivers and I found that they assume that virtual
>address space in kernel mode is equal to the physical one.
Yes, it's "pmap_mapdev()". I originally wrote it for someone to map a 1MB
shared memory device (an ATM controller), but it is also being used in the PCI
code. Someday I plan to use it in all device drivers that use/map device
>But there is something strange: they convert physical addresses
>to virtual ones by simply assigning, but they convert virtual
>addresses to physical ones using kvtop(). Why ? For additional
The fact that the first 1MB of physical memory is mapped at KERNBASE is a
total hack and kludge. So converting from physical to virtual addresses using
this is a hack. Using kvtop() to convert a virtual address to a physical one,
however, isn't a hack at all - the information is gotten from the page tables
as it should be.