+// Determine what (if any) type of legacy (BIOS) boot support is available
+static VOID FindLegacyBootType(VOID) {
+#ifdef __MAKEWITH_TIANO
+ EFI_STATUS Status;
+ EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
+#endif
+
+ 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....
+#ifdef __MAKEWITH_TIANO
+ Status = gBS->LocateProtocol (&gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
+ if (!EFI_ERROR (Status))
+ GlobalConfig.LegacyType = LEGACY_TYPE_UEFI;
+#endif
+
+ // Macs have their own system. If the firmware vendor code contains the
+ // string "Apple", assume it's available. Note that this overrides the
+ // UEFI type, and might yield false positives if the vendor string
+ // contains "Apple" as part of something bigger, so this isn't 100%
+ // perfect.
+ if (StriSubCmp(L"Apple", ST->FirmwareVendor))
+ 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() {
+ 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')
+ 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 ");
+#ifdef __MAKEWITH_TIANO
+ Print(L"your computer lacks\n");
+ Print(L"the necessary Compatibility Support Module (CSM) support.\n");
+#else
+ Print(L"this program was\n");
+ Print(L"compiled without the necessary support. Please visit\n");
+ Print(L"http://www.rodsbooks.com/refind/getting.html and download and install a rEFInd\n");
+ Print(L"binary built with the TianoCore EDK2 to enable legacy boot support.\n");
+#endif
+ PauseForKey();
+ } // if (found)
+ } // if no legacy support
+} // static VOID WarnIfLegacyProblems()