Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

Conversion functions

The page_to_virt() function is used to convert the struct page (as returned by alloc_pages(), for example) into the kernel address. virt_to_page() takes a kernel virtual address and returns its associated struct page instance (as if it was allocated using the alloc_pages() function). Both virt_to_page() and page_to_virt() are defined in <asm/page.h>:

struct page *virt_to_page(void *kaddr); 
void *page_to_virt(struct page *pg) 

The page_address() macro can be used to return the virtual address that corresponds to the beginning address (the logical address of course) of a struct page instance:

void *page_address(const struct page *page) 

We can see how it is used in the get_zeroed_page() function:

unsigned long get_zeroed_page(unsigned ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content