Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/pmax Use the PROM bitmap, if available, to determin...



details:   https://anonhg.NetBSD.org/src/rev/bfc0b498ac2d
branches:  trunk
changeset: 514158:bfc0b498ac2d
user:      mhitch <mhitch%NetBSD.org@localhost>
date:      Fri Aug 24 15:33:16 2001 +0000

description:
Use the PROM bitmap, if available, to determine available memory.  Also
add support of multiple memory segments so machines that allow mixed
memory sizes can utilize all available memory.

diffstat:

 sys/arch/pmax/include/dec_prom.h  |   4 +-
 sys/arch/pmax/include/vmparam.h   |   4 +-
 sys/arch/pmax/pmax/dec_3max.c     |   6 +-
 sys/arch/pmax/pmax/dec_3maxplus.c |   6 +-
 sys/arch/pmax/pmax/dec_3min.c     |   6 +-
 sys/arch/pmax/pmax/dec_maxine.c   |   6 +-
 sys/arch/pmax/pmax/machdep.c      |  77 ++++++++++++++++++++++++++++----------
 sys/arch/pmax/pmax/machdep.h      |   5 ++-
 sys/arch/pmax/pmax/promcall.c     |  31 ++++++++++++++-
 9 files changed, 105 insertions(+), 40 deletions(-)

diffs (truncated from 334 to 300 lines):

diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/include/dec_prom.h
--- a/sys/arch/pmax/include/dec_prom.h  Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/include/dec_prom.h  Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dec_prom.h,v 1.16 2001/07/30 17:05:51 mhitch Exp $     */
+/*     $NetBSD: dec_prom.h,v 1.17 2001/08/24 15:33:17 mhitch Exp $     */
 
 /*
  * Copyright (c) 1992, 1993
@@ -76,7 +76,7 @@
 
 #define DEC_PROM_MAGIC 0x30464354
 
-typedef struct {
+typedef struct memmap {
        int     pagesize;       /* system page size */
        u_char  bitmap[15360];  /* bit for each page indicating safe to use */
 } memmap;
diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/include/vmparam.h
--- a/sys/arch/pmax/include/vmparam.h   Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/include/vmparam.h   Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vmparam.h,v 1.13 2000/01/11 20:36:17 ad Exp $  */
+/*     $NetBSD: vmparam.h,v 1.14 2001/08/24 15:33:17 mhitch Exp $      */
 
 #ifndef _PMAX_VMPARAM_H_
 #define _PMAX_VMPARAM_H_
@@ -15,6 +15,6 @@
 #define        VM_FREELIST_DEFAULT     0
 #define        VM_FREELIST_FIRST8      1
 
-#define        VM_PHYSSEG_MAX          2
+#define        VM_PHYSSEG_MAX          16      /* 15 + 1 free lists */
 
 #endif /* !_PMAX_VMPARAM_H_ */
diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/pmax/dec_3max.c
--- a/sys/arch/pmax/pmax/dec_3max.c     Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/pmax/dec_3max.c     Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_3max.c,v 1.33 2001/08/22 06:59:39 nisimura Exp $ */
+/* $NetBSD: dec_3max.c,v 1.34 2001/08/24 15:33:16 mhitch Exp $ */
 
 /*
  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
@@ -73,7 +73,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_3max.c,v 1.33 2001/08/22 06:59:39 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_3max.c,v 1.34 2001/08/24 15:33:16 mhitch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -115,7 +115,7 @@
        platform.cons_init = dec_3max_cons_init;
        platform.iointr = dec_3max_intr;
        platform.intr_establish = dec_3max_intr_establish;
-       platform.memsize = memsize_scan;
+       platform.memsize = memsize_bitmap;
        /* no high resolution timer available */
 
        /* clear any memory errors */
diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/pmax/dec_3maxplus.c
--- a/sys/arch/pmax/pmax/dec_3maxplus.c Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/pmax/dec_3maxplus.c Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_3maxplus.c,v 1.44 2001/08/22 06:59:40 nisimura Exp $ */
+/* $NetBSD: dec_3maxplus.c,v 1.45 2001/08/24 15:33:16 mhitch Exp $ */
 
 /*
  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
@@ -73,7 +73,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_3maxplus.c,v 1.44 2001/08/22 06:59:40 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_3maxplus.c,v 1.45 2001/08/24 15:33:16 mhitch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -123,7 +123,7 @@
        platform.cons_init = dec_3maxplus_cons_init;
        platform.iointr = dec_3maxplus_intr;
        platform.intr_establish = dec_3maxplus_intr_establish;
-       platform.memsize = memsize_scan;
+       platform.memsize = memsize_bitmap;
        platform.clkread = kn03_clkread;
        /* 3MAX+ has IOASIC free-running high resolution timer */
 
diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/pmax/dec_3min.c
--- a/sys/arch/pmax/pmax/dec_3min.c     Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/pmax/dec_3min.c     Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_3min.c,v 1.46 2001/08/22 06:59:40 nisimura Exp $ */
+/* $NetBSD: dec_3min.c,v 1.47 2001/08/24 15:33:16 mhitch Exp $ */
 
 /*
  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
@@ -73,7 +73,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_3min.c,v 1.46 2001/08/22 06:59:40 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_3min.c,v 1.47 2001/08/24 15:33:16 mhitch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -126,7 +126,7 @@
        platform.cons_init = dec_3min_cons_init;
        platform.iointr = dec_3min_intr;
        platform.intr_establish = dec_3min_intr_establish;
-       platform.memsize = memsize_scan;
+       platform.memsize = memsize_bitmap;
        platform.clkread = kn02ba_clkread;
 
        /* clear any memory errors */
diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/pmax/dec_maxine.c
--- a/sys/arch/pmax/pmax/dec_maxine.c   Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/pmax/dec_maxine.c   Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_maxine.c,v 1.37 2001/08/22 06:59:41 nisimura Exp $ */
+/* $NetBSD: dec_maxine.c,v 1.38 2001/08/24 15:33:16 mhitch Exp $ */
 
 /*
  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
@@ -73,7 +73,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_maxine.c,v 1.37 2001/08/22 06:59:41 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_maxine.c,v 1.38 2001/08/24 15:33:16 mhitch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -123,7 +123,7 @@
        platform.cons_init = dec_maxine_cons_init;
        platform.iointr = dec_maxine_intr;
        platform.intr_establish = dec_maxine_intr_establish;
-       platform.memsize = memsize_scan;
+       platform.memsize = memsize_bitmap;
        platform.clkread = kn02ca_clkread;
        /* MAXINE has 1 microsec. free-running high resolution timer */
  
diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/pmax/machdep.c
--- a/sys/arch/pmax/pmax/machdep.c      Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/pmax/machdep.c      Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.193 2001/08/22 06:59:42 nisimura Exp $   */
+/*     $NetBSD: machdep.c,v 1.194 2001/08/24 15:33:16 mhitch Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.193 2001/08/22 06:59:42 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.194 2001/08/24 15:33:16 mhitch Exp $");
 
 #include "fs_mfs.h"
 #include "opt_ddb.h"
@@ -333,30 +333,27 @@
        physmem = (*platform.memsize)(kernend);
 
        /*
-        * Now that we know how much memory we have, initialize the
-        * mem cluster array.
-        */
-       mem_clusters[0].start = 0;              /* XXX is this correct? */
-       mem_clusters[0].size  = ctob(physmem);
-       mem_cluster_cnt = 1;
-
-       /*
         * Load the rest of the available pages into the VM system.
         * Put the first 8M of RAM onto a lower-priority free list, since
         * some TC boards (e.g. PixelStamp boards) are only able to DMA
         * into this region, and we want them to have a fighting chance of
         * allocating their DMA memory during autoconfiguration.
         */
-       first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
-       last = mem_clusters[0].start + mem_clusters[0].size;
-       if (last <= (8 * 1024 * 1024)) {
-               uvm_page_physload(atop(first), atop(last), atop(first),
-                   atop(last), VM_FREELIST_DEFAULT);
-       } else {
-               uvm_page_physload(atop(first), atop(8 * 1024 * 1024),
-                   atop(first), atop(8 * 1024 * 1024), VM_FREELIST_FIRST8);
-               uvm_page_physload(atop(8 * 1024 * 1024), atop(last),
-                   atop(8 * 1024 * 1024), atop(last), VM_FREELIST_DEFAULT);
+       for (i = 0, physmem = 0; i < mem_cluster_cnt; ++i) {
+               first = mem_clusters[i].start;
+               if (first == 0)
+                       first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
+               last = mem_clusters[i].start + mem_clusters[i].size;
+               physmem += atop(mem_clusters[i].size);
+               if (i != 0 || last <= (8 * 1024 * 1024)) {
+                       uvm_page_physload(atop(first), atop(last), atop(first),
+                           atop(last), VM_FREELIST_DEFAULT);
+               } else {
+                       uvm_page_physload(atop(first), atop(8 * 1024 * 1024),
+                           atop(first), atop(8 * 1024 * 1024), VM_FREELIST_FIRST8);
+                       uvm_page_physload(atop(8 * 1024 * 1024), atop(last),
+                           atop(8 * 1024 * 1024), atop(last), VM_FREELIST_DEFAULT);
+               }
        }
 
        /*
@@ -654,6 +651,14 @@
                mem++;
        }
 
+       /*
+        * Now that we know how much memory we have, initialize the
+        * mem cluster array.
+        */
+       mem_clusters[0].start = 0;              /* XXX is this correct? */
+       mem_clusters[0].size  = ctob(physmem);
+       mem_cluster_cnt = 1;
+
        /* clear any memory error conditions possibly caused by probe */
        (*platform.bus_reset)();
        return (mem);
@@ -666,8 +671,38 @@
 memsize_bitmap(first)
        caddr_t first;
 {
+       memmap *prom_memmap = (memmap *)first;
+       int i, mapbytes;
+       int segstart, curaddr, xsize, segnum;
 
-       panic("memsize_bitmap not implemented");
+       mapbytes = prom_getbitmap(prom_memmap);
+       if (mapbytes == 0)
+               return (memsize_scan(first));
+
+       segstart = curaddr = i = segnum = 0;
+       xsize = prom_memmap->pagesize * 8;
+       while (i < mapbytes) {
+               while (prom_memmap->bitmap[i] == 0xff && i < mapbytes) {
+                       ++i;
+                       curaddr += xsize;
+               }
+               if (curaddr > segstart) {
+                       mem_clusters[segnum].start = segstart;
+                       mem_clusters[segnum].size = curaddr - segstart;
+                       ++segnum;
+               }
+               while (i < mapbytes && prom_memmap->bitmap[i] != 0xff) {
+                       ++i;
+                       curaddr += xsize;
+               }
+               segstart = curaddr;
+       }
+       mem_cluster_cnt = segnum;
+       for (i = 0; i < segnum; ++i) {
+               printf("segment %2d start %08lx size %08lx\n", i,
+                   (long)mem_clusters[i].start, (long)mem_clusters[i].size);
+       }
+       return (mapbytes * 8);
 }
 
 /*
diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/pmax/machdep.h
--- a/sys/arch/pmax/pmax/machdep.h      Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/pmax/machdep.h      Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.h,v 1.8 2000/03/28 23:57:30 simonb Exp $ */
+/* $NetBSD: machdep.h,v 1.9 2001/08/24 15:33:17 mhitch Exp $ */
 
 /*
  * Copyright (c) 1998 Jonathan Stone.  All rights reserved.
@@ -33,6 +33,8 @@
 /* max memory for a model */
 extern int physmem_boardmax;   /* {model,simm}-specific bound on physmem */
 
+struct memmap;
+
 /* PROM callback routines - see pmax/promcall.c */
 void    prom_findcons __P((int *, int *, int *));
 void    prom_halt __P((int, char *)) __attribute__((__noreturn__));
@@ -40,3 +42,4 @@
 int     prom_scsiid __P((int));
 char   *prom_getenv __P((char *));
 int     prom_systype __P((void));
+int     prom_getbitmap __P((struct memmap *));
diff -r cc2e4956972b -r bfc0b498ac2d sys/arch/pmax/pmax/promcall.c
--- a/sys/arch/pmax/pmax/promcall.c     Fri Aug 24 15:28:47 2001 +0000
+++ b/sys/arch/pmax/pmax/promcall.c     Fri Aug 24 15:33:16 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: promcall.c,v 1.7 2000/03/30 14:45:13 simonb Exp $      */
+/*     $NetBSD: promcall.c,v 1.8 2001/08/24 15:33:17 mhitch Exp $      */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: promcall.c,v 1.7 2000/03/30 14:45:13 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promcall.c,v 1.8 2001/08/24 15:33:17 mhitch Exp $");



Home | Main Index | Thread Index | Old Index