Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Use proper macro, variable names, types, and assign...



details:   https://anonhg.NetBSD.org/src/rev/06fb16701355
branches:  trunk
changeset: 749692:06fb16701355
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Dec 05 23:16:57 2009 +0000

description:
Use proper macro, variable names, types, and assignments for readability.

diffstat:

 sys/arch/cesfic/cesfic/pmap_bootstrap.c   |   89 ++++++++++++++-----------
 sys/arch/hp300/hp300/pmap_bootstrap.c     |  104 +++++++++++++++--------------
 sys/arch/luna68k/luna68k/pmap_bootstrap.c |   88 ++++++++++++++-----------
 sys/arch/mac68k/mac68k/pmap_bootstrap.c   |   77 ++++++++++++----------
 sys/arch/mvme68k/mvme68k/pmap_bootstrap.c |   95 +++++++++++++++-----------
 sys/arch/news68k/news68k/pmap_bootstrap.c |   97 +++++++++++++++------------
 sys/arch/next68k/next68k/pmap_bootstrap.c |  105 ++++++++++++++++-------------
 sys/arch/x68k/x68k/pmap_bootstrap.c       |   90 ++++++++++++++-----------
 8 files changed, 413 insertions(+), 332 deletions(-)

diffs (truncated from 1751 to 300 lines):

diff -r bdfcb9515c63 -r 06fb16701355 sys/arch/cesfic/cesfic/pmap_bootstrap.c
--- a/sys/arch/cesfic/cesfic/pmap_bootstrap.c   Sat Dec 05 22:44:08 2009 +0000
+++ b/sys/arch/cesfic/cesfic/pmap_bootstrap.c   Sat Dec 05 23:16:57 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.22 2009/12/05 15:31:07 tsutsui Exp $      */
+/*     $NetBSD: pmap_bootstrap.c,v 1.23 2009/12/05 23:16:57 tsutsui Exp $      */
 
 /* 
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.22 2009/12/05 15:31:07 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.23 2009/12/05 23:16:57 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -85,7 +85,7 @@
 {
        paddr_t kstpa, kptpa, kptmpa, lkptpa, lwp0upa;
        u_int nptpages, kstsize;
-       st_entry_t protoste, *ste;
+       st_entry_t protoste, *ste, *este;
        pt_entry_t protopte, *pte, *epte;
 
        /*
@@ -165,10 +165,10 @@
                 * First invalidate the entire "segment table" pages
                 * (levels 1 and 2 have the same "invalid" value).
                 */
-               pte = (u_int *)kstpa;
-               epte = &pte[kstsize * NPTEPG];
-               while (pte < epte)
-                       *pte++ = SG_NV;
+               ste = (st_entry_t *)kstpa;
+               este = &ste[kstsize * NPTEPG];
+               while (ste < este)
+                       *ste++ = SG_NV;
 
                /*
                 * Initialize level 2 descriptors (which immediately
@@ -179,24 +179,25 @@
                 * now to save the HW the expense of doing it.
                 */
                num = nptpages * (NPTEPG / SG4_LEV3SIZE);
-               pte = &((u_int *)kstpa)[SG4_LEV1SIZE];
-               epte = &pte[num];
+               ste = (st_entry_t *)kstpa;
+               ste = &ste[SG4_LEV1SIZE];
+               este = &ste[num];
                protoste = kptpa | SG_U | SG_RW | SG_V;
