#define MACOSX_LOADER_PATH L"System\\Library\\CoreServices\\boot.efi"
#if defined (EFIX64)
#define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\shellx64.efi"
+#define DRIVER_DIRS L"drivers,drivers_x64"
#elif defined (EFI32)
#define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\shellia32.efi"
+#define DRIVER_DIRS L"drivers,drivers_ia32"
#else
#define SHELL_NAMES L"\\EFI\\tools\\shell.efi"
#endif
static REFIT_MENU_SCREEN MainMenu = { L"Main Menu", NULL, 0, NULL, 0, NULL, 0, L"Automatic boot" };
static REFIT_MENU_SCREEN AboutMenu = { L"About", NULL, 0, NULL, 0, NULL, 0, NULL };
-REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 20, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 20, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
{TAG_SHELL, TAG_ABOUT, TAG_SHUTDOWN, TAG_REBOOT, 0, 0, 0, 0, 0 }};
// Structure used to hold boot loader filenames and time stamps in
{
if (AboutMenu.EntryCount == 0) {
AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
- AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.3.5");
+ AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.1.1");
AddMenuInfoLine(&AboutMenu, L"");
AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
// load the image into memory
ReturnStatus = Status = EFI_NOT_FOUND; // in case the list is empty
for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; DevicePathIndex++) {
+// Print(L"About to try loading '%s' from '%s'\n", ImageTitle, DevicePathToStr(DevicePaths[DevicePathIndex]));
+// PauseForKey();
ReturnStatus = Status = refit_call6_wrapper(BS->LoadImage, FALSE, SelfImageHandle, DevicePaths[DevicePathIndex], NULL, 0, &ChildImageHandle);
if (ReturnStatus != EFI_NOT_FOUND)
break;
}
if (Entry->SubScreen != NULL) {
NewEntry->SubScreen = CopyMenuScreen(Entry->SubScreen);
-// NewEntry->SubScreen = AllocatePool(sizeof(REFIT_MENU_SCREEN));
-// if (NewEntry->SubScreen != NULL)
-// CopyMem(NewEntry->SubScreen, Entry->SubScreen, sizeof(REFIT_MENU_SCREEN));
}
} // if
return (NewEntry);
Entry->me.Title = PoolPrint(L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : LoaderPath, Volume->VolName);
Entry->me.Row = 0;
Entry->me.BadgeImage = Volume->VolBadgeImage;
- Entry->LoaderPath = StrDuplicate(LoaderPath);
+ if ((LoaderPath != NULL) && (LoaderPath[0] != L'\\')) {
+ Entry->LoaderPath = StrDuplicate(L"\\");
+ } else {
+ Entry->LoaderPath = NULL;
+ }
+ MergeStrings(&(Entry->LoaderPath), LoaderPath, 0);
+// Entry->LoaderPath = StrDuplicate(LoaderPath);
Entry->VolName = Volume->VolName;
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
SetLoaderDefaults(Entry, LoaderPath, Volume);
CHAR16 FileName[256], *Extension;
struct LOADER_LIST *LoaderList = NULL, *NewLoader;
- if (!SelfDirPath || !Path || ((StriCmp(Path, SelfDirPath) == 0) && Volume != SelfVolume) ||
- (StriCmp(Path, SelfDirPath) != 0)) {
+ if ((!SelfDirPath || !Path || ((StriCmp(Path, SelfDirPath) == 0) && Volume->DeviceHandle != SelfVolume->DeviceHandle) ||
+ (StriCmp(Path, SelfDirPath) != 0)) && (!IsIn(Path, GlobalConfig.DontScan))) {
// look through contents of the directory
DirIterOpen(Volume->RootDir, Path, &DirIter);
while (DirIterNext(&DirIter, 2, Pattern, &DirEntry)) {
if ((Volume->RootDir != NULL) && (Volume->VolName != NULL)) {
// check for Mac OS X boot loader
- StrCpy(FileName, MACOSX_LOADER_PATH);
- if (FileExists(Volume->RootDir, FileName)) {
- AddLoaderEntry(FileName, L"Mac OS X", Volume);
- }
+ if (!IsIn(L"System\\Library\\CoreServices", GlobalConfig.DontScan)) {
+ StrCpy(FileName, MACOSX_LOADER_PATH);
+ if (FileExists(Volume->RootDir, FileName)) {
+ AddLoaderEntry(FileName, L"Mac OS X", Volume);
+ }
- // check for XOM
- StrCpy(FileName, L"System\\Library\\CoreServices\\xom.efi");
- if (FileExists(Volume->RootDir, FileName)) {
- AddLoaderEntry(FileName, L"Windows XP (XoM)", Volume);
- }
+ // check for XOM
+ StrCpy(FileName, L"System\\Library\\CoreServices\\xom.efi");
+ if (FileExists(Volume->RootDir, FileName)) {
+ AddLoaderEntry(FileName, L"Windows XP (XoM)", Volume);
+ }
+ } // if Mac directory not in GlobalConfig.DontScan list
// check for Microsoft boot loader/menu
StrCpy(FileName, L"EFI\\Microsoft\\Boot\\Bootmgfw.efi");
- if (FileExists(Volume->RootDir, FileName)) {
+ if (FileExists(Volume->RootDir, FileName) && !IsIn(L"EFI\\Microsoft\\Boot", GlobalConfig.DontScan)) {
AddLoaderEntry(FileName, L"Microsoft EFI boot", Volume);
}
// file line.
static VOID LoadDrivers(VOID)
{
- CHAR16 *Directory;
+ CHAR16 *Directory, *SelfDirectory;
UINTN i = 0, Length, NumFound = 0;
- // load drivers from the "drivers" subdirectory of rEFInd's home directory
- Directory = StrDuplicate(SelfDirPath);
- CleanUpPathNameSlashes(Directory);
- MergeStrings(&Directory, L"drivers", L'\\');
- NumFound += ScanDriverDir(Directory);
+ // load drivers from the subdirectories of rEFInd's home directory specified
+ // in the DRIVER_DIRS constant.
+ while ((Directory = FindCommaDelimited(DRIVER_DIRS, i++)) != NULL) {
+ SelfDirectory = StrDuplicate(SelfDirPath);
+ CleanUpPathNameSlashes(SelfDirectory);
+ MergeStrings(&SelfDirectory, Directory, L'\\');
+ NumFound += ScanDriverDir(SelfDirectory);
+ FreePool(Directory);
+ FreePool(SelfDirectory);
+ }
// Scan additional user-specified driver directories....
+ i = 0;
while ((Directory = FindCommaDelimited(GlobalConfig.DriverDirs, i++)) != NULL) {
CleanUpPathNameSlashes(Directory);
Length = StrLen(Directory);
UINTN i;
ScanVolumes();
- // Commented-out below: Was part of an attempt to get rEFInd to
- // re-scan disk devices on pressing Esc; but doesn't work (yet), so
- // removed....
-// MainMenu.Title = StrDuplicate(L"Main Menu 2");
-// MainMenu.TitleImage = NULL;
-// MainMenu.InfoLineCount = 0;
-// MainMenu.InfoLines = NULL;
-// MainMenu.EntryCount = 0;
-// MainMenu.Entries = NULL;
-// MainMenu.TimeoutSeconds = 20;
-// MainMenu.TimeoutText = StrDuplicate(L"Automatic boot");
- // DebugPause();
// scan for loaders and tools, add them to the menu
for (i = 0; i < NUM_SCAN_OPTIONS; i++) {
} // for
} // static VOID ScanForTools
+// Rescan for boot loaders
+VOID RescanAll(VOID) {
+ EG_PIXEL BGColor;
+
+ BGColor.b = 255;
+ BGColor.g = 175;
+ BGColor.r = 100;
+ BGColor.a = 0;
+ egDisplayMessage(L"Scanning for new boot loaders; please wait....", &BGColor);
+ FreeList((VOID ***) &(MainMenu.Entries), &MainMenu.EntryCount);
+ MainMenu.Entries = NULL;
+ MainMenu.EntryCount = 0;
+ ReadConfig();
+ ConnectAllDriversToAllControllers();
+ ScanForBootloaders();
+ ScanForTools();
+ SetupScreen();
+} // VOID RescanAll()
+
//
// main entry point
//
-
EFI_STATUS
EFIAPI
efi_main (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
while (MainLoopRunning) {
MenuExit = RunMainMenu(&MainMenu, Selection, &ChosenEntry);
- // We don't allow exiting the main menu with the Escape key.
+ // The Escape key triggers a re-scan operation....
if (MenuExit == MENU_EXIT_ESCAPE) {
- FreeList((VOID ***) &(MainMenu.Entries), &MainMenu.EntryCount);
- MainMenu.Entries = NULL;
- MainMenu.EntryCount = 0;
- ReadConfig();
- ConnectAllDriversToAllControllers();
- ScanForBootloaders();
- ScanForTools();
- SetupScreen();
+ RescanAll();
continue;
}