Introduce pmap_prefer() which is used to obtain a cache-friendly virtual

address.
This commit is contained in:
pk 1994-12-10 11:43:56 +00:00
parent d781cfcf1d
commit c09156bf8b
2 changed files with 40 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.h,v 1.8 1994/11/20 20:53:22 deraadt Exp $ */
/* $NetBSD: pmap.h,v 1.9 1994/12/10 11:44:28 pk Exp $ */
/*
* Copyright (c) 1992, 1993
@ -170,9 +170,12 @@ extern pmap_t kernel_pmap;
void pmap_bootstrap __P((int nmmu, int nctx));
void pmap_init __P((vm_offset_t phys_start, vm_offset_t phys_end));
int pmap_count_ptes __P((struct pmap *));
vm_offset_t pmap_prefer __P((vm_offset_t, vm_offset_t));
#define pmap_resident_count(pmap) pmap_count_ptes(pmap)
#define PMAP_PREFER(pa,va) pmap_prefer((pa),(va))
#endif /* KERNEL */
#endif /* _SPARC_PMAP_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: pmap.c,v 1.23 1994/12/06 08:34:12 deraadt Exp $ */
/* $NetBSD: pmap.c,v 1.24 1994/12/10 11:43:56 pk Exp $ */
/*
* Copyright (c) 1992, 1993
@ -2840,6 +2840,41 @@ pmap_count_ptes(pm)
return (total);
}
/*
* Find first virtual address >= va that doesn't cause
* a cache alias on physical address pa.
*/
vm_offset_t
pmap_prefer(pa, va)
register vm_offset_t pa;
register vm_offset_t va;
{
register struct pvlist *pv;
register long m, d;
if (cputyp == CPU_SUN4)
m = 0x20000;
else if (cputyp == CPU_SUN4C)
m = 0x10000;
else
return va;
if (!managed(pa))
return va;
pv = pvhead(pa);
if (pv->pv_pmap == NULL)
/* Unusable, tell caller to try another one */
return (vm_offset_t)-1;
d = (long)(pv->pv_va & (m - 1)) - (long)(va & (m - 1));
if (d < 0)
va += m;
va += d;
return va;
}
pmap_redzone()
{
setpte(KERNBASE, 0);