Source-Changes-HG archive

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

[src/yamt-km]: src/sys/arch/next68k change kernel va layout, following mac68k.



details:   https://anonhg.NetBSD.org/src/rev/913b1d034d4a
branches:  yamt-km
changeset: 573355:913b1d034d4a
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Feb 23 09:11:30 2005 +0000

description:
change kernel va layout, following mac68k.

diffstat:

 sys/arch/next68k/include/vmparam.h        |    4 +-
 sys/arch/next68k/next68k/pmap_bootstrap.c |  171 ++++++++++--------------------
 2 files changed, 59 insertions(+), 116 deletions(-)

diffs (truncated from 356 to 300 lines):

diff -r 2884279892a2 -r 913b1d034d4a sys/arch/next68k/include/vmparam.h
--- a/sys/arch/next68k/include/vmparam.h        Wed Feb 23 08:45:13 2005 +0000
+++ b/sys/arch/next68k/include/vmparam.h        Wed Feb 23 09:11:30 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.16 2003/08/07 16:28:55 agc Exp $ */
+/*     $NetBSD: vmparam.h,v 1.16.10.1 2005/02/23 09:11:30 yamt Exp $   */
 
 /*
  * This file was taken from from mvme68k/include/vmparam.h and
@@ -162,7 +162,7 @@
 #define VM_MAXUSER_ADDRESS     ((vaddr_t)0xFFF00000)
 #define VM_MAX_ADDRESS         ((vaddr_t)0xFFF00000)
 #define VM_MIN_KERNEL_ADDRESS  ((vaddr_t)0)
-#define VM_MAX_KERNEL_ADDRESS  ((vaddr_t)0xFFFFF000)
+#define VM_MAX_KERNEL_ADDRESS  ((vaddr_t)(0-PAGE_SIZE*NPTEPG*2))
 
 /* virtual sizes (bytes) for various kernel submaps */
 #define VM_PHYS_SIZE           (USRIOSIZE*PAGE_SIZE)
diff -r 2884279892a2 -r 913b1d034d4a sys/arch/next68k/next68k/pmap_bootstrap.c
--- a/sys/arch/next68k/next68k/pmap_bootstrap.c Wed Feb 23 08:45:13 2005 +0000
+++ b/sys/arch/next68k/next68k/pmap_bootstrap.c Wed Feb 23 09:11:30 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.18 2005/01/19 01:58:21 chs Exp $  */
+/*     $NetBSD: pmap_bootstrap.c,v 1.18.2.1 2005/02/23 09:11:30 yamt Exp $     */
 
 /*
  * This file was taken from mvme68k/mvme68k/pmap_bootstrap.c
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.18 2005/01/19 01:58:21 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.18.2.1 2005/02/23 09:11:30 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/kcore.h>
@@ -109,9 +109,7 @@
 void
 pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
 {
-       paddr_t kstpa, kptpa, eiiopa, iiopa, kptmpa, lkptpa, p0upa;
-        paddr_t emonopa, monopa;
-        paddr_t ecolorpa, colorpa;
+       paddr_t kstpa, kptpa, kptmpa, lkptpa, p0upa;
        u_int nptpages, kstsize;
        st_entry_t protoste, *ste;
        pt_entry_t protopte, *pte, *epte;
@@ -127,22 +125,6 @@
         *      kptpa           statically allocated
         *                      kernel PT pages         Sysptsize+ pages
         *
-        *      iiopa           internal IO space
-        *                      PT pages                IIOMAPSIZE pages
-        *
-        *      eiiopa          page following
-        *                      internal IO space
-         *
-         *      monopa          mono fb PT pages        MONOSIZE pages
-         *   
-         *      emonopa         page following
-         *                      mono fb pages
-        *
-         *      colorpa         color fb PT pages       COLORSIZE pages
-         *   
-         *      ecolorpa        page following
-         *                      color fb pages
-         *
         * [ Sysptsize is the number of pages of PT, and IIOMAPSIZE
         *   is the number of PTEs, hence we need to round
         *   the total to a page boundary with IO maps at the end. ]
@@ -164,25 +146,16 @@
                kstsize = 1;
        kstpa = nextpa;
        nextpa += kstsize * PAGE_SIZE;
-       kptpa = nextpa;
-       nptpages = RELOC(Sysptsize, int) +
-               (IIOMAPSIZE + MONOMAPSIZE + COLORMAPSIZE + NPTEPG - 1) / NPTEPG;
-       nextpa += nptpages * PAGE_SIZE;
-       eiiopa = nextpa;                /* just a reference for later */
-       iiopa = nextpa - IIOMAPSIZE * sizeof(pt_entry_t);
-       
-       emonopa = nextpa - IIOMAPSIZE * sizeof(pt_entry_t);
-       monopa = emonopa - MONOMAPSIZE * sizeof(pt_entry_t);
-
-       ecolorpa = emonopa - MONOMAPSIZE * sizeof(pt_entry_t);
-       colorpa = ecolorpa - COLORMAPSIZE * sizeof(pt_entry_t);
-
        kptmpa = nextpa;
        nextpa += PAGE_SIZE;
        lkptpa = nextpa;
        nextpa += PAGE_SIZE;
        p0upa = nextpa;
        nextpa += USPACE;
