Memory Addressing

The Page Global Directory includes the addresses of several Page Middle Directories, which in turn include the addresses of several Page Tables. Each Page Table entry points to a page frame. The linear address is thus split into four parts. The figure does not show the bit numbers because the size of each part depends on the computer architecture.

 

/* PAGE_SHIFT determines the page size */

#define PAGE_SHIFT      12

#define PAGE_SIZE      (1UL << PAGE_SHIFT)

#define PAGE_MASK      (~(PAGE_SIZE-1)

 

/*

 * PMD_SHIFT determines the size of the area a second-level page table can map

 */

#define PMD_SHIFT      20

#define PMD_SIZE       (1UL << PMD_SHIFT)

#define PMD_MASK       (~(PMD_SIZE-1))

 

/*

 * PGDIR_SHIFTdetermines what a third-level page table entry can map

 */

#define PGDIR_SHIFT    20

#define PGDIR_SIZE     (1UL << PGDIR_SHIFT)

#define PGDIR_MASK     (~(PGDIR_SIZE-1))

 

/*

 * entries per pagedirectory level: the sa110 is two-level, so

 * we don't reallyhave any PMD directory physically.

 */

#define PTRS_PER_PTE   256

#define PTRS_PER_PMD   1

#define PTRS_PER_PGD   4096

#define USER_PTRS_PER_PGD  (TASK_SIZE/PGDIR_SIZE)

Thelinear address space of a process is divided into two parts:

• Linear addresses from 0x00000000 to PAGE_OFFSET -1 can be addressedwhen the processis in either User or Kernel Mode.

• Linear addresses from PAGE_OFFSET to 0xffffffff can be addressed onlywhen the processis in Kernel Mode.

Usually,the PAGE_OFFSET macro yields the value 0xc0000000: this means that the fourth giga byte of linear addresses is reserved for the kernel, while the first three giga bytes are accessible from both the kernel and the user programs. However, the value of PAGE_OFFSET maybe customized by the user when the Linux kernel image is compiled.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值