Merge 15334:15712 from trunk (but don't activate xmlbuild)
Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xboxcons.c
Modified: branches/xen/reactos/boot/freeldr/freeldr/freeldr.c
Added: branches/xen/reactos/boot/freeldr/freeldr/freeldr.xml
Added: branches/xen/reactos/boot/freeldr/freeldr/freeldr_base.xml
Added: branches/xen/reactos/boot/freeldr/freeldr/freeldr_base64k.xml
Added: branches/xen/reactos/boot/freeldr/freeldr/freeldr_main.xml
Added: branches/xen/reactos/boot/freeldr/freeldr/freeldr_startup.xml
Modified: branches/xen/reactos/boot/freeldr/freeldr/mm/mm.c
Modified: branches/xen/reactos/boot/freeldr/freeldr/reactos/reactos.c
Modified: branches/xen/reactos/boot/freeldr/freeldr/reactos/setupldr.c
Added: branches/xen/reactos/boot/freeldr/freeldr/setupldr.xml
Added: branches/xen/reactos/boot/freeldr/freeldr/setupldr_main.xml
Modified: branches/xen/reactos/boot/freeldr/freeldr/ui/ui.c
Property changes on: branches/xen/reactos/boot/freeldr/freeldr
___________________________________________________________________
Name: lastmerge
   - 15334
   + 15712

Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
--- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/hardware.c	2005-06-01 01:59:05 UTC (rev 15712)
+++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/hardware.c	2005-06-01 16:27:21 UTC (rev 15713)
@@ -1715,7 +1715,7 @@
     /* Set 'Identifier' value */
     strcpy(Buffer,
 	   "PCAT_ENHANCED");
-    Error = RegSetValue(ControllerKey,
+    Error = RegSetValue(PeripheralKey,
 			"Identifier",
 			REG_SZ,
 			Buffer,

Modified: branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xboxcons.c
--- branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xboxcons.c	2005-06-01 01:59:05 UTC (rev 15712)
+++ branches/xen/reactos/boot/freeldr/freeldr/arch/i386/xboxcons.c	2005-06-01 16:27:21 UTC (rev 15713)
@@ -73,6 +73,8 @@
     {
       ;
     }
+
+  return 0;
 }
 
 /* EOF */

Modified: branches/xen/reactos/boot/freeldr/freeldr/freeldr.c
--- branches/xen/reactos/boot/freeldr/freeldr/freeldr.c	2005-06-01 01:59:05 UTC (rev 15712)
+++ branches/xen/reactos/boot/freeldr/freeldr/freeldr.c	2005-06-01 16:27:21 UTC (rev 15713)
@@ -35,7 +35,7 @@
 
 	DebugInit();
 
-	DbgPrint((DPRINT_WARNING, "BootMain() called. BootDrive = 0x%x BootPartition = %d\n", BootDrive, BootPartition));
+	DbgPrint((DPRINT_WARNING, "BootMain() called.\n"));
 
 	if (!MmInitializeMemoryManager())
 	{

Copied: branches/xen/reactos/boot/freeldr/freeldr/freeldr.xml (from rev 15712, trunk/reactos/boot/freeldr/freeldr/freeldr.xml)

Copied: branches/xen/reactos/boot/freeldr/freeldr/freeldr_base.xml (from rev 15712, trunk/reactos/boot/freeldr/freeldr/freeldr_base.xml)

Copied: branches/xen/reactos/boot/freeldr/freeldr/freeldr_base64k.xml (from rev 15712, trunk/reactos/boot/freeldr/freeldr/freeldr_base64k.xml)

Copied: branches/xen/reactos/boot/freeldr/freeldr/freeldr_main.xml (from rev 15712, trunk/reactos/boot/freeldr/freeldr/freeldr_main.xml)

Copied: branches/xen/reactos/boot/freeldr/freeldr/freeldr_startup.xml (from rev 15712, trunk/reactos/boot/freeldr/freeldr/freeldr_startup.xml)

Modified: branches/xen/reactos/boot/freeldr/freeldr/mm/mm.c
--- branches/xen/reactos/boot/freeldr/freeldr/mm/mm.c	2005-06-01 01:59:05 UTC (rev 15712)
+++ branches/xen/reactos/boot/freeldr/freeldr/mm/mm.c	2005-06-01 16:27:21 UTC (rev 15713)
@@ -36,10 +36,30 @@
 VOID		MemAllocTest(VOID);
 #endif // DEBUG
 
+/*
+ * Hack alert
+ * Normally, we allocate whole pages. This is ofcourse wastefull for small
+ * allocations (a few bytes). So, for small allocations (smaller than a page)
+ * we sub-allocate. When the first small allocation is done, a page is
+ * requested. We keep a pointer to that page in SubAllocationPage. The alloc
+ * is satisfied by returning a pointer to the beginning of the page. We also
+ * keep track of how many bytes are still available in the page in SubAllocationRest.
+ * When the next small request comes in, we try to allocate it just after the
+ * memory previously allocated. If it won't fit, we allocate a new page and
+ * the whole process starts again.
+ * Note that suballocations are done back-to-back, there's no bookkeeping at all.
+ * That also means that we cannot really free suballocations. So, when a free is
+ * done and it is determined that this might be a free of a sub-allocation, we
+ * just no-op the free.
+ * Perhaps we should use the heap routines from ntdll here.
+ */
+static PVOID    SubAllocationPage = NULL;
+static unsigned SubAllocationRest = 0;
+
 PVOID MmAllocateMemory(ULONG MemorySize)
 {
-	ULONG		PagesNeeded;
-	ULONG		FirstFreePageFromEnd;
+	ULONG	PagesNeeded;
+	ULONG	FirstFreePageFromEnd;
 	PVOID	MemPointer;
 
 	if (MemorySize == 0)
@@ -49,6 +69,14 @@
 		return NULL;
 	}
 
+	MemorySize = ROUND_UP(MemorySize, 4);
+	if (MemorySize <= SubAllocationRest)
+	{
+		MemPointer = SubAllocationPage + MM_PAGE_SIZE - SubAllocationRest;
+		SubAllocationRest -= MemorySize;
+		return MemPointer;
+	}
+
 	// Find out how many blocks it will take to
 	// satisfy this allocation
 	PagesNeeded = ROUND_UP(MemorySize, MM_PAGE_SIZE) / MM_PAGE_SIZE;
@@ -76,6 +104,13 @@
 	FreePagesInLookupTable -= PagesNeeded;
 	MemPointer = (PVOID)(FirstFreePageFromEnd * MM_PAGE_SIZE);
 
+	if (MemorySize < MM_PAGE_SIZE)
+	{
+		SubAllocationPage = MemPointer;
+		SubAllocationRest = MM_PAGE_SIZE - MemorySize;
+	}
+		
+
 #ifdef DEBUG
 	IncrementAllocationCount();
 	DbgPrint((DPRINT_MEMORY, "Allocated %d bytes (%d pages) of memory starting at page %d. AllocCount: %d\n", MemorySize, PagesNeeded, FirstFreePageFromEnd, AllocationCount));
@@ -235,6 +270,13 @@
 
 #endif
 
+	/* If this allocation is only a single page, it could be a sub-allocated page.
+	 * Just don't free it */
+	if (1 == PageCount)
+	{
+		return;
+	}
+
 	// Loop through our array and mark all the
 	// blocks as free
 	for (Idx=PageNumber; Idx<(PageNumber + PageCount); Idx++)

Modified: branches/xen/reactos/boot/freeldr/freeldr/reactos/reactos.c
--- branches/xen/reactos/boot/freeldr/freeldr/reactos/reactos.c	2005-06-01 01:59:05 UTC (rev 15712)
+++ branches/xen/reactos/boot/freeldr/freeldr/reactos/reactos.c	2005-06-01 16:27:21 UTC (rev 15713)
@@ -760,6 +760,16 @@
 	if (!FrLdrLoadDriver(szHalName, 10))
 		return;
 
+#if 0
+    /* Load bootvid */
+		strcpy(value, "INBV.DLL");
+		strcpy(szHalName, szBootPath);
+		strcat(szHalName, "SYSTEM32\\");
+		strcat(szHalName, value);
+
+	if (!FrLdrLoadDriver(szHalName, 10))
+		return;
+#endif
 	/*
 	 * Load the System hive from disk
 	 */

Modified: branches/xen/reactos/boot/freeldr/freeldr/reactos/setupldr.c
--- branches/xen/reactos/boot/freeldr/freeldr/reactos/setupldr.c	2005-06-01 01:59:05 UTC (rev 15712)
+++ branches/xen/reactos/boot/freeldr/freeldr/reactos/setupldr.c	2005-06-01 16:27:21 UTC (rev 15713)
@@ -34,7 +34,7 @@
 #include "registry.h"
 
 
-//#define USE_UI
+#define USE_UI
 
 
 static BOOL
@@ -88,7 +88,7 @@
    * Update the status bar with the current file
    */
 #ifdef USE_UI
-  sprintf(szBuffer, "Reading %s", szShortName);
+  sprintf(szBuffer, "Setup is loading files (%s)", szShortName);
   UiDrawStatusText(szBuffer);
 #else
   printf("Reading %s\n", szShortName);
@@ -155,7 +155,7 @@
    * Update the status bar with the current file
    */
 #ifdef USE_UI
-  sprintf(szBuffer, "Reading %s", szShortName);
+  sprintf(szBuffer, "Setup is loading files (%s)", szShortName);
   UiDrawStatusText(szBuffer);
 #else
   printf("Reading %s\n", szShortName);
@@ -220,7 +220,7 @@
    * Update the status bar with the current file
    */
 #ifdef USE_UI
-  sprintf(szBuffer, "Reading %s", szShortName);
+  sprintf(szBuffer, "Setup is loading files (%s)", szShortName);
   UiDrawStatusText(szBuffer);
 #else
   printf("Reading %s\n", szShortName);
@@ -232,6 +232,7 @@
   return(TRUE);
 }
 
+BOOL SetupUiInitialize(VOID);
 
 VOID RunLoader(VOID)
 {
@@ -294,7 +295,7 @@
 #endif
 
 #ifdef USE_UI
-  UiInitialize();
+  SetupUiInitialize();
   UiDrawStatusText("");
 #endif
 

Copied: branches/xen/reactos/boot/freeldr/freeldr/setupldr.xml (from rev 15712, trunk/reactos/boot/freeldr/freeldr/setupldr.xml)

Copied: branches/xen/reactos/boot/freeldr/freeldr/setupldr_main.xml (from rev 15712, trunk/reactos/boot/freeldr/freeldr/setupldr_main.xml)

Modified: branches/xen/reactos/boot/freeldr/freeldr/ui/ui.c
--- branches/xen/reactos/boot/freeldr/freeldr/ui/ui.c	2005-06-01 01:59:05 UTC (rev 15712)
+++ branches/xen/reactos/boot/freeldr/freeldr/ui/ui.c	2005-06-01 16:27:21 UTC (rev 15713)
@@ -27,6 +27,7 @@
 #include <inifile.h>
 #include <version.h>
 #include <video.h>
+#include <reactos/buildno.h>
 
 ULONG	UiScreenWidth = 80;							// Screen Width
 ULONG	UiScreenHeight = 25;							// Screen Height
@@ -197,7 +198,40 @@
 	UserInterfaceUp = TRUE;
 
 	DbgPrint((DPRINT_UI, "UiInitialize() returning TRUE.\n"));
+	return TRUE;
+}
 
+BOOL SetupUiInitialize(VOID)
+{
+
+	CHAR	DisplayModeText[260];
+	ULONG	Depth;
+
+	
+	DisplayModeText[0] = '\0';
+	
+
+	UiDisplayMode = MachVideoSetDisplayMode(DisplayModeText, TRUE);
+	MachVideoGetDisplaySize(&UiScreenWidth, &UiScreenHeight, &Depth);
+
+	TuiInitialize();
+
+	// Draw the backdrop and fade it in if special effects are enabled
+	TuiFillArea(0,
+			0,
+			UiScreenWidth - 1,
+			UiScreenHeight - 2,
+			0,
+			ATTR(UiBackdropFgColor, UiBackdropBgColor));
+
+    UiStatusBarBgColor = 7;
+	UserInterfaceUp = TRUE;
+    
+    TuiDrawText(4, 1, "ReactOS " KERNEL_VERSION_STR " Setup", ATTR(COLOR_GRAY, UiBackdropBgColor));
+    TuiDrawText(3, 2, "\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD\xCD", ATTR(COLOR_GRAY, UiBackdropBgColor));
+
+	DbgPrint((DPRINT_UI, "UiInitialize() returning TRUE.\n"));
+
 	return TRUE;
 }