some cleanup

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2023-06-12 14:35:14 +03:00
parent 3238813474
commit 76614b3208
2 changed files with 7 additions and 130 deletions

View File

@ -591,84 +591,13 @@ EFI_STATUS ConfigManager::LoadSMBIOSPlist(const XStringW& ConfName)
void ConfigManager::FillSmbiosWithDefaultValue(MacModel Model, const SmbiosPlistClass::SmbiosDictClass& smbiosDictClass)
{
// Checks are now done in SmbiosDictClass
// //gSettings.Smbios.BiosVersion = ApplePlatformData[Model].firmwareVersion;
// // Check for BiosVersion and BiosReleaseDate by Sherlocks
// if ( smbiosDictClass.getBiosVersion().isDefined() ) {
// int c = compareBiosVersion(gSettings.Smbios.BiosVersion, smbiosDictClass.dgetBiosVersion());
// if ( c == 0 ) {
// DBG("Found same BiosVersion in clover and config\n");
// }else
// if ( c < 0 ) {
// DBG("Using latest BiosVersion from config\n");
// gSettings.Smbios.BiosVersion = smbiosDictClass.dgetBiosVersion();
// }else{
// DBG("Using latest BiosVersion from clover\n");
// }
// }else{
// DBG("BiosVersion: not set, Using BiosVersion from clover\n");
// }
// DBG("BiosVersion: %s\n", gSettings.Smbios.BiosVersion.c_str());
if ( smbiosDictClass.getBiosVersion().isDefined() ) gSettings.Smbios.BiosVersion = smbiosDictClass.getBiosVersion().value();
// //gSettings.Smbios.BiosReleaseDate = GetReleaseDate(Model); // AppleReleaseDate
// int compareReleaseDateResult = 0;
// if ( smbiosDictClass.getBiosReleaseDate().isDefined() ) {
// compareReleaseDateResult = compareReleaseDate(GetReleaseDate(Model), smbiosDictClass.dgetBiosReleaseDate());
// if ( compareReleaseDateResult == 0 ) {
// DBG("Found same BiosReleaseDate in clover and config\n");
// }else
// if ( compareReleaseDateResult == -1 ) {
// DBG("Using latest BiosReleaseDate from config\n");
// gSettings.Smbios.BiosReleaseDate = smbiosDictClass.dgetBiosReleaseDate();
// }else
// if ( compareReleaseDateResult == 1 ) {
// DBG("Using latest BiosReleaseDate from clover\n");
// }
// }else{
// DBG("BiosReleaseDate: not set, Using BiosReleaseDate from clover\n");
// }
// if ( !smbiosDictClass.getBiosReleaseDate().isDefined() || compareReleaseDateResult == -2 )
// {
// //DBG("Found unknown date format from config\n");
// size_t len = gSettings.Smbios.BiosReleaseDate.length();
// const char* j = gSettings.Smbios.BiosVersion.c_str();
//
// j += AsciiStrLen(j);
// while (*j != '.') {
// j--;
// }
//
// if ( len == 8 ) {
// gSettings.Smbios.BiosReleaseDate.S8Printf("%c%c/%c%c/%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]);
// //DBG("Using the date of used BiosVersion\n");
// } else if ( len == 10 ) {
// gSettings.Smbios.BiosReleaseDate.S8Printf("%c%c/%c%c/20%c%c\n", j[3], j[4], j[5], j[6], j[1], j[2]);
// //DBG("Using the date of used BiosVersion\n");
// }
// }
// DBG("BiosReleaseDate: %s\n", gSettings.Smbios.BiosReleaseDate.c_str());
if ( smbiosDictClass.getBiosReleaseDate().isDefined() ) gSettings.Smbios.BiosReleaseDate = smbiosDictClass.getBiosReleaseDate().value();
// gSettings.Smbios.EfiVersion.takeValueFrom(ApplePlatformData[Model].efiversion);
// if ( smbiosDictClass.getEfiVersion().isDefined() ) {
// if (AsciiStrVersionToUint64(gSettings.Smbios.EfiVersion, 4, 5) > AsciiStrVersionToUint64(smbiosDictClass.dgetEfiVersion(), 4, 5)) {
// DBG("Using latest EfiVersion from clover: %s\n", gSettings.Smbios.EfiVersion.c_str());
// } else if (AsciiStrVersionToUint64(gSettings.Smbios.EfiVersion, 4, 5) < AsciiStrVersionToUint64(smbiosDictClass.dgetEfiVersion(), 4, 5)) {
// gSettings.Smbios.EfiVersion = smbiosDictClass.dgetEfiVersion();
// DBG("Using latest EfiVersion from config: %s\n", gSettings.Smbios.EfiVersion.c_str());
// } else {
// DBG("Using EfiVersion from clover: %s\n", gSettings.Smbios.EfiVersion.c_str());
// }
// } else if ( gSettings.Smbios.EfiVersion.notEmpty() ) {
// DBG("Using EfiVersion from clover: %s\n", gSettings.Smbios.EfiVersion.c_str());
// }
if ( smbiosDictClass.getEfiVersion().isDefined() ) gSettings.Smbios.EfiVersion = smbiosDictClass.getEfiVersion().value();
@ -925,10 +854,9 @@ EFI_STATUS ConfigManager::LoadConfig(const XStringW& ConfName)
EFI_STATUS Status = LoadConfigPlist(ConfName);
if ( EFI_ERROR(Status) ) {
DBG("LoadConfigPlist return %s. Config not loaded\n", efiStrError(Status));
//return Status; // Let's try to continue with default values.
}
/*Status = */ LoadSMBIOSPlist(L"smbios"_XSW); // we don't need Status. If not loaded correctly, smbiosPlist is !defined and will be ignored by AssignOldNewSettings()
LoadSMBIOSPlist(L"smbios"_XSW); // we don't need Status. If not loaded correctly, smbiosPlist is !defined and will be ignored by AssignOldNewSettings()
if ( smbiosPlist.getSMBIOS().isDefined() && smbiosPlist.getSMBIOS().getProductName().isDefined() ) {
GlobalConfig.CurrentModel = smbiosPlist.SMBIOS.dgetModel();

View File

@ -3085,41 +3085,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
BootScreen.EraseTextXY();
BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
}
// //Second step. Load config.plist into gSettings
// for (i=0; i<2; i++) {
// if (gConfigDict[i]) {
// Status = GetUserSettings(gConfigDict[i], gSettings);
// afterGetUserSettings(gSettings);
// if (EFI_ERROR(Status)) {
// DBG("Error in Second part of settings %llu: %s\n", i, efiStrError(Status));
// }
// }
// }
afterGetUserSettings(gSettings);
afterGetUserSettings(gSettings);
// dropDSM = 0xFFFF; //by default we drop all OEM _DSM. They have no sense for us.
// if (defDSM) {
// dropDSM = gSettings.DropOEM_DSM; //if set by user
// }
// Load any extra SMBIOS information
// if (!EFI_ERROR(LoadUserSettings(L"smbios"_XSW, &smbiosTags)) && (smbiosTags != NULL)) {
// const TagDict* dictPointer = smbiosTags->dictPropertyForKey("SMBIOS");
// if (dictPointer) {
// ParseSMBIOSSettings(gSettings, dictPointer);
// } else {
// DBG("Invalid smbios.plist, not overriding config.plist!\n");
// }
// }
/*
if (gFirmwareClover || gDriversFlags.EmuVariableLoaded) {
if (gSettings.Boot.StrictHibernate) {
DBG(" Don't use StrictHibernate with emulated NVRAM!\n");
}
gSettings.Boot.StrictHibernate = false;
}
*/
HaveDefaultVolume = gSettings.Boot.DefaultVolume.notEmpty();
if (!gFirmwareClover &&
!gDriversFlags.EmuVariableLoaded &&
@ -3165,13 +3133,12 @@ RefitMain (IN EFI_HANDLE ImageHandle,
GetOutputs();
for (i = 0; i < AudioList.size(); i++) {
if (AudioList[i].Name.notEmpty()) {
// Never change this log, otherwise clients will stop interprete the output.
// Never change this log, otherwise clients will stop interpret the output.
MsgLog("Found Audio Device %ls (%s) at index %llu\n", AudioList[i].Name.wc_str(), AudioOutputNames[AudioList[i].Device], i);
}
}
if (!GlobalConfig.isFastBoot()) {
// CHAR16 *TmpArgs;
if (gThemeNeedInit) {
UINTN Size = 0;
InitTheme((CHAR8*)GetNvramVariable(L"Clover.Theme", gEfiAppleBootGuid, NULL, &Size));
@ -3179,7 +3146,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
} else if (GlobalConfig.gThemeChanged) {
DBG("change theme\n");
InitTheme(NULL);
//OptionMenu.FreeMenu(); // it is already freed at loop beginning
AboutMenu.Entries.setEmpty();
HelpMenu.Entries.setEmpty();
}
@ -3240,14 +3206,13 @@ RefitMain (IN EFI_HANDLE ImageHandle,
MenuEntryOptions.Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_OPTIONS);
// DBG("Options: IconID=%lld name=%s empty=%s\n", MenuEntryOptions.Image.Id, MenuEntryOptions.Image.Name.c_str(),
// MenuEntryOptions.Image.isEmpty()?"пусто":"нет");
if (gSettings.Boot.DisableCloverHotkeys)
MenuEntryOptions.ShortcutLetter = 0x00;
MainMenu.AddMenuEntry(&MenuEntryOptions, false);
MenuEntryAbout.Image = ThemeX.GetIcon((INTN)BUILTIN_ICON_FUNC_ABOUT);
// DBG("About: IconID=%lld name=%s empty=%s\n", MenuEntryAbout.Image.Id, MenuEntryAbout.Image.Name.c_str(),
// MenuEntryAbout.Image.isEmpty()?"пусто":"нет");
if (gSettings.Boot.DisableCloverHotkeys)
MenuEntryAbout.ShortcutLetter = 0x00;
MainMenu.AddMenuEntry(&MenuEntryAbout, false);
@ -3263,12 +3228,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
MainMenu.AddMenuEntry(&MenuEntryShutdown, false);
}
// font already changed and this message very quirky, clear line here
// if (!gSettings.Boot.NoEarlyProgress && !GlobalConfig.isFastBoot() && gSettings.Boot.Timeout>0) {
// XStringW Message = L" "_XSW;
// BootScreen.EraseTextXY();
// DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER);
// }
}
// wait for user ACK when there were errors
FinishTextScreen(false);
@ -3285,15 +3244,10 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
MainLoopRunning = true;
// MainMenu.TimeoutSeconds = gSettings.Boot.Timeout >= 0 ? gSettings.Boot.Timeout : 0;
if (DefaultEntry && (GlobalConfig.isFastBoot() ||
(gSettings.Boot.SkipHibernateTimeout &&
DefaultEntry->getLOADER_ENTRY()
&& OSFLAG_ISSET(DefaultEntry->getLOADER_ENTRY()->Flags, OSFLAG_HIBERNATED)
)
)
)
{
&& OSFLAG_ISSET(DefaultEntry->getLOADER_ENTRY()->Flags, OSFLAG_HIBERNATED)))) {
if (DefaultEntry->getLOADER_ENTRY()) {
DefaultEntry->StartLoader();
} else if (DefaultEntry->getLEGACY_ENTRY()){
@ -3301,12 +3255,10 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
gSettings.Boot.FastBoot = false; //Hmm... will never be here
}
// XBool MainAnime = MainMenu.GetAnime();
// DBG("MainAnime=%d\n", MainAnime);
AfterTool = false;
gEvent = 0; //clear to cancel loop
while (MainLoopRunning) {
// CHAR8 *LastChosenOS = NULL;
if (gSettings.Boot.Timeout == 0 && DefaultEntry != NULL && !ReadAllKeyStrokes()) {
// go strait to DefaultVolume loading
MenuExit = MENU_EXIT_TIMEOUT;
@ -3376,10 +3328,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if ( ChosenEntry->getREFIT_MENU_ITEM_RESET() ) { // Restart
if (MenuExit == MENU_EXIT_DETAILS) {
// EFI_KEY_DATA KeyData;
// ZeroMem(&KeyData, sizeof KeyData);
// SimpleTextEx->ReadKeyStrokeEx (SimpleTextEx, &KeyData);
// if ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) {
//do clear cmos as for AMI BIOS
// not sure for more robust method
IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, 0x10);