The Linear Address Fields

The following macros simplify Page Table handling:

PAGE_SHIFT

Specifies the length in bits of the Offset field; when applied to 80 x 86 processors, it yields the value 12. Since all the addresses in a page must fit in the Offset field, the size of a page on 80 x 86 systems is 212 or the familiar 4,096 bytes; the page_shift of 12 can thus be considered the logarithm base 2 of the total page size. This macro is used by page_size to return the size of the page. Finally, the page_mask macro yields the value 0xfffff000 and is used to mask all the bits of the Offset field.

PMD_SHIFT

The total length in bits of the Middle Directory and Table fields of a linear address; in other words, the logarithm of the size of the area a Page Middle Directory entry can map. The pmd_size macro computes the size of the area mapped by a single entry of the Page Middle Directory — that is, of a Page Table. The pmd_mask macro is used to mask all the bits of the Offset and Table fields.

When PAE is disabled, pmd_shift yields the value 22 (12 from Offset plus 10 from Table), pmd_size yields 222 or 4 MB, and pmd_mask yields 0xffc00000. Conversely, when PAE is enabled, pmd_shift yields the value 21 (12 from Offset plus 9 from Table), pmd_size yields 221 or 2 MB, and pmd_mask yields 0xffe00000.

PGDIR_SHIFT

Determines the logarithm of the size of the area a Page Global Directory entry can map. The pgdir_size macro computes the size of the area mapped by a single entry of the Page Global Directory. The pgdir_mask macro is used to mask all the bits of the Offset, Table, and Middle Dir fields.

When PAE is disabled, pgdir_shift yields the value 22 (the same value yielded by pmd_shift), pgdir_size yields 222 or 4 MB, and pgdir_mask yields 0xffc00000. Conversely, when PAE is enabled, pgdir_shift yields the value 30 (12 from Offset plus 9 from Table plus 9 from Middle Dir), pgdir_size yields 230 or

1 GB, and pgdir_mask yields 0xc0000000.

PTRS_PER_PTE, PTRS_PER_PMD, and PTRS_PER_PGD

Compute the number of entries in the Page Table, Page Middle Directory, and Page Global Directory. They yield the values 1,024, 1, and 1,024, respectively, when PAE is disabled, and the values 4, 512, and 512, respectively, when PAE is enabled

+1 0

Post a comment