开发者

implement mmap with multiple pages in device driver

开发者 https://www.devze.com 2023-01-19 00:07 出处:网络
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 examp

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号