Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386/i386 - Allocate memory map entry correctly to ...



details:   https://anonhg.NetBSD.org/src/rev/9e97e7cf42ea
branches:  trunk
changeset: 508801:9e97e7cf42ea
user:      kanaoka <kanaoka%NetBSD.org@localhost>
date:      Fri Apr 20 09:10:45 2001 +0000

description:
- Allocate memory map entry correctly to avoid Compatibilty Holes.
 - Update some comments.

 patch provided by: enami tsugutomo <enami%sm.sony.co.jp@localhost>
      suggested by: John Hawkinson <jhawk%MIT.EDU@localhost>

diffstat:

 sys/arch/i386/i386/machdep.c |  184 ++++++++++++++++++++++--------------------
 1 files changed, 96 insertions(+), 88 deletions(-)

diffs (214 lines):

diff -r 4f7aba2c346e -r 9e97e7cf42ea sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Fri Apr 20 07:58:04 2001 +0000
+++ b/sys/arch/i386/i386/machdep.c      Fri Apr 20 09:10:45 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.432 2001/04/18 05:44:10 kanaoka Exp $    */
+/*     $NetBSD: machdep.c,v 1.433 2001/04/20 09:10:45 kanaoka Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -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,6 +1793,77 @@
 
 #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
-                        */
-                       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,
-                                   bim->entry[x].type);
-                               continue;
-                       }
-
-                       /*
-                        * XXX Chop the last page off the size so that
-                        * XXX it can fit in avail_end.
+                        *   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_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,
+                       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);
-                       }
-
-                       /*
-                        * 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++;
+                               add_mem_cluster(0x100000, seg_end,
+                                   bim->entry[x].type);
+                       } else
+                               add_mem_cluster(seg_start, seg_end,
+                                   bim->entry[x].type);
                }
        }
 #endif /* ! REALBASEMEM && ! REALEXTMEM */



Home | Main Index | Thread Index | Old Index