Subject: Re: CVS commit: syssrc
To: None <enami@sm.sony.co.jp>
From: Masanori Kanaoka <kanaoka@ann.hi-ho.ne.jp>
List: source-changes
Date: 04/20/2001 12:48:29
----Next_Part(Fri_Apr_20_12:48:29_2001_272)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
Subject: Re: CVS commit: syssrc
Message-ID: <tkrg0f5ffgi.fsf@parity-error.sm.sony.co.jp>
$ + seg_end shouldn't be re-calcurated by using
$ bim->entry[x].size after adjusting seg_start. it
$ overruns.
$
$ + setting seg_end to 0x9ffff is wrong since it will be
$ truncated to page boundary later. 0xa0000 is fine.
$
$ + is there no case that the hole is completely
$ included the memory range? The fix just throws
$ any pages before the hole in such case. If there is
$ implicit assumption that there is no such case, it
$ should be commented.
Thanks for pointing my wrong and sending ELEGANT patch.
I applied your patch, it works fine for me with Toshiba Satellite2550X.
I update a part of comment in your patch.I attach next patch.
If no problems,I will commit this patch later.
Any suggestion?
Thanks a lot jhawk@MIT.EDU, enami@sm.sony.co.jp for your help!!
---
Masanori Kanaoka kanaoka@ann.hi-ho.ne.jp
----Next_Part(Fri_Apr_20_12:48:29_2001_272)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="machdep.diff"
Index: machdep.c
===================================================================
RCS file: /ftp/cvs/syssrc/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.432
diff -u -r1.432 machdep.c
--- machdep.c 2001/04/18 05:44:10 1.432
+++ machdep.c 2001/04/20 03:10:35
@@ -234,6 +234,10 @@
void identifycpu __P((void));
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) */
+
const struct i386_cache_info *cpu_itlb_info, *cpu_dtlb_info, *cpu_icache_info,
*cpu_dcache_info, *cpu_l2cache_info;
@@ -1789,7 +1793,78 @@
#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;
{
@@ -1875,95 +1950,28 @@
seg_end = bim->entry[x].addr + bim->entry[x].size;
/*
- * XXX: avoid Compatibility Holes
- * PC-compatible frame buffer 0xa0000-0xbffff
- * adapter ROM space 0xc0000-0xdffff
- * system BIOS space 0xe0000-0xfffff
+ * 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.
*/
- if (seg_start >= 0xa0000) {
- if (seg_end <= 0xfffff) {
- printf("WARNING: skipping "
- "Compatibility Holes...\n ");
- continue;
- } else {
- if (seg_start <= 0xfffff) {
- seg_start = 0x100000;
- seg_end = seg_start
- + bim->entry[x].size;
- }
- }
- } else {
- if (seg_end >= 0xa0000 && seg_end <= 0xfffff) {
- seg_end = 0x9ffff;
- }
- if (seg_end >= 0xfffff) {
- seg_start = 0x100000;
- seg_end = seg_start
- + bim->entry[x].size;
- }
- }
-
- if (seg_end > 0x100000000ULL) {
- printf("WARNING: skipping large "
- "memory map entry: "
- "0x%qx/0x%qx/0x%x\n",
- bim->entry[x].addr,
- bim->entry[x].size,
+ 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);
- 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;
- }
-
- /*
- * 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 %d "
- "(0x%qx/0x%qx/0x%x) FROM "
- "IOMEM EXTENT MAP!\n",
- x, seg_start, seg_end - seg_start,
+ add_mem_cluster(0x100000, seg_end,
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++;
+ } else
+ add_mem_cluster(seg_start, seg_end,
+ bim->entry[x].type);
}
}
#endif /* ! REALBASEMEM && ! REALEXTMEM */
----Next_Part(Fri_Apr_20_12:48:29_2001_272)----