Added a new function map_chunk() used during init_arm() when setting up

the kernel page tables. map_chunk() replaces running a loop, calling
map_entry() and in addition where possible it will use L1 section mappings
or L2 large page mappings instead of L2 small page mappings in order to
reduce the TLB entried needed for the kernel.
This commit is contained in:
mark 1998-08-30 23:17:44 +00:00
parent 82661d453d
commit 45faa60d85

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.46 1998/08/29 03:09:14 mark Exp $ */
/* $NetBSD: machdep.c,v 1.47 1998/08/30 23:17:44 mark Exp $ */
/*
* Copyright (c) 1994-1996 Mark Brinicombe.
@ -263,6 +263,71 @@ map_pagetable(pagetable, va, pa)
L1_PTE((pa & PG_FRAME) + 0xc00);
}
vm_size_t
map_chunk(pd, pt, va, pa, size, acc, flg)
vm_offset_t pd;
vm_offset_t pt;
vm_offset_t va;
vm_offset_t pa;
vm_size_t size;
u_int acc;
u_int flg;
{
pd_entry_t *l1pt = (pd_entry_t *)pd;
pt_entry_t *l2pt = (pt_entry_t *)pt;
vm_size_t remain;
u_int loop;
remain = (size + (NBPG - 1)) & ~(NBPG - 1);
#ifdef VERBOSE_INIT_ARM
printf("map_chunk: pa=%lx va=%lx sz=%lx rem=%lx acc=%x flg=%x\n",
pa, va, size, remain, acc, flg);
printf("map_chunk: ");
#endif
size = remain;
while (remain > 0) {
/* Can we do a section mapping ? */
if (l1pt && !((pa | va) & (L1_SEC_SIZE - 1))
&& remain >= L1_SEC_SIZE) {
#ifdef VERBOSE_INIT_ARM
printf("S");
#endif
l1pt[(va >> PDSHIFT)] = L1_SECPTE(pa, acc, flg);
va += L1_SEC_SIZE;
pa += L1_SEC_SIZE;
remain -= L1_SEC_SIZE;
} else
/* Can we do a large page mapping ? */
if (!((pa | va) & (L2_LPAGE_SIZE - 1))
&& (remain >= L2_LPAGE_SIZE)) {
#ifdef VERBOSE_INIT_ARM
printf("L");
#endif
for (loop = 0; loop < 16; ++loop)
l2pt[((va >> PGSHIFT) & 0x3f0) + loop] =
L2_LPTE(pa, acc, flg);
va += L2_LPAGE_SIZE;
pa += L2_LPAGE_SIZE;
remain -= L2_LPAGE_SIZE;
} else
/* All we can do is a small page mapping */
{
#ifdef VERBOSE_INIT_ARM
printf("P");
#endif
l2pt[((va >> PGSHIFT) & 0x3ff)] = L2_SPTE(pa, acc, flg);
va += NBPG;
pa += NBPG;
remain -= NBPG;
}
}
#ifdef VERBOSE_INIT_ARM
printf("\n");
#endif
return(size);
}
void
map_entry(pagetable, va, pa)