+       kptpa = nextpa;
+       nptpages = RELOC(Sysptsize, int) +
+               (IIOMAPSIZE + MONOMAPSIZE + COLORMAPSIZE + NPTEPG - 1) / NPTEPG;
+       nextpa += nptpages * PAGE_SIZE;
 
        /*
         * Clear all PTEs to zero
@@ -234,11 +207,11 @@
                 * Initialize level 2 descriptors (which immediately
                 * follow the level 1 table).  We need:
                 *      NPTEPG / SG4_LEV3SIZE
-                * level 2 descriptors to map each of the nptpages+1
+                * level 2 descriptors to map each of the nptpages
                 * pages of PTEs.  Note that we set the "used" bit
                 * now to save the HW the expense of doing it.
                 */
-               num = (nptpages + 1) * (NPTEPG / SG4_LEV3SIZE);
+               num = nptpages * (NPTEPG / SG4_LEV3SIZE);
                pte = &((u_int *)kstpa)[SG4_LEV1SIZE];
                epte = &pte[num];
                protoste = kptpa | SG_U | SG_RW | SG_V;
@@ -269,7 +242,13 @@
                 * Now initialize the final portion of that block of
                 * descriptors to map the "last PT page".
                 */
-               pte = &((u_int *)kstpa)[kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE];
+               pte = &((u_int *)kstpa)[kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE*2];
+               epte = &pte[NPTEPG/SG4_LEV3SIZE];
+               protoste = kptmpa | SG_U | SG_RW | SG_V;
+               while (pte < epte) {
+                       *pte++ = protoste;
+                       protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
+               }
                epte = &pte[NPTEPG/SG4_LEV3SIZE];
                protoste = lkptpa | SG_U | SG_RW | SG_V;
                while (pte < epte) {
@@ -279,36 +258,44 @@
                /*
                 * Initialize Sysptmap
                 */
+               pte = ((u_int *)kstpa)[kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE*2];
+               epte = &pte[NPTEPG/SG4_LEV3SIZE];
+               protoste = kptmpa | SG_U | SG_RW | SG_V;
+               while (pte < epte) {
+                       *pte++ = protoste;
+                       protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
+               }
                pte = (u_int *)kptmpa;
-               epte = &pte[nptpages+1];
+               epte = &pte[nptpages];
                protopte = kptpa | PG_RW | PG_CI | PG_U | PG_V;
                while (pte < epte) {
                        *pte++ = protopte;
                        protopte += PAGE_SIZE;
                }
                /*
-                * Invalidate all but the last remaining entry.
+                * Invalidate all but the last two remaining entries.
                 */
-               epte = &((u_int *)kptmpa)[NPTEPG-1];
+               epte = &((u_int *)kptmpa)[NPTEPG-2];
                while (pte < epte) {
                        *pte++ = PG_NV;
                }
                /*
-                * Initialize the last to point to the page
+                * Initialize the last ones to point to Sysptmap and the page
                 * table page allocated earlier.
                 */
+               *pte = kptmpa | PG_RW | PG_CI | PG_V;
+               pte++;
                *pte = lkptpa | PG_RW | PG_CI | PG_U | PG_V;
        } else
 #endif /* M68040 || M68060 */
        {
                /*
                 * Map the page table pages in both the HW segment table
-                * and the software Sysptmap.  Note that Sysptmap is also
-                * considered a PT page hence the +1.
+                * and the software Sysptmap
                 */
                ste = (u_int *)kstpa;
                pte = (u_int *)kptmpa;
-               epte = &pte[nptpages+1];
+               epte = &pte[nptpages];
                protoste = kptpa | SG_RW | SG_V;
                protopte = kptpa | PG_RW | PG_CI | PG_V;
                while (pte < epte) {
@@ -318,17 +305,21 @@
                        protopte += PAGE_SIZE;
                }
                /*
-                * Invalidate all but the last remaining entries in both.
+                * Invalidate all but the last two remaining entries in both.
                 */
-               epte = &((u_int *)kptmpa)[NPTEPG-1];
+               epte = &((u_int *)kptmpa)[NPTEPG-2];
                while (pte < epte) {
                        *ste++ = SG_NV;
                        *pte++ = PG_NV;
                }
                /*
-                * Initialize the last to point to point to the page
+                * Initialize the last ones to point to Sysptmap and the page
                 * table page allocated earlier.
                 */
+               *ste = kptmpa | SG_RW | SG_V;
+               *pte = kptmpa | PG_RW | PG_CI | PG_V;
+               ste++;
+               pte++;
                *ste = lkptpa | SG_RW | SG_V;
                *pte = lkptpa | PG_RW | PG_CI | PG_V;
        }
