Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/arch/powerpc/powerpc Pullup 1.6 [tsubai]:



details:   https://anonhg.NetBSD.org/src/rev/e45f437c22ba
branches:  netbsd-1-5
changeset: 489914:e45f437c22ba
user:      tv <tv%NetBSD.org@localhost>
date:      Wed Oct 18 17:14:11 2000 +0000

description:
Pullup 1.6 [tsubai]:
In mem_regions(), remove zero sized entry returned from OF.
Since this function uses size == 0 to delimiter, valid entries must not
contain 0 in size field.

diffstat:

 sys/arch/powerpc/powerpc/ofw_machdep.c |  50 ++++++++++++++++++++++++++-------
 1 files changed, 39 insertions(+), 11 deletions(-)

diffs (69 lines):

diff -r dac8eac13a66 -r e45f437c22ba sys/arch/powerpc/powerpc/ofw_machdep.c
--- a/sys/arch/powerpc/powerpc/ofw_machdep.c    Wed Oct 18 17:13:00 2000 +0000
+++ b/sys/arch/powerpc/powerpc/ofw_machdep.c    Wed Oct 18 17:14:11 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ofw_machdep.c,v 1.5 2000/05/23 13:25:43 tsubai Exp $   */
+/*     $NetBSD: ofw_machdep.c,v 1.5.4.1 2000/10/18 17:14:11 tv Exp $   */
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -60,21 +60,49 @@
 mem_regions(memp, availp)
        struct mem_region **memp, **availp;
 {
-       int phandle, i, j, cnt;
-       
+       int phandle, i, cnt;
+
        /*
         * Get memory.
         */
-       if ((phandle = OF_finddevice("/memory")) == -1
-           || OF_getprop(phandle, "reg",
-                         OFmem, sizeof OFmem[0] * OFMEM_REGIONS)
-              <= 0
-           || OF_getprop(phandle, "available",
-                         OFavail, sizeof OFavail[0] * OFMEM_REGIONS)
-              <= 0)
-               panic("no memory?");
+       if ((phandle = OF_finddevice("/memory")) == -1)
+               goto error;
+
+       bzero(OFmem, sizeof OFmem);
+       cnt = OF_getprop(phandle, "reg",
+               OFmem, sizeof OFmem[0] * OFMEM_REGIONS);
+       if (cnt <= 0)
+               goto error;
+
+       /* Remove zero sized entry in the returned data. */
+       cnt /= sizeof OFmem[0];
+       for (i = 0; i < cnt; i++)
+               if (OFmem[i].size == 0) {
+                       bcopy(&OFmem[i + 1], &OFmem[i],
+                             (cnt - i) * sizeof OFmem[0]);
+                       cnt--;
+               }
+
+       bzero(OFavail, sizeof OFavail);
+       cnt = OF_getprop(phandle, "available",
+               OFavail, sizeof OFavail[0] * OFMEM_REGIONS);
+       if (cnt <= 0)
+               goto error;
+
+       cnt /= sizeof OFavail[0];
+       for (i = 0; i < cnt; i++)
+               if (OFavail[i].size == 0) {
+                       bcopy(&OFavail[i + 1], &OFavail[i],
+                             (cnt - i) * sizeof OFavail[0]);
+                       cnt--;
+               }
+
        *memp = OFmem;
        *availp = OFavail;
+       return;
+
+error:
+       panic("no memory?");
 }
 
 void



Home | Main Index | Thread Index | Old Index