Commit bbe302ee authored by Brian Gerst's avatar Brian Gerst Committed by Patrick Mochel

[PATCH] i386 mm init cleanup part 2

The remaining cleanups are to switch to using pfn instead of vaddr, and
improve readability.
parent 131ca9c0
...@@ -181,22 +181,16 @@ unsigned long __PAGE_KERNEL = _PAGE_KERNEL; ...@@ -181,22 +181,16 @@ unsigned long __PAGE_KERNEL = _PAGE_KERNEL;
static void __init pagetable_init (void) static void __init pagetable_init (void)
{ {
unsigned long vaddr, end; unsigned long vaddr, pfn;
pgd_t *pgd, *pgd_base; pgd_t *pgd, *pgd_base;
int i, j, k; int i, j, k;
pmd_t *pmd; pmd_t *pmd;
pte_t *pte, *pte_base; pte_t *pte, *pte_base;
/*
* This can be zero as well - no problem, in that case we exit
* the loops anyway due to the PTRS_PER_* conditions.
*/
end = (unsigned long)__va(max_low_pfn*PAGE_SIZE);
pgd_base = swapper_pg_dir; pgd_base = swapper_pg_dir;
#if CONFIG_X86_PAE #if CONFIG_X86_PAE
for (i = 0; i < PTRS_PER_PGD; i++) for (i = 0; i < PTRS_PER_PGD; i++)
set_pgd(pgd_base + i, __pgd(1 + __pa(empty_zero_page))); set_pgd(pgd_base + i, __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
#endif #endif
if (cpu_has_pse) { if (cpu_has_pse) {
set_in_cr4(X86_CR4_PSE); set_in_cr4(X86_CR4_PSE);
...@@ -207,41 +201,28 @@ static void __init pagetable_init (void) ...@@ -207,41 +201,28 @@ static void __init pagetable_init (void)
} }
i = __pgd_offset(PAGE_OFFSET); i = __pgd_offset(PAGE_OFFSET);
pfn = 0;
pgd = pgd_base + i; pgd = pgd_base + i;
for (; i < PTRS_PER_PGD; pgd++, i++) { for (; i < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, i++) {
vaddr = i*PGDIR_SIZE;
if (end && (vaddr >= end))
break;
#if CONFIG_X86_PAE #if CONFIG_X86_PAE
pmd = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE); pmd = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
set_pgd(pgd, __pgd(__pa(pmd) + 0x1)); set_pgd(pgd, __pgd(__pa(pmd) | _PAGE_PRESENT));
#else #else
pmd = (pmd_t *)pgd; pmd = (pmd_t *) pgd;
#endif #endif
if (pmd != pmd_offset(pgd, 0)) for (j = 0; j < PTRS_PER_PMD && pfn < max_low_pfn; pmd++, j++) {
BUG();
for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
if (end && (vaddr >= end))
break;
if (cpu_has_pse) { if (cpu_has_pse) {
set_pmd(pmd, pfn_pmd(__pa(vaddr) >> PAGE_SHIFT, PAGE_KERNEL_LARGE)); set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE));
continue; pfn += PTRS_PER_PTE;
} } else {
pte_base = pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE); pte_base = pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
for (k = 0; k < PTRS_PER_PTE; pte++, k++) { for (k = 0; k < PTRS_PER_PTE && pfn < max_low_pfn; pte++, pfn++, k++)
vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE; set_pte(pte, pfn_pte(pfn, PAGE_KERNEL));
if (end && (vaddr >= end))
break;
*pte = pfn_pte(__pa(vaddr) >> PAGE_SHIFT, PAGE_KERNEL);
}
set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte_base)));
if (pte_base != pte_offset_kernel(pmd, 0))
BUG();
set_pmd(pmd, __pmd(__pa(pte_base) | _KERNPG_TABLE));
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment