What is ioremap()

ioremap() function is used to map the physical addres of an I/O device to the kernel virtual address. Kernel creates a page table i.e mapping of virtual address to the physical address requested.When we do iounmap() this mapping is destroyed.

The ioremap function takes two parameters:

  • start of the memory region
  • size of the memory region
void *ioremap(unsigned long phys_addr, unsigned long size);

void iounmap(void * addr)

phys_addr is required only if physical memory areas described by a physical address are mapped with ioremap. This information is held in phys_addr.

On many systems, I/O memory is not directly accessible in this way at all. So a mapping must be set up first. This is the role of the ioremap function. The function is designed specifically to assign virtual addresses to I/O memory regions.

Related Post