Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3516839
  • 博文数量: 1805
  • 博客积分: 135
  • 博客等级: 入伍新兵
  • 技术积分: 3345
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-19 20:01
文章分类

全部博文(1805)

文章存档

2017年(19)

2016年(80)

2015年(341)

2014年(438)

2013年(349)

2012年(332)

2011年(248)

分类: LINUX

2014-09-22 14:55:29

1)phys_to_virt/virt_to_phys函数定义
  1. arch/arm/include/asm/memory.h
  2. 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

  3. 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
  1. #ifdef CONFIG_MMU

  2. /*
  3.  * PAGE_OFFSET - the virtual address of the start of the kernel image
  4.  * TASK_SIZE - the maximum size of a user space task.
  5.  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
  6.  */
  7. #define PAGE_OFFSET        UL(CONFIG_PAGE_OFFSET)
  8. #define TASK_SIZE        (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
  9. #define TASK_UNMAPPED_BASE    (UL(CONFIG_PAGE_OFFSET) / 3)

  10. /*
  11.  * The maximum size of a 26-bit user space task.
  12.  */
  13. #define TASK_SIZE_26        UL(0x04000000)

  14. ......
  15. ......
  16. #else /* CONFIG_MMU */

  17. /*
  18.  * The limitation of user task size can grow up to the end of free ram region.
  19.  * It is difficult to define and perhaps will never meet the original meaning
  20.  * of this define that was meant to.
  21.  * Fortunately, there is no reference for this in noMMU mode, for now.
  22.  */
  23. #ifndef TASK_SIZE
  24. #define TASK_SIZE        (CONFIG_DRAM_SIZE)
  25. #endif

  26. #ifndef TASK_UNMAPPED_BASE
  27. #define TASK_UNMAPPED_BASE    UL(0x00000000)
  28. #endif

  29. #ifndef PHYS_OFFSET
  30. #define PHYS_OFFSET         UL(CONFIG_DRAM_BASE)
  31. #endif


  32. ......
  33. ......
  34. #endif /* !CONFIG_MMU */

 

     
  1. arch/arm/Kconfig

  2. 1165 config PAGE_OFFSET   ----这个就是CONFIG_PAGE_OFFSET宏,默认值为0xC0000000
  3. 1166 hex
  4. 1167 default 0x40000000 if VMSPLIT_1G
  5. 1168 default 0x80000000 if VMSPLIT_2G
  6. 1169 default 0xC0000000
阅读(371) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~