From b8b7caccfee5d45ed851a93957f3abcf0347cebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 27 Dec 2012 21:52:40 +0000 Subject: [PATCH] [FREELDR] - 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 --- .../boot/freeldr/freeldr/arch/i386/custom.c | 94 ++++++++++++++++++- .../boot/freeldr/freeldr/arch/i386/i386rtl.c | 2 +- .../freeldr/freeldr/include/arch/pc/machpc.h | 2 + .../boot/freeldr/freeldr/include/freeldr.h | 1 + .../boot/freeldr/freeldr/include/reactos.h | 4 +- .../boot/freeldr/freeldr/reactos/arcname.c | 3 +- .../boot/freeldr/freeldr/windows/setupldr.c | 2 +- 7 files changed, 98 insertions(+), 10 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/custom.c b/reactos/boot/freeldr/freeldr/arch/i386/custom.c index 680a76c23e8..fc8acf3c478 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/custom.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/custom.c @@ -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) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c b/reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c index a5f01b6c833..f423ea43d4b 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/i386rtl.c @@ -22,7 +22,7 @@ void sound(int freq); void delay(unsigned msec); -void PcBeep(void) +VOID PcBeep(VOID) { sound(700); delay(200); diff --git a/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h b/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h index 6cd31dd7a77..4d7c39ae8ba 100644 --- a/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h +++ b/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h @@ -26,6 +26,8 @@ VOID PcMachInit(const char *CmdLine); +VOID PcBeep(VOID); + VOID PcConsPutChar(int Ch); BOOLEAN PcConsKbHit(VOID); int PcConsGetCh(VOID); diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index 5c1aead7d37..4aa964c7dcd 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -119,6 +119,7 @@ #endif VOID BootMain(LPSTR CmdLine); +VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem); VOID RunLoader(VOID); #endif // defined __FREELDR_H diff --git a/reactos/boot/freeldr/freeldr/include/reactos.h b/reactos/boot/freeldr/freeldr/include/reactos.h index 8b8d8c02e50..a5df3205c3a 100644 --- a/reactos/boot/freeldr/freeldr/include/reactos.h +++ b/reactos/boot/freeldr/freeldr/include/reactos.h @@ -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 diff --git a/reactos/boot/freeldr/freeldr/reactos/arcname.c b/reactos/boot/freeldr/freeldr/reactos/arcname.c index a51218f0e63..7b38171799c 100644 --- a/reactos/boot/freeldr/freeldr/reactos/arcname.c +++ b/reactos/boot/freeldr/freeldr/reactos/arcname.c @@ -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; diff --git a/reactos/boot/freeldr/freeldr/windows/setupldr.c b/reactos/boot/freeldr/freeldr/windows/setupldr.c index 2dd80f3714e..c0f94b0f978 100644 --- a/reactos/boot/freeldr/freeldr/windows/setupldr.c +++ b/reactos/boot/freeldr/freeldr/windows/setupldr.c @@ -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;