diff --git a/boot/freeldr/freeldr/CMakeLists.txt b/boot/freeldr/freeldr/CMakeLists.txt index 0f6947b3b0d..53eaca33b74 100644 --- a/boot/freeldr/freeldr/CMakeLists.txt +++ b/boot/freeldr/freeldr/CMakeLists.txt @@ -81,7 +81,6 @@ list(APPEND FREELDR_BOOTMGR_SOURCE miscboot.c options.c oslist.c - version.c ui/directui.c ui/gui.c ui/minitui.c diff --git a/boot/freeldr/freeldr/arch/arm/macharm.c b/boot/freeldr/freeldr/arch/arm/macharm.c index 348d3041e52..d38a38924f7 100644 --- a/boot/freeldr/freeldr/arch/arm/macharm.c +++ b/boot/freeldr/freeldr/arch/arm/macharm.c @@ -139,7 +139,7 @@ ArmInitializeBootDevices(VOID) return FALSE; /* On ARM platforms, the loader is always in RAM */ - strcpy(FrldrBootPath, "ramdisk(0)"); + strcpy(FrLdrBootPath, "ramdisk(0)"); return TRUE; } diff --git a/boot/freeldr/freeldr/arch/i386/hwdisk.c b/boot/freeldr/freeldr/arch/i386/hwdisk.c index 952a58e9f86..9f623a36fe6 100644 --- a/boot/freeldr/freeldr/arch/i386/hwdisk.c +++ b/boot/freeldr/freeldr/arch/i386/hwdisk.c @@ -378,32 +378,32 @@ DiskIsDriveRemovable(UCHAR DriveNumber) static BOOLEAN DiskGetBootPath(BOOLEAN IsPxe) { - if (*FrldrBootPath) + if (*FrLdrBootPath) return TRUE; // FIXME! FIXME! Do this in some drive recognition procedure!!!! if (IsPxe) { - RtlStringCbCopyA(FrldrBootPath, sizeof(FrldrBootPath), "net(0)"); + RtlStringCbCopyA(FrLdrBootPath, sizeof(FrLdrBootPath), "net(0)"); } else /* 0x49 is our magic ramdisk drive, so try to detect it first */ if (FrldrBootDrive == 0x49) { /* This is the ramdisk. See ArmInitializeBootDevices() too... */ - // RtlStringCbPrintfA(FrldrBootPath, sizeof(FrldrBootPath), "ramdisk(%u)", 0); - RtlStringCbCopyA(FrldrBootPath, sizeof(FrldrBootPath), "ramdisk(0)"); + // RtlStringCbPrintfA(FrLdrBootPath, sizeof(FrLdrBootPath), "ramdisk(%u)", 0); + RtlStringCbCopyA(FrLdrBootPath, sizeof(FrLdrBootPath), "ramdisk(0)"); } else if (FrldrBootDrive < 0x80) { /* This is a floppy */ - RtlStringCbPrintfA(FrldrBootPath, sizeof(FrldrBootPath), + RtlStringCbPrintfA(FrLdrBootPath, sizeof(FrLdrBootPath), "multi(0)disk(0)fdisk(%u)", FrldrBootDrive); } else if (FrldrBootPartition == 0xFF) { /* Boot Partition 0xFF is the magic value that indicates booting from CD-ROM (see isoboot.S) */ - RtlStringCbPrintfA(FrldrBootPath, sizeof(FrldrBootPath), + RtlStringCbPrintfA(FrLdrBootPath, sizeof(FrLdrBootPath), "multi(0)disk(0)cdrom(%u)", FrldrBootDrive - 0x80); } else @@ -420,7 +420,7 @@ DiskGetBootPath(BOOLEAN IsPxe) FrldrBootPartition = BootPartition; - RtlStringCbPrintfA(FrldrBootPath, sizeof(FrldrBootPath), + RtlStringCbPrintfA(FrLdrBootPath, sizeof(FrLdrBootPath), "multi(0)disk(0)rdisk(%u)partition(%lu)", FrldrBootDrive - 0x80, FrldrBootPartition); } @@ -437,7 +437,7 @@ PcInitializeBootDevices(VOID) DiskCount = EnumerateHarddisks(&BootDriveReported); - /* Initialize FrldrBootPath, the boot path we're booting from (the "SystemPartition") */ + /* Initialize FrLdrBootPath, the boot path we're booting from (the "SystemPartition") */ DiskGetBootPath(PxeInit()); /* Add it, if it's a floppy or cdrom */ @@ -473,9 +473,9 @@ PcInitializeBootDevices(VOID) TRACE("Checksum: %x\n", Checksum); /* Fill out the ARC disk block */ - AddReactOSArcDiskInfo(FrldrBootPath, Signature, Checksum, TRUE); + AddReactOSArcDiskInfo(FrLdrBootPath, Signature, Checksum, TRUE); - FsRegisterDevice(FrldrBootPath, &DiskVtbl); + FsRegisterDevice(FrLdrBootPath, &DiskVtbl); DiskCount++; // This is not accounted for in the number of pre-enumerated BIOS drives! TRACE("Additional boot drive detected: 0x%02X\n", (int)FrldrBootDrive); } diff --git a/boot/freeldr/freeldr/arch/powerpc/mach.c b/boot/freeldr/freeldr/arch/powerpc/mach.c index 6c240a29ce9..840cbfa5657 100644 --- a/boot/freeldr/freeldr/arch/powerpc/mach.c +++ b/boot/freeldr/freeldr/arch/powerpc/mach.c @@ -24,7 +24,6 @@ #include "compat.h" extern void BootMain( PSTR CmdLine ); -extern const PCSTR GetFreeLoaderVersionString(VOID); extern ULONG CacheSizeLimit; of_proxy ofproxy; void *PageDirectoryStart, *PageDirectoryEnd; @@ -32,7 +31,7 @@ static int chosen_package, stdin_handle, stdout_handle, part_handle = -1; int mmu_handle = 0; int claimed[4]; BOOLEAN AcpiPresent = FALSE; -CHAR FrldrBootPath[MAX_PATH] = "", BootPart[MAX_PATH] = "", CmdLine[MAX_PATH] = "bootprep"; +CHAR FrLdrBootPath[MAX_PATH] = "", BootPart[MAX_PATH] = "", CmdLine[MAX_PATH] = "bootprep"; jmp_buf jmp; volatile char *video_mem = 0; @@ -468,7 +467,7 @@ void PpcOfwInit() return; } - printf( "FreeLDR version [%s]\n", GetFreeLoaderVersionString() ); + printf( "FreeLDR version [%s]\n", FrLdrVersionString ); BootMain( CmdLine ); } @@ -487,7 +486,7 @@ void MachInit(const char *CmdLine) { char *sep; BootPart[0] = 0; - FrldrBootPath[0] = 0; + FrLdrBootPath[0] = 0; printf( "Determining boot device: [%s]\n", CmdLine ); @@ -505,18 +504,18 @@ void MachInit(const char *CmdLine) { if( strlen(BootPart) == 0 ) { if (ofproxy) len = ofw_getprop(chosen_package, "bootpath", - FrldrBootPath, sizeof(FrldrBootPath)); + FrLdrBootPath, sizeof(FrLdrBootPath)); else len = 0; if( len < 0 ) len = 0; - FrldrBootPath[len] = 0; - printf( "Boot Path: %s\n", FrldrBootPath ); + FrLdrBootPath[len] = 0; + printf( "Boot Path: %s\n", FrLdrBootPath ); - sep = strrchr(FrldrBootPath, ','); + sep = strrchr(FrLdrBootPath, ','); - strcpy(BootPart, FrldrBootPath); + strcpy(BootPart, FrLdrBootPath); if( sep ) { - BootPart[sep - FrldrBootPath] = 0; + BootPart[sep - FrLdrBootPath] = 0; } } diff --git a/boot/freeldr/freeldr/arch/powerpc/prep.c b/boot/freeldr/freeldr/arch/powerpc/prep.c index 713e6163af4..0d33e921bc4 100644 --- a/boot/freeldr/freeldr/arch/powerpc/prep.c +++ b/boot/freeldr/freeldr/arch/powerpc/prep.c @@ -141,7 +141,7 @@ void PpcPrepInit() MachVtbl.HwDetect = PpcPrepHwDetect; MachVtbl.HwIdle = PcPrepHwIdle; - printf( "FreeLDR version [%s]\n", GetFreeLoaderVersionString() ); + printf( "FreeLDR version [%s]\n", FrLdrVersionString ); BootMain( "" ); } diff --git a/boot/freeldr/freeldr/arcname.c b/boot/freeldr/freeldr/arcname.c index 26ba703da5b..0a4ec6254de 100644 --- a/boot/freeldr/freeldr/arcname.c +++ b/boot/freeldr/freeldr/arcname.c @@ -39,10 +39,8 @@ DissectArcPath( /* Get the path (optional) */ if (Path) - { - p = ArcPath + 11; - *Path = p; - } + *Path = ArcPath + 10; + return TRUE; } diff --git a/boot/freeldr/freeldr/bootmgr.c b/boot/freeldr/freeldr/bootmgr.c index ca2e531612e..4e2d9a8d2ef 100644 --- a/boot/freeldr/freeldr/bootmgr.c +++ b/boot/freeldr/freeldr/bootmgr.c @@ -109,7 +109,7 @@ BuildArgvForOsLoader( Size = 0; /* i == 0: Program name */ /* i == 1: SystemPartition : from where FreeLdr has been started */ - Size += (strlen("SystemPartition=") + strlen(FrldrBootPath) + 1) * sizeof(CHAR); + Size += (strlen("SystemPartition=") + strlen(FrLdrBootPath) + 1) * sizeof(CHAR); /* i == 2: LoadIdentifier : ASCII string that may be used to associate an identifier with a set of load parameters */ if (LoadIdentifier) { @@ -135,7 +135,7 @@ BuildArgvForOsLoader( /* i == 1: SystemPartition */ { strcpy(SettingName, "SystemPartition="); - strcat(SettingName, FrldrBootPath); + strcat(SettingName, FrLdrBootPath); *Args++ = SettingName; SettingName += (strlen(SettingName) + 1); @@ -197,20 +197,23 @@ VOID LoadOperatingSystem(IN OperatingSystemItem* OperatingSystem) DriveMapMapDrivesInSection(SectionId); #endif - /* Loop through the OS loading method table and find a suitable OS to boot */ - for (i = 0; i < sizeof(OSLoadingMethods) / sizeof(OSLoadingMethods[0]); ++i) + /* Find the suitable OS loader to start */ + for (i = 0; ; ++i) { - if (_stricmp(BootType, OSLoadingMethods[i].BootType) == 0) - { - Argv = BuildArgvForOsLoader(OperatingSystem->LoadIdentifier, SectionId, &Argc); - if (Argv) - { - OSLoadingMethods[i].OsLoader(Argc, Argv, NULL); - FrLdrHeapFree(Argv, TAG_STRING); - } + if (i >= RTL_NUMBER_OF(OSLoadingMethods)) return; - } + if (_stricmp(BootType, OSLoadingMethods[i].BootType) == 0) + break; } + + /* Build the ARC-compatible argument vector */ + Argv = BuildArgvForOsLoader(OperatingSystem->LoadIdentifier, SectionId, &Argc); + if (!Argv) + return; // Unexpected failure. + + /* Start the OS loader */ + OSLoadingMethods[i].OsLoader(Argc, Argv, NULL); + FrLdrHeapFree(Argv, TAG_STRING); } #ifdef HAS_OPTION_MENU_EDIT_CMDLINE @@ -231,15 +234,17 @@ VOID EditOperatingSystemEntry(IN OperatingSystemItem* OperatingSystem) /* We must have the "BootType" value (it has been possibly added by InitOperatingSystemList()) */ ASSERT(*BootType); - /* Loop through the OS loading method table and find a suitable OS entry editor */ - for (i = 0; i < sizeof(OSLoadingMethods) / sizeof(OSLoadingMethods[0]); ++i) + /* Find the suitable OS entry editor */ + for (i = 0; ; ++i) { - if (_stricmp(BootType, OSLoadingMethods[i].BootType) == 0) - { - OSLoadingMethods[i].EditOsEntry(OperatingSystem); + if (i >= RTL_NUMBER_OF(OSLoadingMethods)) return; - } + if (_stricmp(BootType, OSLoadingMethods[i].BootType) == 0) + break; } + + /* Run it */ + OSLoadingMethods[i].EditOsEntry(OperatingSystem); } #endif // HAS_OPTION_MENU_EDIT_CMDLINE diff --git a/boot/freeldr/freeldr/custom.c b/boot/freeldr/freeldr/custom.c index cf6065345d0..604d7ac9629 100644 --- a/boot/freeldr/freeldr/custom.c +++ b/boot/freeldr/freeldr/custom.c @@ -61,7 +61,7 @@ VOID OptionMenuCustomBoot(VOID) if (!UiDisplayMenu("Please choose a boot method:", NULL, FALSE, CustomBootMenuList, - sizeof(CustomBootMenuList) / sizeof(CustomBootMenuList[0]), + RTL_NUMBER_OF(CustomBootMenuList), 0, -1, &SelectedMenuItem, TRUE, @@ -123,7 +123,7 @@ EditCustomBootDisk( TIMEINFO* TimeInfo; ULONG_PTR SectionId = OperatingSystem->SectionId; CHAR SectionName[100]; - /* The following is a trick for saving some stack space */ + /* This construct is a trick for saving some stack space */ union { struct @@ -218,7 +218,7 @@ EditCustomBootPartition( TIMEINFO* TimeInfo; ULONG_PTR SectionId = OperatingSystem->SectionId; CHAR SectionName[100]; - /* The following is a trick for saving some stack space */ + /* This construct is a trick for saving some stack space */ union { struct @@ -328,7 +328,7 @@ EditCustomBootSectorFile( TIMEINFO* TimeInfo; ULONG_PTR SectionId = OperatingSystem->SectionId; CHAR SectionName[100]; - /* The following is a trick for saving some stack space */ + /* This construct is a trick for saving some stack space */ union { struct @@ -461,7 +461,7 @@ EditCustomBootLinux( TIMEINFO* TimeInfo; ULONG_PTR SectionId = OperatingSystem->SectionId; CHAR SectionName[100]; - /* The following is a trick for saving some stack space */ + /* This construct is a trick for saving some stack space */ union { struct diff --git a/boot/freeldr/freeldr/disk/scsiport.c b/boot/freeldr/freeldr/disk/scsiport.c index e05e1b2be85..21b7390e021 100644 --- a/boot/freeldr/freeldr/disk/scsiport.c +++ b/boot/freeldr/freeldr/disk/scsiport.c @@ -1611,7 +1611,7 @@ LoadBootDeviceDriver(VOID) InitializeListHead(&ModuleListHead); /* Create full ntbootdd.sys path */ - strcpy(NtBootDdPath, FrldrBootPath); + strcpy(NtBootDdPath, FrLdrBootPath); strcat(NtBootDdPath, "\\NTBOOTDD.SYS"); /* Load file */ diff --git a/boot/freeldr/freeldr/freeldr.c b/boot/freeldr/freeldr/freeldr.c index f266081f067..11c0d462687 100644 --- a/boot/freeldr/freeldr/freeldr.c +++ b/boot/freeldr/freeldr/freeldr.c @@ -26,7 +26,17 @@ DBG_DEFAULT_CHANNEL(WARNING); /* GLOBALS ********************************************************************/ -CCHAR FrldrBootPath[MAX_PATH] = ""; +#define TOSTRING_(X) #X +#define TOSTRING(X) TOSTRING_(X) + +const PCSTR FrLdrVersionString = +#if (FREELOADER_PATCH_VERSION == 0) + "FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION); +#else + "FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION) "." TOSTRING(FREELOADER_PATCH_VERSION); +#endif + +CCHAR FrLdrBootPath[MAX_PATH] = ""; /* FUNCTIONS ******************************************************************/ diff --git a/boot/freeldr/freeldr/include/disk.h b/boot/freeldr/freeldr/include/disk.h index c07ed0117c8..b08993a5e8f 100644 --- a/boot/freeldr/freeldr/include/disk.h +++ b/boot/freeldr/freeldr/include/disk.h @@ -123,7 +123,7 @@ extern SIZE_T DiskReadBufferSize; /* ARC path of the boot drive and partition */ -extern CCHAR FrldrBootPath[MAX_PATH]; +extern CCHAR FrLdrBootPath[MAX_PATH]; /////////////////////////////////////////////////////////////////////////////////////// diff --git a/boot/freeldr/freeldr/include/ver.h b/boot/freeldr/freeldr/include/ver.h index d796f7a6489..a7b7f2af488 100644 --- a/boot/freeldr/freeldr/include/ver.h +++ b/boot/freeldr/freeldr/include/ver.h @@ -36,4 +36,4 @@ #define FREELOADER_MINOR_VERSION 0 #define FREELOADER_PATCH_VERSION 0 -const PCSTR GetFreeLoaderVersionString(VOID); +extern const PCSTR FrLdrVersionString; diff --git a/boot/freeldr/freeldr/lib/inifile/ini_init.c b/boot/freeldr/freeldr/lib/inifile/ini_init.c index 5d9991e2411..b63a578085a 100644 --- a/boot/freeldr/freeldr/lib/inifile/ini_init.c +++ b/boot/freeldr/freeldr/lib/inifile/ini_init.c @@ -34,7 +34,7 @@ BOOLEAN IniFileInitialize(VOID) TRACE("IniFileInitialize()\n"); /* Try to open freeldr.ini */ - Status = FsOpenFile("freeldr.ini", FrldrBootPath, OpenReadOnly, &FileId); + Status = FsOpenFile("freeldr.ini", FrLdrBootPath, OpenReadOnly, &FileId); if (Status != ESUCCESS) { ERR("Error while opening freeldr.ini, Status: %d\n", Status); diff --git a/boot/freeldr/freeldr/ui/tui.c b/boot/freeldr/freeldr/ui/tui.c index 9b5fad75efe..d8fa4028b4c 100644 --- a/boot/freeldr/freeldr/ui/tui.c +++ b/boot/freeldr/freeldr/ui/tui.c @@ -110,7 +110,7 @@ VOID TuiDrawBackdrop(VOID) // TuiDrawText(2, 1, - GetFreeLoaderVersionString(), + FrLdrVersionString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor)); // diff --git a/boot/freeldr/freeldr/version.c b/boot/freeldr/freeldr/version.c deleted file mode 100644 index fcd25213bca..00000000000 --- a/boot/freeldr/freeldr/version.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * FreeLoader - * Copyright (C) 1998-2003 Brian Palmer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include - -#define TOSTRING_(X) #X -#define TOSTRING(X) TOSTRING_(X) - -static const PCSTR FreeLoaderVersionString = -#if (FREELOADER_PATCH_VERSION == 0) - "FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION); -#else - "FreeLoader v" TOSTRING(FREELOADER_MAJOR_VERSION) "." TOSTRING(FREELOADER_MINOR_VERSION) "." TOSTRING(FREELOADER_PATCH_VERSION); -#endif - -const PCSTR GetFreeLoaderVersionString(VOID) -{ - return FreeLoaderVersionString; -}