version 1.104, 2013/06/22 15:13:55 |
version 1.105, 2013/06/23 03:16:46 |
Line 592 try586: /* Use the `cpuid' instruction. |
|
Line 592 try586: /* Use the `cpuid' instruction. |
|
cmpl %eax,RELOC(nkptp)+1*4 |
cmpl %eax,RELOC(nkptp)+1*4 |
jnz 1b |
jnz 1b |
|
|
/* Clear tables */ |
/* Clear tables */ |
movl %esi,%edi |
movl %esi,%edi |
xorl %eax,%eax |
xorl %eax,%eax |
cld |
cld |
movl RELOC(tablesize),%ecx |
movl RELOC(tablesize),%ecx |
shrl $2,%ecx |
shrl $2,%ecx |
rep |
rep |
stosl |
stosl |
|
|
leal (PROC0_PTP1_OFF)(%esi), %ebx |
leal (PROC0_PTP1_OFF)(%esi), %ebx |
|
|
/* |
/* |
* Build initial page tables. |
* Build initial page tables. |
*/ |
*/ |
/* |
/* |
* Compute &__data_start - KERNBASE. This can't be > 4G, |
* Compute &__data_start - KERNBASE. This can't be > 4G, |
* or we can't deal with it anyway, since we can't load it in |
* or we can't deal with it anyway, since we can't load it in |
* 32 bit mode. So use the bottom 32 bits. |
* 32 bit mode. So use the bottom 32 bits. |
*/ |
*/ |
movl $RELOC(__data_start),%edx |
movl $RELOC(__data_start),%edx |
andl $~PGOFSET,%edx |
andl $~PGOFSET,%edx |
|
|
/* |
/* |
* Skip the first MB. |
* Skip the first MB. |
*/ |
*/ |
movl $_RELOC(KERNTEXTOFF),%eax |
movl $_RELOC(KERNTEXTOFF),%eax |
movl %eax,%ecx |
movl %eax,%ecx |
shrl $(PGSHIFT-2),%ecx /* ((n >> PGSHIFT) << 2) for # pdes */ |
shrl $(PGSHIFT-2),%ecx /* ((n >> PGSHIFT) << 2) for # pdes */ |
#ifdef PAE |
#ifdef PAE |
shll $1,%ecx /* pdes are twice larger with PAE */ |
shll $1,%ecx /* pdes are twice larger with PAE */ |
#endif |
#endif |
addl %ecx,%ebx |
addl %ecx,%ebx |
|
|
/* Map the kernel text read-only. */ |
/* Map the kernel text read-only. */ |
movl %edx,%ecx |
movl %edx,%ecx |
Line 648 try586: /* Use the `cpuid' instruction. |
|
Line 648 try586: /* Use the `cpuid' instruction. |
|
/* |
/* |
* Construct a page table directory. |
* Construct a page table directory. |
*/ |
*/ |
/* Set up top level entries for identity mapping */ |
/* Set up top level entries for identity mapping */ |
leal (PROC0_PDIR_OFF)(%esi),%ebx |
leal (PROC0_PDIR_OFF)(%esi),%ebx |
leal (PROC0_PTP1_OFF)(%esi),%eax |
leal (PROC0_PTP1_OFF)(%esi),%eax |
orl $(PG_V|PG_KW), %eax |
orl $(PG_V|PG_KW), %eax |
movl RELOC(nkptp)+1*4,%ecx |
movl RELOC(nkptp)+1*4,%ecx |
fillkpt |
fillkpt |
|
|
/* Set up top level entries for actual kernel mapping */ |
/* Set up top level entries for actual kernel mapping */ |
leal (PROC0_PDIR_OFF + L2_SLOT_KERNBASE*PDE_SIZE)(%esi),%ebx |
leal (PROC0_PDIR_OFF + L2_SLOT_KERNBASE*PDE_SIZE)(%esi),%ebx |
leal (PROC0_PTP1_OFF)(%esi),%eax |
leal (PROC0_PTP1_OFF)(%esi),%eax |
orl $(PG_V|PG_KW), %eax |
orl $(PG_V|PG_KW), %eax |
movl RELOC(nkptp)+1*4,%ecx |
movl RELOC(nkptp)+1*4,%ecx |
fillkpt |
fillkpt |
|
|
/* Install a PDE recursively mapping page directory as a page table! */ |
/* Install a PDE recursively mapping page directory as a page table! */ |
leal (PROC0_PDIR_OFF + PDIR_SLOT_PTE*PDE_SIZE)(%esi),%ebx |
leal (PROC0_PDIR_OFF + PDIR_SLOT_PTE*PDE_SIZE)(%esi),%ebx |
leal (PROC0_PDIR_OFF)(%esi),%eax |
leal (PROC0_PDIR_OFF)(%esi),%eax |
orl $(PG_V|PG_KW),%eax |
orl $(PG_V|PG_KW),%eax |
movl $PDP_SIZE,%ecx |
movl $PDP_SIZE,%ecx |
fillkpt |
fillkpt |
|
|
Line 694 try586: /* Use the `cpuid' instruction. |
|
Line 694 try586: /* Use the `cpuid' instruction. |
|
movl %esi,%eax # phys address of ptd in proc 0 |
movl %esi,%eax # phys address of ptd in proc 0 |
movl %eax,%cr3 # load ptd addr into mmu |
movl %eax,%cr3 # load ptd addr into mmu |
|
|
/* |
/* |
* 2. Enable paging and the rest of it. |
* 2. Enable paging and the rest of it. |
*/ |
*/ |
movl %cr0,%eax # get control word |
movl %cr0,%eax # get control word |
# enable paging & NPX emulation |
# enable paging & NPX emulation |
orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax |
orl $(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_EM|CR0_MP|CR0_WP|CR0_AM),%eax |
Line 706 try586: /* Use the `cpuid' instruction. |
|
Line 706 try586: /* Use the `cpuid' instruction. |
|
ret |
ret |
|
|
begin: |
begin: |
/* |
/* |
* We have arrived. |
* We have arrived. |
* There's no need anymore for the identity mapping in low |
* There's no need anymore for the identity mapping in low |
* memory, remove it. |
* memory, remove it. |
*/ |
*/ |
movl _C_LABEL(nkptp)+1*4,%ecx |
movl _C_LABEL(nkptp)+1*4,%ecx |
leal (PROC0_PDIR_OFF)(%esi),%ebx # old, phys address of PDIR |
leal (PROC0_PDIR_OFF)(%esi),%ebx # old, phys address of PDIR |
addl $(KERNBASE), %ebx # new, virtual address of PDIR |
addl $(KERNBASE), %ebx # new, virtual address of PDIR |
1: movl $0,(PDE_SIZE-4)(%ebx) # Upper bits (for PAE) |
1: movl $0,(PDE_SIZE-4)(%ebx) # Upper bits (for PAE) |
movl $0,(%ebx) |
movl $0,(%ebx) |
addl $PDE_SIZE,%ebx |
addl $PDE_SIZE,%ebx |
loop 1b |
loop 1b |
|
|
/* Relocate atdevbase. */ |
/* Relocate atdevbase. */ |
|
|
movl %edx,_C_LABEL(atdevbase) |
movl %edx,_C_LABEL(atdevbase) |
|
|
/* Set up bootstrap stack. */ |
/* Set up bootstrap stack. */ |
leal (PROC0_STK_OFF+KERNBASE)(%esi),%eax |
leal (PROC0_STK_OFF+KERNBASE)(%esi),%eax |
movl %eax,_C_LABEL(lwp0uarea) |
movl %eax,_C_LABEL(lwp0uarea) |
leal (KSTACK_SIZE-FRAMESIZE)(%eax),%esp |
leal (KSTACK_SIZE-FRAMESIZE)(%eax),%esp |
movl %esi,(KSTACK_SIZE+PCB_CR3)(%eax) # pcb->pcb_cr3 |
movl %esi,(KSTACK_SIZE+PCB_CR3)(%eax) # pcb->pcb_cr3 |
|
|
call _C_LABEL(initgdt) |
call _C_LABEL(initgdt) |
addl $4,%esp |
addl $4,%esp |
|
|
movl _C_LABEL(tablesize),%eax |
movl _C_LABEL(tablesize),%eax |
addl %esi,%eax # skip past stack and page tables |
addl %esi,%eax # skip past stack and page tables |
|
|
#ifdef PAE |
#ifdef PAE |
|
|
movl %esp, %ebx # save start of available space |
movl %esp, %ebx # save start of available space |
movl $_RELOC(tmpstk),%esp # bootstrap stack end location |
movl $_RELOC(tmpstk),%esp # bootstrap stack end location |
|
|
/* Clear BSS first so that there are no surprises... */ |
/* Clear BSS first so that there are no surprises... */ |
xorl %eax,%eax |
xorl %eax,%eax |
movl $RELOC(__bss_start),%edi |
movl $RELOC(__bss_start),%edi |
movl $RELOC(_end),%ecx |
movl $RELOC(_end),%ecx |
|
|
rep stosb |
rep stosb |
|
|
/* Copy the necessary stuff from start_info structure. */ |
/* Copy the necessary stuff from start_info structure. */ |
/* We need to copy shared_info early, so that sti/cli work */ |
/* We need to copy shared_info early, so that sti/cli work */ |
movl $RELOC(start_info_union),%edi |
movl $RELOC(start_info_union),%edi |
movl $128,%ecx |
movl $128,%ecx |
rep movsl |
rep movsl |