Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Move initialization of protection_codes[] and kerne...



details:   https://anonhg.NetBSD.org/src/rev/4c045290e1ae
branches:  trunk
changeset: 749698:4c045290e1ae
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Dec 06 06:41:28 2009 +0000

description:
Move initialization of protection_codes[] and kernel_pmap()
from MD pmap bootstrap sources to common pmap_bootstrap_finalize().

Tested on atari, hp300, mac68k, and news68k.

XXX: Why is protection_codes[] array initialized at run time?

diffstat:

 sys/arch/amiga/amiga/amiga_init.c         |   8 +---
 sys/arch/amiga/amiga/machdep.c            |   7 +--
 sys/arch/amiga/amiga/pmap_bootstrap.c     |  43 +----------------------
 sys/arch/atari/atari/atari_init.c         |  10 +---
 sys/arch/atari/atari/pmap_bootstrap.c     |  39 +--------------------
 sys/arch/atari/include/pmap.h             |   4 +-
 sys/arch/cesfic/cesfic/pmap_bootstrap.c   |  47 +++----------------------
 sys/arch/hp300/hp300/pmap_bootstrap.c     |  47 +++----------------------
 sys/arch/luna68k/luna68k/pmap_bootstrap.c |  55 ++++-------------------------
 sys/arch/m68k/include/pmap_motorola.h     |   6 ++-
 sys/arch/m68k/m68k/pmap_motorola.c        |  34 +++++++++++++++++-
 sys/arch/mac68k/mac68k/pmap_bootstrap.c   |  44 +++--------------------
 sys/arch/mvme68k/mvme68k/pmap_bootstrap.c |  57 +++++-------------------------
 sys/arch/news68k/news68k/pmap_bootstrap.c |  51 ++++-----------------------
 sys/arch/next68k/next68k/pmap_bootstrap.c |  51 ++++-----------------------
 sys/arch/x68k/x68k/pmap_bootstrap.c       |  31 ++++------------
 16 files changed, 112 insertions(+), 422 deletions(-)

diffs (truncated from 1045 to 300 lines):

diff -r 0a752528919f -r 4c045290e1ae sys/arch/amiga/amiga/amiga_init.c
--- a/sys/arch/amiga/amiga/amiga_init.c Sun Dec 06 06:30:52 2009 +0000
+++ b/sys/arch/amiga/amiga/amiga_init.c Sun Dec 06 06:41:28 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amiga_init.c,v 1.115 2009/12/06 00:33:59 tsutsui Exp $ */
+/*     $NetBSD: amiga_init.c,v 1.116 2009/12/06 06:41:28 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1994 Michael L. Hitch
@@ -36,7 +36,7 @@
 #include "opt_devreload.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amiga_init.c,v 1.115 2009/12/06 00:33:59 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amiga_init.c,v 1.116 2009/12/06 06:41:28 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -67,10 +67,6 @@
 
 extern u_int   lowram;
 extern u_int   Umap;
-extern u_int   Sysseg_pa;
-#if defined(M68040) || defined(M68060)
-extern u_int   protostfree;
-#endif
 extern u_long boot_partition;
 vaddr_t                amiga_uptbase;
 #ifdef P5PPC68KBOARD
diff -r 0a752528919f -r 4c045290e1ae sys/arch/amiga/amiga/machdep.c
--- a/sys/arch/amiga/amiga/machdep.c    Sun Dec 06 06:30:52 2009 +0000
+++ b/sys/arch/amiga/amiga/machdep.c    Sun Dec 06 06:41:28 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.222 2009/11/24 18:19:52 mhitch Exp $     */
+/*     $NetBSD: machdep.c,v 1.223 2009/12/06 06:41:28 tsutsui Exp $    */
 
 /*
  * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@@ -86,7 +86,7 @@
 #include "opt_panicbutton.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.222 2009/11/24 18:19:52 mhitch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.223 2009/12/06 06:41:28 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -536,7 +536,6 @@
        const struct bdevsw *bdev;
        int nblks;
        int i;
-       extern u_int Sysseg_pa;
        extern int end[];
 
        memset(&cpu_kcore_hdr, 0, sizeof(cpu_kcore_hdr));
@@ -569,7 +568,7 @@
        /*
         * Initialize the pointer to the kernel segment table.
         */
