From c599e7d43923f8b37f3fe4de995c31ac7151170b Mon Sep 17 00:00:00 2001 From: mrg Date: Thu, 8 Jan 1998 11:39:30 +0000 Subject: [PATCH] add new version of non contiguous memory code, written by chuck cranor, called "MACHINE_NEW_NONCONGIG". this is required for UVM, the new VM system (also written by chuck) that is coming soon. adds new functions: vm_page_physload() -- tell the VM system about an area of memory. vm_physseg_find() -- returns index in vm_physmem array that this address is in. and several new versions of old functions/macros defined in vm_page.h. this is the sparc portion. --- sys/arch/sparc/include/vmparam.h | 19 +++++++++++++++++- sys/arch/sparc/sparc/machdep.c | 4 ++-- sys/arch/sparc/sparc/pmap.c | 34 ++++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/sys/arch/sparc/include/vmparam.h b/sys/arch/sparc/include/vmparam.h index 64356b139fef..6d594b57eb2e 100644 --- a/sys/arch/sparc/include/vmparam.h +++ b/sys/arch/sparc/include/vmparam.h @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.13 1997/07/12 16:20:03 perry Exp $ */ +/* $NetBSD: vmparam.h,v 1.14 1998/01/08 11:39:30 mrg Exp $ */ /* * Copyright (c) 1992, 1993 @@ -131,7 +131,24 @@ #define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES) #define VM_KMEM_SIZE (NKMEMCLUSTERS*CLBYTES) +#if defined(MACHINE_NEW_NONCONTIG) + +#define VM_PHYSSEG_MAX 32 /* we only have one "hole" */ +#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH +#define VM_PHYSSEG_NOADD /* can't add RAM after vm_mem_init */ + +/* + * pmap specific data stored in the vm_physmem[] array + */ + +struct pmap_physseg { + /* NULL */ +}; + + +#else #define MACHINE_NONCONTIG /* VM <=> pmap interface modifier */ +#endif #if defined (_KERNEL) && !defined(_LOCORE) struct vm_map; diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c index 9483479b8519..5a4e13c0fab0 100644 --- a/sys/arch/sparc/sparc/machdep.c +++ b/sys/arch/sparc/sparc/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.95 1997/12/23 23:57:24 tv Exp $ */ +/* $NetBSD: machdep.c,v 1.96 1998/01/08 11:39:32 mrg Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -215,7 +215,7 @@ cpu_startup() */ printf(version); /*identifycpu();*/ -#ifndef MACHINE_NONCONTIG +#if !defined(MACHINE_NEW_NONCONTIG) && !defined(MACHINE_NONCONTIG) physmem = btoc(avail_end); #endif printf("real mem = %d\n", ctob(physmem)); diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c index 9f6b198b64e6..8501b5d9c989 100644 --- a/sys/arch/sparc/sparc/pmap.c +++ b/sys/arch/sparc/sparc/pmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.104 1998/01/02 22:57:56 thorpej Exp $ */ +/* $NetBSD: pmap.c,v 1.105 1998/01/08 11:39:35 mrg Exp $ */ /* * Copyright (c) 1996 @@ -3026,6 +3026,37 @@ pmap_bootstrap4_4c(nctx, nregion, nsegment) for (p = (caddr_t)trapbase; p < etext; p += NBPG) setpte4(p, getpte4(p) & mask); } +#if defined(MACHINE_NEW_NONCONTIG) + while (1) { + if (avail_next >= + pmemarr[cpmemarr].addr + pmemarr[cpmemarr].len) { + if (++cpmemarr == npmemarr) + break; /* DONE */ + + if (avail_next < pmemarr[cpmemarr].addr) + avail_next = pmemarr[cpmemarr].addr; + continue; + } + + if (avail_next == unavail_start) { + avail_next = unavail_end; + continue; + } + +#if defined(DIAGNOSTIC) + if (avail_next >= avail_end) + panic("pmap: too much memory!?"); +#endif + + vm_page_physload( + atop(avail_next), + atop(pmemarr[cpmemarr].addr) + atop(pmemarr[cpmemarr].len), + atop(avail_next), + atop(pmemarr[cpmemarr].addr) + atop(pmemarr[cpmemarr].len)); + + avail_next = pmemarr[cpmemarr].addr + pmemarr[cpmemarr].len; + } +#endif } #endif @@ -5055,7 +5086,6 @@ pmap_changeprot4m(pm, va, prot, wired) setpgt4m(&sp->sg_pte[VA_SUN4M_VPG(va)], (pte & ~SRMMU_PROT_MASK) | newprot); - out: setcontext4m(ctx); splx(s);