LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 750|回复: 1

页表问题

[复制链接]
发表于 2005-6-22 15:44:14 | 显示全部楼层 |阅读模式
内核2.6.11的页表两层映射  include/asm-i386/pgtable-2level-defs.h
代码如下:

  1. #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
  2. #define _I386_PGTABLE_2LEVEL_DEFS_H

  3. /*
  4. * traditional i386 two-level paging structure:
  5. */

  6. #define PGDIR_SHIFT        22
  7. #define PTRS_PER_PGD        1024

  8. /*
  9. * the i386 is two-level, so we don't really have any
  10. * PMD directory physically.
  11. */

  12. #define PTRS_PER_PTE        1024

  13. #endif /* _I386_PGTABLE_2LEVEL_DEFS_H */
复制代码

以及include/asm-i386/pgtable-3level-defs.h

  1. #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
  2. #define _I386_PGTABLE_3LEVEL_DEFS_H

  3. /*
  4. * PGDIR_SHIFT determines what a top-level page table entry can map
  5. */
  6. #define PGDIR_SHIFT        30
  7. #define PTRS_PER_PGD        4

  8. /*
  9. * PMD_SHIFT determines the size of the area a middle-level
  10. * page table can map
  11. */
  12. #define PMD_SHIFT        21
  13. #define PTRS_PER_PMD        512

  14. /*
  15. * entries per page directory level
  16. */
  17. #define PTRS_PER_PTE        512

  18. #endif /* _I386_PGTABLE_3LEVEL_DEFS_H */

复制代码

能有解释下三层映射为什么这么分,
PGDIR_SHIFT        30
才2位,PMD,PT都9位
那么offset对32位CPU是不是要12位啊
发表于 2005-6-22 16:09:33 | 显示全部楼层
Post by jassiue

能有解释下三层映射为什么这么分,
PGDIR_SHIFT        30
才2位,PMD,PT都9位
那么offset对32位CPU是不是要12位啊


这主要是解决在32位机器上使用 36 位地址的问题
详见intel文档关于pae部分
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表