diff --git a/Include/Guid/AppleApfsInfo.h b/Include/Guid/AppleApfsInfo.h index 39689de1b..626b2acbf 100644 --- a/Include/Guid/AppleApfsInfo.h +++ b/Include/Guid/AppleApfsInfo.h @@ -39,8 +39,12 @@ extern EFI_GUID gAppleApfsContainerInfoGuid; { 0xB4, 0x4E, 0x97, 0x45, 0x15, 0xD2, 0x7C, 0x78 } } -#define APPLE_APFS_VOLUME_ROLE_RECOVERY BIT2 -#define APPLE_APFS_VOLUME_ROLE_PREBOOT BIT4 +#define APPLE_APFS_VOLUME_ROLE_RECOVERY BIT2 // 0x04 +#define APPLE_APFS_VOLUME_ROLE_PREBOOT BIT4 // 0x10 +#define APPLE_APFS_VOLUME_ROLE_DATA BIT6 // 0x40 +#define APPLE_APFS_VOLUME_ROLE_VM BIT3 // 0x08 +#define APPLE_APFS_VOLUME_ROLE_SYSTEM BIT0 // 0x01 Main partition. Joint with DATA. +//#define APPLE_APFS_VOLUME_ROLE_UPDATE 0xC0 // I got 0xC0, maybe the meaning is DATA + UPDATE ? typedef UINT32 APPLE_APFS_VOLUME_ROLE; diff --git a/OpenCorePkg b/OpenCorePkg index b2824181e..39fb43413 160000 --- a/OpenCorePkg +++ b/OpenCorePkg @@ -1 +1 @@ -Subproject commit b2824181efe897583c7c6d7b817e6707842eb564 +Subproject commit 39fb43413e5d3377de65bd0355a11b790edada4f diff --git a/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj b/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj index e0404f40b..3496d78fd 100644 --- a/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj +++ b/Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj @@ -187,6 +187,7 @@ 9A670D2224E53FD500B5D780 /* XBuffer_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A670D2024E53FD400B5D780 /* XBuffer_tests.cpp */; }; 9A670D2324E53FD500B5D780 /* XBuffer_tests.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A670D2124E53FD500B5D780 /* XBuffer_tests.h */; }; 9A7AEDE7245963BF003AAD04 /* XToolsCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A7AEDE6245963BF003AAD04 /* XToolsCommon.h */; }; + 9A80B49F2540175E00E56B08 /* OC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A80B49E2540175D00E56B08 /* OC.h */; }; 9A9AEB94243F7B5600FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */; }; 9A9AEB97243F7B5600FBD7D8 /* unicode_conversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9AEB93243F7B5600FBD7D8 /* unicode_conversions.h */; }; 9A9AEB99243F7B7A00FBD7D8 /* printf_lite-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9AEB98243F7B7900FBD7D8 /* printf_lite-test.h */; }; @@ -787,6 +788,7 @@ 9A670D2024E53FD400B5D780 /* XBuffer_tests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBuffer_tests.cpp; sourceTree = ""; }; 9A670D2124E53FD500B5D780 /* XBuffer_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBuffer_tests.h; sourceTree = ""; }; 9A7AEDE6245963BF003AAD04 /* XToolsCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XToolsCommon.h; sourceTree = ""; }; + 9A80B49E2540175D00E56B08 /* OC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OC.h; sourceTree = ""; }; 9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = ""; }; 9A9AEB93243F7B5600FBD7D8 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = ""; }; 9A9AEB98243F7B7900FBD7D8 /* printf_lite-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printf_lite-test.h"; sourceTree = ""; }; @@ -1135,6 +1137,7 @@ 9AC77F1324176C04005CDD5C /* include */ = { isa = PBXGroup; children = ( + 9A80B49E2540175D00E56B08 /* OC.h */, 9AD469542452B63300D6D0DB /* XToolsConf.h */, 9AD4694D2452B5A600D6D0DB /* Devices.h */, 9AD4694C2452B5A600D6D0DB /* Efi.h */, @@ -1529,6 +1532,7 @@ 9AD469552452B63300D6D0DB /* XToolsConf.h in Headers */, 9AD469512452B5A600D6D0DB /* Devices.h in Headers */, 9A28CC98241AB34800F3D247 /* XString_test.h in Headers */, + 9A80B49F2540175E00E56B08 /* OC.h in Headers */, 9A61B3012522165100AEE0FA /* Self.h in Headers */, 9AC7807424176C04005CDD5C /* REFIT_MENU_SCREEN.h in Headers */, 9A105B7C24483AE40006DE06 /* StartupSound.h in Headers */, diff --git a/rEFIt_UEFI/Platform/BootLog.cpp b/rEFIt_UEFI/Platform/BootLog.cpp index 543dc1b72..92f7a0ac4 100644 --- a/rEFIt_UEFI/Platform/BootLog.cpp +++ b/rEFIt_UEFI/Platform/BootLog.cpp @@ -81,7 +81,7 @@ static EFI_FILE_PROTOCOL* gLogFile = NULL; // Just instanciante this, the destructor will restore the callback. class SuspendMemLogCallback { - MEM_LOG_CALLBACK memlogCallBack_saved; + MEM_LOG_CALLBACK memlogCallBack_saved = NULL; public: SuspendMemLogCallback() { memlogCallBack_saved = GetMemLogCallback(); diff --git a/rEFIt_UEFI/Platform/Hibernate.cpp b/rEFIt_UEFI/Platform/Hibernate.cpp index bae02bdba..f3af5a58e 100644 --- a/rEFIt_UEFI/Platform/Hibernate.cpp +++ b/rEFIt_UEFI/Platform/Hibernate.cpp @@ -29,8 +29,6 @@ #define CREATE_NEW_BOOT_IMAGE 1 -extern XObjArray Volumes; - #pragma pack(push, 1) // diff --git a/rEFIt_UEFI/Platform/LegacyBoot.cpp b/rEFIt_UEFI/Platform/LegacyBoot.cpp index bd36ca698..c842b0895 100644 --- a/rEFIt_UEFI/Platform/LegacyBoot.cpp +++ b/rEFIt_UEFI/Platform/LegacyBoot.cpp @@ -29,8 +29,6 @@ Copyright (c) 2006 JLA #define DBG(...) DebugLog(0, __VA_ARGS__) // until a better solution is found, force DebugLog(0, ...) to prevent saving to DebugLog, which may cause legacy boot to fail #endif -extern XObjArray Volumes; - #pragma pack(push) #pragma pack(1) diff --git a/rEFIt_UEFI/Platform/Nvram.cpp b/rEFIt_UEFI/Platform/Nvram.cpp index b01df6c0f..ad56632e8 100644 --- a/rEFIt_UEFI/Platform/Nvram.cpp +++ b/rEFIt_UEFI/Platform/Nvram.cpp @@ -23,8 +23,6 @@ #define DBG(...) DebugLog (DEBUG_SET, __VA_ARGS__) #endif -extern XObjArray Volumes; - // for saving nvram.plist and it's data TagDict* gNvramDict; diff --git a/rEFIt_UEFI/Platform/Posix/abort.cpp b/rEFIt_UEFI/Platform/Posix/abort.cpp index 10212bff8..22219f2ab 100755 --- a/rEFIt_UEFI/Platform/Posix/abort.cpp +++ b/rEFIt_UEFI/Platform/Posix/abort.cpp @@ -27,6 +27,7 @@ static void panic_(const char* format, VA_LIST va) #ifdef CLOVER_BUILD extern void egSetGraphicsModeEnabled(BOOLEAN); +extern const LString8 gBuildId; #endif #define FATAL_ERROR_MSG "\nA fatal error happened. System halted.\n" @@ -35,6 +36,7 @@ static void panic_(const char* format, VA_LIST va) #ifdef CLOVER_BUILD egSetGraphicsModeEnabled(false); #endif + printf("Clover build id: %s\n", gBuildId.c_str()); if ( format ) { vprintf(format, va); #ifdef DEBUG_ON_SERIAL_PORT diff --git a/rEFIt_UEFI/Platform/SelfOem.cpp b/rEFIt_UEFI/Platform/SelfOem.cpp index ee251211d..33d45a43a 100644 --- a/rEFIt_UEFI/Platform/SelfOem.cpp +++ b/rEFIt_UEFI/Platform/SelfOem.cpp @@ -135,7 +135,7 @@ EFI_STATUS SelfOem::_initialize() - if ( m_KextsDir != NULL ) panic("%s : m_KextsDir != NULL", __FUNCTION__); + if ( m_KextsDir != NULL ) panic("%s : Kexts dir != NULL.", __FUNCTION__); if ( oemDirExists() ) { Status = m_OemDir->Open(m_OemDir, &m_KextsDir, KEXTS_DIRNAME.wc_str(), EFI_FILE_MODE_READ, 0); if ( !EFI_ERROR(Status) ) { @@ -192,6 +192,8 @@ EFI_STATUS SelfOem::initialize(const XString8& confName, bool isFirmwareClover, EFI_STATUS SelfOem::reInitialize() { + if ( m_ConfName.isEmpty() ) panic("%s : initialize() must called once first", __FUNCTION__); + closeHandle(); // No need to call _setOemPathRelToSelfDir again, but need to open m_OemDir, if it exists diff --git a/rEFIt_UEFI/entry_scan/entry_scan.h b/rEFIt_UEFI/entry_scan/entry_scan.h index 33dd2d5ba..f7e3bde8b 100644 --- a/rEFIt_UEFI/entry_scan/entry_scan.h +++ b/rEFIt_UEFI/entry_scan/entry_scan.h @@ -45,7 +45,6 @@ extern REFIT_MENU_ITEM_SHUTDOWN MenuEntryShutdown; //extern REFIT_MENU_ENTRY MenuEntryExit; extern REFIT_MENU_SCREEN MainMenu; -extern XObjArray Volumes; // common const XIcon& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, const EFI_DEVICE_PATH_PROTOCOL *DevicePath); diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index 63e8c4dd7..3955145e5 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -439,6 +439,7 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry) } return Status; } + STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Array& LoaderOptions, IN CONST XStringW& FullTitle, @@ -810,10 +811,13 @@ void LOADER_ENTRY::AddDefaultMenu() SubScreen->AddMenuInfoLine_f("APFS volume name: %ls", DisplayedVolName.wc_str()); } if ( Volume->ApfsFileSystemUUID.notEmpty() ) { - SubScreen->AddMenuInfoLine_f("APFS File System UUID: %s", Volume->ApfsFileSystemUUID.c_str()); + SubScreen->AddMenuInfoLine_f("APFS file system UUID: %s", Volume->ApfsFileSystemUUID.c_str()); + } + if ( Volume->ApfsContainerUUID.notEmpty() ) { + SubScreen->AddMenuInfoLine_f("APFS container UUID: %s", Volume->ApfsContainerUUID.c_str()); } if ( APFSTargetUUID.notEmpty() ) { - SubScreen->AddMenuInfoLine_f("APFS Target UUID: %ls", APFSTargetUUID.wc_str()); + SubScreen->AddMenuInfoLine_f("APFS target UUID: %ls", APFSTargetUUID.wc_str()); } SubScreen->AddMenuInfoLine_f("Options: %s", LoadOptions.ConcatAll(" "_XS8).c_str()); // loader-specific submenu entries @@ -1002,7 +1006,7 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr return NULL; } - DBG(" AddLoaderEntry for Volume Name=%ls\n", Volume->VolName.wc_str()); + DBG(" AddLoaderEntry for Volume Name=%ls, idx=%zu\n", Volume->VolName.wc_str(), MainMenu.Entries.sizeIncludingHidden()); if (OSFLAG_ISSET(Flags, OSFLAG_DISABLED)) { DBG(" skipped because entry is disabled\n"); return NULL; @@ -1020,6 +1024,10 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr // } // } // } + if ( Volume->ApfsContainerUUID.notEmpty() ) DBG(" ApfsContainerUUID=%s\n", Volume->ApfsContainerUUID.c_str()); + if ( Volume->ApfsFileSystemUUID.notEmpty() ) DBG(" ApfsFileSystemUUID=%s\n", Volume->ApfsFileSystemUUID.c_str()); + if ( APFSTargetUUID.notEmpty() ) DBG(" APFSTargetUUID=%ls\n", APFSTargetUUID.wc_str()); + Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, FullTitle, LoaderTitle, Volume, APFSTargetUUID, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE); if (Entry != NULL) { if ((Entry->LoaderType == OSTYPE_OSX) || @@ -1344,10 +1352,6 @@ void ScanLoader(void) continue; } -// if (Volume->Hidden) { -// DBG(", hidden\n"); -// continue; -// } DBG("\n"); // check for Mac OS X Install Data @@ -1412,7 +1416,7 @@ void ScanLoader(void) AddLoaderEntry(MACOSX_LOADER_PATH, NullXString8Array, L""_XSW, L"OS X"_XSW, Volume, L""_XSW, NULL, OSTYPE_OSX, 0); // 10.8 - 10.11 } else { XString8 OSVersion; - if ( Volume->ApfsFileSystemUUID.notEmpty() && Volume->ApfsTargetUUIDArray.size() == 0 ) + if ( Volume->ApfsFileSystemUUID.notEmpty() && (Volume->ApfsRole & APPLE_APFS_VOLUME_ROLE_SYSTEM) != 0 ) { XStringW plist = SWPrintf("\\System\\Library\\CoreServices\\SystemVersion.plist"); if ( !FileExists(Volume->RootDir, plist) ) { @@ -1444,7 +1448,7 @@ void ScanLoader(void) if ( PlistBuffer ) FreePool(PlistBuffer); } } - if ( OSVersion.isEmpty() || !OSVersion.equal("11.0") ) { + if ( !OSVersion.equal("11.0") ) { AddLoaderEntry(MACOSX_LOADER_PATH, NullXString8Array, L""_XSW, L"macOS"_XSW, Volume, L""_XSW, NULL, OSTYPE_OSX, 0); // 10.12+ } } @@ -1519,73 +1523,130 @@ void ScanLoader(void) for (UINTN i = 0; i < Volume->ApfsTargetUUIDArray.size(); i++) { const XString8& ApfsTargetUUID = Volume->ApfsTargetUUIDArray[i]; + XStringW FullTitle; + XStringW FullTitleRecovery; + XStringW FullTitleInstaller; + XStringW LoaderTitle; + XStringW LoaderTitleInstaller; - const LOADER_ENTRY* targetLoaderEntry = NULL; - for ( size_t entryIdx = 0 ; entryIdx < MainMenu.Entries.size() ; entryIdx ++ ) - { - if ( MainMenu.Entries[entryIdx].getLOADER_ENTRY() ) { - const LOADER_ENTRY* loaderEntry = MainMenu.Entries[entryIdx].getLOADER_ENTRY(); - if ( loaderEntry->Volume->ApfsFileSystemUUID == ApfsTargetUUID ) { - targetLoaderEntry = loaderEntry; - } - } - } - if ( targetLoaderEntry ) { - AddLoaderEntry(SWPrintf("\\%s\\System\\Library\\CoreServices\\boot.efi", ApfsTargetUUID.c_str()), NullXString8Array, SWPrintf("Boot Mac OS X from %ls via %ls", targetLoaderEntry->DisplayedVolName.wc_str(), Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX, 0); - //Try to add Recovery APFS entry - AddLoaderEntry(SWPrintf("\\%s\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, SWPrintf("Boot Mac OS X Recovery for %ls via %ls", targetLoaderEntry->DisplayedVolName.wc_str(), Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_RECOVERY, 0); - //Try to add macOS install entry - AddLoaderEntry(SWPrintf("\\%s\\com.apple.installer\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, L""_XSW, L"macOS Install Prebooter"_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX_INSTALLER, 0); - } - else - { - REFIT_VOLUME* targetVolume = NULL; - for (UINTN VolumeIndex2 = 0; VolumeIndex2 < Volumes.size(); VolumeIndex2++) { - REFIT_VOLUME* Volume2 = &Volumes[VolumeIndex2]; - //DBG("name %ls uuid=%ls \n", Volume2->VolName, Volume2->ApfsFileSystemUUID.wc_str()); + REFIT_VOLUME* targetVolume = NULL; + for (UINTN VolumeIndex2 = 0; VolumeIndex2 < Volumes.size(); VolumeIndex2++) { + REFIT_VOLUME* Volume2 = &Volumes[VolumeIndex2]; + //DBG("name %ls uuid=%ls \n", Volume2->VolName, Volume2->ApfsFileSystemUUID.wc_str()); + if ( Volume2->ApfsContainerUUID == Volume->ApfsContainerUUID ) { if ( Volume2->ApfsFileSystemUUID == ApfsTargetUUID ) { targetVolume = Volume2; } } - if ( targetVolume ) { - AddLoaderEntry(SWPrintf("\\%s\\System\\Library\\CoreServices\\boot.efi", ApfsTargetUUID.c_str()), NullXString8Array, SWPrintf("Boot Mac OS X from %ls via %ls", targetVolume->VolName.wc_str(), Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX, 0); - //Try to add Recovery APFS entry - AddLoaderEntry(SWPrintf("\\%s\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, SWPrintf("Boot Mac OS X Recovery for %ls via %ls", targetVolume->VolName.wc_str(), Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_RECOVERY, 0); - //Try to add macOS install entry - AddLoaderEntry(SWPrintf("\\%s\\com.apple.installer\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, SWPrintf("Boot Mac OS X Install for %ls via %ls", targetVolume->VolName.wc_str(), Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX_INSTALLER, 0); - } else { - AddLoaderEntry(SWPrintf("\\%s\\System\\Library\\CoreServices\\boot.efi", ApfsTargetUUID.c_str()), NullXString8Array, L""_XSW, L"FileVault Prebooter"_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX, 0); - //Try to add Recovery APFS entry - AddLoaderEntry(SWPrintf("\\%s\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, SWPrintf("Boot Mac OS X Recovery via %ls", Volume->VolName.wc_str()), L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_RECOVERY, 0); - //Try to add macOS install entry - AddLoaderEntry(SWPrintf("\\%s\\com.apple.installer\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, L""_XSW, L"macOS Install Prebooter"_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX_INSTALLER, 0); + } + if ( targetVolume ) { + if ( (targetVolume->ApfsRole & APPLE_APFS_VOLUME_ROLE_DATA) != 0 ) { + for (UINTN VolumeIndex2 = 0; VolumeIndex2 < Volumes.size(); VolumeIndex2++) { + REFIT_VOLUME* Volume2 = &Volumes[VolumeIndex2]; + //DBG("name %ls uuid=%ls \n", Volume2->VolName, Volume2->ApfsFileSystemUUID.wc_str()); + if ( Volume2->ApfsContainerUUID == targetVolume->ApfsContainerUUID ) { + if ( (Volume2->ApfsRole & APPLE_APFS_VOLUME_ROLE_SYSTEM) != 0 ) { + targetVolume = Volume2; + } + } + } } } + if ( FullTitle.isEmpty() ) { + if ( targetVolume ) { + FullTitle.SWPrintf("Boot Mac OS X from %ls via %ls", targetVolume->getVolLabelOrOSXVolumeNameOrVolName().wc_str(), Volume->getVolLabelOrOSXVolumeNameOrVolName().wc_str()); + FullTitleRecovery.SWPrintf("Boot Mac OS X Recovery for %ls via %ls", targetVolume->getVolLabelOrOSXVolumeNameOrVolName().wc_str(), Volume->getVolLabelOrOSXVolumeNameOrVolName().wc_str()); + FullTitleInstaller.SWPrintf("Boot Mac OS X Install for %ls via %ls", targetVolume->getVolLabelOrOSXVolumeNameOrVolName().wc_str(), Volume->getVolLabelOrOSXVolumeNameOrVolName().wc_str()); + }else{ + FullTitle.SWPrintf("Boot Mac OS X via %ls", Volume->getVolLabelOrOSXVolumeNameOrVolName().wc_str()); + FullTitleRecovery.SWPrintf("Boot Mac OS X Recovery via %ls", Volume->getVolLabelOrOSXVolumeNameOrVolName().wc_str()); + FullTitleInstaller.SWPrintf("Mac OS X Install via %ls", Volume->getVolLabelOrOSXVolumeNameOrVolName().wc_str()); + } + } + AddLoaderEntry(SWPrintf("\\%s\\System\\Library\\CoreServices\\boot.efi", ApfsTargetUUID.c_str()), NullXString8Array, FullTitle, LoaderTitle, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX, 0); + //Try to add Recovery APFS entry + AddLoaderEntry(SWPrintf("\\%s\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, FullTitleRecovery, L""_XSW, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_RECOVERY, 0); + //Try to add macOS install entry + AddLoaderEntry(SWPrintf("\\%s\\com.apple.installer\\boot.efi", Volume->ApfsTargetUUIDArray[i].c_str()), NullXString8Array, FullTitleInstaller, LoaderTitleInstaller, Volume, Volume->ApfsTargetUUIDArray[i], NULL, OSTYPE_OSX_INSTALLER, 0); } } } + // Hide redundant preboot partition for (size_t entryIdx1 = 0; entryIdx1 < MainMenu.Entries.sizeIncludingHidden(); entryIdx1++) { - LOADER_ENTRY* loaderEntry1Ptr = MainMenu.Entries.ElementAt(entryIdx1).getLOADER_ENTRY(); - if ( !loaderEntry1Ptr ) continue; - LOADER_ENTRY& loaderEntry1 = *loaderEntry1Ptr; + LOADER_ENTRY* loaderEntry1Ptr = MainMenu.Entries.ElementAt(entryIdx1).getLOADER_ENTRY(); + if ( !loaderEntry1Ptr ) continue; + LOADER_ENTRY& loaderEntry1 = *loaderEntry1Ptr; - if ( loaderEntry1.LoaderType == OSTYPE_OSX && loaderEntry1.APFSTargetUUID.notEmpty() ) + if ( loaderEntry1.LoaderType == OSTYPE_OSX && loaderEntry1.APFSTargetUUID.notEmpty() ) + { + for ( size_t entryIdx2 = 0 ; entryIdx2 < MainMenu.Entries.sizeIncludingHidden() ; entryIdx2 ++ ) { - for ( size_t entryIdx2 = 0 ; entryIdx2 < MainMenu.Entries.sizeIncludingHidden() ; entryIdx2 ++ ) - { - if ( MainMenu.Entries.ElementAt(entryIdx2).getLOADER_ENTRY() ) { - LOADER_ENTRY& loaderEntry2 = *MainMenu.Entries.ElementAt(entryIdx2).getLOADER_ENTRY(); + if ( MainMenu.Entries.ElementAt(entryIdx2).getLOADER_ENTRY() ) { + LOADER_ENTRY& loaderEntry2 = *MainMenu.Entries.ElementAt(entryIdx2).getLOADER_ENTRY(); + if ( loaderEntry2.Volume->ApfsContainerUUID == loaderEntry1.Volume->ApfsContainerUUID ) { if ( loaderEntry2.Volume->ApfsFileSystemUUID == loaderEntry1.APFSTargetUUID ) { loaderEntry1.Hidden = true; } } } } + } } + bool hasMovedSomething; + // Re-order preboot partition + do { + hasMovedSomething = false; + for (size_t prebootIdx = 0; !hasMovedSomething && prebootIdx < MainMenu.Entries.sizeIncludingHidden(); prebootIdx++) + { + LOADER_ENTRY* loaderEntry1Ptr = MainMenu.Entries.ElementAt(prebootIdx).getLOADER_ENTRY(); + if ( !loaderEntry1Ptr ) continue; + LOADER_ENTRY& loaderEntry1 = *loaderEntry1Ptr; + + if ( (loaderEntry1.Volume->ApfsRole & APPLE_APFS_VOLUME_ROLE_PREBOOT) != 0 ) + { + size_t idxMain = MainMenu.Entries.getApfsLoaderIdx(loaderEntry1.Volume->ApfsContainerUUID, loaderEntry1.APFSTargetUUID); + if ( idxMain != SIZE_T_MAX && idxMain != prebootIdx+1 ) { + DBG("Move preboot entry %zu before system %zu\n", prebootIdx, idxMain); + MainMenu.Entries.moveBefore(prebootIdx, idxMain); // this will move preboot entry just before main + hasMovedSomething = true; + } + } + } + } while ( hasMovedSomething ); + + // Re-order recovery partition + do { + hasMovedSomething = false; + for (size_t recoveryIdx = 0; !hasMovedSomething && recoveryIdx < MainMenu.Entries.sizeIncludingHidden(); recoveryIdx++) + { + LOADER_ENTRY* loaderEntry1Ptr = MainMenu.Entries.ElementAt(recoveryIdx).getLOADER_ENTRY(); + if ( !loaderEntry1Ptr ) continue; + LOADER_ENTRY& loaderEntry1 = *loaderEntry1Ptr; + + if ( (loaderEntry1.Volume->ApfsRole & APPLE_APFS_VOLUME_ROLE_RECOVERY) != 0 ) + { + size_t idxMain = MainMenu.Entries.getApfsLoaderIdx(loaderEntry1.Volume->ApfsContainerUUID, loaderEntry1.APFSTargetUUID); + if ( idxMain != SIZE_T_MAX ) { + if ( idxMain + 1 != recoveryIdx ) { + DBG("Move recovery entry %zu after system %zu\n", recoveryIdx, idxMain); + MainMenu.Entries.moveAfter(recoveryIdx, idxMain); // this will move preboot entry just before main + hasMovedSomething = true; + } + }else{ + size_t idxPreboot = MainMenu.Entries.getApfsPrebootLoaderIdx(loaderEntry1.Volume->ApfsContainerUUID, loaderEntry1.APFSTargetUUID); + if ( idxPreboot + 1 != recoveryIdx ) { + DBG("Move recovery entry %zu after preboot %zu\n", recoveryIdx, idxPreboot); + MainMenu.Entries.moveAfter(recoveryIdx, idxPreboot); // this will move preboot entry just before main + hasMovedSomething = true; + } + } + } + } + } while ( hasMovedSomething ); } STATIC void AddCustomEntry(IN UINTN CustomIndex, diff --git a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h index 8fc2f057f..71aa1f55e 100644 --- a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h +++ b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h @@ -123,6 +123,70 @@ public: } panic("EntryArray::operator[] nIndex > size()"); } + + size_t getApfsLoaderIdx(const XString8& ApfsContainerUUID, const XString8& ApfsFileSystemUUID) + { + for ( size_t i=0 ; i < XObjArray::size() ; i++ ) { + if ( XObjArray::ElementAt(i).getLOADER_ENTRY() ) { + if ( XObjArray::ElementAt(i).getLOADER_ENTRY()->Volume->ApfsContainerUUID == ApfsContainerUUID ) { + if ( XObjArray::ElementAt(i).getLOADER_ENTRY()->Volume->ApfsFileSystemUUID == ApfsFileSystemUUID ) { + return i; + } + } + } + } + return SIZE_T_MAX; + } + + size_t getApfsPrebootLoaderIdx(const XString8& ApfsContainerUUID, const XString8& ApfsFileSystemUUID) + { + for ( size_t i=0 ; i < XObjArray::size() ; i++ ) { + if ( XObjArray::ElementAt(i).getLOADER_ENTRY() ) { + if ( (XObjArray::ElementAt(i).getLOADER_ENTRY()->Volume->ApfsRole & APPLE_APFS_VOLUME_ROLE_PREBOOT) != 0 ) { + if ( XObjArray::ElementAt(i).getLOADER_ENTRY()->Volume->ApfsContainerUUID == ApfsContainerUUID ) { + if ( XObjArray::ElementAt(i).getLOADER_ENTRY()->APFSTargetUUID == ApfsFileSystemUUID ) { + return i; + } + } + } + } + } + return SIZE_T_MAX; + } + + template + void moveBefore(IntegralType1 idxFrom, IntegralType2 idxTo) + { + if (idxFrom < 0) panic("EntryArray::move(IntegralType1, IntegralType2) : idxFrom < 0. System halted\n"); + if (idxFrom > XObjArray::size()) panic("EntryArray::move(IntegralType1, IntegralType2) : idxFrom > size(). System halted\n"); + if (idxTo < 0) panic("EntryArray::move(IntegralType1, IntegralType2) : idxTo < 0. System halted\n"); + if (idxTo > XObjArray::size()) panic("EntryArray::move(IntegralType1, IntegralType2) : idxTo > size(). System halted\n"); + + REFIT_ABSTRACT_MENU_ENTRY* entry = &ElementAt(idxFrom); + RemoveWithoutFreeingAtIndex(idxFrom); + if ( idxTo > idxFrom ) { + InsertRef(entry, idxTo-1, true); + }else{ + InsertRef(entry, idxTo, true); + } + } + + template + void moveAfter(IntegralType1 idxFrom, IntegralType2 idxTo) + { + if (idxFrom < 0) panic("EntryArray::move(IntegralType1, IntegralType2) : idxFrom < 0. System halted\n"); + if (idxFrom > XObjArray::size()) panic("EntryArray::move(IntegralType1, IntegralType2) : idxFrom > size(). System halted\n"); + if (idxTo < 0) panic("EntryArray::move(IntegralType1, IntegralType2) : idxTo < 0. System halted\n"); + if (idxTo > XObjArray::size()) panic("EntryArray::move(IntegralType1, IntegralType2) : idxTo > size(). System halted\n"); + + REFIT_ABSTRACT_MENU_ENTRY* entry = &ElementAt(idxFrom); + RemoveWithoutFreeingAtIndex(idxFrom); + if ( idxTo > idxFrom ) { + InsertRef(entry, idxTo, true); + }else{ + InsertRef(entry, idxTo+1, true); + } + } }; class REFIT_MENU_SCREEN diff --git a/rEFIt_UEFI/include/OC.h b/rEFIt_UEFI/include/OC.h new file mode 100644 index 000000000..379ec22d3 --- /dev/null +++ b/rEFIt_UEFI/include/OC.h @@ -0,0 +1,129 @@ +/* + * OC.h + * + * Created on: Oct 21, 2020 + * Author: jief + */ + +#ifndef INCLUDE_OC_H_ +#define INCLUDE_OC_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + +//#include "../../OpenCorePkg/Include/Acidanthera/OpenCore.h" + +#include +#include +#include +#include +#include +//#include // OC_CPU_INFO +//#include // OC_BOOTSTRAP_PROTOCOL + +#include + +extern OC_GLOBAL_CONFIG mOpenCoreConfiguration; +extern OC_STORAGE_CONTEXT mOpenCoreStorage; +//extern OC_CPU_INFO mOpenCoreCpuInfo; +//extern OC_BOOTSTRAP_PROTOCOL mOpenCoreBootStrap; +//extern OC_RSA_PUBLIC_KEY* mOpenCoreVaultKey; +//extern EFI_HANDLE mLoadHandle; + +EFI_STATUS +EFIAPI +OcStartImage_2 ( + IN OC_BOOT_ENTRY *Chosen, + IN EFI_HANDLE ImageHandle, + OUT UINTN *ExitDataSize, + OUT CHAR16 **ExitData OPTIONAL + ); + +EFI_STATUS +EFIAPI +OcKernelFileOpen ( + IN EFI_FILE_PROTOCOL *This, + OUT EFI_FILE_PROTOCOL **NewHandle, + IN CHAR16 *FileName, + IN UINT64 OpenMode, + IN UINT64 Attributes + ); + +EFI_STATUS +EFIAPI +InternalEfiLoadImage ( + IN BOOLEAN BootPolicy, + IN EFI_HANDLE ParentImageHandle, + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN void *SourceBuffer OPTIONAL, + IN UINTN SourceSize, + OUT EFI_HANDLE *ImageHandle + ); + +EFI_STATUS +EFIAPI +OcStartImage ( + IN EFI_HANDLE ImageHandle, + OUT UINTN *ExitDataSize, + OUT CHAR16 **ExitData OPTIONAL + ); + +void +OcLoadBooterUefiSupport ( + IN OC_GLOBAL_CONFIG *Config + ); + +UINT64 +InternalCalculateARTFrequencyIntel ( + OUT UINT64 *CPUFrequency, + OUT UINT64 *TscAdjustPtr OPTIONAL, + IN BOOLEAN Recalculate + ); + +EFI_STATUS +ClOcReadConfigurationFile( + IN OC_STORAGE_CONTEXT *Storage, + IN CONST CHAR16* configPath, + OUT OC_GLOBAL_CONFIG *Config + ); + +EFI_STATUS +InternalGetApfsSpecialFileInfo ( + IN EFI_FILE_PROTOCOL *Root, + IN OUT APPLE_APFS_VOLUME_INFO **VolumeInfo OPTIONAL, + IN OUT APPLE_APFS_CONTAINER_INFO **ContainerInfo OPTIONAL + ); + +void +OcMain ( + IN OC_STORAGE_CONTEXT *Storage, + IN EFI_DEVICE_PATH_PROTOCOL *LoadPath OPTIONAL + ); + + +#ifdef __cplusplus +} // extern "C" +#endif + +#define OC_STRING_ASSIGN_N(ocString, value, len) do { \ + if( len >= sizeof(ocString.Value) ) { \ + memset(ocString.Value, 0, sizeof(ocString.Value)); \ + ocString.DynValue = (__typeof__(ocString.DynValue))malloc(len); \ + memcpy(ocString.DynValue, value, len); \ + ocString.MaxSize = (UINT32)len; \ + ocString.Size = (UINT32)len; /* unsafe cast */ \ + }else{ \ + ocString.DynValue = NULL; \ + memcpy(ocString.Value, value, len); \ + ocString.MaxSize = sizeof(ocString.Value); \ + ocString.Size = (UINT32)len; /* unsafe cast */ \ + } \ +} while (0) + +#define OC_STRING_ASSIGN(ocString, value) OC_STRING_ASSIGN_N(ocString, value, strlen(value)+1) + + + +#endif /* INCLUDE_OC_H_ */ diff --git a/rEFIt_UEFI/libeg/libeg.h b/rEFIt_UEFI/libeg/libeg.h index ab956b891..7b48d866d 100755 --- a/rEFIt_UEFI/libeg/libeg.h +++ b/rEFIt_UEFI/libeg/libeg.h @@ -45,6 +45,7 @@ extern "C" { #include +#include } /* types */ @@ -164,8 +165,8 @@ public: EFI_HANDLE DeviceHandle; EFI_FILE *RootDir; XStringW DevicePathString; - XStringW VolName; - XStringW VolLabel; + XStringW VolName; // comes from EfiLibFileSystemInfo, EfiLibFileSystemVolumeLabelInfo, "EFI" if gEfiPartTypeSystemPartGuid or "Unknown HD" + XStringW VolLabel; // comes from \\.VolumeLabel.txt, or empty. UINT8 DiskKind; LEGACY_OS *LegacyOS; BOOLEAN Hidden; @@ -183,7 +184,10 @@ public: UINT32 DriveCRC32; EFI_GUID RootUUID; //for recovery it is UUID of parent partition UINT64 SleepImageOffset; + XStringW osxVolumeName = NullXStringW; // comes from \\System\\Library\\CoreServices\\.disk_label.contentDetails, or empty. XString8 ApfsFileSystemUUID; // apfs file system UUID of that partition. It's not the UUID of subfolder like in Preboot. + XString8 ApfsContainerUUID = NullXString8; + APPLE_APFS_VOLUME_ROLE ApfsRole = 0; XString8Array ApfsTargetUUIDArray; // this is the array of folders that are named as UUID REFIT_VOLUME() : DevicePath(0), DeviceHandle(0), RootDir(0), DevicePathString(), VolName(), VolLabel(), DiskKind(0), LegacyOS(0), Hidden(0), BootType(0), IsAppleLegacy(0), HasBootCode(0), @@ -194,6 +198,11 @@ public: const REFIT_VOLUME& operator = ( const REFIT_VOLUME & ) = delete; // Can be defined if needed ~REFIT_VOLUME() {} + const XStringW getVolLabelOrOSXVolumeNameOrVolName() { + if ( VolLabel.notEmpty() ) return VolLabel; + if ( osxVolumeName.notEmpty() ) return osxVolumeName; + return VolName; + } }; class KEXT_PATCH diff --git a/rEFIt_UEFI/refit.inf b/rEFIt_UEFI/refit.inf index eba5d2054..e9070b93f 100644 --- a/rEFIt_UEFI/refit.inf +++ b/rEFIt_UEFI/refit.inf @@ -365,6 +365,7 @@ OpenCoreLib #OcDebugLogLib OcDebugLogLibOc2Clover + OcAppleBootPolicyLib [Guids] gEfiAcpiTableGuid diff --git a/rEFIt_UEFI/refit/lib.cpp b/rEFIt_UEFI/refit/lib.cpp index 6dc25e1aa..bbbd19ca4 100644 --- a/rEFIt_UEFI/refit/lib.cpp +++ b/rEFIt_UEFI/refit/lib.cpp @@ -35,6 +35,7 @@ */ #include // Only use angled for Platform, else, xcode project won't compile +#include "lib.h" #include "screen.h" #include "../Platform/guid.h" #include "../Platform/APFS.h" @@ -42,6 +43,7 @@ #include "../Platform/Settings.h" #include "Self.h" #include "SelfOem.h" +#include "../include/OC.h" #ifndef DEBUG_ALL #define DEBUG_LIB 1 @@ -69,7 +71,12 @@ BOOLEAN gThemeOptionsChanged = FALSE; REFIT_VOLUME *SelfVolume = NULL; //REFIT_VOLUME **Volumes = NULL; //UINTN VolumesCount = 0; -XObjArray Volumes; +VolumesArrayClass Volumes; + +//REFIT_VOLUME* VolumesArrayClass::getApfsPartitionWithUUID(const XString8& ApfsContainerUUID, const XString8& APFSTargetUUID) +//{ +//} + // // Unicode collation protocol interface // @@ -561,6 +568,25 @@ static void ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl FreeAlignedPages((void*)SectorBuffer, EFI_SIZE_TO_PAGES (2048)); } +//Set Entry->VolName to .disk_label.contentDetails if it exists +STATIC XStringW GetOSXVolumeName(REFIT_VOLUME *Volume) +{ + XStringW returnValue; + EFI_STATUS Status = EFI_NOT_FOUND; + CONST CHAR16* targetNameFile = L"\\System\\Library\\CoreServices\\.disk_label.contentDetails"; + CHAR8* fileBuffer; + UINTN fileLen = 0; + if(FileExists(Volume->RootDir, targetNameFile)) { + Status = egLoadFile(Volume->RootDir, targetNameFile, (UINT8 **)&fileBuffer, &fileLen); + if(!EFI_ERROR(Status)) { + returnValue.strncpy(fileBuffer, fileLen); + FreePool(fileBuffer); + return returnValue; + } + } + return NullXStringW; +} + //at start we have only Volume->DeviceHandle static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume) { @@ -592,9 +618,6 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume) // DumpHex(1, 0, GetDevicePathSize(Volume->DevicePath), Volume->DevicePath); //#endif } - if ( Volume->ApfsFileSystemUUID.notEmpty() ) { - DBG(" apfsFileSystemUUID=%s\n", Volume->ApfsFileSystemUUID.c_str()); - } #else DBG("\n"); #endif @@ -794,6 +817,27 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume) return EFI_SUCCESS; } + if ( Volume->ApfsFileSystemUUID.notEmpty() ) { + APPLE_APFS_CONTAINER_INFO *ApfsContainerInfo; + APPLE_APFS_VOLUME_INFO *ApfsVolumeInfo; + EFI_STATUS Status = InternalGetApfsSpecialFileInfo(Volume->RootDir, &ApfsVolumeInfo, &ApfsContainerInfo); + if ( !EFI_ERROR(Status) ) { + //DBG("Status : %s, APFS role : %x\n", efiStrError(Status), ApfsVolumeInfo->Role); + Volume->ApfsRole = ApfsVolumeInfo->Role; + Volume->ApfsContainerUUID = GuidLEToXString8(ApfsContainerInfo->Uuid); + }else{ + MsgLog("Status : %s, APFS role : %x\n", efiStrError(Status), ApfsVolumeInfo->Role); + } + } + if ( Volume->ApfsFileSystemUUID.notEmpty() ) { + DBG(" apfsFileSystemUUID=%s, ApfsContainerUUID=%s, ApfsRole=0x%x\n", Volume->ApfsFileSystemUUID.c_str(), Volume->ApfsContainerUUID.c_str(), Volume->ApfsRole); + } + + + Volume->osxVolumeName = GetOSXVolumeName(Volume); + DBG(" osxVolumeName=%ls\n", Volume->osxVolumeName.wc_str()); + + if ( FileExists(Volume->RootDir, L"\\.VolumeLabel.txt") ) { EFI_FILE* FileHandle; Status = Volume->RootDir->Open(Volume->RootDir, &FileHandle, L"\\.VolumeLabel.txt", EFI_FILE_MODE_READ, 0); @@ -838,7 +882,7 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume) { void *Instance; if (!EFI_ERROR(gBS->HandleProtocol(Volume->DeviceHandle, &gEfiPartTypeSystemPartGuid, &Instance))) { - Volume->VolName = L"EFI"_XSW; \ + Volume->VolName = L"EFI"_XSW; } } if (Volume->VolName.isEmpty()) { @@ -873,6 +917,8 @@ static EFI_STATUS ScanVolume(IN OUT REFIT_VOLUME *Volume) } DirIterClose(&DirIter); } + + DBG(" label : %ls\n", Volume->getVolLabelOrOSXVolumeNameOrVolName().wc_str()); //Status = GetOSVersion(Volume); NOTE: Sothor - We will find icon names later once we have found boot.efi on the volume //here we set Volume->IconName (tiger,leo,snow,lion,cougar, etc) diff --git a/rEFIt_UEFI/refit/lib.h b/rEFIt_UEFI/refit/lib.h index be221503a..dcad33d61 100644 --- a/rEFIt_UEFI/refit/lib.h +++ b/rEFIt_UEFI/refit/lib.h @@ -69,15 +69,6 @@ extern XTheme ThemeX; //global variable defined in lib.cpp #define REFIT_DEBUG (2) -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef __cplusplus -} -#endif - // // lib module // @@ -298,9 +289,19 @@ typedef enum { #define SCREEN_EDGE_BOTTOM 80000 extern REFIT_VOLUME *SelfVolume; + #ifdef __cplusplus -extern XObjArray Volumes; +class VolumesArrayClass : public XObjArray +{ + public: +// REFIT_VOLUME* getApfsPartitionWithUUID(const XString8& ApfsContainerUUID, const XString8& APFSTargetUUID); + +}; + +extern VolumesArrayClass Volumes; + #endif + //extern UINTN VolumesCount; extern BOOLEAN gThemeChanged; @@ -469,10 +470,6 @@ void DebugPause(void); -#ifdef _cplusplus -extern XObjArray Volumes; -#endif - // // BmLib diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 5cc623168..22fa1d3d1 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -75,9 +75,8 @@ #include "SelfOem.h" #include "../Platform/Net.h" -extern "C" { -#include "../../OpenCorePkg/Include/Acidanthera/OpenCore.h" -} +#include "../include/OC.h" + #ifndef DEBUG_ALL #define DEBUG_MAIN 1 @@ -572,103 +571,6 @@ void CheckEmptyFB() } } -extern "C" { -#include -#include -#include -#include -#include - -extern OC_GLOBAL_CONFIG mOpenCoreConfiguration; -extern OC_STORAGE_CONTEXT mOpenCoreStorage; -extern OC_CPU_INFO mOpenCoreCpuInfo; -extern OC_BOOTSTRAP_PROTOCOL mOpenCoreBootStrap; -extern OC_RSA_PUBLIC_KEY* mOpenCoreVaultKey; -extern EFI_HANDLE mLoadHandle; - -EFI_STATUS -EFIAPI -OcStartImage_2 ( - IN OC_BOOT_ENTRY *Chosen, - IN EFI_HANDLE ImageHandle, - OUT UINTN *ExitDataSize, - OUT CHAR16 **ExitData OPTIONAL - ); - -EFI_STATUS -EFIAPI -OcKernelFileOpen ( - IN EFI_FILE_PROTOCOL *This, - OUT EFI_FILE_PROTOCOL **NewHandle, - IN CHAR16 *FileName, - IN UINT64 OpenMode, - IN UINT64 Attributes - ); - -EFI_STATUS -EFIAPI -InternalEfiLoadImage ( - IN BOOLEAN BootPolicy, - IN EFI_HANDLE ParentImageHandle, - IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN void *SourceBuffer OPTIONAL, - IN UINTN SourceSize, - OUT EFI_HANDLE *ImageHandle - ); - -EFI_STATUS -EFIAPI -OcStartImage ( - IN EFI_HANDLE ImageHandle, - OUT UINTN *ExitDataSize, - OUT CHAR16 **ExitData OPTIONAL - ); - -void -OcLoadBooterUefiSupport ( - IN OC_GLOBAL_CONFIG *Config - ); - -UINT64 -InternalCalculateARTFrequencyIntel ( - OUT UINT64 *CPUFrequency, - OUT UINT64 *TscAdjustPtr OPTIONAL, - IN BOOLEAN Recalculate - ); - -EFI_STATUS -ClOcReadConfigurationFile( - IN OC_STORAGE_CONTEXT *Storage, - IN CONST CHAR16* configPath, - OUT OC_GLOBAL_CONFIG *Config - ); - -void -OcMain ( - IN OC_STORAGE_CONTEXT *Storage, - IN EFI_DEVICE_PATH_PROTOCOL *LoadPath OPTIONAL - ); - -} // extern "C" - -#define OC_STRING_ASSIGN_N(ocString, value, len) do { \ - if( len >= sizeof(ocString.Value) ) { \ - memset(ocString.Value, 0, sizeof(ocString.Value)); \ - ocString.DynValue = (__typeof__(ocString.DynValue))malloc(len); \ - memcpy(ocString.DynValue, value, len); \ - ocString.MaxSize = (UINT32)len; \ - ocString.Size = (UINT32)len; /* unsafe cast */ \ - }else{ \ - ocString.DynValue = NULL; \ - memcpy(ocString.Value, value, len); \ - ocString.MaxSize = sizeof(ocString.Value); \ - ocString.Size = (UINT32)len; /* unsafe cast */ \ - } \ -} while (0) - -#define OC_STRING_ASSIGN(ocString, value) OC_STRING_ASSIGN_N(ocString, value, strlen(value)+1) - - size_t setKextAtPos(XObjArray* kextArrayPtr, const XString8& kextName, size_t pos) { XObjArray& kextArray = *kextArrayPtr; @@ -829,6 +731,8 @@ void LOADER_ENTRY::StartLoader() DbgHeader("StartLoader"); + DBG("Starting %ls\n", FileDevicePathToXStringW(DevicePath).wc_str()); + if (Settings.notEmpty()) { DBG(" Settings: %ls\n", Settings.wc_str()); TagDict* dict; @@ -1125,7 +1029,8 @@ DBG("Beginning OC\n"); BOOLEAN NoContents = FALSE; XStringW infoPlistPath = getKextPlist(dirPath, KextEntry, &NoContents); //it will be fullPath, including dir TagDict* dict = getInfoPlist(infoPlistPath); - BOOLEAN inject = checkOSBundleRequired(dict); +// BOOLEAN inject = checkOSBundleRequired(dict); + BOOLEAN inject = true; if (inject) { if ( infoPlistPath.notEmpty()) { if (NoContents) {