Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/2884279892a2
branches:  yamt-km
changeset: 573354:2884279892a2
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Feb 23 08:45:13 2005 +0000

description:
change kernel va layout, following mac68k.
XXX why maps p0upa cache invalidated?

diffstat:

 sys/arch/x68k/include/vmparam.h     |    4 +-
 sys/arch/x68k/x68k/pmap_bootstrap.c |  110 ++++++++++++++++++++---------------
 2 files changed, 64 insertions(+), 50 deletions(-)

diffs (281 lines):

diff -r 21f4c8d9f407 -r 2884279892a2 sys/arch/x68k/include/vmparam.h
--- a/sys/arch/x68k/include/vmparam.h   Wed Feb 23 07:48:23 2005 +0000
+++ b/sys/arch/x68k/include/vmparam.h   Wed Feb 23 08:45:13 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.26 2003/08/07 16:30:28 agc Exp $ */
+/*     $NetBSD: vmparam.h,v 1.26.10.1 2005/02/23 08:45:13 yamt Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -147,7 +147,7 @@
 #define VM_MAXUSER_ADDRESS     ((vaddr_t)0xFFFFD000)
 #define VM_MAX_ADDRESS         ((vaddr_t)0xFFFFD000)
 #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))
 
 /* virtual sizes (bytes) for various kernel submaps */
 #define VM_PHYS_SIZE           (USRIOSIZE*PAGE_SIZE)
diff -r 21f4c8d9f407 -r 2884279892a2 sys/arch/x68k/x68k/pmap_bootstrap.c
--- a/sys/arch/x68k/x68k/pmap_bootstrap.c       Wed Feb 23 07:48:23 2005 +0000
+++ b/sys/arch/x68k/x68k/pmap_bootstrap.c       Wed Feb 23 08:45:13 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.27 2005/01/18 07:12:16 chs Exp $  */
+/*     $NetBSD: pmap_bootstrap.c,v 1.27.2.1 2005/02/23 08:45:13 yamt Exp $     */
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.27 2005/01/18 07:12:16 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.27.2.1 2005/02/23 08:45:13 yamt Exp $");
 
 #include "opt_m680x0.h"
 
@@ -91,7 +91,7 @@
 void
 pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
 {
-       paddr_t kstpa, kptpa, iiopa, eiiopa, kptmpa, p0upa;
+       paddr_t kstpa, kptpa, kptmpa, p0upa;
        u_int nptpages, kstsize;
        st_entry_t protoste, *ste;
        pt_entry_t protopte, *pte, *epte;
@@ -105,9 +105,6 @@
         *      kptpa           statically allocated
         *                      kernel PT pages         Sysptsize+ pages
         *
-        *      iiopa           internal IO space
-        *                      PT pages                IIOMAPSIZE 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. ]
@@ -125,21 +122,19 @@
                kstsize = 1;
        kstpa = nextpa;
        nextpa += kstsize * PAGE_SIZE;
+       kptmpa = nextpa;
+       nextpa += PAGE_SIZE;
+       p0upa = nextpa;
+       nextpa += USPACE;
        kptpa = nextpa;
        nptpages = RELOC(Sysptsize, int) +
                (IIOMAPSIZE + NPTEPG - 1) / NPTEPG;
        nextpa += nptpages * PAGE_SIZE;
-       eiiopa = nextpa;                /* just a reference for later */
-       iiopa = nextpa - IIOMAPSIZE * sizeof(pt_entry_t);
-       kptmpa = nextpa;
-       nextpa += PAGE_SIZE;
-       p0upa = nextpa;
-       nextpa += USPACE;
 
        /*
         * Clear all PTEs to zero
         */
-       for (pte = (pt_entry_t *)kstpa; pte < (pt_entry_t *)p0upa; pte++)
+       for (pte = (pt_entry_t *)kstpa; pte < (pt_entry_t *)nexpta; pte++)
                *pte = 0;
 
        /*
@@ -177,11 +172,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;
@@ -202,10 +197,37 @@
                        protoste += (SG4_LEV2SIZE * sizeof(st_entry_t));
                }
                /*
+                * Initialize the final level 1 descriptor to map the last
+                * block of level 2 descriptors.
+                */
+               ste = ((u_int *)kstpa)[SG4_LEV1SIZE-1];
+               pte = ((u_int *)kstpa)[kstsize*NPTEPG - SG4_LEV2SIZE];
+               *ste = (u_int)pte | SG_U | SG_RW | SG_V;
+               /*
+                * Now initialize the final portion of that block of
+                * descriptors to map Sysmap.
+                */
+               pte = ((u_int *)kstpa)
+                               [kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE];
+               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));
+               }
+               /*
                 * Initialize Sysptmap
                 */
