Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/28af00391d36
branches:  yamt-km
changeset: 573356:28af00391d36
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Feb 23 09:42:43 2005 +0000

description:
change kernel va layout, following mac68k.

diffstat:

 sys/arch/news68k/include/vmparam.h        |    4 +-
 sys/arch/news68k/news68k/pmap_bootstrap.c |  109 ++++++++++++++---------------
 2 files changed, 54 insertions(+), 59 deletions(-)

diffs (258 lines):

diff -r 913b1d034d4a -r 28af00391d36 sys/arch/news68k/include/vmparam.h
--- a/sys/arch/news68k/include/vmparam.h        Wed Feb 23 09:11:30 2005 +0000
+++ b/sys/arch/news68k/include/vmparam.h        Wed Feb 23 09:42:43 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.11 2003/08/07 16:28:50 agc Exp $ */
+/*     $NetBSD: vmparam.h,v 1.11.10.1 2005/02/23 09:42:43 yamt Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -155,7 +155,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))
 
 /* virtual sizes (bytes) for various kernel submaps */
 #define VM_PHYS_SIZE           (USRIOSIZE*PAGE_SIZE)
diff -r 913b1d034d4a -r 28af00391d36 sys/arch/news68k/news68k/pmap_bootstrap.c
--- a/sys/arch/news68k/news68k/pmap_bootstrap.c Wed Feb 23 09:11:30 2005 +0000
+++ b/sys/arch/news68k/news68k/pmap_bootstrap.c Wed Feb 23 09:42:43 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.11 2004/09/04 13:43:11 tsutsui Exp $      */
+/*     $NetBSD: pmap_bootstrap.c,v 1.11.6.1 2005/02/23 09:42:43 yamt Exp $     */
 
 /* 
  * Copyright (c) 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.11 2004/09/04 13:43:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.11.6.1 2005/02/23 09:42:43 yamt Exp $");
 
 #include <sys/param.h>
 
@@ -91,7 +91,7 @@
 void
 pmap_bootstrap(paddr_t nextpa, paddr_t firstpa)
 {
-       paddr_t kstpa, kptpa, iiopa, eiopa, kptmpa, p0upa;
+       paddr_t kstpa, kptpa, kptmpa, p0upa;
        u_int nptpages, kstsize;
        st_entry_t protoste, *ste;
        pt_entry_t protopte, *pte, *epte;
@@ -106,12 +106,6 @@
         *      kptpa           statically allocated
         *                      kernel PT pages         Sysptsize+ pages
         *
-        *      iiopa           internal IO space
-        *                      PT pages                iiomapsize pages
-        *
-        *      eiopa           external IO space
-        *                      PT pages                eiomapsize pages
-        *
         * [ Sysptsize is the number of pages of PT, IIOMAPSIZE and
         *   EIOMAPSIZE are the number of PTEs, hence we need to round
         *   the total to a page boundary with IO maps at the end. ]
@@ -142,16 +136,14 @@
 #endif
        kstpa = nextpa;
        nextpa += kstsize * PAGE_SIZE;
+       kptmpa = nextpa;
+       nextpa += PAGE_SIZE;
+       p0upa = nextpa;
+       nextpa += USPACE;
        kptpa = nextpa;
        nptpages = RELOC(Sysptsize, int) +
                (iiomapsize + eiomapsize + NPTEPG - 1) / NPTEPG;
        nextpa += nptpages * PAGE_SIZE;
-       eiopa = nextpa - eiomapsize * sizeof(pt_entry_t);
-       iiopa = eiopa - iiomapsize * sizeof(pt_entry_t);
-       kptmpa = nextpa;
-       nextpa += PAGE_SIZE;
-       p0upa = nextpa;
-       nextpa += USPACE;
 
        /*
         * Clear all PTEs to zero
@@ -205,11 +197,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;
@@ -237,10 +229,28 @@
                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;
@@ -249,21 +259,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
        {
                /*
                 * 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) {
@@ -275,11 +288,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;
        }
        /*
         * Initialize kernel page table.
@@ -321,13 +338,20 @@
        /*
         * Finally, validate the internal IO space PTEs (RW+CI).
         */
-       pte = (u_int *)iiopa;
-       epte = (u_int *)eiopa;
+
+#define        PTE2VA(pte)     m68k_ptob(pte - ((pt_entry_t *)kptpa))
+
        protopte = RELOC(intiobase_phys, u_int) | PG_RW | PG_CI | PG_V;
+       epte = &pte[iiomapsize];
+       RELOC(initiobase, char *) = PTE2VA(pte);
+       RELOC(initiolimit, char *) = PTE2VA(epte);
        while (pte < epte) {
                *pte++ = protopte;
                protopte += PAGE_SIZE;
        }
+       RELOC(extiobase, char *) = PTE2VA(pte);
+       pte += eiomapsize;
+       RELOC(virtual_avail, vaddr_t) = PTE2VA(pte);
 
        /*
         * Calculate important exported kernel virtual addresses
@@ -347,20 +371,7 @@
         * Immediately follows `nptpages' of static kernel page table.
         */
        RELOC(Sysmap, pt_entry_t *) =
-               (pt_entry_t *)m68k_ptob(nptpages * NPTEPG);
-       /*
-        * intiobase, intiolimit: base and end of internal IO space.
-        */
-       RELOC(intiobase, char *) =
-               (char *)m68k_ptob(nptpages*NPTEPG - (iiomapsize + eiomapsize));
-       RELOC(intiolimit, char *) =
-               (char *)m68k_ptob(nptpages*NPTEPG - eiomapsize);
-       /*
-        * extiobase: base of external IO space.
-        * eiomapsize pages at the end of the static kernel page table.
-        */
-       RELOC(extiobase, char *) =
-               (char *)m68k_ptob(nptpages*NPTEPG - eiomapsize);
+           (pt_entry_t *)m68k_ptob((NPTEPG - 1) * NPTEPG);
 
        /*
         * Setup u-area for process 0.
@@ -391,8 +402,6 @@
            (m68k_round_page(MSGBUFSIZE));
        RELOC(mem_size, vsize_t) = m68k_ptob(RELOC(physmem, int));
 
-       RELOC(virtual_avail, vaddr_t) =
-               VM_MIN_KERNEL_ADDRESS + (vaddr_t)(nextpa - firstpa);
        RELOC(virtual_end, vaddr_t) = VM_MAX_KERNEL_ADDRESS;
 
 #if 0
@@ -450,14 +459,14 @@
                 * descriptor mask noting that we have used:
                 *      0:              level 1 table
                 *      1 to `num':     map page tables
-                *      MAXKL2SIZE-1:   maps last-page page table
+                *      MAXKL2SIZE-1:   maps kptmpa
                 */
 #ifdef M68040
                if (RELOC(mmutype, int) == MMU_68040) {
                        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--);
@@ -487,17 +496,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,
-           intiotop_phys - intiobase_phys,
-           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