1)phys_to_virt/virt_to_phys函数定义
- arch/arm/include/asm/memory.h
- 131 #ifndef __virt_to_phys
132 #define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
133 #define __phys_to_virt(x) ((x) - PHYS_OFFSET + PAGE_OFFSET)
134 #endif
- 182 static inline unsigned long virt_to_phys(void *x)
183 {
184 return __virt_to_phys((unsigned long)(x));
185 }
186
187 static inline void *phys_to_virt(unsigned long x)
188 {
189 return (void *)(__phys_to_virt((unsigned long)(x)));
190 }
2)PAGE_OFFSET/PHYS_OFFSET两个宏的定义
PHYS_OFFSET宏,通常在特定的板子的memory.h文件种定义,对应的物理内存的地址。而PAGE_OFFSET其实就是虚拟地址的起始地址。在arch/arm/include/asm/memory.h文件中定义,默认值为0xC0000000。
arch/arm/include/asm/memory.h
- #ifdef CONFIG_MMU
- /*
- * PAGE_OFFSET - the virtual address of the start of the kernel image
- * TASK_SIZE - the maximum size of a user space task.
- * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
- */
- #define PAGE_OFFSET UL(CONFIG_PAGE_OFFSET)
- #define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
- #define TASK_UNMAPPED_BASE (UL(CONFIG_PAGE_OFFSET) / 3)
- /*
- * The maximum size of a 26-bit user space task.
- */
- #define TASK_SIZE_26 UL(0x04000000)
- ......
- ......
- #else /* CONFIG_MMU */
- /*
- * The limitation of user task size can grow up to the end of free ram region.
- * It is difficult to define and perhaps will never meet the original meaning
- * of this define that was meant to.
- * Fortunately, there is no reference for this in noMMU mode, for now.
- */
- #ifndef TASK_SIZE
- #define TASK_SIZE (CONFIG_DRAM_SIZE)
- #endif
- #ifndef TASK_UNMAPPED_BASE
- #define TASK_UNMAPPED_BASE UL(0x00000000)
- #endif
- #ifndef PHYS_OFFSET
- #define PHYS_OFFSET UL(CONFIG_DRAM_BASE)
- #endif
- ......
- ......
- #endif /* !CONFIG_MMU */
- arch/arm/Kconfig
- 1165 config PAGE_OFFSET ----这个就是CONFIG_PAGE_OFFSET宏,默认值为0xC0000000
- 1166 hex
- 1167 default 0x40000000 if VMSPLIT_1G
- 1168 default 0x80000000 if VMSPLIT_2G
- 1169 default 0xC0000000
阅读(686) | 评论(0) | 转发(0) |