Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Sync MMU table initialization with amiga and atari ...



details:   https://anonhg.NetBSD.org/src/rev/adc3701f46cb
branches:  trunk
changeset: 749695:adc3701f46cb
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Dec 06 02:42:34 2009 +0000

description:
Sync MMU table initialization with amiga and atari a bit:

- for 040/060, move L2 descs for Sysptmap from the last L2 block in segment
  table pages to the contiguous block with ones for segment table mappings

- for 020/030, invalidate ste and pte entries separately since
  ste size (TIA_SIZE) and pte size (TIB_SIZE) could be different
  on 8KB/page systems

Tested on hp300 (040), mac68k (LC040), and news68k (030)
(and untested on others).

XXX: some more stuff in pmap_bootstrap.c could be moved into
XXX: common pmap_bootstrap_finalize()?

diffstat:

 sys/arch/cesfic/cesfic/pmap_bootstrap.c   |   92 ++++++++++++++------------
 sys/arch/hp300/hp300/pmap_bootstrap.c     |   92 ++++++++++++++------------
 sys/arch/luna68k/luna68k/pmap_bootstrap.c |   89 +++++++++++++-----------
 sys/arch/mac68k/mac68k/pmap_bootstrap.c   |   92 ++++++++++++++------------
 sys/arch/mvme68k/mvme68k/pmap_bootstrap.c |  103 ++++++++++++++++-------------
 sys/arch/news68k/news68k/pmap_bootstrap.c |   99 +++++++++++++++-------------
 sys/arch/next68k/next68k/pmap_bootstrap.c |   99 +++++++++++++++-------------
 sys/arch/x68k/x68k/pmap_bootstrap.c       |   97 +++++++++++++++-------------
 8 files changed, 412 insertions(+), 351 deletions(-)

diffs (truncated from 1601 to 300 lines):

diff -r 0babce9ce97f -r adc3701f46cb sys/arch/cesfic/cesfic/pmap_bootstrap.c
--- a/sys/arch/cesfic/cesfic/pmap_bootstrap.c   Sun Dec 06 01:35:40 2009 +0000
+++ b/sys/arch/cesfic/cesfic/pmap_bootstrap.c   Sun Dec 06 02:42:34 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.23 2009/12/05 23:16:57 tsutsui Exp $      */
+/*     $NetBSD: pmap_bootstrap.c,v 1.24 2009/12/06 02:42:34 tsutsui Exp $      */
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.23 2009/12/05 23:16:57 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.24 2009/12/06 02:42:34 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -87,6 +87,7 @@
        u_int nptpages, kstsize;
        st_entry_t protoste, *ste, *este;
        pt_entry_t protopte, *pte, *epte;
