[FREELDR]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 27 Dec 2012 21:52:40 +0000 (21:52 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 27 Dec 2012 21:52:40 +0000 (21:52 +0000)
- Move PcBeep function declaration to a better header.
- Resuscitate OptionMenuCustomBootReactOS() from revision r52491, update it to match recent changes in freeldr as well as making it using new boot method, and reuse ConstructArcPath.
  Why I'm doing this ? Because it can be useful to enter personalized boot options by hand at boot time rather than being obliged to edit freeldr.ini. This needs care, not brutal deletion.

svn path=/trunk/; revision=58020

reactos/boot/freeldr/freeldr/arch/i386/custom.c
reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c
reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h
reactos/boot/freeldr/freeldr/include/freeldr.h
reactos/boot/freeldr/freeldr/include/reactos.h
reactos/boot/freeldr/freeldr/reactos/arcname.c
reactos/boot/freeldr/freeldr/windows/setupldr.c

index 680a76c..fc8acf3 100644 (file)
@@ -67,6 +67,9 @@ VOID OptionMenuCustomBoot(VOID)
        case 2: // Boot Sector File
                OptionMenuCustomBootBootSectorFile();
                break;
+       case 3: // ReactOS
+               OptionMenuCustomBootReactOS();
+               break;
        case 4: // Linux
                OptionMenuCustomBootLinux();
                break;
@@ -117,7 +120,8 @@ VOID OptionMenuCustomBootDisk(VOID)
        OperatingSystem.LoadIdentifier  = NULL;
        OperatingSystem.OsLoadOptions   = NULL;
 
-       LoadAndBootDrive(&OperatingSystem, 0);
+       // LoadAndBootDrive(&OperatingSystem, 0);
+       LoadOperatingSystem(&OperatingSystem);
 }
 
 VOID OptionMenuCustomBootPartition(VOID)
@@ -177,7 +181,8 @@ VOID OptionMenuCustomBootPartition(VOID)
        OperatingSystem.LoadIdentifier  = NULL;
        OperatingSystem.OsLoadOptions   = NULL;
 
-       LoadAndBootPartition(&OperatingSystem, 0);
+       // LoadAndBootPartition(&OperatingSystem, 0);
+       LoadOperatingSystem(&OperatingSystem);
 }
 
 VOID OptionMenuCustomBootBootSectorFile(VOID)
@@ -250,7 +255,87 @@ VOID OptionMenuCustomBootBootSectorFile(VOID)
        OperatingSystem.LoadIdentifier  = NULL;
        OperatingSystem.OsLoadOptions   = NULL;
 
-       LoadAndBootBootSector(&OperatingSystem, 0);
+       // LoadAndBootBootSector(&OperatingSystem, 0);
+       LoadOperatingSystem(&OperatingSystem);
+}
+
+VOID OptionMenuCustomBootReactOS(VOID)
+{
+       ULONG_PTR       SectionId;
+       CHAR            SectionName[100];
+       CHAR            BootDriveString[20];
+       CHAR            BootPartitionString[20];
+       CHAR            ReactOSSystemPath[200];
+       CHAR            ReactOSARCPath[200];
+       CHAR            ReactOSOptions[200];
+       TIMEINFO*       TimeInfo;
+       OperatingSystemItem     OperatingSystem;
+
+       RtlZeroMemory(SectionName, sizeof(SectionName));
+       RtlZeroMemory(BootDriveString, sizeof(BootDriveString));
+       RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString));
+       RtlZeroMemory(ReactOSSystemPath, sizeof(ReactOSSystemPath));
+       RtlZeroMemory(ReactOSOptions, sizeof(ReactOSOptions));
+
+       if (!UiEditBox(BootDrivePrompt, BootDriveString, 20))
+       {
+               return;
+       }
+
+       if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20))
+       {
+               return;
+       }
+
+       if (!UiEditBox(ReactOSSystemPathPrompt, ReactOSSystemPath, 200))
+       {
+               return;
+       }
+
+       if (!UiEditBox(ReactOSOptionsPrompt, ReactOSOptions, 200))
+       {
+               return;
+       }
+
+       // Generate a unique section name
+       TimeInfo = ArcGetTime();
+       sprintf(SectionName, "CustomReactOS%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second);
+
+       // Add the section
+       if (!IniAddSection(SectionName, &SectionId))
+       {
+               return;
+       }
+
+       // Add the BootType
+       if (!IniAddSettingValueToSection(SectionId, "BootType", "Windows2003"))
+       {
+               return;
+       }
+
+       // Construct the ReactOS ARC system path
+       ConstructArcPath(ReactOSARCPath, ReactOSSystemPath, DriveMapGetBiosDriveNumber(BootDriveString), atoi(BootPartitionString));
+
+       // Add the system path
+       if (!IniAddSettingValueToSection(SectionId, "SystemPath", ReactOSARCPath))
+       {
+               return;
+       }
+
+       // Add the CommandLine
+       if (!IniAddSettingValueToSection(SectionId, "Options", ReactOSOptions))
+       {
+               return;
+       }
+
+       UiMessageBox(CustomBootPrompt);
+
+       OperatingSystem.SystemPartition = SectionName;
+       OperatingSystem.LoadIdentifier  = NULL;
+       OperatingSystem.OsLoadOptions   = NULL; // ReactOSOptions
+
+       // LoadAndBootWindows(&OperatingSystem, _WIN32_WINNT_WS03);
+       LoadOperatingSystem(&OperatingSystem);
 }
 
 VOID OptionMenuCustomBootLinux(VOID)
