Skip to content

Commit

Permalink
sparc32: beautify srmmu_inherit_prom_mappings()
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Ravnborg <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
sravnborg authored and davem330 committed Jul 26, 2012
1 parent f71a2aa commit 7cdfbc7
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions arch/sparc/mm/srmmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,44 +677,48 @@ static inline unsigned long srmmu_probe(unsigned long vaddr)
static void __init srmmu_inherit_prom_mappings(unsigned long start,
unsigned long end)
{
unsigned long probed;
unsigned long addr;
pgd_t *pgdp;
pmd_t *pmdp;
pte_t *ptep;
int what = 0; /* 0 = normal-pte, 1 = pmd-level pte, 2 = pgd-level pte */
unsigned long prompte;
int what; /* 0 = normal-pte, 1 = pmd-level pte, 2 = pgd-level pte */

while (start <= end) {
if (start == 0)
break; /* probably wrap around */
if (start == 0xfef00000)
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;
continue;
}

/* A red snapper, see what it really is. */
what = 0;
addr = start - PAGE_SIZE;

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;
}

if (!(start & ~(SRMMU_PGDIR_MASK))) {
if (srmmu_probe((start-PAGE_SIZE) + SRMMU_PGDIR_SIZE) ==
prompte)
if (srmmu_probe(addr + SRMMU_PGDIR_SIZE) == probed)
what = 2;
}

pgdp = pgd_offset_k(start);
if (what == 2) {
*(pgd_t *)__nocache_fix(pgdp) = __pgd(prompte);
*(pgd_t *)__nocache_fix(pgdp) = __pgd(probed);
start += SRMMU_PGDIR_SIZE;
continue;
}
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)
early_pgtable_allocfail("pmd");
memset(__nocache_fix(pmdp), 0, SRMMU_PMD_TABLE_SIZE);
Expand All @@ -734,13 +738,15 @@ static void __init srmmu_inherit_prom_mappings(unsigned long start,
* good hardware PTE piece. Alternatives seem worse.
*/
unsigned int x; /* Index of HW PMD in soft cluster */
unsigned long *val;
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;
continue;
}
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;
}
}
Expand Down

0 comments on commit 7cdfbc7

Please sign in to comment.