X-Git-Url: https://code.delx.au/refind/blobdiff_plain/11fa7da805c3e263f8b05339f1900baa73a2ffd4..2a6ed1155086a30aaa01ced44b559183e7521083:/refind/main.c diff --git a/refind/main.c b/refind/main.c index 7ea5571..d01b0de 100644 --- a/refind/main.c +++ b/refind/main.c @@ -61,13 +61,15 @@ #define EFI_SECURITY_VIOLATION EFIERR (26) #endif #endif -//#else + #include "../EfiLib/BdsHelper.h" #include "../EfiLib/legacy.h" #ifndef EFI_OS_INDICATIONS_BOOT_TO_FW_UI #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL -#else +#endif + +#ifdef __MAKEWITH_TIANO #define LibLocateHandle gBS->LocateHandleBuffer #endif @@ -166,7 +168,7 @@ static VOID AboutrEFInd(VOID) if (AboutMenu.EntryCount == 0) { AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.8.0.3"); + AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.8.1"); AddMenuInfoLine(&AboutMenu, L""); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer"); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012-2014 Roderick W. Smith"); @@ -1246,9 +1248,12 @@ static BOOLEAN HasSignedCounterpart(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN MergeStrings(&NewFile, Path, 0); MergeStrings(&NewFile, Filename, L'\\'); MergeStrings(&NewFile, L".efi.signed", 0); - if (FileExists(Volume->RootDir, NewFile)) - retval = TRUE; - MyFreePool(NewFile); + if (NewFile != NULL) { + CleanUpPathNameSlashes(NewFile); + if (FileExists(Volume->RootDir, NewFile)) + retval = TRUE; + MyFreePool(NewFile); + } // if return retval; } // BOOLEAN HasSignedCounterpart() @@ -1268,8 +1273,7 @@ static BOOLEAN ScanLoaderDir(IN REFIT_VOLUME *Volume, IN CHAR16 *Path, IN CHAR16 BOOLEAN FoundFallbackDuplicate = FALSE; if ((!SelfDirPath || !Path || ((StriCmp(Path, SelfDirPath) == 0) && (Volume->DeviceHandle != SelfVolume->DeviceHandle)) || - (StriCmp(Path, SelfDirPath) != 0)) && - (ShouldScan(Volume, Path))) { + (StriCmp(Path, SelfDirPath) != 0)) && (ShouldScan(Volume, Path))) { // look through contents of the directory DirIterOpen(Volume->RootDir, Path, &DirIter); while (DirIterNext(&DirIter, 2, Pattern, &DirEntry)) { @@ -1702,7 +1706,7 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Vo Entry->me.BadgeImage = Volume->VolBadgeImage; Entry->Volume = Volume; Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : - ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? L"USB" : L"HD"); + ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? L"USB" : L"HD"); Entry->Enabled = TRUE; // create the submenu @@ -1762,11 +1766,16 @@ static LEGACY_ENTRY * AddLegacyEntryUEFI(BDS_COMMON_OPTION *BdsOption, IN UINT16 LEGACY_ENTRY *Entry, *SubEntry; REFIT_MENU_SCREEN *SubScreen; CHAR16 ShortcutLetter = 0; - CHAR16 *LegacyDescription = BdsOption->Description; + CHAR16 *LegacyDescription = StrDuplicate(BdsOption->Description); if (IsInSubstring(LegacyDescription, GlobalConfig.DontScanVolumes)) return NULL; + // Remove stray spaces, since many EFIs produce descriptions with lots of + // extra spaces, especially at the end; this throws off centering of the + // description on the screen.... + LimitStringLength(LegacyDescription, 100); + // prepare the menu entry Entry = AllocateZeroPool(sizeof(LEGACY_ENTRY)); Entry->me.Title = AllocateZeroPool(256 * sizeof(CHAR16)); @@ -2038,6 +2047,7 @@ static UINTN ScanDriverDir(IN CHAR16 *Path) return (NumFound); } +#ifdef __MAKEWITH_GNUEFI static EFI_STATUS ConnectAllDriversToAllControllers(VOID) { EFI_STATUS Status; @@ -2105,6 +2115,12 @@ Done: MyFreePool (AllHandleBuffer); return Status; } /* EFI_STATUS ConnectAllDriversToAllControllers() */ +#else +static EFI_STATUS ConnectAllDriversToAllControllers(VOID) { + BdsLibConnectAllDriversToAllControllers(); + return 0; +} +#endif // Load all EFI drivers from rEFInd's "drivers" subdirectory and from the // directories specified by the user in the "scan_driver_dirs" configuration @@ -2148,8 +2164,7 @@ static VOID FindLegacyBootType(VOID) { GlobalConfig.LegacyType = LEGACY_TYPE_NONE; - // UEFI-style legacy BIOS support is available only with the TianoCore EDK2 - // build environment, and then only with some EFI implementations.... + // UEFI-style legacy BIOS support is available only with some EFI implementations.... Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios); if (!EFI_ERROR (Status)) GlobalConfig.LegacyType = LEGACY_TYPE_UEFI; @@ -2163,22 +2178,24 @@ static VOID FindLegacyBootType(VOID) { GlobalConfig.LegacyType = LEGACY_TYPE_MAC; } // static VOID FindLegacyBootType -// Warn the user if legacy OS scans are enabled but the firmware or this -// application can't support them.... -static VOID WarnIfLegacyProblems() { +// Warn the user if legacy OS scans are enabled but the firmware can't support them.... +static VOID WarnIfLegacyProblems(VOID) { BOOLEAN found = FALSE; UINTN i = 0; if (GlobalConfig.LegacyType == LEGACY_TYPE_NONE) { do { - if (GlobalConfig.ScanFor[i] == 'h' || GlobalConfig.ScanFor[i] == 'b' || GlobalConfig.ScanFor[i] == 'c') + if (GlobalConfig.ScanFor[i] == 'h' || GlobalConfig.ScanFor[i] == 'b' || GlobalConfig.ScanFor[i] == 'c' || + GlobalConfig.ScanFor[i] == 'H' || GlobalConfig.ScanFor[i] == 'B' || GlobalConfig.ScanFor[i] == 'C') found = TRUE; i++; } while ((i < NUM_SCAN_OPTIONS) && (!found)); + if (found) { Print(L"NOTE: refind.conf's 'scanfor' line specifies scanning for one or more legacy\n"); Print(L"(BIOS) boot options; however, this is not possible because your computer lacks\n"); - Print(L"the necessary Compatibility Support Module (CSM) support.\n"); + Print(L"the necessary Compatibility Support Module (CSM) support or that support is\n"); + Print(L"disabled in your firmware.\n"); PauseForKey(); } // if (found) } // if no legacy support @@ -2393,14 +2410,15 @@ static VOID ScanForTools(VOID) { } // static VOID ScanForTools // Rescan for boot loaders -VOID RescanAll(VOID) { +static VOID RescanAll(BOOLEAN DisplayMessage) { 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); + if (DisplayMessage) + egDisplayMessage(L"Scanning for new boot loaders; please wait....", &BGColor); FreeList((VOID ***) &(MainMenu.Entries), &MainMenu.EntryCount); MainMenu.Entries = NULL; MainMenu.EntryCount = 0; @@ -2522,7 +2540,6 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) CopyMem(GlobalConfig.ScanFor, "ihebocm ", NUM_SCAN_OPTIONS); SetConfigFilename(ImageHandle); ReadConfig(GlobalConfig.ConfigFilename); -// ScanVolumes(); InitScreen(); WarnIfLegacyProblems(); @@ -2544,10 +2561,11 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) BGColor.g = 175; BGColor.r = 100; BGColor.a = 0; - egDisplayMessage(L"Pausing before disk scan; please wait....", &BGColor); + if (GlobalConfig.ScanDelay > 1) + egDisplayMessage(L"Pausing before disk scan; please wait....", &BGColor); for (i = 0; i < GlobalConfig.ScanDelay; i++) refit_call1_wrapper(BS->Stall, 1000000); - RescanAll(); + RescanAll(GlobalConfig.ScanDelay > 1); } // if if (GlobalConfig.DefaultSelection) @@ -2559,7 +2577,7 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) // The Escape key triggers a re-scan operation.... if (MenuExit == MENU_EXIT_ESCAPE) { MenuExit = 0; - RescanAll(); + RescanAll(TRUE); continue; }