summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2002-03-13 00:24:22 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2002-03-13 00:24:22 +0000
commit28857c6da590c454e695be1822fa6e2cbc7b24a8 (patch)
treeb19b58a1cbb4a7f2c554b4e4248faa8a1d58258c
parent8c9ff39213d156dc31183316f6ce101a0c425c35 (diff)
On sparc, PAGE_SIZE and friends might not be a compile-time constant.
Instead of using a homegrown set of variables in this case, rely on uvmexp fields once uvm has been initialized. This requires a few #include <uvm/uvm_extern.h> here and there in the kernel as well. Idea from art@, changes by me.
-rw-r--r--sys/arch/sparc/dev/fd.c4
-rw-r--r--sys/arch/sparc/dev/zs.c4
-rw-r--r--sys/arch/sparc/include/param.h60
-rw-r--r--sys/arch/sparc/sparc/cache.c5
-rw-r--r--sys/arch/sparc/sparc/locore.s14
-rw-r--r--sys/arch/sparc/sparc/pmap.c7
-rw-r--r--sys/kern/sys_generic.c4
7 files changed, 45 insertions, 53 deletions
diff --git a/sys/arch/sparc/dev/fd.c b/sys/arch/sparc/dev/fd.c
index 484f9d426a5..5cea4853fff 100644
--- a/sys/arch/sparc/dev/fd.c
+++ b/sys/arch/sparc/dev/fd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fd.c,v 1.24 2001/03/24 01:37:28 ho Exp $ */
+/* $OpenBSD: fd.c,v 1.25 2002/03/13 00:24:21 miod Exp $ */
/* $NetBSD: fd.c,v 1.51 1997/05/24 20:16:19 pk Exp $ */
/*-
@@ -69,6 +69,8 @@
#include <dev/cons.h>
+#include <uvm/uvm_extern.h>
+
#include <machine/cpu.h>
#include <machine/autoconf.h>
#include <machine/conf.h>
diff --git a/sys/arch/sparc/dev/zs.c b/sys/arch/sparc/dev/zs.c
index 73fa2e28b5e..3762e8118a9 100644
--- a/sys/arch/sparc/dev/zs.c
+++ b/sys/arch/sparc/dev/zs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zs.c,v 1.31 2002/01/30 20:45:34 nordin Exp $ */
+/* $OpenBSD: zs.c,v 1.32 2002/03/13 00:24:21 miod Exp $ */
/* $NetBSD: zs.c,v 1.49 1997/08/31 21:26:37 pk Exp $ */
/*
@@ -73,6 +73,8 @@
#include <ddb/db_var.h>
#endif
+#include <uvm/uvm_extern.h>
+
#include <machine/autoconf.h>
#include <machine/conf.h>
#include <machine/cpu.h>
diff --git a/sys/arch/sparc/include/param.h b/sys/arch/sparc/include/param.h
index e6b88e4fe84..6cc039b0f4b 100644
--- a/sys/arch/sparc/include/param.h
+++ b/sys/arch/sparc/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.23 2002/02/19 21:56:28 miod Exp $ */
+/* $OpenBSD: param.h,v 1.24 2002/03/13 00:24:21 miod Exp $ */
/* $NetBSD: param.h,v 1.29 1997/03/10 22:50:37 pk Exp $ */
/*
@@ -83,16 +83,6 @@
#define SUN4_PGSHIFT 13 /* for a sun4 machine */
#define SUN4CM_PGSHIFT 12 /* for a sun4c or sun4m machine */
-/*
- * The following variables are always defined and initialized (in locore)
- * so independently compiled modules (e.g. LKMs) can be used irrespective
- * of the `options SUN4?' combination a particular kernel was configured with.
- * See also the definitions of NBPG, PGOFSET and PGSHIFT below.
- */
-#if defined(_KERNEL) && !defined(_LOCORE)
-extern int nbpg, pgofset, pgshift;
-#endif
-
#define KERNBASE 0xf8000000 /* start of kernel virtual space */
#define KERNTEXTOFF 0xf8004000 /* start of kernel text */
@@ -218,12 +208,12 @@ extern int mmumod;
# define CPU_ISSUN4 (cputyp == CPU_SUN4)
# define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
-# define NBPG nbpg
-# define PGOFSET pgofset
-# define PGSHIFT pgshift
-# define PAGE_SIZE nbpg
-# define PAGE_MASK pgofset
-# define PAGE_SHIFT pgshift
+# define NBPG uvmexp.pagesize
+# define PGOFSET uvmexp.pagemask
+# define PGSHIFT uvmexp.pageshift
+# define PAGE_SIZE uvmexp.pagesize
+# define PAGE_MASK uvmexp.pagemask
+# define PAGE_SHIFT uvmexp.pageshift
#elif defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
# define CPU_ISSUN4M (cputyp == CPU_SUN4M)
# define CPU_ISSUN4C (cputyp == CPU_SUN4C)
@@ -242,12 +232,12 @@ extern int mmumod;
# define CPU_ISSUN4 (cputyp == CPU_SUN4)
# define CPU_ISSUN4OR4C (cputyp == CPU_SUN4)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4M)
-# define NBPG nbpg
-# define PGOFSET pgofset
-# define PGSHIFT pgshift
-# define PAGE_SIZE nbpg
-# define PAGE_MASK pgofset
-# define PAGE_SHIFT pgshift
+# define NBPG uvmexp.pagesize
+# define PGOFSET uvmexp.pagemask
+# define PGSHIFT uvmexp.pageshift
+# define PAGE_SIZE uvmexp.pagesize
+# define PAGE_MASK uvmexp.pagemask
+# define PAGE_SHIFT uvmexp.pageshift
#elif defined(SUN4M) && !defined(SUN4C) && !defined(SUN4)
# define CPU_ISSUN4M (1)
# define CPU_ISSUN4C (0)
@@ -266,12 +256,12 @@ extern int mmumod;
# define CPU_ISSUN4 (cputyp == CPU_SUN4)
# define CPU_ISSUN4OR4C (1)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C)
-# define NBPG nbpg
-# define PGOFSET pgofset
-# define PGSHIFT pgshift
-# define PAGE_SIZE nbpg
-# define PAGE_MASK pgofset
-# define PAGE_SHIFT pgshift
+# define NBPG uvmexp.pagesize
+# define PGOFSET uvmexp.pagemask
+# define PGSHIFT uvmexp.pageshift
+# define PAGE_SIZE uvmexp.pagesize
+# define PAGE_MASK uvmexp.pagemask
+# define PAGE_SHIFT uvmexp.pageshift
#elif !defined(SUN4M) && defined(SUN4C) && !defined(SUN4)
# define CPU_ISSUN4M (0)
# define CPU_ISSUN4C (1)
@@ -302,12 +292,12 @@ extern int mmumod;
# define CPU_ISSUN4 (cputyp == CPU_SUN4)
# define CPU_ISSUN4OR4C (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
# define CPU_ISSUN4COR4M (cputyp == CPU_SUN4C || cputyp == CPU_SUN4M)
-# define NBPG nbpg
-# define PGOFSET pgofset
-# define PGSHIFT pgshift
-# define PAGE_SIZE nbpg
-# define PAGE_MASK pgofset
-# define PAGE_SHIFT pgshift
+# define NBPG uvmexp.pagesize
+# define PGOFSET uvmexp.pagemask
+# define PGSHIFT uvmexp.pageshift
+# define PAGE_SIZE uvmexp.pagesize
+# define PAGE_MASK uvmexp.pagemask
+# define PAGE_SHIFT uvmexp.pageshift
#endif
#endif /* _SPARC_PARAM_H_ */
diff --git a/sys/arch/sparc/sparc/cache.c b/sys/arch/sparc/sparc/cache.c
index 4fe55973023..b2988d2f5ff 100644
--- a/sys/arch/sparc/sparc/cache.c
+++ b/sys/arch/sparc/sparc/cache.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cache.c,v 1.15 2001/12/19 08:58:05 art Exp $ */
+/* $OpenBSD: cache.c,v 1.16 2002/03/13 00:24:21 miod Exp $ */
/* $NetBSD: cache.c,v 1.34 1997/09/26 22:17:23 pk Exp $ */
/*
@@ -62,8 +62,9 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <uvm/uvm_extern.h>
+
#include <machine/ctlreg.h>
-#include <machine/pte.h>
#include <sparc/sparc/asm.h>
#include <sparc/sparc/cache.h>
diff --git a/sys/arch/sparc/sparc/locore.s b/sys/arch/sparc/sparc/locore.s
index 439011af7f0..247c2de32ea 100644
--- a/sys/arch/sparc/sparc/locore.s
+++ b/sys/arch/sparc/sparc/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.45 2002/02/20 22:28:23 deraadt Exp $ */
+/* $OpenBSD: locore.s,v 1.46 2002/03/13 00:24:21 miod Exp $ */
/* $NetBSD: locore.s,v 1.73 1997/09/13 20:36:48 pk Exp $ */
/*
@@ -218,12 +218,9 @@ _cputypvallen = _cputypvar - _cputypval
#endif
/*
- * There variables are pointed to by the cpp symbols PGSHIFT, NBPG,
- * and PGOFSET.
+ * nbpg is used by pmap_bootstrap(), pgofset is used internally.
*/
- .globl _pgshift, _nbpg, _pgofset
-_pgshift:
- .word 0
+ .globl _nbpg
_nbpg:
.word 0
_pgofset:
@@ -3694,10 +3691,7 @@ startmap_done:
sethi %hi(_cputyp), %o0 ! what type of cpu we are on
st %g4, [%o0 + %lo(_cputyp)]
- sethi %hi(_pgshift), %o0 ! pgshift = log2(nbpg)
- st %g5, [%o0 + %lo(_pgshift)]
-
- mov 1, %o0 ! nbpg = 1 << pgshift
+ mov 1, %o0 ! nbpg = 1 << pgshift (g5)
sll %o0, %g5, %g5
sethi %hi(_nbpg), %o0 ! nbpg = bytes in a page
st %g5, [%o0 + %lo(_nbpg)]
diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c
index 575c69550c6..477df39f5b6 100644
--- a/sys/arch/sparc/sparc/pmap.c
+++ b/sys/arch/sparc/sparc/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.119 2002/01/24 10:15:07 art Exp $ */
+/* $OpenBSD: pmap.c,v 1.120 2002/03/13 00:24:21 miod Exp $ */
/* $NetBSD: pmap.c,v 1.118 1998/05/19 19:00:18 thorpej Exp $ */
/*
@@ -2576,13 +2576,14 @@ void
pmap_bootstrap(nctx, nregion, nsegment)
int nsegment, nctx, nregion;
{
+ extern int nbpg; /* locore.s */
- uvmexp.pagesize = NBPG;
+ uvmexp.pagesize = nbpg;
uvm_setpagesize();
#if defined(SUN4) && (defined(SUN4C) || defined(SUN4M))
/* In this case NPTESG is not a #define */
- nptesg = (NBPSG >> pgshift);
+ nptesg = (NBPSG >> uvmexp.pageshift);
#endif
#if 0
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index de65194f32a..14fe3c2ee92 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_generic.c,v 1.37 2002/02/13 19:08:06 art Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.38 2002/03/13 00:24:18 miod Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
@@ -63,6 +63,8 @@
#include <sys/mount.h>
#include <sys/syscallargs.h>
+#include <uvm/uvm_extern.h>
+
int selscan __P((struct proc *, fd_set *, fd_set *, int, register_t *));
int seltrue __P((dev_t, int, struct proc *));
void pollscan __P((struct proc *, struct pollfd *, int, register_t *));