Subject: Re: Cranky machine...
To: None <entropy@tappedin.com>
From: Masanori Kanaoka <kanaoka@ann.hi-ho.ne.jp>
List: port-i386
Date: 07/06/2001 14:53:27
Hi,

       From: maximum entropy <entropy@tappedin.com>
    Subject: Re: Cranky machine...
      Date : Thu, 05 Jul 2001 22:46:16 -0400 (EDT)

$ Now the machine boots 1.5W.  But these options were never needed
$ before on this machine (which has been running NetBSD since
$ 1.2something.)  I strongly suspect that a bug has been introduced into
$ the memory probe routines after 1.5.

kern/13915 also had same problem.It said "April-19 kernel boot".

Next patch is reverting only memory probe routines to April-19. 
How about trying next patch?

Regards!
---
 Masanori Kanaoka	kanaoka@ann.hi-ho.ne.jp

Index: machdep.c
===================================================================
RCS file: /ftp/cvs/syssrc/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.446
diff -u -r1.446 machdep.c
--- machdep.c	2001/06/19 15:54:48	1.446
+++ machdep.c	2001/07/06 05:38:58
@@ -235,9 +235,6 @@
 void	identifycpu __P((struct cpu_info *));
 void	init386 __P((paddr_t));
 
-#if !defined(REALBASEMEM) && !defined(REALEXTMEM)
-void	add_mem_cluster	__P((u_int64_t, u_int64_t, u_int32_t));
-#endif /* !defnied(REALBASEMEM) && !defined(REALEXTMEM) */
 
 /*
  * Map Brand ID from cpuid instruction to brand name.
@@ -2137,77 +2134,7 @@
 
 #define	KBTOB(x)	((size_t)(x) * 1024UL)
 
-#if !defined(REALBASEMEM) && !defined(REALEXTMEM)
-void
-add_mem_cluster(seg_start, seg_end, type)
-	u_int64_t seg_start, seg_end;
-	u_int32_t type;
-{
-	extern struct extent *iomem_ex;
-
-	if (seg_end > 0x100000000ULL) {
-		printf("WARNING: skipping large "
-		    "memory map entry: "
-		    "0x%qx/0x%qx/0x%x\n",
-		    seg_start,
-		    (seg_end - seg_start),
-		    type);
-		return;
-	}
-
-	/*
-	 * XXX Chop the last page off the size so that
-	 * XXX it can fit in avail_end.
-	 */
-	if (seg_end == 0x100000000ULL)
-		seg_end -= PAGE_SIZE;
-
-	if (seg_end <= seg_start)
-		return;
-
-	/*
-	 * Allocate the physical addresses used by RAM
-	 * from the iomem extent map.  This is done before
-	 * the addresses are page rounded just to make
-	 * sure we get them all.
-	 */
-	if (extent_alloc_region(iomem_ex, seg_start,
-	    seg_end - seg_start, EX_NOWAIT)) {
-		/* XXX What should we do? */
-		printf("WARNING: CAN'T ALLOCATE "
-		    "MEMORY SEGMENT "
-		    "(0x%qx/0x%qx/0x%x) FROM "
-		    "IOMEM EXTENT MAP!\n",
-		    seg_start, seg_end - seg_start, type);
-	}
-
-	/*
-	 * If it's not free memory, skip it.
-	 */
-	if (type != BIM_Memory)
-		return;
-
-	/* XXX XXX XXX */
-	if (mem_cluster_cnt >= VM_PHYSSEG_MAX)
-		panic("init386: too many memory segments");
 
-	seg_start = round_page(seg_start);
-	seg_end = trunc_page(seg_end);
-
-	if (seg_start == seg_end)
-		return;
-
-	mem_clusters[mem_cluster_cnt].start = seg_start;
-	mem_clusters[mem_cluster_cnt].size =
-	    seg_end - seg_start;
-
-	if (avail_end < seg_end)
-		avail_end = seg_end;
-	physmem += atop(mem_clusters[mem_cluster_cnt].size);
-	mem_cluster_cnt++;
-}
-#endif /* !defined(REALBASEMEM) && !defined(REALEXTMEM) */
-
 void
 init386(first_avail)
 	vaddr_t first_avail;
@@ -2304,29 +2231,68 @@
 			seg_start = bim->entry[x].addr;
 			seg_end = bim->entry[x].addr + bim->entry[x].size;
 
+			if (seg_end > 0x100000000ULL) {
+				printf("WARNING: skipping large "
+		    			"memory map entry: "
+		    			"0x%qx/0x%qx/0x%x\n",
+		    			seg_start,
+		    			(seg_end - seg_start),
+		    			bim->entry[x].type);
+				continue;
+			}
+
+			/*
+			 * XXX Chop the last page off the size so that
+			 * XXX it can fit in avail_end.
+			 */
+			if (seg_end == 0x100000000ULL) {
+				seg_end -= PAGE_SIZE;
+				if (seg_end <= seg_start)
+					continue;
+			}
+
 			/*
-			 *   Avoid Compatibility Holes.
-			 * XXX  Holes within memory space that allow access
-			 * XXX to be directed to the PC-compatible frame buffer
-			 * XXX (0xa0000-0xbffff),to adapter ROM space 
-			 * XXX (0xc0000-0xdffff), and to system BIOS space
-			 * XXX (0xe0000-0xfffff).
-			 * XXX  Some laptop(for example,Toshiba Satellite2550X)
-			 * XXX report this area and occurred problems,
-			 * XXX so we avoid this area.
+			 * Allocate the physical addresses used by RAM
+			 * from the iomem extent map.  This is done before
+			 * the addresses are page rounded just to make
+			 * sure we get them all.
 			 */
-			if (seg_start < 0x100000 && seg_end > 0xa0000) {
-				printf("WARNING: memory map entry overlaps "
-				    "with ``Compatibility Holes'': "
-				    "0x%qx/0x%qx/0x%x\n", seg_start,
-				    seg_end - seg_start, bim->entry[x].type);
-				add_mem_cluster(seg_start, 0xa0000,
-				    bim->entry[x].type);
-				add_mem_cluster(0x100000, seg_end,
-				    bim->entry[x].type);
-			} else
-				add_mem_cluster(seg_start, seg_end,
-				    bim->entry[x].type);
+			if (extent_alloc_region(iomem_ex, seg_start,
+	    			seg_end - seg_start, EX_NOWAIT)) {
+				/* XXX What should we do? */
+				printf("WARNING: CAN'T ALLOCATE "
+		    			"MEMORY SEGMENT "
+		    			"(0x%qx/0x%qx/0x%x) FROM "
+		    			"IOMEM EXTENT MAP!\n",
+		    			seg_start, 
+					seg_end - seg_start, 
+					bim->entry[x].type);
+			}
+
+			/*
+			 * If it's not free memory, skip it.
+	 		 */
+			if (bim->entry[x].type != BIM_Memory)
+				continue;
+
+			/* XXX XXX XXX */
+			if (mem_cluster_cnt >= VM_PHYSSEG_MAX)
+				panic("init386: too many memory segments");
+
+			seg_start = round_page(seg_start);
+			seg_end = trunc_page(seg_end);
+
+			if (seg_start == seg_end)
+				continue;
+
+			mem_clusters[mem_cluster_cnt].start = seg_start;
+			mem_clusters[mem_cluster_cnt].size =
+	    			seg_end - seg_start;
+
+			if (avail_end < seg_end)
+				avail_end = seg_end;
+			physmem += atop(mem_clusters[mem_cluster_cnt].size);
+			mem_cluster_cnt++;
 		}
 	}
 #endif /* ! REALBASEMEM && ! REALEXTMEM */