implement mmap with multiple pages in device driver
I have a device driver that uses buffers in RAM that I want the user to be able to map to user space. I have read http://lwn.net/images/pdf/LDD3/ch15.pdf which talks about using nopages, but the example there only uses single pages and says you can adjust usage counts to make it work for multiple pages. I don't understand how that works. It uses get_free_page with an order of 0 (so 1 free page) to allocate its buffers, but my buffer is two pages long.
What does the usage c开发者_高级运维ount have to do with anything? From what I understand, only the first page is counted.
I believe the pages will have to be contiguous in memory. Then with a call to remap_pfn_range()
(2.6 kernel) or remap_page_range()
(2.4 kernel) the pages can be memory mapped to user space.
It was some years ago that I did this for a device driver. I believe I used this website as a guide: http://www.scs.ch/~frey/linux/memorymap.html
精彩评论