next up previous
Next: Start Paging Up: MM Sub-System initialization. Previous: Memory categorization

Paging start

File : arch/i386/kernel/head.S
"head.S"  holds the code where paging is started. The entry point name is startup_32.
All page table initializations are done here. Initial page tables (which are compiled are into the kernel) are set up and paging is started by setting the PG bit in cr0 register and the page directory pointer in the cr3 register. The compiled in page directory is stored in swapper_pg_dir symbol and the page tables in pg0 and pg1 symbols. (remember: page middle tables are not used in i386 arch. They fold into the first level page table. This also is not entirely true. When PAE is enabled the scheme changes, which we will see separately later)
The kernel code is loaded in physical address 0x100000. This is how it would look. (only symbols of interest to MM are shown here)

phy_layout.png
The contents of swapper_pg_dir and pg0 are:
pg_dir.png
Considering the above:

A virtual address of 0x100000 and 0xC0000000 will point to the same page tables and thus will transform to the same physical address. This identity mapping is needed for the kernel at boot time. Later, Proper page tables will be initialized in paging_init function.

A small piece of code helps start paging and relocate the eip from physical address to kernel virtual address (1MB + something to __PAGE_OFFSET + something) in head.S.


next up previous
Next: Start Paging Up: MM Sub-System initialization. Previous: Memory categorization
2002-09-22