Monday, June 3, 2013

ioremap return address

ioremap and vmalloc same area will return vmalloc virtual address, but does not allocate any ioremap physical memory, ioremap also need to create a new page table to access the physical page.
ioremap obtain the virtual address space needed to release iounmap.

ioremap main device used to map physical memory into the kernel's virtual address space, so that the kernel virtual address space can be accessed through the device memory.
Use ioremap points to note:
1 Try not directly access these virtual addresses, using a dedicated function io operations can increase the portability, of course, some special cases, such as android pmem is the physical memory of ioremap, so you can directly access the memory
(2) In some cases, you may not want the system cache to play a role, this time to be mapped using ioremap_nocache

Today accidentally hit the next ioremap return address, is actually 0x9c820000, rather than 0xCxxx xxxx
Again OK to print the address code no problem, check the code did not find out where the problem, and finally found the answer dmesg    
Virtual kernel memory layout:
    Vector: 0xffff0000 - 0xffff1000 (4 kB) 
    fixmap: 0xFFF00000 - 0xfffe0000 (896 kB) 
    DMA: 0xf9e00000 - 0xFFE00000 (96 MB) 
    vmalloc: 0x9c800000 - 0xf4000000 (1400 MB) 
    lowmem: 0x80000000 - 0x9c000000 (448 MB) 
    pkmap: 0x7fe00000 - 0x80000000 (2 MB) 
    modules: 0x7F000000 - 0x7fe00000 (14 MB) 
      . init: 0x80008000 - 0x8004e000 (280 kB) 
      . text: 0x8004e000 - 0x8086a000 (8304 kB)
      . Data: 0x80892000 - 0x808dfba0 (311 kB)

Appears to be defined as the 2G ~ 4G kernel space, and returns exactly ioremap address is within the address range vmalloc.

No comments:

Post a Comment