+               pte = ((u_int *)kstpa)
+                               [kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE];
+               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_V;
                while (pte < epte) {
                        *pte++ = protopte;
@@ -214,21 +236,24 @@
                /*
                 * Invalidate all but the last remaining entry.
                 */
-               epte = &((u_int *)kptmpa)[NPTEPG];
+               epte = &((u_int *)kptmpa)[NPTEPG-1];
                while (pte < epte) {
                        *pte++ = PG_NV;
                }
+               /*
+                * Initialize the last one to point to Sysptmap.
+                */
+               *pte = kptmpa | PG_RW | PG_CI | 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) {
@@ -240,11 +265,15 @@
                /*
                 * Invalidate all but the last remaining entries in both.
                 */
-               epte = &((u_int *)kptmpa)[NPTEPG];
+               epte = &((u_int *)kptmpa)[NPTEPG-1];
                while (pte < epte) {
                        *ste++ = SG_NV;
                        *pte++ = PG_NV;
                }
+               /*
+                * Initialize the last one to point to Sysptmap.
+                */
+               *pte = kptmpa | PG_RW | PG_CI | PG_V;
        }
 
        /*
@@ -259,6 +288,7 @@
         * Validate PTEs for kernel text (RO)
         */
        pte = &((u_int *)kptpa)[m68k_btop(KERNBASE)];
+       /* XXX why KERNBASE relative? */
        epte = &pte[m68k_btop(m68k_trunc_page(&etext))];
        protopte = firstpa | PG_RO | PG_V;
        while (pte < epte) {
@@ -285,6 +315,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;
@@ -296,16 +327,17 @@
                *pte++ = protopte;
                protopte += PAGE_SIZE;
        }
-       /*
-        * Finally, validate the internal IO space PTEs (RW+CI).
-        */
-       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_V;
+       RELOC(IODEVbase, char *) = PTE2VA(pte);
+       epte = &pte[IIOMAPSIZE];
        while (pte < epte) {
                *pte++ = protopte;
                protopte += PAGE_SIZE;
        }
+       RELOC(virtual_avail, vaddr_t) = PTE2VA(pte);
 
        /*
         * Calculate important exported kernel virtual addresses
@@ -325,17 +357,15 @@
         * Immediately follows `nptpages' of static kernel page table.
         */
        RELOC(Sysmap, pt_entry_t *) =
-               (pt_entry_t *)m68k_ptob(nptpages * NPTEPG);
+           (pt_entry_t *)m68k_ptob((NPTEPG - 1) * NPTEPG);
        /*
         * IODEVbase, intiolimit: base and end of internal (DIO) IO space.
         * IIOMAPSIZE pages prior to external IO space at end of static
         * kernel page table.
         */
-       RELOC(IODEVbase, char *) =
-               (char *)m68k_ptob(nptpages*NPTEPG - IIOMAPSIZE);
        RELOC(intiobase, u_int8_t *) = RELOC(IODEVbase, u_int8_t *); /* XXX */
        RELOC(intiolimit, char *) =
-               (char *)m68k_ptob(nptpages*NPTEPG);
+           RELOC(intiobase, u_int8_t *) + m68k_ptob(IIOMAPSIZE);
 
        /*
         * Setup u-area for process 0.
@@ -364,8 +394,6 @@
                        /* XXX allow for msgbuf */
                        - m68k_round_page(MSGBUFSIZE);
        RELOC(mem_size, psize_t) = m68k_ptob(RELOC(physmem, int));
-       RELOC(virtual_avail, vaddr_t) =
-               VM_MIN_KERNEL_ADDRESS + (nextpa - firstpa);
        RELOC(virtual_end, vaddr_t) = VM_MAX_KERNEL_ADDRESS;
 
        /*
@@ -411,10 +439,11 @@
                        int num;
                        
                        kpm->pm_stfree = ~l2tobm(0);
-                       num = roundup((nptpages + 1) * (NPTEPG / SG4_LEV3SIZE),
+                       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++)
@@ -440,18 +469,3 @@
                RELOC(virtual_avail, vaddr_t) = va;
        }
 }
-
-void
-pmap_init_md(void)
-{
-       vaddr_t addr;
-
-       addr = (vaddr_t) intiobase;
-       if (uvm_map(kernel_map, &addr,
-                   m68k_ptob(IIOMAPSIZE),
-                   NULL, UVM_UNKNOWN_OFFSET, 0,
-                   UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
-                               UVM_INH_NONE, UVM_ADV_RANDOM,
-                               UVM_FLAG_FIXED)) != 0)
-               panic("pmap_init_md: uvm_map failed");
-}



Home | Main Index | Thread Index | Old Index