Commit 7cdfbc74 authored by Sam Ravnborg's avatar Sam Ravnborg Committed by David S. Miller

sparc32: beautify srmmu_inherit_prom_mappings()

Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f71a2aac
...@@ -677,44 +677,48 @@ static inline unsigned long srmmu_probe(unsigned long vaddr) ...@@ -677,44 +677,48 @@ static inline unsigned long srmmu_probe(unsigned long vaddr)
static void __init srmmu_inherit_prom_mappings(unsigned long start, static void __init srmmu_inherit_prom_mappings(unsigned long start,
unsigned long end) unsigned long end)
{ {
unsigned long probed;
unsigned long addr;
pgd_t *pgdp; pgd_t *pgdp;
pmd_t *pmdp; pmd_t *pmdp;
pte_t *ptep; pte_t *ptep;
int what = 0; /* 0 = normal-pte, 1 = pmd-level pte, 2 = pgd-level pte */ int what; /* 0 = normal-pte, 1 = pmd-level pte, 2 = pgd-level pte */
unsigned long prompte;
while (start <= end) { while (start <= end) {
if (start == 0) if (start == 0)
break; /* probably wrap around */ break; /* probably wrap around */
if (start == 0xfef00000) if (start == 0xfef00000)
start = KADB_DEBUGGER_BEGVM; start = KADB_DEBUGGER_BEGVM;
if (!(prompte = srmmu_probe(start))) { probed = srmmu_probe(start);
if (!probed) {
/* continue probing until we find an entry */
start += PAGE_SIZE; start += PAGE_SIZE;
continue; continue;
} }
/* A red snapper, see what it really is. */ /* A red snapper, see what it really is. */
what = 0; what = 0;
addr = start - PAGE_SIZE;
if (!(start & ~(SRMMU_REAL_PMD_MASK))) { if (!(start & ~(SRMMU_REAL_PMD_MASK))) {
if (srmmu_probe((start - PAGE_SIZE) + SRMMU_REAL_PMD_SIZE) == prompte) if (srmmu_probe(addr + SRMMU_REAL_PMD_SIZE) == probed)
what = 1; what = 1;
} }
if (!(start & ~(SRMMU_PGDIR_MASK))) { if (!(start & ~(SRMMU_PGDIR_MASK))) {
if (srmmu_probe((start-PAGE_SIZE) + SRMMU_PGDIR_SIZE) == if (srmmu_probe(addr + SRMMU_PGDIR_SIZE) == probed)
prompte)
what = 2; what = 2;
} }
pgdp = pgd_offset_k(start); pgdp = pgd_offset_k(start);
if (what == 2) { if (what == 2) {
*(pgd_t *)__nocache_fix(pgdp) = __pgd(prompte); *(pgd_t *)__nocache_fix(pgdp) = __pgd(probed);
start += SRMMU_PGDIR_SIZE; start += SRMMU_PGDIR_SIZE;
continue; continue;
} }
if (pgd_none(*(pgd_t *)__nocache_fix(pgdp))) { if (pgd_none(*(pgd_t *)__nocache_fix(pgdp))) {
pmdp = __srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE, SRMMU_PMD_TABLE_SIZE); pmdp = __srmmu_get_nocache(SRMMU_PMD_TABLE_SIZE,
SRMMU_PMD_TABLE_SIZE);
if (pmdp == NULL) if (pmdp == NULL)
early_pgtable_allocfail("pmd"); early_pgtable_allocfail("pmd");
memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE); memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE);
...@@ -734,13 +738,15 @@ static void __init srmmu_inherit_prom_mappings(unsigned long start, ...@@ -734,13 +738,15 @@ static void __init srmmu_inherit_prom_mappings(unsigned long start,
* good hardware PTE piece. Alternatives seem worse. * good hardware PTE piece. Alternatives seem worse.
*/ */
unsigned int x; /* Index of HW PMD in soft cluster */ unsigned int x; /* Index of HW PMD in soft cluster */
unsigned long *val;
x = (start >> PMD_SHIFT) & 15; x = (start >> PMD_SHIFT) & 15;
*(unsigned long *)__nocache_fix(&pmdp->pmdv[x]) = prompte; val = &pmdp->pmdv[x];
*(unsigned long *)__nocache_fix(val) = probed;
start += SRMMU_REAL_PMD_SIZE; start += SRMMU_REAL_PMD_SIZE;
continue; continue;
} }
ptep = pte_offset_kernel(__nocache_fix(pmdp), start); ptep = pte_offset_kernel(__nocache_fix(pmdp), start);
*(pte_t *)__nocache_fix(ptep) = __pte(prompte); *(pte_t *)__nocache_fix(ptep) = __pte(probed);
start += PAGE_SIZE; start += PAGE_SIZE;
} }
} }
......
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