我如何用 printk 打印函数 ioremap_nocache 返回的地址的值?
void * ioremap_nocache (unsigned long phys_addr, unsigned long size);
http://mirror.linux.org.au/linux-mandocs/2.6.4-cset-20040312_2111/ioremap_nocache.html
我需要知道存储的虚拟地址的值,以调试打开、读取和写入的函数。
我如何用 printk 打印函数 ioremap_nocache 返回的地址的值?
void * ioremap_nocache (unsigned long phys_addr, unsigned long size);
http://mirror.linux.org.au/linux-mandocs/2.6.4-cset-20040312_2111/ioremap_nocache.html
我需要知道存储的虚拟地址的值,以调试打开、读取和写入的函数。
You can use both %lu
or %p
to print a pointer. They have different representation
void *pointer = ioremap_nocache(phys_addr, size);
unsigned long cast = pointer;
printk("%lu - %p", cast, pointer); // '15294563 - 0x499602d2'
This work also with printf()
您可以使用以下
unsigned long x = ioremap_nocache (addr, size);
printk(" %lu",x);