From 2cb4b24a5d8b6e1b82ac81491a0788b8ec1c670b Mon Sep 17 00:00:00 2001 From: Slice Date: Sat, 17 Jun 2023 00:44:39 +0300 Subject: [PATCH] smbios automatic chooser Signed-off-by: Slice --- BaseTools/Conf/tools_def.template | 6 +- BaseTools/Source/C/GenFw/Elf64Convert.c | 12 +- rEFIt_UEFI/Platform/Settings.cpp | 2 + rEFIt_UEFI/Platform/Settings.h | 54 ++----- rEFIt_UEFI/Settings/ConfigManager.cpp | 59 +++++++- rEFIt_UEFI/Settings/ConfigManager.h | 2 + .../Settings/ConfigPlist/ConfigPlistClass.h | 37 ++++- rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h | 68 +++++---- rEFIt_UEFI/cpp_lib/XmlLiteDictTypes.cpp | 78 +--------- rEFIt_UEFI/entry_scan/legacy.cpp | 21 +-- rEFIt_UEFI/entry_scan/loader.cpp | 99 ++---------- rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp | 30 ++-- rEFIt_UEFI/gui/menu_items/menu_items.h | 1 + rEFIt_UEFI/refit/lib.h | 65 ++++---- rEFIt_UEFI/refit/main.cpp | 36 +++-- rEFIt_UEFI/refit/menu.cpp | 141 +++++++----------- 16 files changed, 302 insertions(+), 409 deletions(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index cf2171e24..755a501eb 100644 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -2063,7 +2063,7 @@ DEFINE GCC49_ASLCC_FLAGS = DEF(GCC48_ASLCC_FLAGS) DEFINE GCC5_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -fno-pic -fno-pie DEFINE GCC5_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -DEFINE GCC5_IA32_X64_DLINK_COMMON = DEF(GCC49_IA32_X64_DLINK_COMMON) +DEFINE GCC5_IA32_X64_DLINK_COMMON = DEF(GCC49_IA32_X64_DLINK_COMMON) -Wl,--no-warn-rwx-segments DEFINE GCC5_IA32_X64_ASLDLINK_FLAGS = DEF(GCC49_IA32_X64_ASLDLINK_FLAGS) DEFINE GCC5_IA32_X64_DLINK_FLAGS = DEF(GCC49_IA32_X64_DLINK_FLAGS) DEFINE GCC5_IA32_DLINK2_FLAGS = DEF(GCC49_IA32_DLINK2_FLAGS) -Wno-error @@ -2086,13 +2086,13 @@ DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto DEFINE GCC53_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) DEFINE GCC53_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-incompatible-ms-struct -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions -DEFINE GCC53_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x240,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds +DEFINE GCC53_IA32_X64_DLINK_COMMON = -nostdlib -Wl,--no-warn-rwx-segments,--gc-sections,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x240,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds DEFINE GCC53_IA32_X64_ASLDLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable DEFINE GCC53_IA32_X64_DLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_COMMON),--entry,$(IMAGE_ENTRY_POINT),-u,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map -DEFINE GCC53_X64_DLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_FLAGS),-melf_x86_64,--oformat=elf64-x86-64,-pie +DEFINE GCC53_X64_DLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_FLAGS),-melf_x86_64,-znoexecstack,--oformat=elf64-x86-64,-pie DEFINE GCC53_ASM_FLAGS = DEF(GCC49_ASM_FLAGS) diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c index d4e303be4..ba9d82fb1 100755 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -941,12 +941,12 @@ WriteSections64 ( SymName = (const UINT8 *)""; } if ( strcmp((const char *)SymName, "__cxa_pure_virtual") == 0 ) { - static int already_printed_once = 0; - if ( !already_printed_once ) { - printf("FIXME reminder : __cxa_pure_virtual is undefined -> ignored. This is happening since gcc 12.1 for unknown reasons.\n"); - already_printed_once = 1; - } - continue; +// static int already_printed_once = 0; +// if ( !already_printed_once ) { +// printf("FIXME reminder : __cxa_pure_virtual is undefined -> ignored. This is happening since gcc 12.1 for unknown reasons.\n"); +// already_printed_once = 1; +// } + continue; } Error (NULL, 0, 3000, "Invalid", "%s: Bad definition for symbol '%s'@%#llx or unsupported symbol type. " diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index a369c9b5b..98e8d41a0 100755 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -54,6 +54,7 @@ INTN OldChosenTheme; +INTN OldChosenSmbios; INTN OldChosenConfig; INTN OldChosenDsdt; UINTN OldChosenAudio; @@ -75,6 +76,7 @@ XStringWArray ThemeNameArray; XStringWArray ConfigsList; XStringWArray DsdtsList; XObjArray AudioList; +XStringWArray SmbiosList; // firmware XBool gFirmwareClover = false; diff --git a/rEFIt_UEFI/Platform/Settings.h b/rEFIt_UEFI/Platform/Settings.h index c0f388a0d..afcd4e6f6 100755 --- a/rEFIt_UEFI/Platform/Settings.h +++ b/rEFIt_UEFI/Platform/Settings.h @@ -2695,63 +2695,35 @@ public: }; - -//extern XObjArray gSettings.RtVariables.BlockRtVariableArray; extern XObjArray AudioList; extern XStringWArray ThemeNameArray; extern XStringWArray ConfigsList; extern XStringWArray DsdtsList; -//extern INTN ScrollButtonsHeight; -//extern INTN ScrollBarDecorationsHeight; -//extern INTN ScrollScrollDecorationsHeight; -//extern INTN LayoutBannerOffset; -//extern INTN LayoutButtonOffset; -//extern INTN LayoutTextOffset; -// this should go in a globals, not in settings +extern XStringWArray SmbiosList; -extern INTN OldChosenTheme; -extern INTN OldChosenConfig; -extern INTN OldChosenDsdt; -extern UINTN OldChosenAudio; -extern XBool SavePreBootLog; -extern UINT8 DefaultAudioVolume; +extern INTN OldChosenTheme; +extern INTN OldChosenConfig; +extern INTN OldChosenSmbios; +extern INTN OldChosenDsdt; +extern UINTN OldChosenAudio; +extern XBool SavePreBootLog; +extern UINT8 DefaultAudioVolume; - -//extern GFX_PROPERTIES gGraphics[]; -//extern HDA_PROPERTIES gAudios[]; -//extern UINTN NGFX; -//extern UINTN NHDA; -//extern UINT16 gCPUtype; extern SETTINGS_DATA gSettings; -extern XBool gFirmwareClover; +extern XBool gFirmwareClover; extern DRIVERS_FLAGS gDriversFlags; extern EFI_EDID_DISCOVERED_PROTOCOL *EdidDiscovered; -//extern UINT8 *gEDID; +extern UINTN gEvent; +extern UINT16 gBacklightLevel; -extern UINTN gEvent; - -extern UINT16 gBacklightLevel; - -//extern XBool defDSM; -//extern UINT16 dropDSM; - -//extern TagDict* gConfigDict[]; // ACPI/PATCHED/AML -extern XObjArray ACPIPatchedAML; - - -// SysVariables -//extern SYSVARIABLES *SysVariables; +extern XObjArray ACPIPatchedAML; // Hold theme fixed IconFormat / extension extern CHAR16 *IconFormat; - - -extern XBool ResumeFromCoreStorage; -//extern XBool gRemapSmBiosIsRequire; // syscl: pass argument for Dell SMBIOS here - +extern XBool ResumeFromCoreStorage; extern EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl; diff --git a/rEFIt_UEFI/Settings/ConfigManager.cpp b/rEFIt_UEFI/Settings/ConfigManager.cpp index 3232f74a9..617d40059 100644 --- a/rEFIt_UEFI/Settings/ConfigManager.cpp +++ b/rEFIt_UEFI/Settings/ConfigManager.cpp @@ -487,7 +487,7 @@ EFI_STATUS LoadPlist(const XStringW& ConfName, C* plist) // XStringW ConfigPlistPath; // XStringW ConfigOemPath; - // DbgHeader("LoadUserSettings"); + DbgHeader("LoadUserSettings"); // load config if ( ConfName.isEmpty() /*|| Dict == NULL*/ ) { @@ -542,7 +542,7 @@ EFI_STATUS LoadPlist(const XStringW& ConfName, C* plist) DebugLog(1, "Use CloverConfigPlistValidator"); if ( plist->getSMBIOS().dgetModel() < MaxMacModel ) { if ( xmlLiteParser.productNameNeeded ) DebugLog(1, " (with --productname=%s)", MachineModelName[plist->getSMBIOS().dgetModel()].c_str()); - }else{ + } else { // This is NOT supposed to happen, since CLover set a default mac model // If a default mac model is not set, a crash would probably happen earlier, but who knows if ( xmlLiteParser.productNameNeeded ) DebugLog(1, "(with --productname=?)"); @@ -552,6 +552,8 @@ EFI_STATUS LoadPlist(const XStringW& ConfName, C* plist) if ( !parsingOk ) { DebugLog(1, "Parsing error while parsing '%ls'.\n", configPlistPath.wc_str()); Status = EFI_LOAD_ERROR; + } else { + } if ( !parsingOk || xmlLiteParser.getXmlParserMessageArray().size() - xmlLiteParser.getXmlParserInfoMessageCount() > 0 ) gBS->Stall(3000000); // 3 seconds delay @@ -588,19 +590,27 @@ EFI_STATUS ConfigManager::LoadSMBIOSPlist(const XStringW& ConfName) return Status; } +void ConfigManager::ReloadSmbios(XStringW& str) +{ + size_t N = SmbiosList.size(); + if (OldChosenSmbios == 0) { + for (size_t i=1; i 0 && SmbiosList[OldChosenSmbios] == h) { + return static_cast(m_fields[i].xmlAbstractType); + } + } + return SMBIOS; + }; }; #endif /* _CONFIGPLISTCLASS_H_ */ diff --git a/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h b/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h index a31ad215b..b606285cf 100755 --- a/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h +++ b/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h @@ -42,6 +42,17 @@ #include "ConfigPlistAbstract.h" +extern XStringWArray ThemeNameArray; +extern XStringWArray ConfigsList; +extern XStringWArray DsdtsList; +extern XStringWArray SmbiosList; + + +extern INTN OldChosenTheme; +extern INTN OldChosenConfig; +extern INTN OldChosenSmbios; + + class SmbiosPlistClass : public ConfigPlistAbstractClass { @@ -190,9 +201,7 @@ public: } }; - - - + XmlUInt8 SlotCount = XmlUInt8(); XmlUInt8 Channels = XmlUInt8(); ModuleArrayClass Modules = ModuleArrayClass(); @@ -234,23 +243,6 @@ public: decltype(SlotCount)::ValueType dgetSlotCount() const { return SlotCount.isDefined() ? SlotCount.value() : 0; }; const decltype(Channels)::ValueType& dgetUserChannels() const { return Channels.isDefined() ? Channels.value() : Channels.nullValue; }; -// decltype(SlotCount)::ValueType dgetSlotMax() const { -// if ( !isDefined() || !Modules.isDefined() || Modules.size() == 0 ) return 0; -// uint8_t max = 0; -// for ( size_t idx = 0 ; idx < Modules.size() ; ++idx ) { -// if ( Modules[idx].dgetModuleSize() > 0 ) { -// if ( Modules[idx].dgetSlotIndex() > UINT8_MAX ) { -// log_technical_bug("Modules[idx].dgetSlotNo() > UINT8_MAX"); -// }else{ -// if ( Modules[idx].dgetSlotIndex() > max ) max = (uint8_t)Modules[idx].dgetSlotIndex(); // safe cast Modules[idx].dgetSlotNo() is <= UINT8_MAX -// } -// } -// } -// return max+1; -// }; -// -// decltype(SlotCount)::ValueType dgetSlotCounts() const { return dgetSlotCountSetting() > dgetSlotMax() ? dgetSlotCountSetting() : dgetSlotMax(); }; - }; class SlotDeviceDictClass : public XmlDict @@ -770,9 +762,29 @@ public: }; SmbiosDictClass SMBIOS = SmbiosDictClass(); + SmbiosDictClass SMBIOS_lion = SmbiosDictClass(); + SmbiosDictClass SMBIOS_mav = SmbiosDictClass(); + SmbiosDictClass SMBIOS_cap = SmbiosDictClass(); + SmbiosDictClass SMBIOS_hsierra = SmbiosDictClass(); + SmbiosDictClass SMBIOS_moja = SmbiosDictClass(); + SmbiosDictClass SMBIOS_cata = SmbiosDictClass(); + SmbiosDictClass SMBIOS_bigsur = SmbiosDictClass(); + SmbiosDictClass SMBIOS_monterey = SmbiosDictClass(); + SmbiosDictClass SMBIOS_ventura = SmbiosDictClass(); + SmbiosDictClass SMBIOS_sonoma = SmbiosDictClass(); - XmlDictField m_fields[1] = { + XmlDictField m_fields[11] = { {"SMBIOS", SMBIOS}, + {"SMBIOS_lion", SMBIOS_lion}, + {"SMBIOS_mav", SMBIOS_mav}, + {"SMBIOS_cap", SMBIOS_cap}, + {"SMBIOS_hsierra", SMBIOS_hsierra}, + {"SMBIOS_moja", SMBIOS_moja}, + {"SMBIOS_cata", SMBIOS_cata}, + {"SMBIOS_bigsur", SMBIOS_bigsur}, + {"SMBIOS_monterey", SMBIOS_monterey}, + {"SMBIOS_ventura", SMBIOS_ventura}, + {"SMBIOS_sonoma", SMBIOS_sonoma}, }; public: @@ -781,13 +793,19 @@ public: public: SmbiosPlistClass() {}; - const decltype(SMBIOS)& getSMBIOS() const { return SMBIOS; }; + const decltype(SMBIOS)& getSMBIOS() const { + for (size_t i=0; i 0 && SmbiosList[OldChosenSmbios] == h) { + return static_cast(m_fields[i].xmlAbstractType); + } + } + return SMBIOS; + }; }; -//extern const ConfigPlist& configPlist; -//extern const ConfigPlist& getConfigPlist(); - #endif /* _SMBIOSPLISTCLASS_H_ */ diff --git a/rEFIt_UEFI/cpp_lib/XmlLiteDictTypes.cpp b/rEFIt_UEFI/cpp_lib/XmlLiteDictTypes.cpp index acc1b73fc..0020ef7cf 100644 --- a/rEFIt_UEFI/cpp_lib/XmlLiteDictTypes.cpp +++ b/rEFIt_UEFI/cpp_lib/XmlLiteDictTypes.cpp @@ -35,9 +35,9 @@ XmlAbstractType& XmlDict::parseValueFromXmlLite(XmlLiteParser* xmlLiteParser, co size_t nb; *keyFound = false; getFields(&fields, &nb); - if ( nb == 0 ) { - panic("Dict '%s' has no field defined", xmlPath.c_str()); - } +// if ( nb == 0 ) { +// panic("Dict '%s' has no field defined", xmlPath.c_str()); +// } for ( size_t idx = 0 ; !*keyFound && idx < nb ; idx++ ) { XmlDictField& xmlDictField = fields[idx]; @@ -54,21 +54,7 @@ if ( strcmp(fieldName, "AutoMerge") == 0 ) { } #endif *keyFound = true; -//#ifdef JIEF_DEBUG -// XmlParserPosition pos = xmlLiteParser->getPosition(); -//#endif -// if ( xmlAbstractType.isDefined() ) { -// xmlLiteParser->addWarning(generateErrors, S8Printf("Tag '%s:%d' is previously defined. Previous value ignored.", xmlPath.c_str(), keyPos.getLine())); -// xmlAbstractType.reset(); -// } -// if ( !xmlAbstractType.parseFromXmlLite(xmlLiteParser, xmlPath, generateErrors) ) { -////#ifdef JIEF_DEBUG -//// xmlAbstractType.reset(); -//// xmlLiteParser->restorePosition(pos); -//// xmlAbstractType.parseFromXmlLite(xmlLiteParser, xmlPath, false); -////#endif -// } if ( xmlAbstractType.isDefined() ) { xmlLiteParser->addWarning(generateErrors, S8Printf("Tag '%s:%d' is previously defined. New value ignored.", xmlPath.c_str(), keyPos.getLine())); xmlLiteParser->skipNextTag(false); @@ -110,9 +96,6 @@ size_t* keyValueLengthPtr) if ( xmlPath.lastChar() == '/' ) xmlSubPath.S8Catf("%.*s", (int)keyValueLength, keyValue); else xmlSubPath.S8Catf("/%.*s", (int)keyValueLength, keyValue); -//#ifdef JIEF_DEBUG -//XmlParserPosition valuePos = xmlLiteParser->getPosition(); -//#endif XBool keyFound; XmlAbstractType& xmlAbstractType = parseValueFromXmlLite(xmlLiteParser, xmlSubPath, generateErrors, keyPos, keyValue, keyValueLength, &keyFound); @@ -125,15 +108,6 @@ size_t* keyValueLengthPtr) xmlLiteParser->skipNextTag(generateErrors); // return value doesn't need to be tested, because skipNextTag() set xmlLiteParser::xmlParsingError to true. } -//#ifdef JIEF_DEBUG -// if ( xmlLiteParser->xmlParsingError ) { -// xmlLiteParser->restorePosition(valuePos); -// reset(); -// XmlAbstractType& xmlAbstractType2 = parseValueFromXmlLite(xmlLiteParser, xmlSubPath, false, keyPos, keyValue, keyValueLength, &keyFound); -// (void)xmlAbstractType2; -// } -//#endif - return xmlAbstractType; } @@ -144,22 +118,13 @@ XBool XmlDict::parseFromXmlLite(XmlLiteParser* xmlLiteParser, const XString8& xm RETURN_IF_FALSE ( xmlLiteParser->consumeOpeningTag("dict", generateErrors) ); setDefined(); -// const char* keyValue; -// size_t keyValueLength; -// XString8 xmlSubPath; - while ( !xmlLiteParser->isEof() && !xmlLiteParser->nextTagIsClosingTag("dict") ) { -// RETURN_IF_FALSE( xmlLiteParser->getKeyTagValue(&keyValue, &keyValueLength, &keyPos, true) ); -// xmlSubPath = xmlPath; -// xmlSubPath.S8Catf("/%.*s", (int)keyValueLength, keyValue); // #ifdef JIEF_DEBUG XmlParserPosition valuePos = xmlLiteParser->getPosition(); (void)valuePos; #endif -// XBool keyFound; -// XmlAbstractType& xmlAbstractType = parseValueFromXmlLite(xmlLiteParser, xmlSubPath, generateErrors, keyPos, keyValue, keyValueLength, &keyFound); XmlParserPosition keyPos = xmlLiteParser->getPosition(); @@ -169,11 +134,7 @@ XmlParserPosition valuePos = xmlLiteParser->getPosition(); XmlAbstractType& xmlAbstractType = parseKeyAndValueFromXmlLite(xmlLiteParser, xmlPath, generateErrors, &keyValue, &keyValueLength); -// if ( xmlLiteParser->xmlParsingError ) { -// //return false; -// } -// else -// { + if ( xmlAbstractType.isDefined() ) { XString8 xmlSubPath = xmlPath.lastChar() == '/' ? S8Printf("%s%.*s", xmlPath.c_str(), (int)keyValueLength, keyValue) : S8Printf("%s/%.*s", xmlPath.c_str(), (int)keyValueLength, keyValue); @@ -189,10 +150,7 @@ XmlParserPosition valuePos = xmlLiteParser->getPosition(); return false; } } - // if !xmlAbstractType.isDefined(), it's because a unknown key, or a comment. - // Just try to continue. } -// } } RETURN_IF_FALSE ( xmlLiteParser->consumeClosingTag("dict", generateErrors) ); return true; @@ -200,30 +158,10 @@ XmlParserPosition valuePos = xmlLiteParser->getPosition(); XBool XmlDict::validate(XmlLiteParser* xmlLiteParser, const XString8& xmlPath, const XmlParserPosition& pos, XBool generateErrors) { - (void)xmlLiteParser; - (void)xmlPath; - (void)pos; - (void)generateErrors; -// XmlDictField* fields; -// size_t nb; -// getFields(&fields, &nb); -// for ( size_t idx = 0 ; idx < nb ; idx++ ) { -// XmlDictField& xmlDictField = fields[idx]; -// XmlAbstractType& xmlAbstractType = xmlDictField.xmlAbstractType; -// XString8 subXmlPath = S8Printf("%s/%s", xmlPath.c_str(), xmlDictField.m_name); -//#ifdef JIEF_DEBUG -////if ( subXmlPath == "/ACPI/DSDT/Name"_XS8 ) { -//if ( subXmlPath == "/Boot/Policy"_XS8 ) { -// printf(""); -//} -//#endif -// if ( !xmlAbstractType.validate(xmlLiteParser, subXmlPath, pos, generateErrors) ) { -// #ifdef JIEF_DEBUG -//// xmlAbstractType.validate(xmlLiteParser, subXmlPath, pos, false); -// #endif -// return false; -// } -// } +// (void)xmlLiteParser; +// (void)xmlPath; +// (void)pos; +// (void)generateErrors; return true; } diff --git a/rEFIt_UEFI/entry_scan/legacy.cpp b/rEFIt_UEFI/entry_scan/legacy.cpp index 88616a483..58e03565a 100755 --- a/rEFIt_UEFI/entry_scan/legacy.cpp +++ b/rEFIt_UEFI/entry_scan/legacy.cpp @@ -215,7 +215,6 @@ void ScanLegacy(void) for (VolumeIndex = 0; VolumeIndex < Volumes.size(); VolumeIndex++) { Volume = &Volumes[VolumeIndex]; -// DBG("test VI=%d\n", VolumeIndex); if ((Volume->BootType != BOOTING_BY_PBR) && (Volume->BootType != BOOTING_BY_MBR) && (Volume->BootType != BOOTING_BY_CD)) { @@ -223,21 +222,6 @@ void ScanLegacy(void) continue; } -// DBG("%2d: '%ls' (%ls)", VolumeIndex, Volume->VolName, Volume->LegacyOS->IconName); - -#if 0 // REFIT_DEBUG > 0 - DBG(" %d %ls\n %d %d %ls %d %ls\n", - VolumeIndex, FileDevicePathToStr(Volume->DevicePath), - Volume->DiskKind, Volume->MbrPartitionIndex, - Volume->IsAppleLegacy ? L"AL" : L"--", Volume->HasBootCode, - Volume->VolName ? Volume->VolName : L"(no name)"); -#endif - - // skip volume if its kind is configured as disabled -/* if ((Volume->DiskKind == DISK_KIND_OPTICAL && (GlobalConfig.DisableFlags & VOLTYPE_OPTICAL)) || - (Volume->DiskKind == DISK_KIND_EXTERNAL && (GlobalConfig.DisableFlags & VOLTYPE_EXTERNAL)) || - (Volume->DiskKind == DISK_KIND_INTERNAL && (GlobalConfig.DisableFlags & VOLTYPE_INTERNAL)) || - (Volume->DiskKind == DISK_KIND_FIREWIRE && (GlobalConfig.DisableFlags & VOLTYPE_FIREWIRE))) */ if (((1ull<DiskKind) & GlobalConfig.DisableFlags) != 0) { // DBG(" hidden\n"); @@ -251,11 +235,8 @@ void ScanLegacy(void) HideIfOthersFound = true; } else if (Volume->HasBootCode) { ShowVolume = true; -// DBG("Volume %d will be shown BlockIo=%X WholeIo=%X\n", -// VolumeIndex, Volume->BlockIO, Volume->WholeDiskBlockIO); if ((Volume->WholeDiskBlockIO == 0) && - Volume->BlockIOOffset == 0 /* && - Volume->OSName == NULL */) + Volume->BlockIOOffset == 0 ) // this is a whole disk (MBR) entry; hide if we have entries for partitions HideIfOthersFound = true; // DBG("Hide it!\n"); diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index b6f3eb2d9..c220eaa57 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -839,7 +839,7 @@ GetOSIconName (const MacOsVersion& OSVersion) if (OSVersion.isEmpty()) { OSIconName = L"mac"_XSW; } else if (OSVersion.elementAt(0) == 14 ){ - // Ventura + // Sonoma OSIconName = L"sonoma,mac"_XSW; } else if (OSVersion.elementAt(0) == 13 ){ // Ventura @@ -918,7 +918,6 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath, EFI_DEVICE_PATH *LoaderDevicePath; XStringW LoaderDevicePathString; XStringW FilePathAsString; -// CONST CHAR16 *OSIconName = NULL; CHAR16 ShortcutLetter; LOADER_ENTRY *Entry; CONST CHAR8 *indent = " "; @@ -944,8 +943,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath, DBG("%sskipped because path `%ls` is self path!\n", indent, LoaderDevicePathString.wc_str()); return NULL; } -// DBG("OSType =%d\n", OSType); - // DBG("prepare the menu entry\n"); + // prepare the menu entry Entry = new LOADER_ENTRY; @@ -1081,23 +1079,11 @@ if ( Entry->APFSTargetUUID.Data1 == 0x99999999 ) { case OSTYPE_OSX: case OSTYPE_RECOVERY: case OSTYPE_OSX_INSTALLER: - OSIconName = GetOSIconName(Entry->macOSVersion);// Sothor - Get OSIcon name using OSVersion - // apianti - force custom logo even when verbose -/* this is not needed, as this flag is also being unset when booting if -v is present (LoadOptions may change until then) - if ( Entry->LoadOptions.containsIC("-v") ) { - // OSX is not booting verbose, so we can set console to graphics mode - Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_USEGRAPHICS); - } -*/ + OSIconName = GetOSIconName(Entry->macOSVersion); if (OSType == OSTYPE_OSX && IsOsxHibernated(Entry)) { Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_HIBERNATED); DBG("%s =>set entry as hibernated\n", indent); } - //always unset checkFakeSmc for installer - if (OSType == OSTYPE_OSX_INSTALLER){ -// Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_CHECKFAKESMC); -// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS); - } ShortcutLetter = 'M'; if ( Entry->DisplayedVolName.isEmpty() ) { // else no sense to override it with dubious name @@ -1136,6 +1122,8 @@ if ( Entry->APFSTargetUUID.Data1 == 0x99999999 ) { break; } //DBG("OSIconName=%ls \n", OSIconName); + Entry->OSName = OSIconName.subString(0, OSIconName.indexOf(',')); //TODO +// SmbiosList.AddReference(OSName.forgetDataWithoutFreeing(), true); Entry->Title = FullTitle; if (Entry->Title.isEmpty() && Volume->VolLabel.notEmpty()) { if (Volume->VolLabel[0] == L'#') { @@ -1222,9 +1210,6 @@ if ( Entry->APFSTargetUUID.Data1 == 0x99999999 ) { } } Entry->BootBgColor = BootBgColor; - -// Entry->KernelAndKextPatches = ((Patches == NULL) ? (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)) : Patches); -// CopyKernelAndKextPatches(&Entry->KernelAndKextPatches, Patches == NULL ? &gSettings.KernelAndKextPatches : Patches); Entry->KernelAndKextPatches = Patches == NULL ? gSettings.KernelAndKextPatches : *Patches; #ifdef DUMP_KERNEL_KEXT_PATCHES @@ -1236,16 +1221,11 @@ if ( Entry->APFSTargetUUID.Data1 == 0x99999999 ) { void LOADER_ENTRY::AddDefaultMenu() { - XStringW FileName; -// CHAR16* TempOptions; -// CHAR16 DiagsFileName[256]; - LOADER_ENTRY *SubEntry; -// REFIT_MENU_SCREEN *SubScreen; -// REFIT_VOLUME *Volume; - UINT64 VolumeSize; + XStringW FileName; + LOADER_ENTRY *SubEntry; + UINT64 VolumeSize; EFI_GUID Guid; - XBool KernelIs64BitOnly; -// UINT64 os_version = AsciiOSVersionToUint64(OSVersion); + XBool KernelIs64BitOnly; constexpr LString8 quietLitteral = "quiet"_XS8; constexpr LString8 splashLitteral = "splash"_XS8; @@ -1303,19 +1283,6 @@ void LOADER_ENTRY::AddDefaultMenu() SubEntry = getPartiallyDuplicatedEntry(); SubEntry->Title.SWPrintf("Boot %s with selected options", macOS); SubScreen->AddMenuEntry(SubEntry, true); -#if 0 - SubEntry = getPartiallyDuplicatedEntry(); - SubEntry->Title.SWPrintf("Boot %s with injected kexts", macOS); - SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_CHECKFAKESMC); - SubEntry->Flags = OSFLAG_SET(SubEntry->Flags, OSFLAG_WITHKEXTS); - SubScreen->AddMenuEntry(SubEntry, true); - - SubEntry = getPartiallyDuplicatedEntry(); - SubEntry->Title.SWPrintf("Boot %s without injected kexts", macOS); - SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_CHECKFAKESMC); - SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_WITHKEXTS); - SubScreen->AddMenuEntry(SubEntry, true); -#endif SubScreen->AddMenuEntry(SubMenuKextInjectMgmt(), true); SubScreen->AddMenuInfo_f("=== boot-args ==="); if (!KernelIs64BitOnly) { @@ -1337,15 +1304,9 @@ void LOADER_ENTRY::AddDefaultMenu() SubScreen->AddMenuCheck("Use Nvidia WEB drivers (nvda_drv=1)", OPT_NVWEBON, 68); SubScreen->AddMenuCheck("Disable PowerNap (darkwake=0)", OPT_POWERNAPOFF, 68); SubScreen->AddMenuCheck("Use XNU CPUPM (-xcpm)", OPT_XCPM, 68); -// SubScreen->AddMenuCheck("Disable Intel Idle Mode (-gux_no_idle)", OPT_GNOIDLE, 68); -// SubScreen->AddMenuCheck("Sleep Uses Shutdown (-gux_nosleep)", OPT_GNOSLEEP, 68); -// SubScreen->AddMenuCheck("Force No Msi Int (-gux_nomsi)", OPT_GNOMSI, 68); -// SubScreen->AddMenuCheck("EHC manage USB2 ports (-gux_defer_usb2)", OPT_EHCUSB, 68); SubScreen->AddMenuCheck("Keep symbols on panic (keepsyms=1)", OPT_KEEPSYMS, 68); SubScreen->AddMenuCheck("Don't reboot on panic (debug=0x100)", OPT_DEBUG, 68); SubScreen->AddMenuCheck("Debug kexts (kextlog=0xffff)", OPT_KEXTLOG, 68); -// SubScreen->AddMenuCheck("Disable AppleALC (-alcoff)", OPT_APPLEALC, 68); -// SubScreen->AddMenuCheck("Disable Shiki (-shikioff)", OPT_SHIKI, 68); if (gSettings.RtVariables.CsrActiveConfig == 0) { SubScreen->AddMenuCheck("No SIP", OSFLAG_NOSIP, 69); @@ -1438,9 +1399,6 @@ void LOADER_ENTRY::AddDefaultMenu() SubEntry->Title.SWPrintf("Run %ls", FileName.wc_str()); SubScreen->AddMenuEntry(SubEntry, true); } - -// SubScreen->AddMenuEntry(&MenuEntryReturn, false); //one-way ticket to avoid confusion - // DBG(" Added '%ls': OSType='%d', OSVersion='%s'\n",Title,LoaderType,OSVersion); } LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Array& LoaderOptions, @@ -1459,32 +1417,13 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr DBG(" skipped because entry is disabled\n"); return NULL; } -// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Flags, OSFLAG_HIDDEN)) { -// DBG(" skipped because entry is hidden\n"); -// return NULL; -// } - //don't add hided entries -// if (!gSettings.ShowHiddenEntries) { -// for (HVi = 0; HVi < gSettings.HVCount; HVi++) { -// if ( LoaderPath.containsIC(gSettings.GUI.HVHideStrings[HVi]) ) { -// DBG(" hiding entry: %ls\n", LoaderPath.s()); -// return NULL; -// } -// } -// } Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, FullTitle, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NullXImage, NULL, false); if (Entry != NULL) { if ((Entry->LoaderType == OSTYPE_OSX) || (Entry->LoaderType == OSTYPE_OSX_INSTALLER ) || (Entry->LoaderType == OSTYPE_RECOVERY)) { -// if (gSettings.WithKexts) { -// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS); -// } -// if (gSettings.WithKextsIfNoFakeSMC) { -// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC); -// Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS); -// } + if (gSettings.SystemParameters.NoCaches) { Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NOCACHES); } @@ -1501,7 +1440,6 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr } } //TODO there is a problem that Entry->Flags is unique while InputItems are global ;( -// InputItems[69].IValue = Entry->Flags; Entry->AddDefaultMenu(); DBG(" Menu entry added at index %zd\n", MainMenu.Entries.sizeIncludingHidden()); MainMenu.AddMenuEntry(Entry, true); @@ -1745,9 +1683,6 @@ STATIC void LinuxScan(REFIT_VOLUME *Volume, UINT8 KernelScan, UINT8 Type, XStrin void AddPRSEntry(REFIT_VOLUME *Volume) { INTN WhatBoot = 0; - //CONST INTN Paper = 1; - //CONST INTN Rock = 2; - //CONST INTN Scissor = 4; WhatBoot |= FileExists(Volume->RootDir, RockBoot)?Rock:0; WhatBoot |= FileExists(Volume->RootDir, PaperBoot)?Paper:0; @@ -1782,10 +1717,10 @@ XString8 GetAuthRootDmg(const EFI_FILE& dir, const XStringW& path) XStringW plist = SWPrintf("%ls\\com.apple.Boot.plist", path.wc_str()); if ( !FileExists(dir, plist) ) return NullXString8; - CHAR8* PlistBuffer = NULL; - UINTN PlistLen; - TagDict* Dict = NULL; - const TagStruct* Prop = NULL; + CHAR8* PlistBuffer = NULL; + UINTN PlistLen; + TagDict* Dict = NULL; + const TagStruct* Prop = NULL; EFI_STATUS Status = egLoadFile(&dir, plist.wc_str(), (UINT8 **)&PlistBuffer, &PlistLen); if (!EFI_ERROR(Status) && PlistBuffer != NULL && ParseXML(PlistBuffer, &Dict, 0) == EFI_SUCCESS) @@ -1878,8 +1813,8 @@ void ScanLoader(void) DBG("\n"); - if ( Volume->ApfsContainerUUID.notNull() ) DBG(" ApfsContainerUUID=%s\n", Volume->ApfsContainerUUID.toXString8().c_str()); - if ( Volume->ApfsFileSystemUUID.notNull() ) DBG(" ApfsFileSystemUUID=%s\n", Volume->ApfsFileSystemUUID.toXString8().c_str()); + if ( Volume->ApfsContainerUUID.notNull() ) {DBG(" ApfsContainerUUID=%s\n", Volume->ApfsContainerUUID.toXString8().c_str());} + if ( Volume->ApfsFileSystemUUID.notNull() ) {DBG(" ApfsFileSystemUUID=%s\n", Volume->ApfsFileSystemUUID.toXString8().c_str());} // check for Mac OS X Install Data @@ -2177,8 +2112,6 @@ void ScanLoader(void) } } - - typedef struct EntryIdx { size_t idx; REFIT_ABSTRACT_MENU_ENTRY* entry; diff --git a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp index 712507f7a..ea9d8544e 100644 --- a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp +++ b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.cpp @@ -497,14 +497,6 @@ UINTN REFIT_MENU_SCREEN::InputDialog() #endif -// if ((Item->ItemType != BoolValue) && -// (Item->ItemType != RadioSwitch) && -// (Item->ItemType != CheckBit)) { -// // Grow Item->SValue to SVALUE_MAX_SIZE if we want to edit a text field -// Item->SValue.dataSized(SVALUE_MAX_SIZE); -// } - -// Buffer = Item->SValue; BackupShift = Item->LineShift; BackupPos = Pos; @@ -516,6 +508,8 @@ UINTN REFIT_MENU_SCREEN::InputDialog() } else if (Item->ItemType == RadioSwitch) { if (Item->IValue == 3) { OldChosenTheme = Pos? Pos - 1: 0xFFFF; + } else if (Item->IValue == 65) { + OldChosenSmbios = Pos; } else if (Item->IValue == 90) { OldChosenConfig = Pos; } else if (Item->IValue == 116) { @@ -1084,10 +1078,10 @@ void REFIT_MENU_SCREEN::TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT for (i = 0; i <= ScrollState.MaxIndex; i++) { ItemWidth = Entries[i].Title.length(); - if (TextMenuWidth < ItemWidth) { + if (TextMenuWidth < ItemWidth) { TextMenuWidth = ItemWidth; - } } + } if (TextMenuWidth > ConWidth - 6) { TextMenuWidth = ConWidth - 6; @@ -1095,6 +1089,8 @@ void REFIT_MENU_SCREEN::TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT if (Entries[0].getREFIT_MENU_SWITCH() && Entries[0].getREFIT_MENU_SWITCH()->Item->IValue == 90) { j = OldChosenConfig; + } else if (Entries[0].getREFIT_MENU_SWITCH() && Entries[0].getREFIT_MENU_SWITCH()->Item->IValue == 65) { + j = OldChosenSmbios; } else if (Entries[0].getREFIT_MENU_SWITCH() && Entries[0].getREFIT_MENU_SWITCH()->Item->IValue == 116) { j = OldChosenDsdt; } else if (Entries[0].getREFIT_MENU_SWITCH() && Entries[0].getREFIT_MENU_SWITCH()->Item->IValue == 119) { @@ -1158,6 +1154,8 @@ void REFIT_MENU_SCREEN::TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT // update chosen config if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 90) { OldChosenItem = OldChosenConfig; + } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 65) { + OldChosenItem = OldChosenSmbios; } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 116) { OldChosenItem = OldChosenDsdt; } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 119) { @@ -1218,6 +1216,8 @@ void REFIT_MENU_SCREEN::TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 90) { OldChosenItem = OldChosenConfig; + } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 65) { + OldChosenItem = OldChosenSmbios; } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 116) { OldChosenItem = OldChosenDsdt; } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 119) { @@ -1254,6 +1254,8 @@ void REFIT_MENU_SCREEN::TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamT if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 90) { OldChosenItem = OldChosenConfig; + } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 65) { + OldChosenItem = OldChosenSmbios; } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 116) { OldChosenItem = OldChosenDsdt; } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 119) { @@ -1562,6 +1564,8 @@ void REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa if (entry.getREFIT_MENU_SWITCH()) { if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 3) { Chosen = (OldChosenTheme == 0xFFFF) ? 0: (OldChosenTheme + 1); + } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 65) { + Chosen = OldChosenSmbios; } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 90) { Chosen = OldChosenConfig; } else if (entry.getREFIT_MENU_SWITCH()->Item->IValue == 116) { @@ -1696,6 +1700,8 @@ void REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 3) { //OldChosenItem = OldChosenTheme; OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: (OldChosenTheme + 1); + } else if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 65) { + OldChosenItem = OldChosenSmbios; } else if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 90) { OldChosenItem = OldChosenConfig; } else if (Entry->getREFIT_MENU_SWITCH()->Item->IValue == 116) { @@ -1760,6 +1766,8 @@ void REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa } else if (EntryL->getREFIT_MENU_SWITCH()) { //radio buttons 0,1 if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 3) { OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1; + } else if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 65) { + OldChosenItem = OldChosenSmbios; } else if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 90) { OldChosenItem = OldChosenConfig; } else if (EntryL->getREFIT_MENU_SWITCH()->Item->IValue == 116) { @@ -1791,6 +1799,8 @@ void REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa if ( EntryC->getREFIT_MENU_SWITCH() ) { if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 3) { OldChosenItem = (OldChosenTheme == 0xFFFF) ? 0: OldChosenTheme + 1; + } else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 65) { + OldChosenItem = OldChosenSmbios; } else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 90) { OldChosenItem = OldChosenConfig; } else if (EntryC->getREFIT_MENU_SWITCH()->Item->IValue == 116) { diff --git a/rEFIt_UEFI/gui/menu_items/menu_items.h b/rEFIt_UEFI/gui/menu_items/menu_items.h index aa17721fa..aa285a09b 100644 --- a/rEFIt_UEFI/gui/menu_items/menu_items.h +++ b/rEFIt_UEFI/gui/menu_items/menu_items.h @@ -355,6 +355,7 @@ class REFIT_ABSTRACT_MENU_ENTRY EFI_GUID APFSTargetUUID; XStringW DisplayedVolName; + XStringW OSName; EFI_DEVICE_PATH *DevicePath; UINT16 Flags; UINT8 LoaderType; diff --git a/rEFIt_UEFI/refit/lib.h b/rEFIt_UEFI/refit/lib.h index 09ea572cc..ff209cc5d 100644 --- a/rEFIt_UEFI/refit/lib.h +++ b/rEFIt_UEFI/refit/lib.h @@ -147,38 +147,39 @@ typedef enum { #define SVALUE_MAX_SIZE 512 -#define SCREEN_UNKNOWN 0 -#define SCREEN_MAIN 1 -#define SCREEN_ABOUT 2 -#define SCREEN_HELP 3 -#define SCREEN_OPTIONS 4 -#define SCREEN_GRAPHICS 5 -#define SCREEN_CPU 6 -#define SCREEN_BINARIES 7 -#define SCREEN_DSDT 8 -#define SCREEN_BOOT 9 -#define SCREEN_SMBIOS 10 -#define SCREEN_TABLES 11 -#define SCREEN_RC_SCRIPTS 12 -#define SCREEN_USB 13 -#define SCREEN_THEME 14 -#define SCREEN_SYSVARS 15 -#define SCREEN_CSR 16 -#define SCREEN_BLC 17 -#define SCREEN_DSM 18 -#define SCREEN_ACPI 19 -#define SCREEN_GUI 20 -#define SCREEN_SYSTEM 21 -#define SCREEN_AUDIO 22 -#define SCREEN_KEXTS 23 -#define SCREEN_KERNELS 24 -#define SCREEN_DSDT_PATCHES 25 -#define SCREEN_DEVICES 26 -#define SCREEN_BOOTER 27 -#define SCREEN_KEXT_INJECT 28 -#define SCREEN_KEXTS_MAN 29 -#define SCREEN_AUDIOPORTS 30 -#define SCREEN_QUIRKS 31 +#define SCREEN_UNKNOWN 0 +#define SCREEN_MAIN 1 +#define SCREEN_ABOUT 2 +#define SCREEN_HELP 3 +#define SCREEN_OPTIONS 4 +#define SCREEN_GRAPHICS 5 +#define SCREEN_CPU 6 +#define SCREEN_BINARIES 7 +#define SCREEN_DSDT 8 +#define SCREEN_BOOT 9 +#define SCREEN_SMBIOS 10 +#define SCREEN_TABLES 11 +#define SCREEN_RC_SCRIPTS 12 +#define SCREEN_USB 13 +#define SCREEN_THEME 14 +#define SCREEN_SYSVARS 15 +#define SCREEN_CSR 16 +#define SCREEN_CHOOSE_SMBIOS 17 +#define SCREEN_DSM 18 +#define SCREEN_ACPI 19 +#define SCREEN_GUI 20 +#define SCREEN_SYSTEM 21 +#define SCREEN_AUDIO 22 +#define SCREEN_KEXTS 23 +#define SCREEN_KERNELS 24 +#define SCREEN_DSDT_PATCHES 25 +#define SCREEN_DEVICES 26 +#define SCREEN_BOOTER 27 +#define SCREEN_KEXT_INJECT 28 +#define SCREEN_KEXTS_MAN 29 +#define SCREEN_AUDIOPORTS 30 +#define SCREEN_QUIRKS 31 + #define MAX_ANIME 41 diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index eed3c0727..2e7383927 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -794,6 +794,8 @@ void LOADER_ENTRY::StartLoader() //Free memory ConfigsList.setEmpty(); DsdtsList.setEmpty(); +// SmbiosList.setEmpty(); + OptionMenu.FreeMenu(); //there is a place to free memory // GuiAnime @@ -812,10 +814,6 @@ void LOADER_ENTRY::StartLoader() fontChain = nextChain; } fontsDB = NULL; -// nsvg__deleteParser(mainParser); //temporary disabled - //destruct_globals_objects(NULL); //we can't destruct our globals here. We need, for example, Volumes. - - //DumpKernelAndKextPatches(KernelAndKextPatches); if ( OSTYPE_IS_OSX(LoaderType) || OSTYPE_IS_OSX_RECOVERY(LoaderType) || OSTYPE_IS_OSX_INSTALLER(LoaderType) ) { @@ -845,8 +843,6 @@ void LOADER_ENTRY::StartLoader() DBG("Beginning OC\n"); -// UINT64 CPUFrequencyFromART; -// InternalCalculateARTFrequencyIntel(&CPUFrequencyFromART, NULL, 1); EFI_LOADED_IMAGE* OcLoadedImage; Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &OcLoadedImage); @@ -1522,6 +1518,7 @@ void LOADER_ENTRY::StartLoader() // first patchACPI and find PCIROOT and RTC // but before ACPI patch we need smbios patch CheckEmptyFB(); + gConf.ReloadSmbios(OSName); SmbiosFillPatchingValues(GlobalConfig.SetTable132, GlobalConfig.EnabledCores, g_SmbiosDiscoveredSettings.RamSlotCount, gConf.SlotDeviceArray, gSettings, gCPUStructure, &g_SmbiosInjectedSettings); PatchSmbios(g_SmbiosInjectedSettings); // DBG("PatchACPI\n"); @@ -2596,17 +2593,17 @@ GetListOfConfigs() if (DirEntry->FileName[0] == L'.') { continue; } - if (StriCmp(DirEntry->FileName, L"config.plist") == 0) { - OldChosenConfig = ConfigsList.size(); // DirEntry->FileName is not yet inserted into ConfigsList. So its index will be ConfigsList.size() - } - size_t NameLen = wcslen(DirEntry->FileName) - 6; //without ".plist" - if ( NameLen <= MAX_INTN ) { - ConfigsList.AddReference(SWPrintf("%.*ls", (int)NameLen, DirEntry->FileName).forgetDataWithoutFreeing(), true); // this avoid to reallocate and copy memory - DBG("- %ls\n", DirEntry->FileName); - }else{ - DBG("- bug!, NameLen > MAX_INTN"); - } + if (StriCmp(DirEntry->FileName, L"config.plist") == 0) { + OldChosenConfig = ConfigsList.size(); // DirEntry->FileName is not yet inserted into ConfigsList. So its index will be ConfigsList.size() } + size_t NameLen = wcslen(DirEntry->FileName) - 6; //without ".plist" + if ( NameLen <= MAX_INTN ) { + ConfigsList.AddReference(SWPrintf("%.*ls", (int)NameLen, DirEntry->FileName).forgetDataWithoutFreeing(), true); // this avoid to reallocate and copy memory + DBG("- %ls\n", DirEntry->FileName); + }else{ + DBG("- bug!, NameLen > MAX_INTN"); + } + } DirIterClose(&DirIter); } @@ -2985,6 +2982,8 @@ RefitMain (IN EFI_HANDLE ImageHandle, if (!GlobalConfig.isFastBoot()) { GetListOfThemes(); GetListOfConfigs(); +// SmbiosList.setEmpty(); +// SmbiosList.AddReference(new XStringW(L"auto"_XSW), true); } // ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings { @@ -3243,6 +3242,11 @@ RefitMain (IN EFI_HANDLE ImageHandle, DefaultEntry = NULL; } +// DBG("found entries SMBIOS:\n"); +// for (size_t i=0; iSubScreen->ID == SCREEN_BLC) { - ChosenEntry->Title.SWPrintf("boot_args->flags [0x%04hx]->", gSettings.RtVariables.BooterConfig); +// } else if (ChosenEntry->SubScreen->ID == SCREEN_BLC) { +// ChosenEntry->Title.SWPrintf("boot_args->flags [0x%04hx]->", gSettings.RtVariables.BooterConfig); } } @@ -1667,10 +1676,6 @@ REFIT_ABSTRACT_MENU_ENTRY *SubMenuGraphics() // ErmaC: Audio submenu REFIT_ABSTRACT_MENU_ENTRY *SubMenuAudio() { - - UINTN i; - - // init REFIT_MENU_ITEM_OPTIONS *Entry; REFIT_MENU_SCREEN *SubScreen; @@ -1680,7 +1685,7 @@ REFIT_ABSTRACT_MENU_ENTRY *SubMenuAudio() // submenu description SubScreen->AddMenuInfoLine_f("Choose options to tune the HDA devices"); SubScreen->AddMenuInfoLine_f("Number of Audio Controller%s=%zu", ((gConf.HdaPropertiesArray.size()!=1)?"s":""), gConf.HdaPropertiesArray.size()); - for (i = 0 ; i < gConf.HdaPropertiesArray.size() ; i++) { + for (UINTN i = 0 ; i < gConf.HdaPropertiesArray.size() ; i++) { SubScreen->AddMenuInfoLine_f("%llu) %ls [%04hX][%04hX]", (i+1), gConf.HdaPropertiesArray[i].controller_name, @@ -2009,7 +2014,7 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuSmbios() REFIT_MENU_ITEM_OPTIONS *Entry; REFIT_MENU_SCREEN *SubScreen; - Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_SMBIOS, "SMBIOS->"_XS8); + Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_SMBIOS, "SMBIOS settings->"_XS8); SubScreen->AddMenuInfoLine_f("%s", gCPUStructure.BrandString.c_str()); SubScreen->AddMenuInfoLine_f("%s", GlobalConfig.OEMProductFromSmbios.c_str()); @@ -2036,6 +2041,32 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuSmbios() return Entry; } + +REFIT_ABSTRACT_MENU_ENTRY* SubMenuChooseSmbios() +{ + REFIT_MENU_ITEM_OPTIONS *Entry; + REFIT_MENU_SCREEN *SubScreen; + REFIT_MENU_SWITCH *InputBootArgs; + + Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_CHOOSE_SMBIOS, "SMBIOS->"_XS8); + + SubScreen->AddMenuInfoLine_f("Select SMBIOS:"); + + for (UINTN i = 0; i < SmbiosList.size(); i++) { + InputBootArgs = new REFIT_MENU_SWITCH; + InputBootArgs->Title = SmbiosList[i]; + InputBootArgs->Row = i; + InputBootArgs->Item = &InputItems[65]; + InputBootArgs->AtClick = ActionEnter; + InputBootArgs->AtRightClick = ActionDetails; + SubScreen->AddMenuEntry(InputBootArgs, true); + } + SubScreen->AddMenuEntry(SubMenuSmbios(), true); + SubScreen->AddMenuEntry(&MenuEntryReturn, false); + return Entry; +} + + REFIT_ABSTRACT_MENU_ENTRY* SubMenuDsdtFix() { REFIT_MENU_ITEM_OPTIONS *Entry; //, *SubEntry; @@ -2213,40 +2244,7 @@ void CreateMenuProps(REFIT_MENU_SCREEN* SubScreen, SETTINGS_DATA::DevicesClass:: break; } } -/* -void CreateMenuAddProp(REFIT_MENU_SCREEN* SubScreen, SETTINGS_DATA::DevicesClass::AddPropertyClass* Prop) -{ - REFIT_INPUT_DIALOG *InputBootArgs; - InputBootArgs = new REFIT_INPUT_DIALOG; - InputBootArgs->Title.SWPrintf(" key: %s", Prop->Key.c_str()); - InputBootArgs->Row = 0xFFFF; //cursor - InputBootArgs->Item = &Prop->MenuItem; - InputBootArgs->AtClick = ActionEnter; - InputBootArgs->AtRightClick = ActionDetails; - SubScreen->AddMenuEntry(InputBootArgs, true); - switch (Prop->ValueType) { - case kTagTypeInteger: - SubScreen->AddMenuInfo_f(" value: 0x%08llx", *(UINT64*)Prop->Value.data()); - break; - case kTagTypeString: - SubScreen->AddMenuInfo_f(" value: %90s", Prop->Value.data()); - break; - case kTagTypeFalse: - SubScreen->AddMenuInfo_f((" value: false")); - break; - case kTagTypeTrue: - SubScreen->AddMenuInfo_f((" value: true")); - break; - case kTagTypeFloat: - SubScreen->AddMenuInfo_f(" value: %f", *(float*)Prop->Value.data()); - break; - default: //type data, print first 24 bytes - SubScreen->AddMenuInfo_f(" value[%zu]: %24s", Prop->Value.size(), Bytes2HexStr((UINT8*)Prop->Value.data(), MIN(24, Prop->Value.size())).c_str()); - break; - } -} -*/ REFIT_ABSTRACT_MENU_ENTRY* SubMenuProperties() { REFIT_MENU_ITEM_OPTIONS *Entry; @@ -2269,44 +2267,7 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuProperties() Entry->SubScreen = SubScreen; return Entry; } -/* -REFIT_ABSTRACT_MENU_ENTRY* SubMenuArbProperties() -{ - REFIT_MENU_ITEM_OPTIONS *Entry; - REFIT_MENU_SCREEN *SubScreen; - Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_DEVICES, "Arbitrary properties->"_XS8); - - for ( size_t idx = 0 ; idx < gSettings.Devices.ArbitraryArray.size() ; ++idx) { - SETTINGS_DATA::DevicesClass::ArbitraryPropertyClass& Prop = gSettings.Devices.ArbitraryArray[idx]; - if ( idx > 0 ) SubScreen->AddMenuInfo_f("------------"); - for ( size_t idxChild = 0 ; idxChild < Prop.CustomPropertyArray.size(); ++idxChild) { - SETTINGS_DATA::DevicesClass::SimplePropertyClass& Props = Prop.CustomPropertyArray[idxChild]; - SubScreen->AddMenuInfo_f("%s", Prop.Label.c_str()); - CreateMenuProps(SubScreen, &Props); - } - } - SubScreen->AddMenuEntry(&MenuEntryReturn, false); - Entry->SubScreen = SubScreen; - return Entry; -} - -REFIT_ABSTRACT_MENU_ENTRY* SubMenuAddProperties() -{ - REFIT_MENU_ITEM_OPTIONS *Entry; - REFIT_MENU_SCREEN *SubScreen; - - Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_DEVICES, "Add properties->"_XS8); - - for ( size_t idx = 0 ; idx < gSettings.Devices.AddPropertyArray.size() ; ++idx) { - SETTINGS_DATA::DevicesClass::AddPropertyClass& Prop = gSettings.Devices.AddPropertyArray[idx]; - CreateMenuAddProp(SubScreen, &Prop); - } - SubScreen->AddMenuEntry(&MenuEntryReturn, false); - Entry->SubScreen = SubScreen; - return Entry; -} -*/ REFIT_ABSTRACT_MENU_ENTRY* SubMenuPCI() { REFIT_MENU_ITEM_OPTIONS *Entry; @@ -2325,8 +2286,6 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuPCI() SubScreen->AddMenuItemInput(100, "FakeID XHCI:", true); SubScreen->AddMenuItemInput(103, "FakeID IMEI:", true); SubScreen->AddMenuEntry(SubMenuProperties(), true); -// SubScreen->AddMenuEntry(SubMenuArbProperties(), true); -// SubScreen->AddMenuEntry(SubMenuAddProperties(), true); SubScreen->AddMenuEntry(&MenuEntryReturn, false); Entry->SubScreen = SubScreen; @@ -2374,7 +2333,6 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuGUI() SubScreen->AddMenuItemInput(70, "Pointer Speed:", true); SubScreen->AddMenuItemInput(72, "Mirror Move", false); - SubScreen->AddMenuEntry(SubMenuThemes(), true); SubScreen->AddMenuEntry(&MenuEntryReturn, false); @@ -2420,7 +2378,7 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuCSR() ModifyTitles(Entry); return Entry; } - +/* REFIT_ABSTRACT_MENU_ENTRY* SubMenuBLC() { // init @@ -2447,7 +2405,7 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuBLC() ModifyTitles(Entry); return Entry; } - +*/ REFIT_ABSTRACT_MENU_ENTRY* SubMenuSystem() { // init @@ -2466,7 +2424,7 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuSystem() SubScreen->AddMenuItemInput(129, "Reset SMC", false); SubScreen->AddMenuEntry(SubMenuCSR(), true); - SubScreen->AddMenuEntry(SubMenuBLC(), true); +// SubScreen->AddMenuEntry(SubMenuBLC(), true); SubScreen->AddMenuEntry(&MenuEntryReturn, false); return Entry; @@ -2572,7 +2530,8 @@ void OptionsMenu(OUT REFIT_ABSTRACT_MENU_ENTRY **ChosenEntry) OptionMenu.AddMenuEntry( SubMenuGUI(), true); } OptionMenu.AddMenuEntry( SubMenuACPI(), true); - OptionMenu.AddMenuEntry( SubMenuSmbios(), true); + OptionMenu.AddMenuEntry( SubMenuChooseSmbios(), true); + // OptionMenu.AddMenuEntry( SubMenuSmbios(), true); OptionMenu.AddMenuEntry( SubMenuBinaries(), true); OptionMenu.AddMenuEntry( SubMenuQuirks(), true); OptionMenu.AddMenuEntry( SubMenuGraphics(), true);