-       m->sysseg_pa = Sysseg_pa;
+       m->sysseg_pa = (paddr_t)pmap_kernel()->pm_stpa;
 
        /*
         * Initialize relocation value such that:
diff -r 0a752528919f -r 4c045290e1ae sys/arch/amiga/amiga/pmap_bootstrap.c
--- a/sys/arch/amiga/amiga/pmap_bootstrap.c     Sun Dec 06 06:30:52 2009 +0000
+++ b/sys/arch/amiga/amiga/pmap_bootstrap.c     Sun Dec 06 06:41:28 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.8 2009/12/06 00:33:59 tsutsui Exp $       */
+/*     $NetBSD: pmap_bootstrap.c,v 1.9 2009/12/06 06:41:29 tsutsui Exp $       */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.8 2009/12/06 00:33:59 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.9 2009/12/06 06:41:29 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -82,13 +82,8 @@
 
 #include <amiga/amiga/memlist.h>
 
-u_int          Sysseg_pa;
-
 extern paddr_t         avail_start;
 extern paddr_t         avail_end;
-#if defined(M68040) || defined(M68060)
-extern u_int           protostfree;
-#endif
 
 extern paddr_t msgbufpa;
 
@@ -193,40 +188,6 @@
        virtual_end = VM_MAX_KERNEL_ADDRESS;
 
        /*
-        * Initialize protection array.
-        * XXX don't use a switch statement, it might produce an
-        * absolute "jmp" table.
-        */
-       {
-               u_int *kp;
-
-               kp = (u_int *)&protection_codes;
-               kp[VM_PROT_NONE|VM_PROT_NONE|VM_PROT_NONE] = 0;
-               kp[VM_PROT_READ|VM_PROT_NONE|VM_PROT_NONE] = PG_RO;
-               kp[VM_PROT_READ|VM_PROT_NONE|VM_PROT_EXECUTE] = PG_RO;
-               kp[VM_PROT_NONE|VM_PROT_NONE|VM_PROT_EXECUTE] = PG_RO;
-               kp[VM_PROT_NONE|VM_PROT_WRITE|VM_PROT_NONE] = PG_RW;
-               kp[VM_PROT_NONE|VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW;
-               kp[VM_PROT_READ|VM_PROT_WRITE|VM_PROT_NONE] = PG_RW;
-               kp[VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW;
-       }
-
-       /*
-        * Kernel page/segment table allocated in locore,
-        * just initialize pointers.
-        */
-       pmap_kernel()->pm_stpa = (st_entry_t *)Sysseg_pa;
-       pmap_kernel()->pm_stab = Sysseg;
-       pmap_kernel()->pm_ptab = Sysmap;
-#if defined(M68040) || defined(M68060)
-       if (mmutype == MMU_68040)
-               pmap_kernel()->pm_stfree = protostfree;
-#endif
-
-       simple_lock_init(&pmap_kernel()->pm_lock);
-       pmap_kernel()->pm_count = 1;
-
-       /*
         * Allocate all the submaps we need
         */
 #define        SYSMAP(c, v, n) \
diff -r 0a752528919f -r 4c045290e1ae sys/arch/atari/atari/atari_init.c
--- a/sys/arch/atari/atari/atari_init.c Sun Dec 06 06:30:52 2009 +0000
+++ b/sys/arch/atari/atari/atari_init.c Sun Dec 06 06:41:28 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atari_init.c,v 1.90 2009/12/06 00:33:59 tsutsui Exp $  */
+/*     $NetBSD: atari_init.c,v 1.91 2009/12/06 06:41:29 tsutsui Exp $  */
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.90 2009/12/06 00:33:59 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atari_init.c,v 1.91 2009/12/06 06:41:29 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mbtype.h"
@@ -117,9 +117,6 @@
 
 extern u_int   lowram;
 int            machineid, mmutype, cputype, astpending;
-#if defined(M68040) || defined(M68060)
-extern u_int   protostfree;
-#endif
 
 extern char            *esym;
 extern struct pcb      *curpcb;
@@ -198,7 +195,6 @@
        vaddr_t         end_loaded;
        paddr_t         kbase;
        u_int           kstsize;
-       paddr_t         Sysseg_pa;
        paddr_t         Sysptmap_pa;
 
 #if defined(_MILANHW_)
@@ -507,7 +503,7 @@
        /*
         * get the pmap module in sync with reality.
         */
-       pmap_bootstrap(vstart, Sysseg_pa);
+       pmap_bootstrap(vstart);
 
        /*
         * Prepare to enable the MMU.
diff -r 0a752528919f -r 4c045290e1ae sys/arch/atari/atari/pmap_bootstrap.c
--- a/sys/arch/atari/atari/pmap_bootstrap.c     Sun Dec 06 06:30:52 2009 +0000
+++ b/sys/arch/atari/atari/pmap_bootstrap.c     Sun Dec 06 06:41:28 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.5 2009/12/06 00:33:59 tsutsui Exp $       */
+/*     $NetBSD: pmap_bootstrap.c,v 1.6 2009/12/06 06:41:29 tsutsui Exp $       */
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -102,7 +102,7 @@
  *     and just syncs the pmap module with what has already been done.
  */
 void
-pmap_bootstrap(vaddr_t vstart, paddr_t sysseg_pa)
+pmap_bootstrap(vaddr_t vstart)
 {
        vaddr_t va;
        int     i;
@@ -149,41 +149,6 @@
        virtual_end   = VM_MAX_KERNEL_ADDRESS;
 
        /*
-        * Initialize protection array.
-        * XXX don't use a switch statement, it might produce an
-        * absolute "jmp" table.
-        */
-       {
-               u_int *kp;
-
-               kp = (u_int *)&protection_codes;
-               kp[VM_PROT_NONE|VM_PROT_NONE|VM_PROT_NONE] = 0;
-               kp[VM_PROT_READ|VM_PROT_NONE|VM_PROT_NONE] = PG_RO;
-               kp[VM_PROT_READ|VM_PROT_NONE|VM_PROT_EXECUTE] = PG_RO;
-               kp[VM_PROT_NONE|VM_PROT_NONE|VM_PROT_EXECUTE] = PG_RO;
-               kp[VM_PROT_NONE|VM_PROT_WRITE|VM_PROT_NONE] = PG_RW;
-               kp[VM_PROT_NONE|VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW;
-               kp[VM_PROT_READ|VM_PROT_WRITE|VM_PROT_NONE] = PG_RW;
-               kp[VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW;
-       }
-
-       /*
-        * Kernel page/segment table allocated in locore,
-        * just initialize pointers.
-        */
-       pmap_kernel()->pm_stpa = (st_entry_t *)sysseg_pa;
-       pmap_kernel()->pm_stab = Sysseg;
-       pmap_kernel()->pm_ptab = Sysmap;
-#if defined(M68040) || defined(M68060)
-       if (mmutype == MMU_68040) {
-               pmap_kernel()->pm_stfree = protostfree;
-       }
-#endif
-
-       simple_lock_init(&pmap_kernel()->pm_lock);
-       pmap_kernel()->pm_count = 1;
-
-       /*
         * Allocate all the submaps we need
         */
 #define        SYSMAP(c, v, n) \
diff -r 0a752528919f -r 4c045290e1ae sys/arch/atari/include/pmap.h
--- a/sys/arch/atari/include/pmap.h     Sun Dec 06 06:30:52 2009 +0000
+++ b/sys/arch/atari/include/pmap.h     Sun Dec 06 06:41:28 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.40 2009/03/13 19:08:20 abs Exp $    */
+/*     $NetBSD: pmap.h,v 1.41 2009/12/06 06:41:29 tsutsui Exp $        */
 
 /* 
  * Copyright (c) 1991 Regents of the University of California.
@@ -103,7 +103,7 @@
 extern struct memseg   boot_segs[NMEM_SEGS];
 extern struct memseg   usable_segs[NMEM_SEGS];
 
-void   pmap_bootstrap(vaddr_t, paddr_t);
+void   pmap_bootstrap(vaddr_t);
 
 #endif /* _KERNEL */
 
diff -r 0a752528919f -r 4c045290e1ae sys/arch/cesfic/cesfic/pmap_bootstrap.c
--- a/sys/arch/cesfic/cesfic/pmap_bootstrap.c   Sun Dec 06 06:30:52 2009 +0000
+++ b/sys/arch/cesfic/cesfic/pmap_bootstrap.c   Sun Dec 06 06:41:28 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.24 2009/12/06 02:42:34 tsutsui Exp $      */
+/*     $NetBSD: pmap_bootstrap.c,v 1.25 2009/12/06 06:41:29 tsutsui Exp $      */
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.24 2009/12/06 02:42:34 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.25 2009/12/06 06:41:29 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,7 +50,6 @@
 #include <uvm/uvm_extern.h>
 
 #define RELOC(v, t)    *((t*)((uintptr_t)&(v) + firstpa - KERNBASE))
-#define RELOCPTR(v, t) ((t)((uintptr_t)RELOC((v), t) + firstpa - KERNBASE))
 
 extern char *etext;
 extern paddr_t avail_start, avail_end;
@@ -369,13 +368,16 @@
        }
 
        /*
-        * Calculate important exported kernel virtual addresses
+        * Calculate important exported kernel addresses and related vaules.
         */
        /*
         * Sysseg: base of kernel segment table
         */
        RELOC(Sysseg, st_entry_t *) =
                (st_entry_t *)(kstpa - firstpa + KERNBASE);
+       RELOC(Sysseg_pa, paddr_t) = kstpa;
+       if (RELOC(mmutype, int) == MMU_68040)



Home | Main Index | Thread Index | Old Index