[kernelreadfans] Re: ULK2 chapter2.2.5.1

  • From: mingz <mingz@xxxxxxxxxxx>
  • To: kernelreadfans@xxxxxxxxxxxxx
  • Date: Sun, 1 Jun 2003 11:00:59 -0400

c&p from Understand linux 2.4 vm.    may helpful.

4.6.1 Bootstrapping

   The assembler function startup_32() is responsible for enabling the paging
   unit in arch/i386/kernel/head.S. While all normal kernel code in vmlinuz
   is compiled with the base address at PAGE_OFFSET + 1MiB, the kernel is
   actually loaded beginning at the first megabyte (0x00100000) of memory4.1.
   The bootstrap code in this file treats 1MiB as its base address by
   subtracting __PAGE_OFFSET from any address until the paging unit is
   enabled so before the paging unit is enabled, a page table mapping has to
   be established which translates the 8MiB of physical memory at the
   beginning of physical memory to the correct place after PAGE_OFFSET.

   Initialisation begins with statically defining at compile time an array
   called swapper_pg_dir which is placed using linker directives at
   0x00101000. It then establishes page table entries for 2 pages, pg0 and
   pg1. As the Page Size Extension (PSE) bit is set in the cr4 register,
   pages translated are 4MiB pages, not 4KiB as is the normal case. The first
   pointers to pg0 and pg1 are placed to cover the region 1-9MiB and the
   second pointers to pg0 and pg1 are placed at PAGE_OFFSET+1MiB. This means
   that when paging is enabled, they will map to the correct pages using
   either physical or virtual addressing.

   Once this mapping has been established, the paging unit is turned on by
   setting a bit in the cr0 register and a jump takes places immediately to
   ensure the Instruction Pointer (EIP register) is correct.

On Sunday 01 June 2003 09:03, you wrote:
> Hi,guys
> 在内核页表建立临时内核页表阶段:(head.S: swapper_pg_dir)
> The address field of entries 0 and 0 x 300 is set to the physical address
> of pg0, while the address field of entries 1 and 0 x 301 is set to the
> physical address of pg1. 
> 在ULK第一版里说,只用初始化pg0,为什么linux2.4.开始需要初始化pg1?什么目的?
> Best Regards
>   Ouyang Kai

| Ming Zhang, PhD. Student                                     
| Dept. of Electrical & Computer Engineering       
| College of Engineering                           
| University of Rhode Island                       
| Kingston RI. 02881                                  
| e-mail: mingz@xxxxxxxxxxx                        
| Tel. (401) 874-2293 Fax  (401) 782-6422          
| http://www.ele.uri.edu/~mingz                     

Other related posts: