Add "FirstAvailable" option for DefaultVolume.

This commit is contained in:
jief666 2024-01-19 04:14:17 +01:00
parent 0cb5da745a
commit 7e105c98da
10 changed files with 31 additions and 13 deletions

@ -1 +1 @@
Subproject commit 0fcc050a44f6fa06788b349e65b4e10fcdabde67
Subproject commit b297330007bb21302d9fce22d49786443a5750ee

View File

@ -670,6 +670,7 @@ public:
XBool NeverDoRecovery = false;
XBool LastBootedVolume = false;
XStringW DefaultVolume = XStringW();
bool BootFirstAvailable = false;
XStringW DefaultLoader = XStringW();
XBool DebugLog = false;
XBool FastBoot = false;
@ -736,6 +737,7 @@ public:
NeverDoRecovery = other.dgetNeverDoRecovery();
LastBootedVolume = other.dgetLastBootedVolume();
DefaultVolume = other.dgetDefaultVolume();
BootFirstAvailable = other.dgetBootFirstAvailable();
DefaultLoader = other.dgetDefaultLoader();
DebugLog = other.dgetDebugLog();
FastBoot = other.dgetFastBoot();

View File

@ -141,7 +141,12 @@ public:
const decltype(DefaultVolume)::ValueType& dgetDefaultVolume() const {
if ( !DefaultVolume.isDefined() ) return DefaultVolume.nullValue;
if ( DefaultVolume.value().isEqualIC("LastBootedVolume") ) return DefaultVolume.nullValue;
return DefaultVolume.isDefined() ? DefaultVolume.value() : DefaultVolume.nullValue;
if ( DefaultVolume.value().isEqualIC("FirstAvailable") ) return DefaultVolume.nullValue;
return DefaultVolume.value();
};
bool dgetBootFirstAvailable() const {
if ( !DefaultVolume.isDefined() ) return false;
return DefaultVolume.value().isEqualIC("FirstAvailable");
};
const XString8& dgetDefaultLoader() const { return DefaultLoader.isDefined() ? DefaultLoader.value() : NullXString8; };
XBool dgetDebugLog() const { return Debug.isDefined() ? Debug.value() : XBool(false); };

View File

@ -110,6 +110,14 @@ class XObjArrayNC
template<typename IntegralType, enable_if(is_integral(IntegralType))>
TYPE &operator[](IntegralType nIndex) { return ElementAt(nIndex); }
size_t indexOf(TYPE& e) const {
size_t i;
for ( i=0 ; i<size() ; i+=1 ) {
if ( &ElementAt(i) == &e ) return i;
}
return MAX_XSIZE;
}
bool operator==(const XObjArrayNC<TYPE>& other) const
{
if ( size() != other.size() ) return false;

View File

@ -310,7 +310,7 @@ void AddCustomLegacy(void)
if (Custom.settings.VolumeType != 0) {
if (((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) == 0) {
DBG("skipped because media is ignored\n");
DBG("skipped because media is ignored (VolumeType=%d DiskKind=%d)\n", Custom.settings.VolumeType, Volume->DiskKind);
continue;
}
}

View File

@ -2406,7 +2406,7 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
}
if (Custom.settings.VolumeType != 0 && ((1<<Volume->DiskKind) & Custom.settings.VolumeType) == 0) {
DBG("skipped because media is ignored\n");
DBG("skipped because media is ignored (VolumeType=%d DiskKind=%d)\n", Custom.settings.VolumeType, Volume->DiskKind);
continue;
}

View File

@ -278,7 +278,7 @@ void AddCustomTool(void)
if (Custom.settings.VolumeType != 0) {
if (((1ull<<Volume->DiskKind) & Custom.settings.VolumeType) == 0) {
DBG("skipped because media is ignored\n");
DBG("skipped because media is ignored (VolumeType=%d DiskKind=%d)\n", Custom.settings.VolumeType, Volume->DiskKind);
continue;
}
}

View File

@ -169,6 +169,10 @@ void REFIT_MENU_SCREEN::DrawTextCorner(UINTN TextC, UINT8 Align)
// Display Clover boot volume
if (SelfVolume->VolLabel.notEmpty() && SelfVolume->VolLabel[0] != L'#') {
Text = SWPrintf("%ls, booted from %ls %ls", gFirmwareRevision, SelfVolume->VolLabel.wc_str(), self.getCloverDirFullPath().wc_str());
}else{
if ( SelfVolume->VolName.notEmpty() ) {
Text = SWPrintf("%ls %ls%ls", gFirmwareRevision, SelfVolume->VolName.wc_str(), self.getCloverDirFullPath().wc_str());
}
}
if (Text.isEmpty()) {
Text = SWPrintf("%ls %ls", gFirmwareRevision, /*SelfVolume->VolName.wc_str(),*/ self.getCloverDirFullPath().wc_str());

View File

@ -584,16 +584,9 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume)
Volume->DevicePathString = FileDevicePathToXStringW(Volume->DevicePath);
}
#if REFIT_DEBUG > 0
if (Volume->DevicePath != NULL) {
DBG(" %ls\n", FileDevicePathToXStringW(Volume->DevicePath).wc_str());
//#if REFIT_DEBUG >= 2
// DumpHex(1, 0, GetDevicePathSize(Volume->DevicePath), Volume->DevicePath);
//#endif
}
#else
DBG("\n");
#endif
Volume->ApfsFileSystemUUID = APFSPartitionUUIDExtract(Volume->DevicePath); // NullXString8 if it's not an APFS volume
Volume->DiskKind = DISK_KIND_INTERNAL; // default
@ -996,6 +989,10 @@ void ScanVolumes(void)
Volume->Hidden = false; // default to not hidden
Status = ScanVolume(Volume);
#ifdef JIEF_DEBUG
DBG(" kind=%d\n", Volume->DiskKind);
#endif
if (!EFI_ERROR(Status)) {
Volume->Index = HandleIndex;
Volumes.AddReference(Volume, true);

View File

@ -2519,6 +2519,8 @@ INTN FindDefaultEntry(void)
// DBG("FindDefaultEntry ...\n");
//DbgHeader("FindDefaultEntry");
if ( gSettings.Boot.BootFirstAvailable ) return 0;
//
// try to detect volume set by Startup Disk or previous Clover selection
// with broken nvram this requires emulation to be installed.
@ -3379,7 +3381,7 @@ displayFreeMemory("Before RunMainMenu"_XS8);
#endif
MenuExit = MainMenu.RunMainMenu(DefaultIndex, &ChosenEntry);
}
// DBG("exit from MainMenu %llu\n", MenuExit); //MENU_EXIT_ENTER=(1) MENU_EXIT_DETAILS=3
// DBG("exit from MainMenu %llu ChosenEntry=%zu\n", MenuExit, MainMenu.Entries.indexOf(*ChosenEntry)); //MENU_EXIT_ENTER=(1) MENU_EXIT_DETAILS=3
// disable default boot - have sense only in the first run
gSettings.Boot.Timeout = -1;
if ((DefaultEntry != NULL) && (MenuExit == MENU_EXIT_TIMEOUT)) {