From c9ff72d4b0e75b0683497678aff962911a9364fe Mon Sep 17 00:00:00 2001 From: srs5694 Date: Sat, 21 Apr 2012 19:40:17 -0400 Subject: [PATCH] Fixed (maybe) a Mac-specific bug that caused hangs on returning from the EFI shell. --- NEWS.txt | 7 +++++++ docs/refind/configfile.html | 7 ++++++- refind/lib.c | 29 ++++++++++++++++++----------- refind/main.c | 4 ++-- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index 71e4ab0..36fb2fb 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,6 +1,13 @@ 0.2.8 (?/??/2012): ------------------ +- Fixed (maybe) a bug that caused rEFInd to crash when returning from an + EFI shell or other programs on Macs, particularly when rEFInd used + graphical mode. I'm not 100% sure this bug is squashed because I still + don't understand the cause and I only have one Mac for testing. See + comments in the ReinitRefitLib() function in refit/lib.c for more + details. + - Added new refind.conf option: scan_all_linux_kernels, which causes Linux kernels that lack ".efi" extensions to be included in scans for EFI boot loaders. This may help integration with Linux distributions that don't diff --git a/docs/refind/configfile.html b/docs/refind/configfile.html index 8083021..354349e 100644 --- a/docs/refind/configfile.html +++ b/docs/refind/configfile.html @@ -109,7 +109,7 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com

  • You can place a boot loader in a directory with a name that matches one of rEFInd's standard icons, which take names of the form os_name.icns. To use this icon, you would place the boot loader in the directory called name.
  • -
  • You can name an icon file after your boot loader, but with an extension of .icns. For instance, if you're using loader.efi, you would name the icon file loader.icns. These icon files should be 128x128 images in Apple's ICNS format. You can create such files easily in OS X or convert PNG files to ICNS format with libicns.
  • +
  • You can name an icon file after your boot loader, but with an extension of .icns. For instance, if you're using loader.efi, you would name the icon file loader.icns. These icon files should be 128x128 images in Apple's ICNS format. You can create such files easily in OS X or convert PNG files to ICNS format with libicns. Note that the scan_all_linux_kernels option can cause loader-specific icon files for Linux kernels (but not other loaders) to be improperly assigned loader tags, so if you want to use this option, you should not also assign your kernels custom icons in this way.
  • If you're booting OS X from its standard boot loader, or if you place a boot loader file in the root directory of a partition, you can create a file called .VolumeIcon.icns that holds an icon file. OS X uses this file for its volume icons, so rEFInd picks up these icons automatically, provided they include 128x128 bitmaps.
  • @@ -187,6 +187,11 @@ timeout 20 directory path(s) Adds the specified directory or directories to the directory list that rEFInd scans for EFI boot loaders when scanfor includes the internal, external, or optical options. Directories are specified relative to the filesystem's root directory. If this option is used, it's applied to all the filesystems that rEFInd scans. If a specified directory doesn't exist, rEFInd ignores it (no error results). + + scan_all_linux_kernels + None + When set, causes rEFInd to add Linux kernels (files with names that begin with vmlinuz or bzImage) to the list of EFI boot loaders, even if they lack .efi filename extensions. The hope is that this will simplify use of rEFInd on distributions that provide kernels with EFI stub loader support but that don't give those kernels names that end in .efi. Of course, the kernels must still be stored on a filesystem that rEFInd can read, and in a directory that it scans. (Drivers and the also_scan_dirs options can help with those issues.) Note that this option can cause unwanted files to be improperly detected and given loader tags, such as older kernels without EFI stub loader support and .icns files used to give kernels unique icons. For this reason, it's disabled by default. + default_selection A substring of a boot loader's title diff --git a/refind/lib.c b/refind/lib.c index 174c27b..9685005 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -157,16 +157,23 @@ EFI_STATUS ReinitRefitLib(VOID) { ReinitVolumes(); - // Below two lines were in rEFIt, but seem to cause problems on - // most systems. OTOH, my Mac Mini produces (apparently harmless) - // errors about "(re)opening our installation volume" (see the - // next function) when returning from programs when these two lines - // are removed. On the gripping hand, the Mac SOMETIMES crashes - // when launching a second program even with these lines removed. - // TODO: Figure out cause of above weirdness and fix it more - // reliably! - /* if (SelfVolume != NULL && SelfVolume->RootDir != NULL) - SelfRootDir = SelfVolume->RootDir; */ + if ((ST->Hdr.Revision >> 16) == 1) { + // Below two lines were in rEFIt, but seem to cause system crashes or + // reboots when launching OSes after returning from programs on most + // systems. OTOH, my Mac Mini produces errors about "(re)opening our + // installation volume" (see the next function) when returning from + // programs when these two lines are removed, and it often crashes + // when returning from a program or when launching a second program + // with these lines removed. Therefore, the preceding if() statement + // executes these lines only on EFIs with a major version number of 1 + // (which Macs have) and not with 2 (which UEFI PCs have). My selection + // of hardware on which to test is limited, though, so this may be the + // wrong test, or there may be a better way to fix this problem. + // TODO: Figure out cause of above weirdness and fix it more + // reliably! + if (SelfVolume != NULL && SelfVolume->RootDir != NULL) + SelfRootDir = SelfVolume->RootDir; + } // if return FinishInitRefitLib(); } @@ -197,7 +204,7 @@ static EFI_STATUS FinishInitRefitLib(VOID) VOID CreateList(OUT VOID ***ListPtr, OUT UINTN *ElementCount, IN UINTN InitialElementCount) { UINTN AllocateCount; - + *ElementCount = InitialElementCount; if (*ElementCount > 0) { AllocateCount = (*ElementCount + 7) & ~7; // next multiple of 8 diff --git a/refind/main.c b/refind/main.c index 7ce4bcc..03b53cc 100644 --- a/refind/main.c +++ b/refind/main.c @@ -96,7 +96,7 @@ static VOID AboutrEFInd(VOID) { if (AboutMenu.EntryCount == 0) { AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.2.7.2"); + AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.2.7.3"); AddMenuInfoLine(&AboutMenu, L""); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer"); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith"); @@ -1134,7 +1134,7 @@ static UINTN ScanDriverDir(IN CHAR16 *Path) // look through contents of the directory DirIterOpen(SelfRootDir, Path, &DirIter); - while (DirIterNext(&DirIter, 2, L"*.efi", &DirEntry)) { + while (DirIterNext(&DirIter, 2, LOADER_MATCH_PATTERNS, &DirEntry)) { if (DirEntry->FileName[0] == '.') continue; // skip this -- 2.39.2