+       u_int stfree = 0;       /* XXX: gcc -Wuninitialized */
 
        /*
         * Calculate important physical addresses:
@@ -159,7 +160,7 @@
         * likely be insufficient in the future (at least for the kernel).
         */
        if (RELOC(mmutype, int) == MMU_68040) {
-               int num;
+               int nl1desc, nl2desc, i;
 
                /*
                 * First invalidate the entire "segment table" pages
@@ -169,7 +170,6 @@
                este = &ste[kstsize * NPTEPG];
                while (ste < este)
                        *ste++ = SG_NV;
-
                /*
                 * Initialize level 2 descriptors (which immediately
                 * follow the level 1 table).  We need:
@@ -178,10 +178,10 @@
                 * pages of PTEs.  Note that we set the "used" bit
                 * now to save the HW the expense of doing it.
                 */
-               num = nptpages * (NPTEPG / SG4_LEV3SIZE);
+               nl2desc = nptpages * (NPTEPG / SG4_LEV3SIZE);
                ste = (st_entry_t *)kstpa;
                ste = &ste[SG4_LEV1SIZE];
-               este = &ste[num];
+               este = &ste[nl2desc];
                protoste = kptpa | SG_U | SG_RW | SG_V;
                while (ste < este) {
                        *ste++ = protoste;
@@ -190,11 +190,12 @@
 
                /*
                 * Initialize level 1 descriptors.  We need:
-                *      howmany(num, SG4_LEV2SIZE)
-                * level 1 descriptors to map the `num' level 2's.
+                *      howmany(nl2desc, SG4_LEV2SIZE)
+                * level 1 descriptors to map the `nl2desc' level 2's.
                 */
+               nl1desc = howmany(nl2desc, SG4_LEV2SIZE);
                ste = (st_entry_t *)kstpa;
-               este = &ste[howmany(num, SG4_LEV2SIZE)];
+               este = &ste[nl1desc];
                protoste = (paddr_t)&ste[SG4_LEV1SIZE] | SG_U | SG_RW | SG_V;
                while (ste < este) {
                        *ste++ = protoste;
@@ -202,20 +203,19 @@
                }
 
                /*
-                * Initialize the final level 1 descriptor to map the last
-                * block of level 2 descriptors.
+                * Initialize the final level 1 descriptor to map the next
+                * block of level 2 descriptors for Sysptmap.
                 */
                ste = (st_entry_t *)kstpa;
                ste = &ste[SG4_LEV1SIZE - 1];
-               este = (st_entry_t *)kstpa;
-               este = &este[kstsize * NPTEPG - SG4_LEV2SIZE];
-               *ste = (paddr_t)este | SG_U | SG_RW | SG_V;
+               *ste = protoste;
                /*
                 * Now initialize the final portion of that block of
                 * descriptors to map kptmpa and the "last PT page".
                 */
+               i = SG4_LEV1SIZE + (nl1desc * SG4_LEV2SIZE);
                ste = (st_entry_t *)kstpa;
-               ste = &ste[kstsize * NPTEPG - NPTEPG / SG4_LEV3SIZE * 2];
+               ste = &ste[i + SG4_LEV2SIZE - NPTEPG / SG4_LEV3SIZE * 2];
                epte = &ste[NPTEPG / SG4_LEV3SIZE];
                protoste = kptmpa | SG_U | SG_RW | SG_V;
                while (ste < este) {
@@ -228,6 +228,23 @@
                        *ste++ = protoste;
                        protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
                }
+               /*
+                * Calculate the free level 2 descriptor mask
+                * noting that we have used:
+                *      0:              level 1 table
+                *      1 to nl1desc:   map page tables
+                *      nl1desc + 1:    maps kptmpa and last-page page table
+                */
+               /* mark an entry for level 1 table */
+               stfree = ~l2tobm(0);
+               /* mark entries for map page tables */
+               for (i = 1; i <= nl1desc; i++)
+                       stfree &= ~l2tobm(i);
+               /* mark an entry for kptmpa and lkptpa */
+               stfree &= ~l2tobm(i);
+               /* mark entries not available */
+               for (i = MAXKL2SIZE; i < sizeof(stfree) * NBBY; i++)
+                       stfree &= ~l2tobm(i);
 
                /*
                 * Initialize Sysptmap
@@ -241,10 +258,10 @@
                }
 
                /*
-                * Invalidate all but the last remaining entry.
+                * Invalidate all remaining entries.
                 */
                epte = (pt_entry_t *)kptmpa;
-               epte = &epte[NPTEPG - 2];
+               epte = &epte[NPTEPG];           /* XXX: should be TIB_SIZE */
                while (pte < epte) {
                        *pte++ = PG_NV;
                }
@@ -252,6 +269,8 @@
                 * Initialize the last to point to kptmpa and the page
                 * table page allocated earlier.
                 */
+               pte = (pt_entry_t *)kptmpa;
+               pte = &pte[NPTEPG - 2];         /* XXX: should be TIA_SIZE */
                *pte = kptmpa | PG_RW | PG_CI | PG_V;
                pte++;
                *pte = lkptpa | PG_RW | PG_CI | PG_V;
@@ -272,18 +291,24 @@
                        protopte += PAGE_SIZE;
                }
                /*
-                * Invalidate all but the last remaining entries in both.
+                * Invalidate all remaining entries in both.
                 */
+               este = (st_entry_t *)kstpa;
+               este = &epte[NPTEPG];           /* XXX: should be TIA_SIZE */
+               while (ste < este)
+                       *ste++ = SG_NV;
                epte = (pt_entry_t *)kptmpa;
-               epte = &epte[NPTEPG - 2];
-               while (pte < epte) {
-                       *ste++ = SG_NV;
+               epte = &epte[NPTEPG];           /* XXX: should be TIB_SIZE */
+               while (pte < epte)
                        *pte++ = PG_NV;
-               }
                /*
                 * Initialize the last to point to kptmpa and the page
                 * table page allocated earlier.
                 */
+               ste = (st_entry_t *)kstpa;
+               ste = &ste[NPTEPG - 2];         /* XXX: should be TIA_SIZE */
+               pte = (pt_entry_t *)kptmpa;
+               pte = &pte[NPTEPG - 2];         /* XXX: should be TIA_SIZE */
                *ste = kptmpa | SG_RW | SG_V;
                *pte = kptmpa | PG_RW | PG_CI | PG_V;
                ste++;
@@ -424,27 +449,8 @@
                simple_lock_init(&kpm->pm_lock);
                kpm->pm_count = 1;
                kpm->pm_stpa = (st_entry_t *)kstpa;
-               /*
-                * For the 040 we also initialize the free level 2
-                * descriptor mask noting that we have used:
-                *      0:              level 1 table
-                *      1 to `num':     map page tables
-                *      MAXKL2SIZE-1:   maps kptmpa and last-page page table
-                */
-               if (RELOC(mmutype, int) == MMU_68040) {
-                       int num;
-                       
-                       kpm->pm_stfree = ~l2tobm(0);
-                       num = roundup(nptpages * (NPTEPG / SG4_LEV3SIZE),
-                                     SG4_LEV2SIZE) / SG4_LEV2SIZE;
-                       while (num)
-                               kpm->pm_stfree &= ~l2tobm(num--);
-                       kpm->pm_stfree &= ~l2tobm(MAXKL2SIZE-1);
-                       for (num = MAXKL2SIZE;
-                            num < sizeof(kpm->pm_stfree)*NBBY;
-                            num++)
-                               kpm->pm_stfree &= ~l2tobm(num);
-               }
+               if (RELOC(mmutype, int) == MMU_68040)
+                       kpm->pm_stfree = stfree;
        }
 
        /*
diff -r 0babce9ce97f -r adc3701f46cb sys/arch/hp300/hp300/pmap_bootstrap.c
--- a/sys/arch/hp300/hp300/pmap_bootstrap.c     Sun Dec 06 01:35:40 2009 +0000
+++ b/sys/arch/hp300/hp300/pmap_bootstrap.c     Sun Dec 06 02:42:34 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.43 2009/12/05 23:16:57 tsutsui Exp $      */
+/*     $NetBSD: pmap_bootstrap.c,v 1.44 2009/12/06 02:42:34 tsutsui Exp $      */
 
 /*
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.43 2009/12/05 23:16:57 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.44 2009/12/06 02:42:34 tsutsui Exp $");
 
 #include <sys/param.h>
 
@@ -97,6 +97,7 @@
        u_int nptpages, kstsize;
        st_entry_t protoste, *ste, *este;
        pt_entry_t protopte, *pte, *epte;
+       u_int stfree = 0;       /* XXX: gcc -Wuninitialized */
 
        /*
         * Calculate important physical addresses:
@@ -167,7 +168,7 @@
         * likely be insufficient in the future (at least for the kernel).
         */
        if (RELOC(mmutype, int) == MMU_68040) {
-               int num;
+               int nl1desc, nl2desc, i;
 
                /*
                 * First invalidate the entire "segment table" pages
@@ -185,10 +186,10 @@
                 * pages of PTEs.  Note that we set the "used" bit
                 * now to save the HW the expense of doing it.
                 */
-               num = nptpages * (NPTEPG / SG4_LEV3SIZE);
+               nl2desc = nptpages * (NPTEPG / SG4_LEV3SIZE);
                ste = (st_entry_t *)kstpa;
                ste = &ste[SG4_LEV1SIZE];
-               este = &ste[num];
+               este = &ste[nl2desc];
                protoste = kptpa | SG_U | SG_RW | SG_V;
                while (ste < este) {
                        *ste++ = protoste;
@@ -196,31 +197,31 @@
                }
                /*
                 * Initialize level 1 descriptors.  We need:
-                *      howmany(num, SG4_LEV2SIZE)
-                * level 1 descriptors to map the `num' level 2's.
+                *      howmany(nl2desc, SG4_LEV2SIZE)
+                * level 1 descriptors to map the `nl2desc' level 2's.
                 */
+               nl1desc = howmany(nl2desc, SG4_LEV2SIZE);
                ste = (st_entry_t *)kstpa;
-               este = &ste[howmany(num, SG4_LEV2SIZE)];
+               este = &ste[nl1desc];
                protoste = (paddr_t)&ste[SG4_LEV1SIZE] | SG_U | SG_RW | SG_V;
                while (ste < este) {
                        *ste++ = protoste;
                        protoste += (SG4_LEV2SIZE * sizeof(st_entry_t));
                }
                /*
-                * Initialize the final level 1 descriptor to map the last
-                * block of level 2 descriptors.
+                * Initialize the final level 1 descriptor to map the next
+                * block of level 2 descriptors for Sysptmap.
                 */
                ste = (st_entry_t *)kstpa;
                ste = &ste[SG4_LEV1SIZE - 1];
-               este = (st_entry_t *)kstpa;
-               este = &este[kstsize * NPTEPG - SG4_LEV2SIZE];
-               *ste = (paddr_t)este | SG_U | SG_RW | SG_V;
+               *ste = protoste;
                /*
                 * Now initialize the final portion of that block of
                 * descriptors to map kptmpa and the "last PT page".
                 */
+               i = SG4_LEV1SIZE + (nl1desc * SG4_LEV2SIZE);
                ste = (st_entry_t *)kstpa;
-               ste = &ste[kstsize * NPTEPG - NPTEPG / SG4_LEV3SIZE * 2];
+               ste = &ste[i + SG4_LEV2SIZE - (NPTEPG / SG4_LEV3SIZE) * 2];
                este = &ste[NPTEPG / SG4_LEV3SIZE];
                protoste = kptmpa | SG_U | SG_RW | SG_V;
                while (ste < este) {
@@ -234,6 +235,24 @@
                        protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
                }
                /*
+                * Calculate the free level 2 descriptor mask
+                * noting that we have used:
+                *      0:              level 1 table



Home | Main Index | Thread Index | Old Index