@@ -352,7 +437,8 @@ VOID OptionMenuCustomBootLinux(VOID)
        OperatingSystem.LoadIdentifier  = "Custom Linux Setup";
        OperatingSystem.OsLoadOptions   = NULL;
 
-       LoadAndBootLinux(&OperatingSystem, 0);
+       // LoadAndBootLinux(&OperatingSystem, 0);
+       LoadOperatingSystem(&OperatingSystem);
 }
 
 VOID OptionMenuReboot(VOID)
index a5f01b6..f423ea4 100644 (file)
@@ -22,7 +22,7 @@
 void sound(int freq);
 void delay(unsigned msec);
 
-void PcBeep(void)
+VOID PcBeep(VOID)
 {
        sound(700);
        delay(200);
index 6cd31dd..4d7c39a 100644 (file)
@@ -26,6 +26,8 @@
 
 VOID PcMachInit(const char *CmdLine);
 
+VOID PcBeep(VOID);
+
 VOID PcConsPutChar(int Ch);
 BOOLEAN PcConsKbHit(VOID);
 int PcConsGetCh(VOID);
index 5c1aead..4aa964c 100644 (file)
 #endif
 
 VOID BootMain(LPSTR CmdLine);
+VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem);
 VOID RunLoader(VOID);
 
 #endif  // defined __FREELDR_H
index 8b8d8c0..a5df320 100644 (file)
@@ -34,6 +34,6 @@ DissectArcPath2(
     OUT ULONG *PathSyntax);
 BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, UCHAR* BootDrive, ULONG* BootPartition);
 VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, UCHAR Disk, ULONG Partition);
+#if 0
 UCHAR ConvertArcNameToBiosDriveNumber(PCHAR ArcPath);
-
-void   PcBeep(void);
+#endif
index a51218f..7b38171 100644 (file)
@@ -160,8 +160,6 @@ DissectArcPath2(
     return FALSE;
 }
 
-
-#if 0
 VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, UCHAR Disk, ULONG Partition)
 {
        char    tmp[50];
@@ -198,6 +196,7 @@ VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, UCHAR Disk, ULONG Parti
        }
 }
 
+#if 0
 UCHAR ConvertArcNameToBiosDriveNumber(PCHAR ArcPath)
 {
        char *  p;
index 2dd80f3..c0f94b0 100644 (file)
@@ -193,7 +193,7 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
         return;
     }
 
-    if (!InfGetDataField (&InfContext, 1, &LoadOptions))
+    if (!InfGetDataField(&InfContext, 1, &LoadOptions))
     {
         ERR("Failed to get load options\n");
         return;