Linux kernel device driver address mapping note collation
- 2020-12-18 02:02:17
- OfStack
#include <asm/io.h>
#define ioremap(cookie,size) __arm_ioremap(cookie, size, MT_DEVICE)
//cookie Represents the physical address, size Represents the mapping size. ioremap Maps the specified physical address to the free virtual address
void __iomem *
__arm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
{
return __arm_ioremap_caller(phys_addr, size, mtype,
__builtin_return_address(0));
}
1. The virtual address mapped from the physical address
Virtual address = ioremap(physical address, how big the map is); iounmap(virtual address) after use; // Delete the mapping table
2.
ioread8( address )/readb()
ioread16( address )/readw()
ioread32( address )/readl()
iowrite8( value , address ) / writeb
iowrite16( value , address ) / writew
iowrite32( value , address ) / writel
#include <asm/sizes.h>
SZ_4K
SZ_1M
conclusion