Re: The other half of the patch to the fancy memory patch

david parsons (o.r.c@p.e.l.l.p.o.r.t.l.a.n.d.o.r.u.s)
9 Sep 1999 13:20:01 -0700


In article <linux.kernel.199909091740.KAA06160@pell.portland.or.us>,
david parsons <orc@pell.portland.or.us> wrote:
>
>I didn't include the differences against arch/i386/kernel/setup.c in
>the patch I mailed last night. This means that Pavel's tweak for
>not applying the e820 memory map unless we read it correctly (and
>the verbosity explaining what the full memory map is like) wouldn't
>actually work with that patch.

And, for those of you who might want to actually USE this patch,
here it is again in patch(1)able format.

____
david parsons \bi/ I blame my general flakiness on C++
\/

--- linux-2.3.17-orig/arch/i386/kernel/setup.c Wed Sep 8 20:19:51 1999
+++ linux-2.3.17/arch/i386/kernel/setup.c Thu Sep 9 08:16:09 1999
@@ -401,18 +401,49 @@

void __init setup_memory_region(void)
{
+#define E820_DEBUG 1
+#ifdef E820_DEBUG
+ int i;
+#endif
+
/*
* If we're lucky and live on a modern system, the setup code
* will have given us a memory map that we can use to properly
* set up memory. If we aren't, we'll fake a memory map.
+ *
+ * We check to see that the memory map contains at least 2 elements
+ * before we'll use it, because the detection code in setup.S may
+ * not be perfect and most every PC known to man has two memory
+ * regions: one from 0 to 640k, and one from 1mb up. (The IBM
+ * thinkpad 560x, for example, does not cooperate with the memory
+ * detection code.)
*/
- if (E820_MAP_NR) {
+ if (E820_MAP_NR > 1) {
/* got a memory map; copy it into a safe place.
*/
e820.nr_map = E820_MAP_NR;
if (e820.nr_map > E820MAX)
e820.nr_map = E820MAX;
memcpy(e820.map, E820_MAP, e820.nr_map * sizeof e820.map[0]);
+#ifdef E820_DEBUG
+ for (i=0; i < e820.nr_map; i++) {
+ printk("e820: %ld @ %08lx ",
+ (unsigned long)(e820.map[i].size),
+ (unsigned long)(e820.map[i].addr));
+ switch (e820.map[i].type) {
+ case E820_RAM: printk("(usable)\n");
+ break;
+ case E820_RESERVED:
+ printk("(reserved)\n");
+ break;
+ case E820_ACPI:
+ printk("(ACPI data)\n");
+ break;
+ default: printk("type %lu\n", e820.map[i].type);
+ break;
+ }
+ }
+#endif
}
else {
/* otherwise fake a memory map; one section from 0k->640k,
@@ -422,8 +453,8 @@

mem_size = (ALT_MEM_K < EXT_MEM_K) ? EXT_MEM_K : ALT_MEM_K;

- add_memory_region(0, LOWMEMSIZE(), 1);
- add_memory_region(HIGH_MEMORY, mem_size << 10, 1);
+ add_memory_region(0, LOWMEMSIZE(), E820_RAM);
+ add_memory_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
}
} /* setup_memory_region */

@@ -503,7 +534,7 @@
*/
e820.nr_map = 0;
usermem = 1;
- add_memory_region(0, LOWMEMSIZE(), 1);
+ add_memory_region(0, LOWMEMSIZE(), E820_RAM);
}
mem_size = memparse(from+4, &from);
if (*from == '@')
@@ -512,7 +543,7 @@
start_at = HIGH_MEMORY;
mem_size -= HIGH_MEMORY;
}
- add_memory_region(start_at, mem_size, 1);
+ add_memory_region(start_at, mem_size, E820_RAM);
}
}
c = *(from++);
@@ -531,7 +562,7 @@
memory_end = 0;
for (i=0; i < e820.nr_map; i++) {
/* RAM? */
- if (e820.map[i].type == 1) {
+ if (e820.map[i].type == E820_RAM) {
unsigned long end = e820.map[i].addr + e820.map[i].size;

if (end > memory_end)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/