From e0ac3b6aeaab38f58d57d592e97f05fd4bedf919 Mon Sep 17 00:00:00 2001 From: srs5694 Date: Mon, 19 Aug 2013 14:53:39 -0400 Subject: [PATCH] Support for memtest86 as a second-row item. --- NEWS.txt | 13 ++++++++++++ docs/refind/installing.html | 20 ++++++++++++++++++- refind.conf-sample | 15 ++++++++------ refind/config.c | 2 ++ refind/global.h | 3 ++- refind/lib.c | 2 +- refind/main.c | 40 +++++++++++++++++++++++++++++++------ 7 files changed, 80 insertions(+), 15 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index f4b8a4a..821dbe8 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,6 +1,19 @@ 0.7.4 (?/??/2013): ------------------ +- Added support for memtest86 as second-row option. Program must be + stored in EFI/tools, EFI/tools/memtest, EFI/tools/memtest86, EFI/memtest, + or EFI/memtest86; and must use the name memtest86.efi, memtest86_x64.efi, + memtest86x64.efi, or bootx64.efi (changing "x64" to "ia32" on IA-32 + systems). The memtest86 program is scanned for when the "showtools" + option includes the "memtest" or "memtest86" token, which it does by + default. + +- Added space to end of "Boot %s from %s" string; enables adding a space + to the end of the "default_selection" item (in quotes) to set a default + that matches a volume name that's identical to another one except for + extra characters at the end of the non-wanted volume's name. + - Fixed bug that could cause rEFInd to hang when launching boot loaders under some conditions. (Launching from Firewire drives on Macs is the known case, but there may be others.) diff --git a/docs/refind/installing.html b/docs/refind/installing.html index afa0241..cfbaa06 100644 --- a/docs/refind/installing.html +++ b/docs/refind/installing.html @@ -834,7 +834,7 @@ $ ioreg -l -p IODeviceTree | grep firmware-abi
  • shell.efi—This - file, placed in the ESP's efi/tools directory, adds the + file, placed in the ESP's EFI/tools directory, adds the ability to launch a text-mode EFI shell from rEFInd. Note that the download link is to a 64-bit binary that must be renamed before rEFInd will recognize it. Additional shell download links appear on the ioreg -l -p IODeviceTree | grep firmware-abi Linux wiki, and on other sites; try a Web search if the shell you find doesn't work to your satisfaction.
  • +
  • Memtest86—This + is a popular tool for performing basic hardware tests, and especially + memory tests. rEFInd recognizes this program when it is stored in the + EFI/tools, EFI/tools/memtest, + EFI/tools/memtest86, EFI/memtest, or + EFI/memtest86 directory, with a program filename of + memtest86.efi, memtest86_x64.efi, + memtest86x64.efi, or bootx64.efi. (Change + x64 to ia32 on IA-32 systems.) Be sure to download + the EFI version of the program. If you get the USB flash drive version, + you should mount the flash drive's ESP (partition 2) and copy the + EFI/BOOT directory to your own ESP's + EFI/tools/memtest or other Memtest86 directory name, as just + specified. rEFInd should then recognize it, provided the + showtools line includes the memtest or + memtest86 token.
  • +
  • gptsync.efi or gptsync_arch.efi—This program creates a hybrid MBR from diff --git a/refind.conf-sample b/refind.conf-sample index 5d49d01..37c6f23 100644 --- a/refind.conf-sample +++ b/refind.conf-sample @@ -133,6 +133,8 @@ timeout 20 # order to display them: # shell - the EFI shell (requires external program; see rEFInd # documentation for details) +# memtest - the memtest86 program, in EFI/tools, EFI/memtest86, +# EFI/memtest, EFI/tools/memtest86, or EFI/tools/memtest # gptsync - the (dangerous) gptsync.efi utility (requires external # program; see rEFInd documentation for details) # apple_recovery - boots the Apple Recovery HD partition, if present @@ -145,9 +147,9 @@ timeout 20 # reboot - a tag to reboot the computer # firmware - a tag to reboot the computer into the firmware's # user interface (ignored on older computers) -# Default is shell,apple_recovery,mok_tool,about,shutdown,reboot,firmware +# Default is shell,memtest,apple_recovery,mok_tool,about,shutdown,reboot,firmware # -#showtools shell, mok_tool, about, reboot, exit, firmware +#showtools shell, memtest, mok_tool, about, reboot, exit, firmware # Directories in which to search for EFI drivers. These drivers can # provide filesystem support, give access to hard disks on plug-in @@ -208,10 +210,11 @@ timeout 20 #dont_scan_volumes "Recovery HD" # Directories that should NOT be scanned for boot loaders. By default, -# rEFInd doesn't scan its own directory or the EFI/tools directory. -# You can "blacklist" additional directories with this option, which -# takes a list of directory names as options. You might do this to -# keep EFI/boot/bootx64.efi out of the menu if that's a duplicate of +# rEFInd doesn't scan its own directory, the EFI/tools directory, the +# EFI/memtest directory, or the EFI/memtest86 directory. You can +# "blacklist" additional directories with this option, which takes a +# list of directory names as options. You might do this to keep +# EFI/boot/bootx64.efi out of the menu if that's a duplicate of # another boot loader or to exclude a directory that holds drivers # or non-bootloader utilities provided by a hardware manufacturer. If # a directory is listed both here and in also_scan_dirs, dont_scan_dirs diff --git a/refind/config.c b/refind/config.c index 97c62d6..5dfea7d 100644 --- a/refind/config.c +++ b/refind/config.c @@ -465,6 +465,8 @@ VOID ReadConfig(CHAR16 *FileName) GlobalConfig.ShowTools[i - 1] = TAG_MOK_TOOL; } else if (StriCmp(FlagName, L"firmware") == 0) { GlobalConfig.ShowTools[i - 1] = TAG_FIRMWARE; + } else if ((StriCmp(FlagName, L"memtest86") == 0) || (StriCmp(FlagName, L"memtest") == 0)) { + GlobalConfig.ShowTools[i - 1] = TAG_MEMTEST; } else { Print(L" unknown showtools flag: '%s'\n", FlagName); } diff --git a/refind/global.h b/refind/global.h index 82772f2..131a47b 100644 --- a/refind/global.h +++ b/refind/global.h @@ -71,7 +71,8 @@ #define TAG_APPLE_RECOVERY (11) #define TAG_MOK_TOOL (12) #define TAG_FIRMWARE (13) -#define NUM_TOOLS (13) +#define TAG_MEMTEST (14) +#define NUM_TOOLS (14) #define NUM_SCAN_OPTIONS 10 diff --git a/refind/lib.c b/refind/lib.c index 6d09f02..2e06c96 100644 --- a/refind/lib.c +++ b/refind/lib.c @@ -1,5 +1,5 @@ /* - * refit/lib.c + * refind/lib.c * General library functions * * Copyright (c) 2006-2009 Christoph Pfisterer diff --git a/refind/main.c b/refind/main.c index 392bed2..37a0b18 100644 --- a/refind/main.c +++ b/refind/main.c @@ -69,9 +69,11 @@ // constants #define MACOSX_LOADER_PATH L"System\\Library\\CoreServices\\boot.efi" +#define MEMTEST_LOCATIONS L"EFI\\tools,EFI\\tools\\memtest86,EFI\\tools\\memtest,EFI\\memtest86,EFI\\memtest" #if defined (EFIX64) #define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\EFI\\tools\\shellx64.efi,\\shell.efi,\\shellx64.efi" #define GPTSYNC_NAMES L"\\EFI\\tools\\gptsync.efi,\\EFI\\tools\\gptsync_x64.efi" +#define MEMTEST_NAMES L"memtest86.efi,memtest86_x64.efi,memtest86x64.efi,bootx64.efi" #define DRIVER_DIRS L"drivers,drivers_x64" #define FALLBACK_FULLNAME L"EFI\\BOOT\\bootx64.efi" #define FALLBACK_BASENAME L"bootx64.efi" @@ -79,6 +81,7 @@ #elif defined (EFI32) #define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\EFI\\tools\\shellia32.efi,\\shell.efi,\\shellia32.efi" #define GPTSYNC_NAMES L"\\EFI\\tools\\gptsync.efi,\\EFI\\tools\\gptsync_ia32.efi" +#define MEMTEST_NAMES L"memtest86.efi,memtest86_ia32.efi,memtest86ia32.efi,bootia32.efi" #define DRIVER_DIRS L"drivers,drivers_ia32" #define FALLBACK_FULLNAME L"EFI\\BOOT\\bootia32.efi" #define FALLBACK_BASENAME L"bootia32.efi" @@ -86,6 +89,7 @@ #else #define SHELL_NAMES L"\\EFI\\tools\\shell.efi,\\shell.efi" #define GPTSYNC_NAMES L"\\EFI\\tools\\gptsync.efi" +#define MEMTEST_NAMES L"memtest86.efi" #define DRIVER_DIRS L"drivers" #define FALLBACK_FULLNAME L"EFI\\BOOT\\boot.efi" /* Not really correct */ #define FALLBACK_BASENAME L"boot.efi" /* Not really correct */ @@ -127,8 +131,8 @@ static REFIT_MENU_SCREEN AboutMenu = { L"About", NULL, 0, NULL, 0, NULL, 0, REFIT_CONFIG GlobalConfig = { FALSE, FALSE, 0, 0, 0, DONT_CHANGE_TEXT_MODE, 20, 0, 0, GRAPHICS_FOR_OSX, LEGACY_TYPE_MAC, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - { TAG_SHELL, TAG_APPLE_RECOVERY, TAG_MOK_TOOL, TAG_ABOUT, TAG_SHUTDOWN, TAG_REBOOT, TAG_FIRMWARE, - 0, 0, 0, 0, 0, 0 } + { TAG_SHELL, TAG_MEMTEST, TAG_APPLE_RECOVERY, TAG_MOK_TOOL, TAG_ABOUT, TAG_SHUTDOWN, + TAG_REBOOT, TAG_FIRMWARE, 0, 0, 0, 0, 0, 0 } }; EFI_GUID GlobalGuid = EFI_GLOBAL_VARIABLE; @@ -151,7 +155,7 @@ static VOID AboutrEFInd(VOID) if (AboutMenu.EntryCount == 0) { AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT); - AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.7.3.4"); + AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.7.3.6"); AddMenuInfoLine(&AboutMenu, L""); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer"); AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012-2013 Roderick W. Smith"); @@ -1007,7 +1011,7 @@ LOADER_ENTRY * AddLoaderEntry(IN CHAR16 *LoaderPath, IN CHAR16 *LoaderTitle, IN if (Entry != NULL) { Entry->Title = StrDuplicate((LoaderTitle != NULL) ? LoaderTitle : LoaderPath); Entry->me.Title = AllocateZeroPool(sizeof(CHAR16) * 256); - SPrint(Entry->me.Title, 255, L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : LoaderPath, Volume->VolName); + SPrint(Entry->me.Title, 255, L"Boot %s from %s ", (LoaderTitle != NULL) ? LoaderTitle : LoaderPath, Volume->VolName); Entry->me.Row = 0; Entry->me.BadgeImage = Volume->VolBadgeImage; if ((LoaderPath != NULL) && (LoaderPath[0] != L'\\')) { @@ -1368,7 +1372,8 @@ static VOID ScanEfiFiles(REFIT_VOLUME *Volume) { // scan subdirectories of the EFI directory (as per the standard) DirIterOpen(Volume->RootDir, L"EFI", &EfiDirIter); while (DirIterNext(&EfiDirIter, 1, NULL, &EfiDirEntry)) { - if (StriCmp(EfiDirEntry->FileName, L"tools") == 0 || EfiDirEntry->FileName[0] == '.') + if (StriCmp(EfiDirEntry->FileName, L"tools") == 0 || (StriCmp(EfiDirEntry->FileName, L"memtest") == 0) || + (StriCmp(EfiDirEntry->FileName, L"memtest86") == 0) || EfiDirEntry->FileName[0] == '.') continue; // skip this, doesn't contain boot loaders or is scanned later SPrint(FileName, 255, L"EFI\\%s", EfiDirEntry->FileName); if (ScanLoaderDir(Volume, FileName, MatchPatterns)) @@ -2198,7 +2203,7 @@ static VOID ScanForBootloaders(VOID) { // Add the second-row tags containing built-in and external tools (EFI shell, // reboot, etc.) static VOID ScanForTools(VOID) { - CHAR16 *FileName = NULL, *MokLocations, *MokName, *PathName, Description[256]; + CHAR16 *FileName = NULL, *MokLocations, *MokName, *MemtestName, *PathName, Description[256]; REFIT_MENU_ENTRY *TempMenuEntry; UINTN i, j, k, VolumeIndex; UINT64 osind; @@ -2262,6 +2267,7 @@ static VOID ScanForTools(VOID) { } // while FileName = NULL; break; + case TAG_APPLE_RECOVERY: FileName = StrDuplicate(L"\\com.apple.recovery.boot\\boot.efi"); for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) { @@ -2274,6 +2280,7 @@ static VOID ScanForTools(VOID) { MyFreePool(FileName); FileName = NULL; break; + case TAG_MOK_TOOL: j = 0; while ((FileName = FindCommaDelimited(MokLocations, j++)) != NULL) { @@ -2293,8 +2300,29 @@ static VOID ScanForTools(VOID) { } // while MOK_NAMES MyFreePool(FileName); } // while MokLocations + break; + case TAG_MEMTEST: + j = 0; + while ((FileName = FindCommaDelimited(MEMTEST_LOCATIONS, j++)) != NULL) { + k = 0; + while ((MemtestName = FindCommaDelimited(MEMTEST_NAMES, k++)) != NULL) { + PathName = StrDuplicate(FileName); + MergeStrings(&PathName, MemtestName, (StriCmp(PathName, L"\\") == 0) ? 0 : L'\\'); + for (VolumeIndex = 0; VolumeIndex < VolumesCount; VolumeIndex++) { + if ((Volumes[VolumeIndex]->RootDir != NULL) && (FileExists(Volumes[VolumeIndex]->RootDir, PathName))) { + SPrint(Description, 255, L"Memory test utility at %s on %s", PathName, Volumes[VolumeIndex]->VolName); + AddToolEntry(Volumes[VolumeIndex]->DeviceHandle, PathName, Description, + BuiltinIcon(BUILTIN_ICON_FUNC_FIRMWARE), 'S', FALSE); + } // if + } // for + MyFreePool(PathName); + MyFreePool(MemtestName); + } // while MEMTEST_NAMES + MyFreePool(FileName); + } // while MEMTEST_LOCATIONS break; + } // switch() } // for } // static VOID ScanForTools -- 2.39.2