From 4af8734cc8ffa2dc7daa4c4336af56bcb555c7ca Mon Sep 17 00:00:00 2001 From: ko2d <143257729+ko2d@users.noreply.github.com> Date: Wed, 30 Aug 2023 16:00:05 +0000 Subject: [PATCH 1/5] Update Build instruction style --- README.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a71e6ee13..1c9e7c121 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,11 @@ Bootloader for macOS, Windows and Linux in UEFI and in legacy mode # Building from Source -`mkdir -p $HOME/src && cd $HOME/src` - -`git clone -q https://github.com/CloverHackyColor/CloverBootloader` - -`cd CloverBootloader && git submodule update --init --recursive` - -`cd OpenCorePkg && git checkout master && git pull` - -`cd ..` - -`./buildme` -# +```bash +mkdir -p $HOME/src && cd $HOME/src +git clone -q https://github.com/CloverHackyColor/CloverBootloader +cd CloverBootloader && git submodule update --init --recursive +cd OpenCorePkg && git checkout master && git pull +cd .. +./buildme +``` From 7ba49e9c771a383ecb09f2134ea738045e2aec1a Mon Sep 17 00:00:00 2001 From: Slice Date: Fri, 1 Sep 2023 23:08:13 +0300 Subject: [PATCH 2/5] universal compilation Signed-off-by: Slice --- CloverPackage/utils/nvram/nvram2.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CloverPackage/utils/nvram/nvram2.c b/CloverPackage/utils/nvram/nvram2.c index 8a055127d..44075eb58 100644 --- a/CloverPackage/utils/nvram/nvram2.c +++ b/CloverPackage/utils/nvram/nvram2.c @@ -120,7 +120,12 @@ int main(int argc, char **argv) mach_port_t mainPort; int argcount = 0; - result = IOMainPort(bootstrap_port, &mainPort); + +#if defined(MAC_OS_VERSION_12_0) + result = IOMainPort(bootstrap_port, &mainPort); +#else + result = IOMasterPort(bootstrap_port, &mainPort); +#endif if (result != KERN_SUCCESS) { errx(1, "Error getting the IOMainPort: %s", mach_error_string(result)); From 2aca955c36ad7a17c31779ebb55d00b18ab37182 Mon Sep 17 00:00:00 2001 From: SergeySlice Date: Sun, 3 Sep 2023 16:59:40 +0300 Subject: [PATCH 3/5] update submodule Signed-off-by: SergeySlice --- OpenCorePkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenCorePkg b/OpenCorePkg index 212c98ec9..3157e8403 160000 --- a/OpenCorePkg +++ b/OpenCorePkg @@ -1 +1 @@ -Subproject commit 212c98ec954b7842696d5d1752ecefc184dfa3e0 +Subproject commit 3157e84036b17e50605afc67762bbd8d411caaa1 From 99fa51da2f49a7c9d203aaebfd8651c681e2f083 Mon Sep 17 00:00:00 2001 From: Slice Date: Mon, 4 Sep 2023 21:56:03 +0300 Subject: [PATCH 4/5] support nvram in legacy boot Signed-off-by: Slice --- rEFIt_UEFI/Platform/Nvram.cpp | 75 ++++++++++------ rEFIt_UEFI/Platform/plist/plist.cpp | 88 ------------------- rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h | 15 +--- rEFIt_UEFI/cpp_lib/XmlLiteParser.cpp | 20 ----- 4 files changed, 50 insertions(+), 148 deletions(-) diff --git a/rEFIt_UEFI/Platform/Nvram.cpp b/rEFIt_UEFI/Platform/Nvram.cpp index 9190161db..b4e5f3ad8 100755 --- a/rEFIt_UEFI/Platform/Nvram.cpp +++ b/rEFIt_UEFI/Platform/Nvram.cpp @@ -930,7 +930,7 @@ LoadNvramPlist( return Status; } -#define SEARCH_ONLY_EFI 1 +#define SEARCH_ONLY_EFI 0 /** Searches all volumes for the most recent nvram.plist and loads it into gNvramDict. */ EFI_STATUS LoadLatestNvramPlist() @@ -1098,17 +1098,15 @@ LoadLatestNvramPlist() return Status; } - +void PutDictToNvram(TagDict* NvramDict, size_t count, EFI_GUID& VendorGuid); /** Puts all vars from nvram.plist to RT vars. Should be used in CloverEFI only * or if some UEFI boot uses EmuRuntimeDxe driver. */ -void -PutNvramPlistToRtVars () +void PutNvramPlistToRtVars() { // EFI_STATUS Status; // const TagStruct* ValTag; - INTN Size; - const VOID *Value; + if (gNvramDict == NULL) { /*Status = */LoadLatestNvramPlist(); @@ -1120,18 +1118,50 @@ PutNvramPlistToRtVars () DbgHeader("PutNvramPlistToRtVars"); + const TagKey* keyTag; + const TagDict* keyDict; + const TagStruct* valueTag; + EFI_GUID VendorGuid = gEfiAppleBootGuid; // iterate over dict elements size_t count = gNvramDict->dictKeyCount(); // ok + DBG("dict count = %ld\n", count); + gNvramDict->getKeyAndValueAtIndex(0, &keyTag, &valueTag); + if (valueTag->isDict()) { + + // this is nvram.plist version 2 + for (size_t tagIdx = 0 ; tagIdx < count ; tagIdx++ ) { + if ( EFI_ERROR(gNvramDict->getKeyAndValueAtIndex(tagIdx, &keyTag, &valueTag)) ) { //If GetKeyValueAtIndex return success, key and value != NULL + MsgLog("MALFORMED PLIST nvram.plist. A key is expected at pos : %zu\n", tagIdx); + continue; + } + keyDict = static_cast(valueTag); + // Key -> VendorGuid + VendorGuid.takeValueFrom(keyTag->keyStringValue()); + size_t dictCount= keyDict->dictKeyCount(); + DBG("got GUID: %08X-%04X-%04X...\n", VendorGuid.Data1, VendorGuid.Data2, VendorGuid.Data3); + PutDictToNvram(const_cast(keyDict), dictCount, VendorGuid); + // + } + } else { + // there is version 1 + PutDictToNvram(gNvramDict, count, gEfiAppleBootGuid); + } +} + +void PutDictToNvram(TagDict* NvramDict, size_t count, EFI_GUID& VendorGuid) +{ + INTN Size = 0; + const VOID *Value = nullptr; + for (size_t tagIdx = 0 ; tagIdx < count ; tagIdx++ ) { const TagKey* keyTag; const TagStruct* valueTag; - if ( EFI_ERROR(gNvramDict->getKeyAndValueAtIndex(tagIdx, &keyTag, &valueTag)) ) { //If GetKeyValueAtIndex return success, key and value != NULL + if ( EFI_ERROR(NvramDict->getKeyAndValueAtIndex(tagIdx, &keyTag, &valueTag)) ) { //If GetKeyValueAtIndex return success, key and value != NULL MsgLog("MALFORMED PLIST nvram.plist. A key is expected at pos : %zu\n", tagIdx); continue; } - EFI_GUID VendorGuid = gEfiAppleBootGuid; // process only valid tags if ( valueTag == NULL ) { // DBG(" ERROR: ValTag is not NULL\n"); @@ -1153,41 +1183,34 @@ PutNvramPlistToRtVars () continue; } - if (keyTag->keyStringValue() == "Boot0082"_XS8 || - keyTag->keyStringValue() == "BootNext"_XS8 ) { - VendorGuid = gEfiGlobalVariableGuid; - // it may happen only in this case - gSettings.Boot.HibernationFixup = true; - } +// if (keyTag->keyStringValue() == "Boot0082"_XS8 || +// keyTag->keyStringValue() == "BootNext"_XS8 ) { +// VendorGuid = gEfiGlobalVariableGuid; +// // it may happen only in this case +// gSettings.Boot.HibernationFixup = true; +// } + + + XStringW KeyBuf = keyTag->keyStringValue(); + DBG(" Adding Key: %ls: ", KeyBuf.wc_str()); - // AsciiStrToUnicodeStrS(Tag.stringValue(), KeyBuf, 128); - XStringW KeyBuf = keyTag->keyStringValue(); -// if (!gSettings.Boot.DebugLog) { - DBG(" Adding Key: %ls: ", KeyBuf.wc_str()); -// } // process value tag if (valueTag->isString()) { // element Value = (void*)valueTag->getString()->stringValue().c_str(); Size = valueTag->getString()->stringValue().length(); -// if (!gSettings.Boot.DebugLog) { - DBG("String: Size = %llu, Val = '%s'\n", Size, valueTag->getString()->stringValue().c_str()); -// } + DBG("String: Size = %llu, Val = '%s'\n", Size, valueTag->getString()->stringValue().c_str()); } else if (valueTag->isData()) { // element Size = valueTag->getData()->dataLenValue(); Value = valueTag->getData()->dataValue(); - // if (gSettings.Boot.DebugLog) { DBG("Size = %llu, Data: ", Size); for (INTN i = 0; i < Size; i++) { DBG("%02hhX ", *(((UINT8*)Value) + i)); } - // } - // if (!gSettings.Boot.DebugLog) { DBG("\n"); - // } else { DBG("ERROR: Unsupported tag type: %s\n", valueTag->getTypeAsXString8().c_str()); continue; diff --git a/rEFIt_UEFI/Platform/plist/plist.cpp b/rEFIt_UEFI/Platform/plist/plist.cpp index 507961e3a..e8e497bcc 100755 --- a/rEFIt_UEFI/Platform/plist/plist.cpp +++ b/rEFIt_UEFI/Platform/plist/plist.cpp @@ -75,95 +75,7 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr); #include "TagFloat.h" #include "TagInt64.h" #include "TagString8.h" -// -////UINTN newtagcount = 0; -////UINTN tagcachehit = 0; -//TagStruct* TagStruct::getEmptyTag() -//{ -// TagStruct* tag; -// -// if ( gTagsFree.size() > 0 ) { -// tag = &gTagsFree[0]; -// gTagsFree.RemoveWithoutFreeingAtIndex(0); -////tagcachehit++; -////DBG("tagcachehit=%lld\n", tagcachehit); -// return tag; -// } -// tag = new TagStruct; -////newtagcount += 1; -////DBG("newtagcount=%lld\n", newtagcount); -// return tag; -//} -// -//TagStruct* TagStruct::getEmptyDictTag() -//{ -// TagStruct* newDictTag = getEmptyTag(); -// newDictTag->type = kTagTypeDict; -// return newDictTag; -//} -// -//TagStruct* TagStruct::getEmptyArrayTag() -//{ -// TagStruct* newArrayTag = getEmptyTag(); -// newArrayTag->type = kTagTypeArray; -// return newArrayTag; -//} -//void TagStruct::FreeTag() -//{ -// // Clear and free the tag. -// type = kTagTypeNone; -// -// _string.setEmpty(); -// _intValue = 0; -// _floatValue = 0; -// -// if ( _data ) { -// FreePool(_data); -// _data = NULL; -// } -// _dataLen = 0; -// -// //while ( tagIdx < _dictOrArrayContent.notEmpty() ) { -// // _dictOrArrayContent[0].FreeTag(); -// // _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0); -// //} -// // this loop is better because removing objects from the end don't do any memory copying. -// for (size_t tagIdx = _dictOrArrayContent.size() ; tagIdx > 0 ; ) { -// tagIdx--; -// _dictOrArrayContent[tagIdx].FreeTag(); -// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(tagIdx); -// } -// -// gTagsFree.AddReference(this, false); -//} - - -//TagStruct* GetNextProperty(TagStruct* dict) -//{ -// TagStruct* tagList, tag; -// -// if (dict->isDict()) { -// return NULL; -// } -// -// tag = NULL; -// tagList = dict->tag; -// while (tagList) -// { -// tag = tagList; -// tagList = tag->tagNext; -// -// if ( !tag->isKey() || tag->keyValue().isEmpty() ) { -// continue; -// -// } -// return tag->tag; -// } -// -// return NULL; -//} -// XBool TagStruct::debugIsEqual(const TagStruct& other, const XString8& label) const { diff --git a/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h b/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h index b0d2cf41c..4beaf8e92 100755 --- a/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h +++ b/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h @@ -152,7 +152,6 @@ public: // Cannot happen if validate has been done properly. panic("invalid DDRx value"); } -// XBool dgetInUse() const { return Size.isDefined() ? Size.value() > 0 : false; }; }; @@ -193,7 +192,7 @@ public: return max+1; }; - const ModuleDictClass& dgetSoltAtIndex(size_t slotIndex) const { + const ModuleDictClass& dgetSlotAtIndex(size_t slotIndex) const { for ( size_t idx = 0; idx < size(); ++idx ) { if ( ElementAt(idx).dgetSlotIndex() == slotIndex ) return ElementAt(idx); @@ -288,7 +287,6 @@ public: } const decltype(Device)::ValueType& dgetDevice() const { return Device.isDefined() ? Device.value() : Device.nullValue; }; uint8_t dgetDeviceN() const { - // if ( !Device.isDefined() ) panic("%s: invalid value. Check validate method.", __PRETTY_FUNCTION__); if ( !Device.isDefined() ) return 0; if (Device.value().isEqualIC("ATI")) { return 0; @@ -528,11 +526,8 @@ public: } } if ( EfiVersion.isDefined() ) { - // DebugLog(1, "have EfiVersion=%s\n", EfiVersion.value().c_str()); long long int result = AsciiStrVersionToUint64(ApplePlatformDataArray[dgetModel()].efiversion, 4, 3); long long int result2 = AsciiStrVersionToUint64(EfiVersion.value(), 4, 3); - // DebugLog(1, "make uint64=%lld vs %lld\n", result, result2); - // DebugLog(1, "compare 1715 %c 1968\n", (result > result2)? '>':'<'); if ( result > result2) { xmlLiteParser->addWarning(generateErrors, S8Printf("EfiVersion '%s' is older than default ('%s') -> ignored. Dict '%s:%d'.", EfiVersion.value().c_str(), ApplePlatformDataArray[dgetModel()].efiversion.c_str(), xmlPath.c_str(), keyPos.getLine())); // Do not set b to false : we don't want to invalidate the whole dict xmlLiteParser->productNameNeeded = !getProductName().isDefined(); @@ -748,12 +743,6 @@ public: if ( ExtendedFirmwareFeaturesMask.isDefined() ) return ExtendedFirmwareFeaturesMask.value(); return GetExtFwFeaturesMask(dgetModel()); }; -// decltype(FirmwareFeatures)::ValueType dgetFirmwareFeatures() const { -// if ( FirmwareFeatures.isDefined() ) return FirmwareFeatures.value(); -// return GetFwFeatures(dgetModel()); -// }; - - }; SmbiosDictClass SMBIOS = SmbiosDictClass(); @@ -804,8 +793,6 @@ public: } return SMBIOS; }; - - }; diff --git a/rEFIt_UEFI/cpp_lib/XmlLiteParser.cpp b/rEFIt_UEFI/cpp_lib/XmlLiteParser.cpp index 11904d8f0..d4e8283d9 100755 --- a/rEFIt_UEFI/cpp_lib/XmlLiteParser.cpp +++ b/rEFIt_UEFI/cpp_lib/XmlLiteParser.cpp @@ -426,15 +426,6 @@ XBool XmlLiteParser::getSimpleTagValue(const char* expectedTag, size_t expectedT addXmlError(generateErrors, S8Printf("Expecting a <%s> at line %d col %d", expectedTag, (*xmlParserPosition).line, (*xmlParserPosition).col)); return false; } -// if ( *valueLength == 0 ) { -// return false; -// // todo Msg -// } -// if ( **value == '#' ) { -// b = skipNextTag(); -// if ( !b ) return false; -// return getSimpleTagValue(expectedTag, expectedTagLength, value, valueLength, xmlParserPosition, generateErrors); -// } return true; } @@ -463,17 +454,6 @@ printf("\n"); currentPos = *xmlParserPosition; return false; } -// if ( *valueLength == 0 ) { -// if ( generateErrors ) addWarning(S8Printf("Expecting text for key tag at line %d col %d. SKipped\n", (*xmlParserPosition).line, (*xmlParserPosition).col)); -// b = skipNextTag(); -// if ( !b ) return false; -// return getKeyTagValue(value, valueLength, xmlParserPosition, generateErrors); -// } -// if ( **value == '#' ) { -// b = skipNextTag(); -// if ( !b ) return false; -// return getKeyTagValue(value, valueLength, xmlParserPosition, generateErrors); -// } return true; } From 6d15a9451baeaffdc5b1e20a2a09849bacc8e01f Mon Sep 17 00:00:00 2001 From: Slice Date: Mon, 4 Sep 2023 22:33:54 +0300 Subject: [PATCH 5/5] add one more variable Signed-off-by: Slice --- CloverPackage/utils/nvram/nvram2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/CloverPackage/utils/nvram/nvram2.c b/CloverPackage/utils/nvram/nvram2.c index 44075eb58..872ca6ab6 100644 --- a/CloverPackage/utils/nvram/nvram2.c +++ b/CloverPackage/utils/nvram/nvram2.c @@ -949,6 +949,7 @@ CFDictionaryRef CreateMyDictionary(void) { key[n++] = "gfx-saved-config-restore-status"; key[n++] = "SkipLogo"; key[n++] = "IASCurrentInstallPhase"; + key[n++] = "IASInstallPhaseList"; for ( i = 0; i < n; i++ ) { snprintf(name, sizeof(name), "%s:%s", gAppleNvramGuid, key[i]); var = CFStringCreateWithCString(NULL, key[i], kCFStringEncodingUTF8);