- }
-
- Status = LegacyBios->GetBbsInfo (LegacyBios, &HddCount, &HddInfo, &BbsCount, &LocalBbsTable);
-
- //Print (L"\n");
- //Print (L" NO Prio bb/dd/ff cl/sc Type Stat segm:offs\n");
- //Print (L"=============================================\n");
-
- for (Idx = 0; Idx < BbsCount; Idx++)
- {
- if(LocalBbsTable[Idx].DeviceType == 0){
- continue;
- }
-
- // Set devices of a particular type to BootPriority of 0. I believe 0 is the highest priority
- if(LocalBbsTable[Idx].DeviceType == DeviceType){
- LocalBbsTable[Idx].BootPriority = 0;
- }
-
-/*
- Print (
- L" %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x %04x:%04x\n",
- (UINTN) Idx,
- (UINTN) LocalBbsTable[Idx].BootPriority,
- (UINTN) LocalBbsTable[Idx].Bus,
- (UINTN) LocalBbsTable[Idx].Device,
- (UINTN) LocalBbsTable[Idx].Function,
- (UINTN) LocalBbsTable[Idx].Class,
- (UINTN) LocalBbsTable[Idx].SubClass,
- (UINTN) LocalBbsTable[Idx].DeviceType,
- (UINTN) * (UINT16 *) &LocalBbsTable[Idx].StatusFlags,
- (UINTN) LocalBbsTable[Idx].BootHandlerSegment,
- (UINTN) LocalBbsTable[Idx].BootHandlerOffset,
- (UINTN) ((LocalBbsTable[Idx].MfgStringSegment << 4) + LocalBbsTable[Idx].MfgStringOffset),
- (UINTN) ((LocalBbsTable[Idx].DescStringSegment << 4) + LocalBbsTable[Idx].DescStringOffset)
- );
-*/
- }
-
- //Print(L"\n");
+ }
+
+ OptionBBS = (BBS_BBS_DEVICE_PATH *) Option->DevicePath;
+ Status = refit_call5_wrapper(LegacyBios->GetBbsInfo, LegacyBios, &HddCount, &HddInfo, &BbsCount, &LocalBbsTable);
+
+// Print (L"\n");
+// Print (L" NO Prio bb/dd/ff cl/sc Type Stat segm:offs\n");
+// Print (L"=============================================\n");
+
+ for (Idx = 0; Idx < BbsCount; Idx++) {
+ if(LocalBbsTable[Idx].DeviceType == 0) {
+ continue;
+ }
+
+ BdsBuildLegacyDevNameString (&LocalBbsTable[Idx], Idx, sizeof (Desc), Desc);
+
+ // Set devices of a particular type to BootPriority of 0 or 1. 0 is the highest priority.
+ if (LocalBbsTable[Idx].DeviceType == OptionBBS->DeviceType) {
+ if (MyStriCmp(Desc, Option->Description)) {
+ // This entry exactly matches what we're looking for; make it highest priority
+ LocalBbsTable[Idx].BootPriority = 0;
+ } else {
+ // This entry doesn't exactly match, but is the right disk type; make it a bit lower
+ // in priority. Done mainly as a fallback in case of string-matching weirdness.
+ LocalBbsTable[Idx].BootPriority = 1;
+ } // if/else
+ } else if (LocalBbsTable[Idx].BootPriority <= 1) {
+ // Something's got a high enough boot priority to interfere with booting
+ // our chosen entry, so bump it down a bit....
+ LocalBbsTable[Idx].BootPriority = 2;
+ } // if/else if
+
+// Print (
+// L" %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x %04x:%04x\n",
+// (UINTN) Idx,
+// (UINTN) LocalBbsTable[Idx].BootPriority,
+// (UINTN) LocalBbsTable[Idx].Bus,
+// (UINTN) LocalBbsTable[Idx].Device,
+// (UINTN) LocalBbsTable[Idx].Function,
+// (UINTN) LocalBbsTable[Idx].Class,
+// (UINTN) LocalBbsTable[Idx].SubClass,
+// (UINTN) LocalBbsTable[Idx].DeviceType,
+// (UINTN) * (UINT16 *) &LocalBbsTable[Idx].StatusFlags,
+// (UINTN) LocalBbsTable[Idx].BootHandlerSegment,
+// (UINTN) LocalBbsTable[Idx].BootHandlerOffset,
+// (UINTN) ((LocalBbsTable[Idx].MfgStringSegment << 4) + LocalBbsTable[Idx].MfgStringOffset),
+// (UINTN) ((LocalBbsTable[Idx].DescStringSegment << 4) + LocalBbsTable[Idx].DescStringOffset)
+// );
+// Print(L"%s\n", Desc);
+
+ } // for
+// PauseForKey();