Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Simplify x86_add_cluster.



details:   https://anonhg.NetBSD.org/src/rev/ac97866bce03
branches:  trunk
changeset: 346526:ac97866bce03
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Jul 17 10:46:43 2016 +0000

description:
Simplify x86_add_cluster.

diffstat:

 sys/arch/x86/x86/x86_machdep.c |  53 +++++++++++++++++------------------------
 1 files changed, 22 insertions(+), 31 deletions(-)

diffs (142 lines):

diff -r bcdc9a42526d -r ac97866bce03 sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c    Sun Jul 17 02:48:07 2016 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c    Sun Jul 17 10:46:43 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_machdep.c,v 1.73 2016/07/16 17:13:25 maxv Exp $    */
+/*     $NetBSD: x86_machdep.c,v 1.74 2016/07/17 10:46:43 maxv Exp $    */
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.73 2016/07/16 17:13:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.74 2016/07/17 10:46:43 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -501,8 +501,7 @@
 }
 
 static int
-x86_add_cluster(phys_ram_seg_t *seg_clusters, int seg_cluster_cnt,
-    struct extent *iomem_ex, uint64_t seg_start, uint64_t seg_end,
+x86_add_cluster(struct extent *iomem_ex, uint64_t seg_start, uint64_t seg_end,
     uint32_t type)
 {
        uint64_t new_physmem = 0;
@@ -523,7 +522,7 @@
                aprint_verbose("WARNING: skipping large memory map entry: "
                    "0x%"PRIx64"/0x%"PRIx64"/0x%x\n",
                    seg_start, (seg_end - seg_start), type);
-               return seg_cluster_cnt;
+               return 0;
        }
 
        /*
@@ -533,16 +532,16 @@
                seg_end -= PAGE_SIZE;
 
        if (seg_end <= seg_start)
-               return seg_cluster_cnt;
+               return 0;
 
-       for (i = 0; i < seg_cluster_cnt; i++) {
-               cluster = &seg_clusters[i];
+       for (i = 0; i < mem_cluster_cnt; i++) {
+               cluster = &mem_clusters[i];
                if ((cluster->start == round_page(seg_start)) &&
                    (cluster->size == trunc_page(seg_end) - cluster->start)) {
 #ifdef DEBUG_MEMLOAD
                        printf("WARNING: skipping duplicate segment entry\n");
 #endif
-                       return seg_cluster_cnt;
+                       return 0;
                }
        }
 
@@ -566,24 +565,22 @@
                            "(0x%"PRIx64"/0x%"PRIx64"/0x%x) FROM "
                            "IOMEM EXTENT MAP!\n",
                            seg_start, seg_end - seg_start, type);
-                       return seg_cluster_cnt;
+                       return 0;
                }
        }
 
-       /*
-        * If it's not free memory, skip it.
-        */
+       /* If it's not free memory, skip it. */
        if (type != BIM_Memory)
-               return seg_cluster_cnt;
+               return 0;
 
-       /* XXX XXX XXX */
-       if (seg_cluster_cnt >= VM_PHYSSEG_MAX)
+       if (mem_cluster_cnt >= VM_PHYSSEG_MAX) {
                panic("%s: too many memory segments (increase VM_PHYSSEG_MAX)",
                        __func__);
+       }
 
 #ifdef PHYSMEM_MAX_ADDR
        if (seg_start >= MBTOB(PHYSMEM_MAX_ADDR))
-               return seg_cluster_cnt;
+               return 0;
        if (seg_end > MBTOB(PHYSMEM_MAX_ADDR))
                seg_end = MBTOB(PHYSMEM_MAX_ADDR);
 #endif
@@ -592,9 +589,9 @@
        seg_end = trunc_page(seg_end);
 
        if (seg_start == seg_end)
-               return seg_cluster_cnt;
+               return 0;
 
-       cluster = &seg_clusters[seg_cluster_cnt];
+       cluster = &mem_clusters[mem_cluster_cnt];
        cluster->start = seg_start;
        if (iomem_ex != NULL)
                new_physmem = physmem + atop(seg_end - seg_start);
@@ -602,7 +599,7 @@
 #ifdef PHYSMEM_MAX_SIZE
        if (iomem_ex != NULL) {
                if (physmem >= atop(MBTOB(PHYSMEM_MAX_SIZE)))
-                       return seg_cluster_cnt;
+                       return 0;
                if (new_physmem > atop(MBTOB(PHYSMEM_MAX_SIZE))) {
                        seg_end = seg_start + MBTOB(PHYSMEM_MAX_SIZE) - ptoa(physmem);
                        new_physmem = atop(MBTOB(PHYSMEM_MAX_SIZE));
@@ -617,9 +614,9 @@
                        avail_end = seg_end;
                physmem = new_physmem;
        }
-       seg_cluster_cnt++;
+       mem_cluster_cnt++;
 
-       return seg_cluster_cnt;
+       return 0;
 }
 
 static int
@@ -680,16 +677,10 @@
                            "0x%"PRIx64"/0x%"PRIx64"/0x%x\n", seg_start,
                            seg_end - seg_start, type);
 
-                       mem_cluster_cnt = x86_add_cluster(mem_clusters,
-                           mem_cluster_cnt, iomem_ex, seg_start, 0xa0000,
-                           type);
-                       mem_cluster_cnt = x86_add_cluster(mem_clusters,
-                           mem_cluster_cnt, iomem_ex, 0x100000, seg_end,
-                           type);
+                       x86_add_cluster(iomem_ex, seg_start, 0xa0000, type);
+                       x86_add_cluster(iomem_ex, 0x100000, seg_end, type);
                } else {
-                       mem_cluster_cnt = x86_add_cluster(mem_clusters,
-                           mem_cluster_cnt, iomem_ex, seg_start, seg_end,
-                           type);
+                       x86_add_cluster(iomem_ex, seg_start, seg_end, type);
                }
        }
 



Home | Main Index | Thread Index | Old Index