@@ -384,6 +375,7 @@
         * map the kernel segment table cache invalidated for 
         * these machines (for the 68040 not strictly necessary, but
         * recommended by Motorola; for the 68060 mandatory)
+        * XXX this includes p0upa.  why?
         */
        epte = &((u_int *)kptpa)[m68k_btop(nextpa - firstpa)];
        protopte = (protopte & ~PG_PROT) | PG_RW;
@@ -402,32 +394,41 @@
         * in this range and it would be nice to be able to access
         * them after the MMU is turned on.
         */
-       pte = (u_int *)iiopa;
-       epte = (u_int *)eiiopa;
+
+#define        PTE2VA(pte)     m68k_ptob(pte - ((pt_entry_t *)kptpa))
+
        protopte = INTIOBASE | PG_RW | PG_CI | PG_U | PG_M | PG_V;
+       epte = &pte[IIOMAPSIZE];
+       RELOC(intiobase, char *) = PTE2VA(pte);
+       RELOC(intiolimit, char *) = PTE2VA(epte);
        while (pte < epte) {
                *pte++ = protopte;
                protopte += PAGE_SIZE;
        }
 
        /* validate the mono fb space PTEs */
-       pte = (u_int *)monopa;
-       epte = (u_int *)emonopa;
+
        protopte = MONOBASE | PG_RW | PG_CWT | PG_U | PG_M | PG_V;
+       epte = &pte[MONOMAPSIZE];
+       RELOC(monobase, char *) = PTE2VA(pte);
+       RELOC(monolimit, char *) = PTE2VA(epte);
        while (pte < epte) {
                *pte++ = protopte;
                protopte += PAGE_SIZE;
        }
 
        /* validate the color fb space PTEs */
-       pte = (u_int *)colorpa;
-       epte = (u_int *)ecolorpa;
        protopte = COLORBASE | PG_RW | PG_CWT | PG_U | PG_M | PG_V;
+       epte = &pte[COLORMAPSIZE];
+       RELOC(colorbase, char *) = PTE2VA(pte);
+       RELOC(colorlimit, char *) = PTE2VA(epte);
        while (pte < epte) {
                *pte++ = protopte;
                protopte += PAGE_SIZE;
        }
 
+       RELOC(virtual_avail, vaddr_t) = PTE2VA(pte);
+
        /*
         * Calculate important exported kernel virtual addresses
         */
@@ -446,37 +447,7 @@
         * Immediately follows `nptpages' of static kernel page table.
         */
        RELOC(Sysmap, pt_entry_t *) =
-               (pt_entry_t *)m68k_ptob(nptpages * NPTEPG);
-
-       /*
-        * colorbase, colorlimit: base and end of color fb space.
-        * COLORMAPSIZE pages prior to external IO space at end of static
-        * kernel page table.
-        */
-       RELOC(colorbase, vaddr_t) =
-               m68k_ptob(nptpages*NPTEPG - IIOMAPSIZE - MONOMAPSIZE - COLORMAPSIZE);
-       RELOC(colorlimit, vaddr_t) =
-               m68k_ptob(nptpages*NPTEPG - IIOMAPSIZE - MONOMAPSIZE);
-
-       /*
-        * monobase, monolimit: base and end of mono fb space.
-        * MONOMAPSIZE pages prior to external IO space at end of static
-        * kernel page table.
-        */
-       RELOC(monobase, vaddr_t) =
-               m68k_ptob(nptpages*NPTEPG - IIOMAPSIZE - MONOMAPSIZE);
-       RELOC(monolimit, vaddr_t) =
-               m68k_ptob(nptpages*NPTEPG - IIOMAPSIZE);
-
-       /*
-        * intiobase, intiolimit: base and end of internal IO space.
-        * IIOMAPSIZE pages prior to external IO space at end of static
-        * kernel page table.
-        */
-       RELOC(intiobase, vaddr_t) =
-               m68k_ptob(nptpages*NPTEPG - IIOMAPSIZE);
-       RELOC(intiolimit, vaddr_t) =
-               m68k_ptob(nptpages*NPTEPG);
+           (pt_entry_t *)m68k_ptob((NPTEPG - 2) * NPTEPG);
 
        /*



Home | Main Index | Thread Index | Old Index