-               while (pte < epte) {
-                       *pte++ = protoste;
+               while (ste < este) {
+                       *ste++ = protoste;
                        protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
                }
 
                /*
                 * Initialize level 1 descriptors.  We need:
-                *      roundup(num, SG4_LEV2SIZE) / SG4_LEV2SIZE
+                *      howmany(num, SG4_LEV2SIZE)
                 * level 1 descriptors to map the `num' level 2's.
                 */
-               pte = (u_int *)kstpa;
-               epte = &pte[roundup(num, SG4_LEV2SIZE) / SG4_LEV2SIZE];
-               protoste = (u_int)&pte[SG4_LEV1SIZE] | SG_U | SG_RW | SG_V;
-               while (pte < epte) {
-                       *pte++ = protoste;
+               ste = (st_entry_t *)kstpa;
+               este = &ste[howmany(num, SG4_LEV2SIZE)];
+               protoste = (paddr_t)&ste[SG4_LEV1SIZE] | SG_U | SG_RW | SG_V;
+               while (ste < este) {
+                       *ste++ = protoste;
                        protoste += (SG4_LEV2SIZE * sizeof(st_entry_t));
                }
 
@@ -204,31 +205,34 @@
                 * 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;
+               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;
                /*
                 * Now initialize the final portion of that block of
                 * descriptors to map kptmpa and the "last PT page".
                 */
-               pte = &((u_int *)kstpa)[kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE*2];
-               epte = &pte[NPTEPG/SG4_LEV3SIZE];
+               ste = (st_entry_t *)kstpa;
+               ste = &ste[kstsize * NPTEPG - NPTEPG / SG4_LEV3SIZE * 2];
+               epte = &ste[NPTEPG / SG4_LEV3SIZE];
                protoste = kptmpa | SG_U | SG_RW | SG_V;
-               while (pte < epte) {
-                       *pte++ = protoste;
+               while (ste < este) {
+                       *ste++ = protoste;
                        protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
                }
-               epte = &pte[NPTEPG/SG4_LEV3SIZE];
+               este = &ste[NPTEPG / SG4_LEV3SIZE];
                protoste = lkptpa | SG_U | SG_RW | SG_V;
-               while (pte < epte) {
-                       *pte++ = protoste;
+               while (ste < este) {
+                       *ste++ = protoste;
                        protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
                }
 
                /*
                 * Initialize Sysptmap
                 */
-               pte = (u_int *)kptmpa;
+               pte = (pt_entry_t *)kptmpa;
                epte = &pte[nptpages];
                protopte = kptpa | PG_RW | PG_CI | PG_V;
                while (pte < epte) {
@@ -239,7 +243,8 @@
                /*
                 * Invalidate all but the last remaining entry.
                 */
-               epte = &((u_int *)kptmpa)[NPTEPG-2];
+               epte = (pt_entry_t *)kptmpa;
+               epte = &epte[NPTEPG - 2];
                while (pte < epte) {
                        *pte++ = PG_NV;
                }
@@ -255,8 +260,8 @@
                 * Map the page table pages in both the HW segment table
                 * and the software Sysptmap.
                 */
-               ste = (u_int *)kstpa;
-               pte = (u_int *)kptmpa;
+               ste = (st_entry_t *)kstpa;
+               pte = (pt_entry_t *)kptmpa;
                epte = &pte[nptpages];
                protoste = kptpa | SG_RW | SG_V;
                protopte = kptpa | PG_RW | PG_CI | PG_V;
@@ -269,7 +274,8 @@
                /*
                 * Invalidate all but the last remaining entries in both.
                 */
-               epte = &((u_int *)kptmpa)[NPTEPG-2];
+               epte = (pt_entry_t *)kptmpa;
+               epte = &epte[NPTEPG - 2];
                while (pte < epte) {
                        *ste++ = SG_NV;
                        *pte++ = PG_NV;
@@ -286,11 +292,14 @@
                *pte = lkptpa | PG_RW | PG_CI | PG_V;
        }
        /*
-        * Invalidate all but the final entry in the last kernel PT page
-        * (u-area PTEs will be validated later).  The final entry maps
-        * the last page of physical memory.
+        * Invalidate all but the final entry in the last kernel PT page.
+        * The final entry maps the last page of physical memory to
+        * prepare a page that is PA == VA to turn on the MMU.
+        *
+        * XXX: This looks copied from hp300 where PA != VA, but
+        * XXX: it's suspicious if this is also required on this port.
         */
-       pte = (u_int *)lkptpa;
+       pte = (pt_entry_t *)lkptpa;
        epte = &pte[NPTEPG];
        while (pte < epte)
                *pte++ = PG_NV;
@@ -299,7 +308,7 @@
         * Initialize kernel page table.
         * Start by invalidating the `nptpages' that we have allocated.
         */
-       pte = (u_int *)kptpa;
+       pte = (pt_entry_t *)kptpa;
        epte = &pte[nptpages * NPTEPG];
        while (pte < epte)
                *pte++ = PG_NV;
@@ -307,7 +316,8 @@
        /*
         * Validate PTEs for kernel text (RO).
         */
-       pte = &((u_int *)kptpa)[m68k_btop(KERNBASE)];
+       pte = (pt_entry_t *)kptpa;
+       pte = &pte[m68k_btop(KERNBASE)];
        epte = &((u_int *)kptpa)[m68k_btop(m68k_trunc_page(&etext))];
        protopte = firstpa | PG_RO | PG_V;
        while (pte < epte) {
@@ -319,7 +329,8 @@
         * by us so far (nextpa - firstpa bytes), and pages for lwp0
         * u-area and page table allocated below (RW).
         */
-       epte = &((u_int *)kptpa)[m68k_btop(KERNBASE + nextpa - firstpa)];
+       epte = (pt_entry_t *)kptpa;
+       epte = &epte[m68k_btop(KERNBASE + nextpa - firstpa)];
        protopte = (protopte & ~PG_PROT) | PG_RW;
        /*
         * Enable copy-back caching of data pages
diff -r bdfcb9515c63 -r 06fb16701355 sys/arch/hp300/hp300/pmap_bootstrap.c
--- a/sys/arch/hp300/hp300/pmap_bootstrap.c     Sat Dec 05 22:44:08 2009 +0000
+++ b/sys/arch/hp300/hp300/pmap_bootstrap.c     Sat Dec 05 23:16:57 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap_bootstrap.c,v 1.42 2009/12/04 18:55:14 tsutsui Exp $      */
+/*     $NetBSD: pmap_bootstrap.c,v 1.43 2009/12/05 23:16:57 tsutsui Exp $      */
 
 /*
  * Copyright (c) 1991, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.42 2009/12/04 18:55:14 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_bootstrap.c,v 1.43 2009/12/05 23:16:57 tsutsui Exp $");
 
 #include <sys/param.h>
 
@@ -95,7 +95,7 @@
 {
        paddr_t kstpa, kptpa, kptmpa, lkptpa, lwp0upa;
        u_int nptpages, kstsize;
-       st_entry_t protoste, *ste;
+       st_entry_t protoste, *ste, *este;
        pt_entry_t protopte, *pte, *epte;
 
        /*
@@ -173,10 +173,10 @@
                 * First invalidate the entire "segment table" pages
                 * (levels 1 and 2 have the same "invalid" value).
                 */
-               pte = (u_int *)kstpa;
-               epte = &pte[kstsize * NPTEPG];
-               while (pte < epte)
-                       *pte++ = SG_NV;
+               ste = (st_entry_t *)kstpa;
+               este = &ste[kstsize * NPTEPG];
+               while (ste < este)
+                       *ste++ = SG_NV;
                /*
                 * Initialize level 2 descriptors (which immediately
                 * follow the level 1 table).  We need:
@@ -186,53 +186,57 @@
                 * now to save the HW the expense of doing it.
                 */
                num = nptpages * (NPTEPG / SG4_LEV3SIZE);
-               pte = &((u_int *)kstpa)[SG4_LEV1SIZE];
-               epte = &pte[num];
+               ste = (st_entry_t *)kstpa;
+               ste = &ste[SG4_LEV1SIZE];
+               este = &ste[num];
                protoste = kptpa | SG_U | SG_RW | SG_V;
-               while (pte < epte) {
-                       *pte++ = protoste;
+               while (ste < este) {
+                       *ste++ = protoste;
                        protoste += (SG4_LEV3SIZE * sizeof(st_entry_t));
                }
                /*
                 * Initialize level 1 descriptors.  We need:
-                *      roundup(num, SG4_LEV2SIZE) / SG4_LEV2SIZE
+                *      howmany(num, SG4_LEV2SIZE)
                 * level 1 descriptors to map the `num' level 2's.
                 */
-               pte = (u_int *)kstpa;
-               epte = &pte[roundup(num, SG4_LEV2SIZE) / SG4_LEV2SIZE];
-               protoste = (u_int)&pte[SG4_LEV1SIZE] | SG_U | SG_RW | SG_V;
-               while (pte < epte) {
-                       *pte++ = protoste;
+               ste = (st_entry_t *)kstpa;
+               este = &ste[howmany(num, SG4_LEV2SIZE)];
+               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.
                 */
-               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;
+               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;
                /*
                 * Now initialize the final portion of that block of
                 * descriptors to map kptmpa and the "last PT page".
                 */
-               pte = &((u_int *)kstpa)[kstsize*NPTEPG - NPTEPG/SG4_LEV3SIZE*2];
-               epte = &pte[NPTEPG/SG4_LEV3SIZE];
+               ste = (st_entry_t *)kstpa;
+               ste = &ste[kstsize * NPTEPG - NPTEPG / SG4_LEV3SIZE * 2];
+               este = &ste[NPTEPG / SG4_LEV3SIZE];



Home | Main Index | Thread Index | Old Index