Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/sparc64 Mostly switch to promlib interface....



details:   https://anonhg.NetBSD.org/src/rev/26e31c2c4e95
branches:  trunk
changeset: 559649:26e31c2c4e95
user:      pk <pk%NetBSD.org@localhost>
date:      Sun Mar 21 14:19:30 2004 +0000

description:
Mostly switch to promlib interface. Postpone the use of prom_makememarr()
since the sparc64 memory range properties aren't compatible yet.

Fix pmap_calculate_colors() in the process.

diffstat:

 sys/arch/sparc64/sparc64/pmap.c |  488 +++++++++++++++++++--------------------
 1 files changed, 234 insertions(+), 254 deletions(-)

diffs (truncated from 1312 to 300 lines):

diff -r 72f5fd7b21c3 -r 26e31c2c4e95 sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c   Sun Mar 21 14:15:35 2004 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c   Sun Mar 21 14:19:30 2004 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: pmap.c,v 1.155 2004/03/14 18:18:56 chs Exp $   */
+/*     $NetBSD: pmap.c,v 1.156 2004/03/21 14:19:30 pk Exp $    */
 /*
- * 
+ *
  * Copyright (C) 1996-1999 Eduardo Horvath.
  * All rights reserved.
  *
@@ -10,7 +10,7 @@
  * are met:
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
- *  
+ *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR  ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.155 2004/03/14 18:18:56 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.156 2004/03/21 14:19:30 pk Exp $");
 
 #undef NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define        HWREF
@@ -50,7 +50,7 @@
 #include <machine/pcb.h>
 #include <machine/sparc64.h>
 #include <machine/ctlreg.h>
-#include <machine/openfirm.h>
+#include <machine/promlib.h>
 #include <machine/kcore.h>
 #include <machine/cpu.h>
 
@@ -82,13 +82,13 @@
  * Diatribe on ref/mod counting:
  *
  * First of all, ref/mod info must be non-volatile.  Hence we need to keep it
- * in the pv_entry structure for each page.  (We could bypass this for the 
+ * in the pv_entry structure for each page.  (We could bypass this for the
  * vm_page, but that's a long story....)
- * 
+ *
  * This architecture has nice, fast traps with lots of space for software bits
  * in the TTE.  To accelerate ref/mod counts we make use of these features.
  *
- * When we map a page initially, we place a TTE in the page table.  It's 
+ * When we map a page initially, we place a TTE in the page table.  It's
  * inserted with the TLB_W and TLB_ACCESS bits cleared.  If a page is really
  * writable we set the TLB_REAL_W bit for the trap handler.
  *
@@ -128,7 +128,6 @@
                           pv_entry_t));
 void   pmap_page_cache __P((struct pmap *, paddr_t, int));
 
-void pmap_alloc_bootargs(void);
 /*
  * First and last managed physical addresses.
  * XXX only used for dumping the system.
@@ -254,7 +253,7 @@
 int    pmap_pages_stolen = 0;
 
 #define        BDPRINTF(n, f)  if (pmapdebug & (n)) prom_printf f
-#define        DPRINTF(n, f)   if (pmapdebug & (n)) printf f 
+#define        DPRINTF(n, f)   if (pmapdebug & (n)) printf f
 #else
 #define        ENTER_STAT(x)
 #define        REMOVE_STAT(x)
@@ -268,7 +267,7 @@
 pv_check()
 {
        int i, j, s;
-       
+
        s = splhigh();
        for (i = 0; i < physmem; i++) {
                struct pv_entry *pv;
@@ -302,7 +301,7 @@
  */
 
 int pmap_next_ctx = 1;
-paddr_t *ctxbusy;      
+paddr_t *ctxbusy;
 LIST_HEAD(, pmap) pmap_ctxlist;
 int numctx;
 #define CTXENTRY       (sizeof(paddr_t))
@@ -350,16 +349,12 @@
 
 /*
  * Enter a TTE into the kernel pmap only.  Don't do anything else.
- * 
- * Use only during bootstrapping since it does no locking and 
+ *
+ * Use only during bootstrapping since it does no locking and
  * can lose ref/mod info!!!!
  *
  */
