[FREELDR]
[reactos.git] / reactos / boot / freeldr / freeldr / windows / winldr.c
index 72d5df4..95ac954 100644 (file)
@@ -203,7 +203,27 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
                /* See KiRosFrldrLpbToNtLpb for details */
                Extension->AcpiTable = (PVOID)1;
        }
-
+    
+#ifndef _M_ARM
+    /* Set headless block pointer */
+    extern HEADLESS_LOADER_BLOCK LoaderRedirectionInformation;
+    extern BOOLEAN WinLdrTerminalConnected;
+    if (WinLdrTerminalConnected)
+    {
+        Extension->HeadlessLoaderBlock = MmHeapAlloc(sizeof(HEADLESS_LOADER_BLOCK));
+        if (Extension->HeadlessLoaderBlock == NULL)
+        {
+            UiMessageBox("Failed to allocate HLB Extension!");
+            while (TRUE);
+            return;
+        }
+        RtlCopyMemory(
+            Extension->HeadlessLoaderBlock,
+            &LoaderRedirectionInformation,
+            sizeof(HEADLESS_LOADER_BLOCK));
+        Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
+    }
+#endif
        /* Load drivers database */
        strcpy(MiscFiles, BootPath);
        strcat(MiscFiles, "AppPatch\\drvmain.sdb");
@@ -215,6 +235,7 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock,
 
        if (LoaderBlock->SetupLdrBlock)
                LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
+
 }
 
 BOOLEAN
@@ -264,10 +285,7 @@ WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock,
        _snprintf(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
        Status = WinLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
        if (!Status)
-       {
-               DPRINTM(DPRINT_WINDOWS, "WinLdrLoadImage() failed\n");
                return FALSE;
-       }
 
        // Allocate a DTE for it
        Status = WinLdrAllocateDataTableEntry(LoaderBlock, DllName, DllName, DriverBase, DriverDTE);
@@ -321,7 +339,6 @@ WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock,
                //FIXME: Maybe remove it from the list and try to continue?
                if (!Status)
                {
-                       DPRINTM(DPRINT_WARNING, "Can't load boot driver: %wZ\n", &BootDriver->FilePath);
                        UiMessageBox("Can't load boot driver!");
                        return FALSE;
                }
@@ -479,6 +496,9 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
                DPRINTM(DPRINT_WINDOWS,"BootOptions: '%s'\n", BootOptions);
        }
 
+       /* Append boot-time options */
+       AppendBootTimeOptions(BootOptions);
+
        //
        // Check if a ramdisk file was given
        //
@@ -514,7 +534,12 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
 
        /* Allocate and minimalistic-initialize LPB */
        AllocateAndInitLPB(&LoaderBlock);
-
+    
+#ifndef _M_ARM
+       /* Setup redirection support */
+       extern void WinLdrSetupEms(IN PCHAR BootOptions);
+       WinLdrSetupEms(BootOptions);
+#endif
        /* Detect hardware */
        UseRealHeap = TRUE;
        LoaderBlock->ConfigurationRoot = MachHwDetect();
@@ -596,16 +621,12 @@ LoadAndBootWindows(PCSTR OperatingSystemName,
        /* Turn on paging mode of CPU*/
        WinLdrTurnOnPaging(LoaderBlock, PcrBasePage, TssBasePage, GdtIdt);
 
-DbgPrint("Heeelooo\n");
-
        /* Save final value of LoaderPagesSpanned */
        LoaderBlockVA->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
 
        DPRINTM(DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
                KiSystemStartup, LoaderBlockVA);
 
-DbgPrint("Heeelooo\n");
-
        WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
        WinLdrpDumpBootDriver(LoaderBlockVA);
        WinLdrpDumpArcDisks(LoaderBlockVA);