]> code.delx.au - refind/commitdiff
Further refinement of the legacy UEFI boot feature.
authorsrs5694 <srs5694@users.sourceforge.net>
Sat, 6 Oct 2012 04:51:03 +0000 (00:51 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Sat, 6 Oct 2012 04:51:03 +0000 (00:51 -0400)
EfiLib/BdsHelper.c
EfiLib/BdsHelper.h
NEWS.txt
docs/refind/configfile.html
docs/refind/features.html
refind/global.h
refind/main.c

index 1f8c5aa69225c732081426a24a0a461e7d253209..af17d4f0e51f8c8e2528bb6354aedda4303065ae 100644 (file)
@@ -32,7 +32,6 @@ UpdateBbsTable (
 {
     UINT16  Idx;
     EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;
-//    EFI_GUID EfiLegacyBootProtocolGuid     = { 0xdb9a1e3d, 0x45cb, 0x4abb, { 0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d }};
     EFI_STATUS                Status;
     UINT16                       HddCount = 0;
     HDD_INFO                     *HddInfo = NULL; 
@@ -85,17 +84,17 @@ UpdateBbsTable (
 }
 
 // Internal helper function
-BOOLEAN ArrayContains(UINT16* Arr, UINT8 ArrLen, UINT8 Target)
-{
-    UINT8 i;
-    for(i = 0; i < ArrLen; i++)
-    {
-       if(Arr[i] == Target)
-          return TRUE;
-    }
-
-  return FALSE;
-}
+// BOOLEAN ArrayContains(UINT16* Arr, UINT8 ArrLen, UINT8 Target)
+// {
+//     UINT8 i;
+//     for(i = 0; i < ArrLen; i++)
+//     {
+//        if(Arr[i] == Target)
+//           return TRUE;
+//     }
+// 
+//   return FALSE;
+// }
 
 /**
     Boot the legacy system with the boot option
@@ -122,24 +121,23 @@ BdsLibDoLegacyBoot (
     }
     OptionBBS = (BBS_BBS_DEVICE_PATH *) Option->DevicePath;
 
-    //Print(L"\n\n");
-    //Print(L"Option->Name='%s'\n", Option->OptionName);
-    //Print(L"Option->Number='%d'\n", Option->OptionNumber);
-    //Print(L"Option->Description='%s'\n", Option->Description);
-    //Print(L"Option->LoadOptionsSize='%d'\n",Option->LoadOptionsSize);
-    //Print(L"Option->BootCurrent='%d'\n",Option->BootCurrent);
-    //Print(L"Option->DevicePath->Type= '%d'\n", Option->DevicePath->Type);
-    //Print(L"Option->DevicePath->SubType= '%d'\n", Option->DevicePath->SubType);
-    //Print(L"Option->DevicePath->Length[0]= '%d'\n", Option->DevicePath->Length[0]);
-    //Print(L"Option->DevicePath->Length[1]= '%d'\n", Option->DevicePath->Length[1]); 
-    //Print(L"OptionBBS->DeviceType='%d'\n",OptionBBS->DeviceType);
-    //Print(L"OptionBBS->StatusFlag='%d'\n",OptionBBS->StatusFlag);
-    //Print(L"OptionBBS->String[0]='%c'\n",OptionBBS->String[0]);
-    //Print(L"About to legacy boot!\n");
-    //PauseForKey();
+//     Print(L"\n\n");
+//     Print(L"Option->Name='%s'\n", Option->OptionName);
+//     Print(L"Option->Number='%d'\n", Option->OptionNumber);
+//     Print(L"Option->Description='%s'\n", Option->Description);
+//     Print(L"Option->LoadOptionsSize='%d'\n",Option->LoadOptionsSize);
+//     Print(L"Option->BootCurrent='%d'\n",Option->BootCurrent);
+//     Print(L"Option->DevicePath->Type= '%d'\n", Option->DevicePath->Type);
+//     Print(L"Option->DevicePath->SubType= '%d'\n", Option->DevicePath->SubType);
+//     Print(L"Option->DevicePath->Length[0]= '%d'\n", Option->DevicePath->Length[0]);
+//     Print(L"Option->DevicePath->Length[1]= '%d'\n", Option->DevicePath->Length[1]);
+//     Print(L"OptionBBS->DeviceType='%d'\n",OptionBBS->DeviceType);
+//     Print(L"OptionBBS->StatusFlag='%d'\n",OptionBBS->StatusFlag);
+//     Print(L"OptionBBS->String[0]='%c'\n",OptionBBS->String[0]);
+//     Print(L"About to legacy boot!\n");
+//     PauseForKey();
 
     UpdateBbsTable(OptionBBS->DeviceType); 
 
     return LegacyBios->LegacyBoot (LegacyBios, (BBS_BBS_DEVICE_PATH *) Option->DevicePath, Option->LoadOptionsSize, Option->LoadOptions);
-}
-
+}
\ No newline at end of file
index 3b3c03b2ddcb901d656b655cf882933df8fbb7d2..23240328934d16c80b42f95ff08b22bd4abd559a 100644 (file)
@@ -25,4 +25,9 @@ BdsLibDoLegacyBoot (
   IN  BDS_COMMON_OPTION           *Option
   );
 
+EFI_STATUS BdsConnectDevicePath  (  IN EFI_DEVICE_PATH_PROTOCOL *    DevicePath,
+                                    OUT EFI_HANDLE *     Handle,
+                                    OUT EFI_DEVICE_PATH_PROTOCOL **     RemainingDevicePath
+);
+
 #endif //_BDS_HELPER_H_
index a4a3f21787914d946f93bd42b0cad496fd5de0d8..421f6bd377cbbf60326591a0c44e3ba7af2723c7 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -4,11 +4,19 @@
 - Added new "scan_delay" feature to impose a delay before scanning
   for disks.
 
-- Changed default "scanfor" option from internal-external-optical to
-  internal-external-optical-manual. This will have no effect with the
-  standard refind.conf file, which has no manual stanzas defined; but some
-  users seem to overlook this setting, and think that adding manual stanzas
-  is enough to activate them. This will make it so.
+- Changed default "scanfor" option from internal-external-optical to either
+  internal-external-optical-manual (for non-Macs) or
+  internal-hdbios-external-biosexternal-optical-cd-manual (for Macs). I've
+  done this for two reasons:
+  - Many Mac users have been confused by the fact that rEFInd needs
+    reconfiguration to detect Windows (or Linux installed in BIOS mode),
+    since rEFIt scans BIOS devices by default. Adding the BIOS options as
+    default for them should help them.
+  - Adding the "manual" option enables users to simply add manual boot
+    stanzas and have them work, which is more intuitive. Adding the
+    "manual" option will have no effect unless manual stanzas are created
+    or uncommented, so this part of the change won't affect users' working
+    default configurations.
 
 - Added new legacy (BIOS) boot support for UEFI-based PCs.
 
index ced903270a459898f65fc369a6064d70f6c91696..a2e7085bb497d4dcc8de905b02b374bb208b2884 100644 (file)
@@ -15,7 +15,7 @@
 href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
 
 <p>Originally written: 3/14/2012; last Web page update:
-8/12/2012, referencing rEFInd 0.4.5</p>
+10/6/2012, referencing rEFInd 0.4.6</p>
 
 
 <p>I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!</p>
@@ -196,7 +196,7 @@ timeout 20
 <tr>
    <td><tt>scanfor</tt></td>
    <td><tt>internal</tt>, <tt>external</tt>, <tt>optical</tt>, <tt>hdbios</tt>, <tt>biosexternal</tt>, <tt>cd</tt>, and <tt>manual</tt></td>
-   <td>Tells rEFInd what methods to use to locate boot loaders. The <tt>internal</tt>, <tt>external</tt>, and <tt>optical</tt> parameters tell rEFInd to scan for EFI boot loaders on internal, external, and optical (CD, DVD, and Blu-ray) devices, respectively. The <tt>hdbios</tt>, <tt>biosexternal</tt>, and <tt>cd</tt> parameters are similar, but scan for BIOS boot loaders. (Note that the BIOS options are likely to be useless on UEFI PCs.) The <tt>manual</tt> parameter tells rEFInd to scan the configuration file for manual settings. You can specify multiple parameters to have the program scan for multiple boot loader types. When you do so, the order determines the order in which the boot loaders appear in the menu. The default is <tt>internal, external, optical</tt>.</td>
+   <td>Tells rEFInd what methods to use to locate boot loaders. The <tt>internal</tt>, <tt>external</tt>, and <tt>optical</tt> parameters tell rEFInd to scan for EFI boot loaders on internal, external, and optical (CD, DVD, and Blu-ray) devices, respectively. The <tt>hdbios</tt>, <tt>biosexternal</tt>, and <tt>cd</tt> parameters are similar, but scan for BIOS boot loaders. (Note that the BIOS options scan more thoroughly and actively on Macs than on UEFI-based PCs; for the latter, only options in the firmware's boot list are scanned.) The <tt>manual</tt> parameter tells rEFInd to scan the configuration file for manual settings. You can specify multiple parameters to have the program scan for multiple boot loader types. When you do so, the order determines the order in which the boot loaders appear in the menu. The default is <tt>internal, external, optical, manual</tt> on most systems, but <tt>internal, hdbios, external, biosexternal, optical, cd, manual</tt> on Macs.</td>
 </tr>
 <tr>
    <td><tt>scan_delay</tt></td>
index 1b6a717e8993e9f319d3eba4836204549fc5b86a..cfccba2ccf14abc975afab267ab7aaf94c8108f9 100644 (file)
@@ -15,7 +15,7 @@
 href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
 
 <p>Originally written: 3/14/2012; last Web page update:
-8/12/2012, referencing rEFInd 0.4.5</p>
+10/6/2012, referencing rEFInd 0.4.6</p>
 
 <p>I'm a technical writer and consultant specializing in Linux technologies. This Web page is provided free of charge and with no annoying outside ads; however, I did take time to prepare it, and Web hosting does cost money. If you find this Web page useful, please consider making a small donation to help keep this site up and running. Thanks!</p>
 
@@ -99,7 +99,9 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
 
 <li>User-configurable graphics and icons&mdash;you can set your own background, set new icons, and so on.</li>
 
-<li>Launch EFI boot loaders or, on Macs, launch BIOS-based boot loaders. (I have yet to get the BIOS-launching feature to work on a UEFI-based PC, but it might work on a model I don't own.)</li>
+<li>Launch EFI boot loaders</li>
+
+<li>Launch legacy (BIOS) boot loaders on Macs and on some UEFI-based PCs. On the latter, the BIOS boot device must be listed in the firmware's boot options. Often only the hard disk and optical disc are listed by default. Scanning for legacy OSes is more thorough on Macs.</li>
 
 <li>Launch options for an external EFI shell or disk partitioner. (See the <a href="installing.html">Installing rEFInd</a> section for information on how to obtain and install these components.)</li>
 
index 62845d781cc88c9d057fad8da9afb877db550a55..82aa65fa56f27103f14830837b22a67ab5586029 100644 (file)
 #define BBS_UNKNOWN       0xff
 #endif
 
+// BIOS Boot Specification (BBS) device types, as returned in DevicePath->Type field
+#define DEVICE_TYPE_HW         0x01
+#define DEVICE_TYPE_ACPI       0x02 /* returned by UEFI boot loader on USB */
+#define DEVICE_TYPE_MESSAGING  0x03
+#define DEVICE_TYPE_MEDIA      0x04 /* returned by EFI boot loaders on hard disk */
+#define DEVICE_TYPE_BIOS       0x05 /* returned by legacy (BIOS) boot loaders */
+#define DEVICE_TYPE_END        0x75 /* end of path */
+
 //TODO: may want to make this configurable via config file
 //static UINT16 SupportedLegacyDevices[] = {BBS_HARDDISK, BBS_CDROM, BBS_USB};
 
index b0f769a806d5e671a08de5f604112f8176b54219..c459d726fd3e52839f70f1ee00f682c8b40834cf 100644 (file)
@@ -115,7 +115,7 @@ static VOID AboutrEFInd(VOID)
 
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.5.5");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.4.5.6");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012 Roderick W. Smith");
@@ -1263,6 +1263,8 @@ static LEGACY_ENTRY * AddLegacyEntryUEFI(BDS_COMMON_OPTION *BdsOption, IN UINT16
     CHAR16                  ShortcutLetter = 0;
     CHAR16 *LegacyDescription = BdsOption->Description;
 
+//    ScanVolume(Volume);
+
     // prepare the menu entry
     Entry = AllocateZeroPool(sizeof(LEGACY_ENTRY));
     Entry->me.Title = AllocateZeroPool(256 * sizeof(CHAR16));
@@ -1310,7 +1312,7 @@ static VOID ScanLegacyUEFI(IN UINTN DiskType)
     EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;
     UINT16                    *BootOrder = NULL;
     UINTN                     Index = 0;
-    UINT16                    BootOption[10];
+    CHAR16                    BootOption[10];
     UINTN                     BootOrderSize = 0;
     CHAR16            Buffer[20];
     BDS_COMMON_OPTION *BdsOption;
@@ -1339,15 +1341,18 @@ static VOID ScanLegacyUEFI(IN UINTN DiskType)
         // Grab each boot option variable from the boot order, and convert
         // the variable into a BDS boot option
         UnicodeSPrint (BootOption, sizeof (BootOption), L"Boot%04x", BootOrder[Index]);
+        Print(L"Scanning '%s'\n", BootOption);
         BdsOption = BdsLibVariableToOption (&TempList, BootOption);
 
         if (BdsOption != NULL) {
-           //Print(L"Option description = '%s'\n", BdsOption->Description);
            BbsDevicePath = (BBS_BBS_DEVICE_PATH *)BdsOption->DevicePath;
 
-           // Only add the entry if it is of a supported type (e.g. USB, HD)
-           // See BdsHelper.c for currently supported types
-           if (BbsDevicePath->DeviceType == DiskType) {
+           // Only add the entry if it is of a requested type (e.g. USB, HD)
+
+           // Two checks necessary because some systems return EFI boot loaders
+           // with a DeviceType value that would inappropriately include them
+           // as legacy loaders....
+           if ((BbsDevicePath->DeviceType == DiskType) && (BdsOption->DevicePath->Type == DEVICE_TYPE_BIOS)) {
               AddLegacyEntryUEFI(BdsOption, BbsDevicePath->DeviceType);
            }
         }
@@ -1793,7 +1798,11 @@ efi_main (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
         return Status;
 
     // read configuration
-    CopyMem(GlobalConfig.ScanFor, "ieom      ", NUM_SCAN_OPTIONS);
+    FindLegacyBootType();
+    if (GlobalConfig.LegacyType == LEGACY_TYPE_MAC)
+       CopyMem(GlobalConfig.ScanFor, "ihebocm   ", NUM_SCAN_OPTIONS);
+    else
+       CopyMem(GlobalConfig.ScanFor, "ieom      ", NUM_SCAN_OPTIONS);
     ReadConfig();
     MainMenu.TimeoutSeconds = GlobalConfig.Timeout;
 
@@ -1801,7 +1810,6 @@ efi_main (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
     refit_call4_wrapper(BS->SetWatchdogTimer, 0x0000, 0x0000, 0x0000, NULL);
 
     // further bootstrap (now with config available)
-    FindLegacyBootType();
     SetupScreen();
     if (GlobalConfig.ScanDelay > 0) {
        BGColor.b = 255;