-static void pmap_enter_kpage __P((vaddr_t, int64_t));
-static void
-pmap_enter_kpage(va, data)
-       vaddr_t va;
-       int64_t data;
+static void pmap_enter_kpage(vaddr_t va, int64_t data)
 {
        paddr_t newp;
 
@@ -371,8 +366,8 @@
                }
 
                ENTER_STAT(ptpneeded);
-               BDPRINTF(PDB_BOOT1, 
-                        ("pseg_set: pm=%p va=%p data=%lx newp %lx\r\n",
+               BDPRINTF(PDB_BOOT1,
+                        ("pseg_set: pm=%p va=%p data=%lx newp %lx\n",
                          pmap_kernel(), va, (long)data, (long)newp));
 #ifdef DEBUG
                if (pmapdebug & PDB_BOOT1)
@@ -385,25 +380,11 @@
  * Check the bootargs to see if we need to enable bootdebug.
  */
 #ifdef DEBUG
-void pmap_bootdebug __P((void));
-void
-pmap_bootdebug() 
+static void pmap_bootdebug(void)
 {
-       int chosen;
-       char *cp;
-       char buf[128];
-
-       /*
-        * Grab boot args from PROM
-        */
-       chosen = OF_finddevice("/chosen");
-       /* Setup pointer to boot flags */
-       OF_getprop(chosen, "bootargs", buf, sizeof(buf));
-       cp = buf;
-       while (*cp != '-')
-               if (*cp++ == '\0')
-                       return;
-       for (;;) 
+       char *cp = prom_getbootargs();
+
+       for (;;)
                switch (*++cp) {
                case '\0':
                        return;
@@ -423,38 +404,35 @@
  * size of the E$/PAGE_SIZE.  However, different CPUs can have different sized
  * E$, so we need to take the GCM of the E$ size.
  */
-static int pmap_calculate_colors __P((void));
-static int 
-pmap_calculate_colors() {
-       int node = 0;
+static int pmap_calculate_colors(void)
+{
+       int node;
        int size, assoc, color, maxcolor = 1;
-       char buf[80];
-
-       while ((node = OF_peer(node))) {
-               if ((OF_getprop(node, "device_type", buf, sizeof(buf)) > 0) &&
-                       strcmp("cpu", buf) == 0) {
-                       /* Found a CPU, get the E$ info. */
-                       if (OF_getprop(node,"ecache-size", &size, 
-                               sizeof(size)) != sizeof(size)) {
-                               printf("pmap_calculate_colors: node %x has "
-                                       "no ecache-size\n", node);
-                               /* If we can't get the E$ size, skip the node */
-                               continue;
-                       }
-                       if (OF_getprop(node, "ecache-associativity", &assoc,
-                               sizeof(assoc)) != sizeof(assoc))
-                               /* Fake asociativity of 1 */
-                               assoc = 1;
-                       color = size/assoc/PAGE_SIZE;
-                       if (color > maxcolor)
-                               maxcolor = color;
+
+       for (node = prom_firstchild(prom_findroot()); node != 0;
+            node = prom_nextsibling(node)) {
+               char *name = prom_getpropstring(node, "device_type");
+               if (strcmp("cpu", name) != 0)
+                       continue;
+
+               /* Found a CPU, get the E$ info. */
+               size = prom_getpropint(node, "ecache-size", -1);
+               if (size == -1) {
+                       prom_printf("pmap_calculate_colors: node %x has "
+                               "no ecache-size\n", node);
+                       /* If we can't get the E$ size, skip the node */
+                       continue;
                }
+
+               assoc = prom_getpropint(node, "ecache-associativity", 1);
+               color = size/assoc/PAGE_SIZE;
+               if (color > maxcolor)
+                       maxcolor = color;
        }
        return (maxcolor);
 }
 
-void
-pmap_alloc_bootargs()
+static void pmap_alloc_bootargs(void)
 {
 /*     extern struct cpu_bootargs *cpu_args; */
        char *v;
@@ -513,7 +491,7 @@
        pmap_bootdebug();
 #endif
 
-       BDPRINTF(PDB_BOOT, ("Entered pmap_bootstrap.\r\n"));
+       BDPRINTF(PDB_BOOT, ("Entered pmap_bootstrap.\n"));
 
        pmap_alloc_bootargs();
 
@@ -528,59 +506,59 @@
         * Find out how big the kernel's virtual address
         * space is.  The *$#@$ prom loses this info
         */
-       if ((vmemh = OF_finddevice("/virtual-memory")) == -1) {
+       if ((vmemh = prom_finddevice("/virtual-memory")) == 0) {
                prom_printf("no virtual-memory?");
-               OF_exit();
+               prom_halt();
        }
        memset(memlist, 0, sizeof(memlist));
        if (OF_getprop(vmemh, "available", memlist, sizeof(memlist)) <= 0) {
                prom_printf("no vmemory avail?");
-               OF_exit();
+               prom_halt();
        }
 
 #ifdef DEBUG
        if (pmapdebug & PDB_BOOT) {
                /* print out mem list */
-               prom_printf("Available virtual memory:\r\n");
+               prom_printf("Available virtual memory:\n");
                for (mp = memlist; mp->size; mp++) {
-                       prom_printf("memlist start %p size %lx\r\n", 
+                       prom_printf("memlist start %p size %lx\n",
                                    (void *)(u_long)mp->start,
                                    (u_long)mp->size);
                }
-               prom_printf("End of available virtual memory\r\n");
+               prom_printf("End of available virtual memory\n");
        }
 #endif
-       /* 
+       /*
         * Get hold or the message buffer.
         */
        msgbufp = (struct kern_msgbuf *)(vaddr_t)MSGBUF_VA;
 /* XXXXX -- increase msgbufsiz for uvmhist printing */
        msgbufsiz = 4*PAGE_SIZE /* round_page(sizeof(struct msgbuf)) */;
-       BDPRINTF(PDB_BOOT, ("Trying to allocate msgbuf at %lx, size %lx\r\n", 
+       BDPRINTF(PDB_BOOT, ("Trying to allocate msgbuf at %lx, size %lx\n",
                            (long)msgbufp, (long)msgbufsiz));
        if ((long)msgbufp !=
            (long)(phys_msgbuf = prom_claim_virt((vaddr_t)msgbufp, msgbufsiz)))
                prom_printf(
-                   "cannot get msgbuf VA, msgbufp=%p, phys_msgbuf=%lx\r\n", 
+                   "cannot get msgbuf VA, msgbufp=%p, phys_msgbuf=%lx\n",
                    (void *)msgbufp, (long)phys_msgbuf);
        phys_msgbuf = prom_get_msgbuf(msgbufsiz, MMU_PAGE_ALIGN);
-       BDPRINTF(PDB_BOOT, 
-               ("We should have the memory at %lx, let's map it in\r\n",
+       BDPRINTF(PDB_BOOT,
+               ("We should have the memory at %lx, let's map it in\n",
                        phys_msgbuf));
-       if (prom_map_phys(phys_msgbuf, msgbufsiz, (vaddr_t)msgbufp, 
+       if (prom_map_phys(phys_msgbuf, msgbufsiz, (vaddr_t)msgbufp,
                          -1/* sunos does this */) == -1)
-               prom_printf("Failed to map msgbuf\r\n");
+               prom_printf("Failed to map msgbuf\n");
        else
-               BDPRINTF(PDB_BOOT, ("msgbuf mapped at %p\r\n", 
+               BDPRINTF(PDB_BOOT, ("msgbuf mapped at %p\n",
                        (void *)msgbufp));
        msgbufmapped = 1;       /* enable message buffer */
        initmsgbuf((caddr_t)msgbufp, msgbufsiz);
 
-       /* 
+       /*
         * Record kernel mapping -- we will map these with a permanent 4MB
         * TLB entry when we initialize the CPU later.
         */
-       BDPRINTF(PDB_BOOT, ("translating kernelstart %p\r\n", 
+       BDPRINTF(PDB_BOOT, ("translating kernelstart %p\n",
                (void *)kernelstart));
        ktext = kernelstart;
        ktextp = prom_vtop(kernelstart);
@@ -597,15 +575,15 @@



Home | Main Index | Thread Index | Old Index