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.