-/* allocate kernel page table pages */
- ALLOCPAGES(NKPT)
- movl %esi,PA(KPTphys)
-
-#ifdef X86_64
-/* allocate PML4 page */
- ALLOCPAGES(1)
- movl %esi,EXT(IdlePML4)
-/* allocate new 3rd level directory page */
- ALLOCPAGES(1)
- movl %esi,EXT(IdlePDPT64)
-#endif
-
-#ifdef PAE
-/* allocate Page Table Directory Page */
- ALLOCPAGES(1)
- movl %esi,PA(EXT(IdlePDPT))
-#endif
-
-/* allocate kernel page directory page */
- ALLOCPAGES(NPGPTD)
- movl %esi,PA(EXT(IdlePTD))
-
-/* map from zero to end of kernel */
- xorl %eax,%eax
- movl PA(physfree),%ecx
- shrl $(PAGE_SHIFT),%ecx
- fillkptphys( $(PTE_W) )
-
-/* map page directory */
-#ifdef PAE
- movl PA(EXT(IdlePDPT)), %eax
- movl $1, %ecx
- fillkptphys( $(PTE_W) )
-
- movl PA(EXT(IdlePDPT64)), %eax
- movl $1, %ecx
- fillkptphys( $(PTE_W) )
-#endif
- movl PA(EXT(IdlePTD)),%eax
- movl $(NPGPTD), %ecx
- fillkptphys( $(PTE_W) )
-
-/* install a pde for temp double map of bottom of VA */
- movl PA(KPTphys),%eax
- xorl %ebx,%ebx
- movl $(NKPT), %ecx
- fillkpt(PA(EXT(IdlePTD)), $(PTE_W))
-
-/* install pde's for page tables */
- movl PA(KPTphys),%eax
- movl $(KPTDI),%ebx
- movl $(NKPT),%ecx
- fillkpt(PA(EXT(IdlePTD)), $(PTE_W))
-
-/* install a pde recursively mapping page directory as a page table */
- movl PA(EXT(IdlePTD)),%eax
- movl $(PTDPTDI),%ebx
- movl $(NPGPTD),%ecx
- fillkpt(PA(EXT(IdlePTD)), $(PTE_W))
-
-#ifdef PAE
- movl PA(EXT(IdlePTD)), %eax
- xorl %ebx, %ebx
- movl $(NPGPTD), %ecx
- fillkpt(PA(EXT(IdlePDPT)), $0)
-#endif
-
-/* install a pde page for commpage use up in high memory */
-
- movl PA(physfree),%eax /* grab next phys page */
- movl %eax,%ebx
- addl $(PAGE_SIZE),%ebx
- movl %ebx,PA(physfree) /* show next free phys pg */
- movl $(COMM_PAGE_BASE_ADDR),%ebx
- shrl $(PDESHIFT),%ebx /* index into pde page */
- movl $(1), %ecx /* # pdes to store */
- fillkpt(PA(EXT(IdlePTD)), $(PTE_W|PTE_U)) /* user has access! */
-
- movl PA(physfree),%edi
- movl %edi,PA(EXT(first_avail)) /* save first available phys addr */
-
-#ifdef PAE
-/*
- * We steal 0x4000 for a temp pdpt and 0x5000-0x8000
- * for temp pde pages in the PAE case. Once we are
- * running at the proper virtual address we switch to
- * the PDPT/PDE's the master is using */
-
- /* clear pdpt page to be safe */
- xorl %eax, %eax
- movl $(PAGE_SIZE),%ecx
- movl $(0x4000),%edi
- cld
- rep
- stosb
-
- /* build temp pdpt */
- movl $(0x5000), %eax
- xorl %ebx, %ebx
- movl $(NPGPTD), %ecx
- fillkpt($(0x4000), $0)
-
- /* copy the NPGPTD pages of pdes */
- movl PA(EXT(IdlePTD)),%eax
- movl $0x5000,%ebx
- movl $((PTEMASK+1)*NPGPTD),%ecx
-1: movl 0(%eax),%edx
- movl %edx,0(%ebx)
- movl 4(%eax),%edx
- movl %edx,4(%ebx)
- addl $(PTESIZE),%eax
- addl $(PTESIZE),%ebx
- loop 1b
-#else
-/* create temp pde for slaves to use
- use unused lomem page and copy in IdlePTD */
- movl PA(EXT(IdlePTD)),%eax
- movl $0x4000,%ebx
- movl $(PTEMASK+1),%ecx
-1: movl 0(%eax),%edx
- movl %edx,0(%ebx)
- addl $(PTESIZE),%eax
- addl $(PTESIZE),%ebx
- loop 1b
-#endif
-
- POSTCODE(PSTART_PAGE_TABLES)
-
-/*
- * Fix initial descriptor tables.
- */
- lea PA(EXT(master_idt)),%esi /* fix IDT */
- movl $(IDTSZ),%ecx
- movl $(PA(fix_idt_ret)),%ebx
- jmp fix_desc_common /* (cannot use stack) */
-fix_idt_ret:
-
- lea PA(EXT(master_gdt)),%esi /* fix GDT */
- movl $(GDTSZ),%ecx
- movl $(PA(fix_gdt_ret)),%ebx
- jmp fix_desc_common /* (cannot use stack) */
-fix_gdt_ret:
-
- lea PA(EXT(master_ldt)),%esi /* fix LDT */
- movl $(LDTSZ),%ecx
- movl $(PA(fix_ldt_ret)),%ebx
- jmp fix_desc_common /* (cannot use stack) */
-fix_ldt_ret:
-
-/*
- *
- */
-
- lgdt PA(EXT(gdtptr)) /* load GDT */
- lidt PA(EXT(idtptr)) /* load IDT */