mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 22:18:13 +00:00
[FREELDR] Minor code improvements + 1 bug-fix.
- "FrldrBootPath" -> "FrLdrBootPath"; - Get rid of GetFreeLoaderVersionString() and use FrLdrVersionString directly instead; - Rephrase some comments; - Use RTL_NUMBER_OF(); - Reduce indent level in LoadOperatingSystem() and EditOperatingSystemEntry(). Bug fix: - Fix DissectArcPath() for "ramdisk(0)" case.
This commit is contained in:
parent
86c94e7858
commit
fc29a6c41c
15 changed files with 68 additions and 92 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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( "" );
|
||||
}
|
||||
|
|
|
@ -39,10 +39,8 @@ DissectArcPath(
|
|||
|
||||
/* Get the path (optional) */
|
||||
if (Path)
|
||||
{
|
||||
p = ArcPath + 11;
|
||||
*Path = p;
|
||||
}
|
||||
*Path = ArcPath + 10;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,21 +197,24 @@ 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 (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)
|
||||
{
|
||||
if (!Argv)
|
||||
return; // Unexpected failure.
|
||||
|
||||
/* Start the OS loader */
|
||||
OSLoadingMethods[i].OsLoader(Argc, Argv, NULL);
|
||||
FrLdrHeapFree(Argv, TAG_STRING);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 ******************************************************************/
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -36,4 +36,4 @@
|
|||
#define FREELOADER_MINOR_VERSION 0
|
||||
#define FREELOADER_PATCH_VERSION 0
|
||||
|
||||
const PCSTR GetFreeLoaderVersionString(VOID);
|
||||
extern const PCSTR FrLdrVersionString;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -110,7 +110,7 @@ VOID TuiDrawBackdrop(VOID)
|
|||
//
|
||||
TuiDrawText(2,
|
||||
1,
|
||||
GetFreeLoaderVersionString(),
|
||||
FrLdrVersionString,
|
||||
ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
|
||||
|
||||
//
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* FreeLoader
|
||||
* Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
|
||||
*
|
||||
* 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 <freeldr.h>
|
||||
|
||||
#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;
|
||||
}
|
Loading…
Reference in a new issue