Article Title: linux memory management initialization. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
ENTRY (startup_32)
/*
* Set segments to known values.
*/
Cld
Lgdt boot_gdt_descr-_ PAGE_OFFSET/* set the segment register */
Movl $ (_ BOOT_DS), % eax
Movl % eax, % ds
Movl % eax, % es
Movl % eax, % fs
Movl % eax, % gs
/*
* Clear BSS first so that there are no surprises...
* No need to cld as DF is already clear from cld abve...
*/
Xorl % eax, % eax
Movl $ __bss_start-_ PAGE_OFFSET, % edi
Movl $ __bss_stop-_ PAGE_OFFSET, % ecx
Subl % edi, % ecx
Shrl $2, % ecx
Rep; stosl
/*
* Copy bootup parameters out of the way.
* Note: % esi still has the pointer to the real-mode data.
* With the kexec as boot loader, parameter segment might be loaded beyond
* Kernel image and might not even be addressable by early boot page tables.
* (Kexec on panic case). Hence copy out the parameters before initializing
* Page tables.
*/
Movl $ (boot_params-_ PAGE_OFFSET), % edi
Movl $ (PARAM_SIZE/4), % ecx
Cld
Rep
Movsl
Movl boot_params-_ PAGE_OFFSET + NEW_CL_POINTER, % esi
Andl % esi, % esi
Jnz 2f # New command line protocol
Cmpw $ (OLD_CL_MAGIC), OLD_CL_MAGIC_ADDR
Jne 1f
Movzwl OLD_CL_OFFSET, % esi
Addl $ (OLD_CL_BASE_ADDR), % esi
2:
Movl $ (saved_command_line-_ PAGE_OFFSET), % edi
Movl $ (COMMAND_LINE_SIZE/4), % ecx
Rep
Movsl
1:
/*
* Initialize page tables. This creates a PVDF and a set of page
* Tables, which are located immediately beyond _ end. The variable
* Init_pg_tables_end is set up to point to the first "safe" location.
* Mappings are created both at virtual address 0 (identity mapping)
* And PAGE_OFFSET for up to _ end + sizeof (page tables) + INIT_MAP_BEYOND_END.
*
* Warning: don't use % esi or the stack in this code. However, % esp
* Can be used as a GPR if you really need it...
*/
Page_pde_offset = (_ PAGE_OFFSET> 20 );
Movl $ (pg0-_ PAGE_OFFSET), % edi
Movl $ (swapper_pg_dir-_ PAGE_OFFSET), % edx
Movl $0x007, % eax/* 0x007 = PRESENT + RW + USER */
10:
Leal 0x007 (% edi), % ecx/* Create PVDF entry */
Movl % ecx, (% edx)/* Store identity PVDF entry */
Movl % ecx, page_pde_offset (% edx)/* Store kernel PVDF entry */
Addl $4, % edx
Movl $1024, % ecx
11:
Stosl
Addl $0x1000, % eax
Loop 11b
/* End condition: we must map up to and including INIT_MAP_BEYOND_END */
/* Bytes beyond the end of our own page tables; the + 0x007 is the attribute bits */
Leal (INIT_MAP_BEYOND_END + 0x007) (% edi), % ebp
Cmpl % ebp, % eax
Jb 10b
Movl % edi, (init_pg_tables_end-_ PAGE_OFFSET)
# Ifdef CONFIG_SMP
Xorl % ebx, % ebx/* This is the boot CPU (BSP )*/
Jmp 3f
/*
* Non-boot CPU entry point; entered from trampoline. S
* We can't lgdt here, because lgdt itself uses a data segment,
* We know the trampoline has already loaded the boot_gdt_table GDT
* For us.
*/
ENTRY (startup_32_smp)
Cld
Movl $ (_ BOOT_DS), % eax
Movl % eax, % ds
Movl % eax, % es
Movl % eax, % fs
Movl % eax, % gs
[1] [2] [3] [4] [5] Next page