Dynamic 3GB support, part 1. Only multiboot.S remains to be changed, all other parts of the Kernel now used KERNEL_BASE based on the command-line (Please don't use /3gb if you don't compile 3GB)
Modified: trunk/reactos/config
Modified: trunk/reactos/ntoskrnl/include/internal/i386/mm.h
Modified: trunk/reactos/ntoskrnl/ke/main.c
Modified: trunk/reactos/ntoskrnl/mm/mminit.c

Modified: trunk/reactos/config
--- trunk/reactos/config	2005-01-26 00:43:49 UTC (rev 13304)
+++ trunk/reactos/config	2005-01-26 05:00:08 UTC (rev 13305)
@@ -45,7 +45,7 @@
 #
 # whether to use a 3GB User, 1GB Kernel memory map
 #
-3GB := 1
+3GB := 0
 
 #
 # Which version of NDIS do we support up to?

Modified: trunk/reactos/ntoskrnl/include/internal/i386/mm.h
--- trunk/reactos/ntoskrnl/include/internal/i386/mm.h	2005-01-26 00:43:49 UTC (rev 13304)
+++ trunk/reactos/ntoskrnl/include/internal/i386/mm.h	2005-01-26 05:00:08 UTC (rev 13305)
@@ -23,14 +23,10 @@
 #endif
 
 
-#ifdef __3GB__
-#define KERNEL_BASE        (0xC0000000)
-#else
-#define KERNEL_BASE        (0x80000000)
-#endif
-
 #ifndef __ASM__
 
+#define KERNEL_BASE        (ULONG)MmSystemRangeStart
+
 #if defined(__GNUC__)
 
 #define FLUSH_TLB   {				\
@@ -65,6 +61,14 @@
 #define PAGE_MASK(x)		((x)&(~0xfff))
 #define PAE_PAGE_MASK(x)	((x)&(~0xfffLL))
 
+#else 
+
+#ifdef __3GB__
+#define KERNEL_BASE        (0xC0000000)
+#else
+#define KERNEL_BASE        (0x80000000)
+#endif
+
 #endif /* ASSEMBLER */
 
 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_MM_H */

Modified: trunk/reactos/ntoskrnl/ke/main.c
--- trunk/reactos/ntoskrnl/ke/main.c	2005-01-26 00:43:49 UTC (rev 13304)
+++ trunk/reactos/ntoskrnl/ke/main.c	2005-01-26 05:00:08 UTC (rev 13305)
@@ -691,6 +691,7 @@
 
   /* Create the SystemRoot symbolic link */
   CPRINT("CommandLine: %s\n", (PCHAR)KeLoaderBlock.CommandLine);
+  DPRINT1("MmSystemRangeStart: 0x%x\n", MmSystemRangeStart);
   Status = IoCreateSystemRootLink((PCHAR)KeLoaderBlock.CommandLine);
   if (!NT_SUCCESS(Status))
   {
@@ -953,6 +954,18 @@
     }
   KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine;
   
+  /* Gotta check 3GB setting right *here* before we use KERNEL_BASE! */
+  if (!_strnicmp(KeLoaderCommandLine, "3GB", 3)) {
+  
+    /* Use 3GB */
+    MmSystemRangeStart = (PVOID)0xC0000000;
+  
+  } else {
+   
+    /* Use 2GB */
+    MmSystemRangeStart = (PVOID)0x80000000;
+  }
+  
   strcpy(KeLoaderModuleStrings[0], "ntoskrnl.exe");
   KeLoaderModules[0].String = (ULONG)KeLoaderModuleStrings[0];
   KeLoaderModules[0].ModStart = KERNEL_BASE;

Modified: trunk/reactos/ntoskrnl/mm/mminit.c
--- trunk/reactos/ntoskrnl/mm/mminit.c	2005-01-26 00:43:49 UTC (rev 13304)
+++ trunk/reactos/ntoskrnl/mm/mminit.c	2005-01-26 05:00:08 UTC (rev 13305)
@@ -324,10 +324,7 @@
       KeLoaderBlock.MemHigher = (MaxMem - 1) * 1024;
    }
 
-   /*
-    * FIXME: Set this based on the system command line
-    */
-   MmSystemRangeStart = (PVOID)KERNEL_BASE; // 0xC0000000
+   /* Set memory limits */
    MmUserProbeAddress = 0x7fff0000;
    MmHighestUserAddress = (PVOID)0x7ffeffff;