ARM Linux下的phys_to_virt/virt_to_phys函数
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
ARM Linux下的phys_to_virt/virt_to_phys函数相关推荐
- ARM Linux下UPnP使用
ARM Linux下UPnP使用 一.UPnP简介 UPnP(Universal Plug and Play)技术是一种屏蔽各种数字设备的硬件和操作系统的通信协议.它是一种数字网络中间件技术, ...
- Linux下的内存对齐函数
在Linux下内存对齐的函数包括posix_memalign, aligned_alloc, memalign, valloc, pvalloc,其各个函数的声明如下: int posix_memal ...
- linux pfn,ARM Linux下的page和pfn之间转换的宏。
ARM Linux下的page和pfn之间转换的宏如下: 1)page_to_pfn 2)pfn_to_page 这两个宏依赖于内核编译时,选择的内存模型.在include/asm-generic/m ...
- linux uname内核,Linux下confstr与uname函数_获取C库与内核信息
Linux下confstr与uname函数_获取C库与内核信息 #include #include //uname int main(int argc, char **argv[]) { struc ...
- linux-arm下如何开启tftp传输,arm linux 下移植busybox 的tftp
(1)进入busybox目录,make menuconfig ,然后在networking中勾选tftp项跟tftpd项. (2)配置/etc/inetd.conf 中关于tftp的选项(此部未验证, ...
- Linux系统常用函数,浅谈linux下的一些常用函数的总结(必看篇)
1.exit()函数 exit(int n) 其实就是直接退出程序, 因为默认的标准程序入口为int main(int argc, char** argv),返回值是int型的. 一般在shell下 ...
- Linux系统怎么编译sin,linux下gcc编译sin函数出错的问题
linux下gcc编译sin函数出错的问题 收藏 Q: I keep getting errors due to library functions being undefined, but I'm ...
- linux下C语言main函数参数解析
1. linux下常见的main函数有两种形式: int main(int argc, char **argv) int main(int argc, char * argv[]) 2. 参数介绍 第 ...
- Linux 下调用UEFI的函数
Linux 下调用UEFI的函数 摘要 Linux 调用UEFI function 时候调用约定的转换 64bits calling convention Microsoft calling conv ...
最新文章
- Redis 系列之一
- java web 项目在tomcat上显示空白页的解决
- Windows -- cmd命令: ipconfig 和 nbtstat
- Duilib教程-非DUI控件
- cv图像翻转_涨点技巧!汇集13个Kaggle图像分类项目的性能提升指南
- jmeter 中的Parameters 和Body Data的区别
- Android模拟器下安装APP报INSTALL_FAILED_NO_MATCHING_ABIS错误解决方案
- [bzoj2816][ZJOI2012]网络(LCT,splay)
- Spring中@Autowired注入static静态变量空指针异常
- mmap文件做成html,mmap()映射到文件的一些总结
- MacOS Mojave 更换开机登录界面壁纸
- 火狐浏览器国内版和国际版区别
- python将输入的字符串反转过来_如何实现python字符串反转?
- 计算机无法关闭密码保护,win7的密码保护共享关闭不了怎么办_解决win7的密码保护共享关闭不了的方法...
- 如何自己编写一个交通仿真软件(一)火种。
- awk 的内置变量 NF、NR、FNR、FS、OFS、RS、ORS
- Git学习总结(二)GitHub账号学生认证
- Project 2016 中文版软件快捷键学习
- html制作图像画廊,创建 Web 照片画廊 (Photoshop)
- 游戏设计的艺术:一本透镜的书——第二十五章 好的游戏是通过游戏测试做出来的