[eros-cvs] cvs commit: eros/src/base/sys/arch/i486/boot memory.c

shap@eros.cs.jhu.edu shap@eros.cs.jhu.edu
Wed, 1 Aug 2001 11:04:56 -0400


shap        01/08/01 11:04:56

  Modified:    src/base/sys/arch/i486/boot memory.c
  Log:
  Artificially limit max memory to 64M for now.

Revision  Changes    Path
1.5       +38 -1     eros/src/base/sys/arch/i486/boot/memory.c

Index: memory.c
===================================================================
RCS file: /cvs/eros/src/base/sys/arch/i486/boot/memory.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- memory.c	2001/07/25 04:50:07	1.4
+++ memory.c	2001/08/01 15:04:56	1.5
@@ -23,6 +23,8 @@
 #include "boot-asm.h"
 #include "debug.h"
 
+#define MEM_LIMIT (64 * 1024 * 1024)
+
 #define align_down(addr, al) (((uint32_t)(addr)) & ~((al)-1))
 
 /* This is the type of the MemInfo structure returned by the Uruk
@@ -126,6 +128,22 @@
 
 	top = base + len;
 	
+#ifdef MEM_LIMIT
+	/* FIX: Ad hoc constraint until I fix the kernel memory
+	   subsystem. */ 
+	if (bmi.Type == AddrRangeMemory) {
+	  if (base >= MEM_LIMIT)
+	    continue;
+
+	  if (top > MEM_LIMIT)
+	    top = MEM_LIMIT;
+
+	  len = top - base;
+	  if (len == 0)
+	    continue;
+	}
+#endif
+
 	if (bmi.Type == AddrRangeMemory)
 	  addrType = "Mem ";
 	else if (bmi.Type == AddrRangeReserved)
@@ -231,6 +249,7 @@
       if (bmi.len > 0) {
 	kpa_t base;
 	kpa_t len;
+	kpa_t top;
 
 	base = bmi.BaseAddrHigh;
 	len = bmi.LengthHigh;
@@ -241,8 +260,26 @@
 	base |= bmi.BaseAddrLow;
 	len |= bmi.LengthLow;
 
+	top = base + len;
+	
+#ifdef MEM_LIMIT
+	/* FIX: Ad hoc constraint until I fix the kernel memory
+	   subsystem. */ 
+	if (bmi.Type == AddrRangeMemory) {
+	  if (base >= MEM_LIMIT)
+	    continue;
+
+	  if (top > MEM_LIMIT)
+	    top = MEM_LIMIT;
+
+	  len = top - base;
+	  if (len == 0)
+	    continue;
+	}
+#endif
+
 	mi[nRegion].base = base;
-	mi[nRegion].bound = base + len;
+	mi[nRegion].bound = top;
 
 	switch(bmi.Type) {
 	case AddrRangeMemory: