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。

  1. arch/arm/include/asm/memory.h
  2. #ifdef CONFIG_MMU
  3. /*
  4. * PAGE_OFFSET - the virtual address of the start of the kernel image
  5. * TASK_SIZE - the maximum size of a user space task.
  6. * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
  7. */
  8. #define PAGE_OFFSET        UL(CONFIG_PAGE_OFFSET)
  9. #define TASK_SIZE        (UL(CONFIG_PAGE_OFFSET) - UL(0x01000000))
  10. #define TASK_UNMAPPED_BASE    (UL(CONFIG_PAGE_OFFSET) / 3)
  11. /*
  12. * The maximum size of a 26-bit user space task.
  13. */
  14. #define TASK_SIZE_26        UL(0x04000000)
  15. ......
  16. ......
  17. #else /* CONFIG_MMU */
  18. /*
  19. * The limitation of user task size can grow up to the end of free ram region.
  20. * It is difficult to define and perhaps will never meet the original meaning
  21. * of this define that was meant to.
  22. * Fortunately, there is no reference for this in noMMU mode, for now.
  23. */
  24. #ifndef TASK_SIZE
  25. #define TASK_SIZE        (CONFIG_DRAM_SIZE)
  26. #endif
  27. #ifndef TASK_UNMAPPED_BASE
  28. #define TASK_UNMAPPED_BASE    UL(0x00000000)
  29. #endif
  30. #ifndef PHYS_OFFSET
  31. #define PHYS_OFFSET         UL(CONFIG_DRAM_BASE)
  32. #endif
  33. ......
  34. ......
  35. #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

ARM Linux下的phys_to_virt/virt_to_phys函数相关推荐

  1. ARM Linux下UPnP使用

    ARM Linux下UPnP使用   一.UPnP简介   UPnP(Universal Plug and Play)技术是一种屏蔽各种数字设备的硬件和操作系统的通信协议.它是一种数字网络中间件技术, ...

  2. Linux下的内存对齐函数

    在Linux下内存对齐的函数包括posix_memalign, aligned_alloc, memalign, valloc, pvalloc,其各个函数的声明如下: int posix_memal ...

  3. linux pfn,ARM Linux下的page和pfn之间转换的宏。

    ARM Linux下的page和pfn之间转换的宏如下: 1)page_to_pfn 2)pfn_to_page 这两个宏依赖于内核编译时,选择的内存模型.在include/asm-generic/m ...

  4. linux uname内核,Linux下confstr与uname函数_获取C库与内核信息

    Linux下confstr与uname函数_获取C库与内核信息 #include #include  //uname int main(int argc, char **argv[]) { struc ...

  5. linux-arm下如何开启tftp传输,arm linux 下移植busybox 的tftp

    (1)进入busybox目录,make menuconfig ,然后在networking中勾选tftp项跟tftpd项. (2)配置/etc/inetd.conf 中关于tftp的选项(此部未验证, ...

  6. Linux系统常用函数,浅谈linux下的一些常用函数的总结(必看篇)

    1.exit()函数 exit(int n)  其实就是直接退出程序, 因为默认的标准程序入口为int main(int argc, char** argv),返回值是int型的. 一般在shell下 ...

  7. Linux系统怎么编译sin,linux下gcc编译sin函数出错的问题

    linux下gcc编译sin函数出错的问题 收藏 Q: I keep getting errors due to library functions being undefined, but I'm ...

  8. linux下C语言main函数参数解析

    1. linux下常见的main函数有两种形式: int main(int argc, char **argv) int main(int argc, char * argv[]) 2. 参数介绍 第 ...

  9. Linux 下调用UEFI的函数

    Linux 下调用UEFI的函数 摘要 Linux 调用UEFI function 时候调用约定的转换 64bits calling convention Microsoft calling conv ...

最新文章

  1. Redis 系列之一
  2. java web 项目在tomcat上显示空白页的解决
  3. Windows -- cmd命令: ipconfig 和 nbtstat
  4. Duilib教程-非DUI控件
  5. cv图像翻转_涨点技巧!汇集13个Kaggle图像分类项目的性能提升指南
  6. jmeter 中的Parameters 和Body Data的区别
  7. Android模拟器下安装APP报INSTALL_FAILED_NO_MATCHING_ABIS错误解决方案
  8. [bzoj2816][ZJOI2012]网络(LCT,splay)
  9. Spring中@Autowired注入static静态变量空指针异常
  10. mmap文件做成html,mmap()映射到文件的一些总结
  11. MacOS Mojave 更换开机登录界面壁纸
  12. 火狐浏览器国内版和国际版区别
  13. python将输入的字符串反转过来_如何实现python字符串反转?
  14. 计算机无法关闭密码保护,win7的密码保护共享关闭不了怎么办_解决win7的密码保护共享关闭不了的方法...
  15. 如何自己编写一个交通仿真软件(一)火种。
  16. awk 的内置变量 NF、NR、FNR、FS、OFS、RS、ORS
  17. Git学习总结(二)GitHub账号学生认证
  18. Project 2016 中文版软件快捷键学习
  19. html制作图像画廊,创建 Web 照片画廊 (Photoshop)
  20. 游戏设计的艺术:一本透镜的书——第二十五章 好的游戏是通过游戏测试做出来的

热门文章

  1. 7-176 数列求和
  2. 码工成长手册:刚毕业的程序员如何快速提升自己?
  3. 【国内chatgpt使用方法合集】(5月22日已更新)
  4. EasyExcel删除模版Sheet页
  5. android开源项目---RoundedImageView制作圆角矩形,椭圆形以其圆形控件
  6. 各主流编程语言适用领域——软件工程
  7. 红米k30支持html,红米K30S至尊纪念版发布:骁龙865+支持144Hz高刷
  8. 应用Python把汉语Excel表转换为拼音表格
  9. 电信和移动差距:关于充话费赠手机的营销对比
  10. 左右联动(仿京东分类)