A memory patch to the 2.3.17 memory detection stuff...

david parsons (orc@pell.portland.or.us)
Thu, 9 Sep 1999 00:06:01 -0700


... synthesised from a bunch of input.

It has a tweak in it to not accept e820 input when the map contains only
one entry.

It has the memory types replaced with symbolic constants, and the debugging
printk's put back in.

And it has the addr/end scheme that Linus suggested.

It's been tested on a grand total of two machines here (and it works for
the both of them; 2 scales to 10 million without any trouble, right?)
but I'd be pleased to have it tested and/or placed into 2.3.18.

-david parsons "Now I guess I can try to figure out why libc 5'ed binaries
Just Don't Do It on my machine :-("

--- linux-2.3.17-orig/include/asm-i386/e820.h Mon Aug 30 10:47:02 1999
+++ linux-2.3.17/include/asm-i386/e820.h Wed Sep 8 20:26:06 1999
@@ -16,6 +16,11 @@
#define E820MAX 32 /* number of entries in E820MAP */
#define E820NR 0x1e8 /* # entries in E820MAP */

+/* for e820map.map[].type */
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3
+
#define HIGH_MEMORY (1024*1024)

#ifndef __ASSEMBLY__
--- linux-2.3.17-orig/arch/i386/mm/init.c Wed Sep 8 20:19:51 1999
+++ linux-2.3.17/arch/i386/mm/init.c Wed Sep 8 20:50:59 1999
@@ -414,25 +414,23 @@
for (avail = i = 0; i < e820.nr_map; i++) {
unsigned long addr, end, size;

- if (e820.map[i].type != 1) /* not usable memory */
+ if (e820.map[i].type != E820_RAM) /* not usable memory */
continue;
addr = e820.map[i].addr;
size = e820.map[i].size;

- /* Overflow large memory reasonably gracefully */
+ /* Silently ignore memory regions starting above 4gb */
if (addr != e820.map[i].addr)
continue;

printk("memory region: %luk @ %08lx\n", size >> 10, addr );

/* Make sure we don't get fractional pages */
- end = (addr + size) & PAGE_MASK;
- addr = PAGE_ALIGN(addr);
- if (end <= addr)
- continue;
+ end = PAGE_OFFSET + ((addr + size) & PAGE_MASK);
+ addr= PAGE_OFFSET + PAGE_ALIGN(addr);
+
+ for ( ; addr < end; addr += PAGE_SIZE) {

- size = end - addr;
- for (addr = addr + PAGE_OFFSET ; size ; addr += PAGE_SIZE, size -= PAGE_SIZE) {
/* this little bit of grossness is for dealing
* with memory borrowing for system bookkeeping
* (smp stacks, zero page, kernel code, etc)
@@ -446,14 +444,11 @@
* in any case, we don't want to hack mem_map
* entries above end_mem.
*/
- if ( addr < start_low_mem )
- continue;
- if ( addr > end_mem )
- continue;
- if ( addr >= HIGH_MEMORY && addr <= start_mem )
+ if ( (addr < start_low_mem)
+ || (addr >= HIGH_MEMORY && addr <= start_mem)
+ || (addr > end_mem) )
continue;

- avail++;
clear_bit(PG_reserved, &mem_map[MAP_NR(addr)].flags);
}
}

-
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/