Each device init typically takes <#1979#> memory_start<#1979#> and returns an updated
value if it allocates space at <#1980#> memory_start<#1980#> (by simply grabbing
it). <#1981#> paging_init()<#1981#> initializes the page tables in the <#1982#>
swapper_pg_dir<#1982#> (starting at 0xc0000000) to cover all of the
physical memory from <#1983#> memory_start<#1983#> to <#1984#> memory_end<#1984#>.
Actually the first 4~MB is done in <#1985#> startup_32<#1985#> (head.S). <#1986#>
memory_start<#1986#> is incremented if any new <#1987#> page_table<#1987#>s are added.
The first page is zeroed to trap null pointer references in the
kernel.
In <#1988#> sched_init()<#1988#> the <#1989#> ldt<#1989#> and <#1990#> tss<#1990#> descriptors for
<#1991#> task[0]<#1991#> are set in the GDT, and loaded into the TR and LDTR (the
only time it's done explicitly). A trap gate (0x80) is set up for
<#1992#> system_call()<#1992#>. The nested task flag is turned off in
preparation for entering user mode. The timer is turned on. The <#1993#>
task_struct<#1993#> for <#1994#> task[0]<#1994#> appears in its entirety in <#1995#>
;SPM_lt;linux/sched.h;SPM_gt;<#1995#>.
<#1996#> mem_map<#1996#> is then constructed by <#1997#> mem_init()<#1997#> to reflect the
current usage of physical pages. This is the state reflected in the
physical memory map of the previous section.
Then \ moves into user mode with an <#1998#> iret<#1998#> after pushing the
current <#1999#> ss<#1999#>, <#2000#> esp<#2000#>, etc. Of course the user segments for <#2001#>
task[0]<#2001#> are mapped right over the kernel segments so execution
continues exactly where it left off.
<#2002#> task[0]<#2002#>:
The first <#2010#> exec()<#2010#> sets the LDT entries for <#2011#> task[1]<#2011#> to the
user values of
base = 0x0, limit = TASK_SIZE = 0xc0000000. Thereafter, no process
sees the kernel segments while in user mode.