diff --git a/Clover.dsc b/Clover.dsc index 1cfb02058..3bcc20952 100644 --- a/Clover.dsc +++ b/Clover.dsc @@ -148,12 +148,14 @@ !ifdef DEBUG_ON_SERIAL_PORT BaseSerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf !else BaseSerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf !endif BaseDebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf - DebugLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf + #DebugLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf @@ -185,7 +187,6 @@ OcConsoleLib|OpenCorePkg/Library/OcConsoleLib/OcConsoleLib.inf OcCpuLib|OpenCorePkg/Library/OcCpuLib/OcCpuLib.inf OcCryptoLib|OpenCorePkg/Library/OcCryptoLib/OcCryptoLib.inf - OcDebugLogLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf OcDevicePathLib|OpenCorePkg/Library/OcDevicePathLib/OcDevicePathLib.inf OcFileLib|OpenCorePkg/Library/OcFileLib/OcFileLib.inf OcMemoryLib|OpenCorePkg/Library/OcMemoryLib/OcMemoryLib.inf @@ -199,7 +200,6 @@ OcTemplateLib|OpenCorePkg/Library/OcTemplateLib/OcTemplateLib.inf OcXmlLib|OpenCorePkg/Library/OcXmlLib/OcXmlLib.inf OcDeviceTreeLib|OpenCorePkg/Library/OcDeviceTreeLib/OcDeviceTreeLib.inf - OcDebugLogLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf OcDataHubLib|OpenCorePkg/Library/OcDataHubLib/OcDataHubLib.inf OcAppleImg4Lib|OpenCorePkg/Library/OcAppleImg4Lib/OcAppleImg4Lib.inf OcAppleKernelLib|OpenCorePkg/Library/OcAppleKernelLib/OcAppleKernelLib.inf @@ -210,7 +210,7 @@ OcAppleSecureBootLib|OpenCorePkg/Library/OcAppleSecureBootLib/OcAppleSecureBootLib.inf OcAppleImageVerificationLib|OpenCorePkg/Library/OcAppleImageVerificationLib/OcAppleImageVerificationLib.inf OcDriverConnectionLib|OpenCorePkg/Library/OcDriverConnectionLib/OcDriverConnectionLib.inf - OcDebugLogLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf + #OcDebugLogLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf OcAcpiLib|OpenCorePkg/Library/OcAcpiLib/OcAcpiLib.inf OcAppleEventLib|OpenCorePkg/Library/OcAppleEventLib/OcAppleEventLib.inf #OcAppleImageConversionLib|OpenCorePkg/Library/OcAppleImageConversionLib/OcAppleImageConversionLib.inf @@ -228,6 +228,7 @@ #OcPngLib|OpenCorePkg/Library/OcPngLib/OcPngLib.inf OpenCoreLib|OpenCorePkg/Platform/OpenCore/OpenCoreLib.inf + OcDebugLogLibOc2Clover|OpenCorePkg/Library/OcDebugLogLibOc2Clover/OcDebugLogLibOc2Clover.inf #MachoLib|Library/MachoLib/MachoLib.inf @@ -282,6 +283,216 @@ # ################################################################################################### [Components] + + OpenCorePkg/Platform/OpenCore/OpenCoreLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcGuardLib/OcGuardLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAfterBootCompatLib/OcAfterBootCompatLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleBootPolicyLib/OcAppleBootPolicyLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleChunklistLib/OcAppleChunklistLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleDiskImageLib/OcAppleDiskImageLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleKeyMapLib/OcAppleKeyMapLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleKeysLib/OcAppleKeysLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleRamDiskLib/OcAppleRamDiskLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcBootManagementLib/OcBootManagementLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcCompressionLib/OcCompressionLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcConsoleLib/OcConsoleLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcCpuLib/OcCpuLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcCryptoLib/OcCryptoLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcDevicePathLib/OcDevicePathLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcFileLib/OcFileLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcMemoryLib/OcMemoryLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcMiscLib/OcMiscLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcOSInfoLib/OcOSInfoLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcRngLib/OcRngLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcRtcLib/OcRtcLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcSerializeLib/OcSerializeLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcStringLib/OcStringLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcStorageLib/OcStorageLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcTemplateLib/OcTemplateLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcXmlLib/OcXmlLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcDeviceTreeLib/OcDeviceTreeLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcDataHubLib/OcDataHubLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleImg4Lib/OcAppleImg4Lib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleKernelLib/OcAppleKernelLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcMachoLib/OcMachoLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcVirtualFsLib/OcVirtualFsLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcMacInfoLib/OcMacInfoLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcApfsLib/OcApfsLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleSecureBootLib/OcAppleSecureBootLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleImageVerificationLib/OcAppleImageVerificationLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcDriverConnectionLib/OcDriverConnectionLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + #OcDebugLogLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf + OpenCorePkg/Library/OcAcpiLib/OcAcpiLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleEventLib/OcAppleEventLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + #OcAppleImageConversionLib|OpenCorePkg/Library/OcAppleImageConversionLib/OcAppleImageConversionLib.inf + OpenCorePkg/Library/OcAudioLib/OcAudioLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcInputLib/OcInputLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcAppleUserInterfaceThemeLib/OcAppleUserInterfaceThemeLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcConfigurationLib/OcConfigurationLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcDevicePropertyLib/OcDevicePropertyLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcFirmwareVolumeLib/OcFirmwareVolumeLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcHashServicesLib/OcHashServicesLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcSmbiosLib/OcSmbiosLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcSmcLib/OcSmcLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + OpenCorePkg/Library/OcPeCoffLib/OcPeCoffLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + #OcPngLib|OpenCorePkg/Library/OcPngLib/OcPngLib.inf + OpenCorePkg/Platform/OpenCore/OpenCoreLib.inf { + + *_*_*_CC_FLAGS = -include OpenCoreFromClover.h + } + + #DuetPkg/BootSector/BootSector.inf #DuetPkg/DxeIpl/DxeIpl.inf { @@ -552,8 +763,7 @@ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x07 gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0xFFFFFFFF - DebugLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf - #DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf } @@ -641,8 +851,7 @@ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0xFFFFFFFF SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf - DebugLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf - #DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf } !else @@ -671,8 +880,7 @@ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0xFFFFFFFF SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf - DebugLib|OpenCorePkg/Library/OcDebugLogLib/OcDebugLogLib.inf - #DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf } !else @@ -748,7 +956,7 @@ DEFINE EXIT_USBKB_FLAG = -DEXIT_USBKB !endif -DEFINE BUILD_OPTIONS=-DCLOVER_BUILD $(VBIOS_PATCH_CLOVEREFI_FLAG) $(ONLY_SATA_0_FLAG) $(BLOCKIO_FLAG) $(NOUSB_FLAG) $(NOUDMA_FLAG) $(AMD_FLAG) $(SECURE_BOOT_FLAG) $(ANDX86_FLAG) $(PS2MOUSE_LEGACYBOOT_FLAG) $(DEBUG_ON_SERIAL_PORT_FLAG) $(EXIT_USBKB_FLAG) +DEFINE BUILD_OPTIONS=-DMDEPKG_NDEBUG -DCLOVER_BUILD $(VBIOS_PATCH_CLOVEREFI_FLAG) $(ONLY_SATA_0_FLAG) $(BLOCKIO_FLAG) $(NOUSB_FLAG) $(NOUDMA_FLAG) $(AMD_FLAG) $(SECURE_BOOT_FLAG) $(ANDX86_FLAG) $(PS2MOUSE_LEGACYBOOT_FLAG) $(DEBUG_ON_SERIAL_PORT_FLAG) $(EXIT_USBKB_FLAG) #MSFT:*_*_*_CC_FLAGS = /FAcs /FR$(@R).SBR /wd4701 /wd4703 $(BUILD_OPTIONS) MSFT:*_*_*_CC_FLAGS = /FAcs $(BUILD_OPTIONS) -Dinline=__inline /Zi -D DISABLE_NEW_DEPRECATED_INTERFACES -D OC_TARGET_DEBUG diff --git a/CloverPkg.dec b/CloverPkg.dec index 7315ced43..e62b7b53b 100644 --- a/CloverPkg.dec +++ b/CloverPkg.dec @@ -194,6 +194,9 @@ ## Include/Protocol/OcAudio.h gOcAudioProtocolGuid = {0x4B228577, 0x6274, 0x4A48, {0x82, 0xAE, 0x07, 0x13, 0xA1, 0x17, 0x19, 0x87}} + gEfiDataHubProtocolGuid = { 0xAE80D021, 0x618E, 0x11D4, { 0xBC, 0xD7, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }} + gEfiProcessorSubClassGuid = { 0x26fdeb7e, 0xb8af, 0x4ccf, { 0xaa, 0x97, 0x02, 0x63, 0x3c, 0xe4, 0x8c, 0xa7 }} + diff --git a/MemoryFix/OsxLowMemFixDrv/OsxLowMemFixDrv.inf b/MemoryFix/OsxLowMemFixDrv/OsxLowMemFixDrv.inf index f1ce7fc48..47d8d3dd0 100644 --- a/MemoryFix/OsxLowMemFixDrv/OsxLowMemFixDrv.inf +++ b/MemoryFix/OsxLowMemFixDrv/OsxLowMemFixDrv.inf @@ -58,6 +58,8 @@ gEfiDiskIoProtocolGuid gEfiDiskIo2ProtocolGuid gEfiGraphicsOutputProtocolGuid + gEfiDataHubProtocolGuid ## PRODUCES + gEfiProcessorSubClassGuid [Depex] diff --git a/OpenCorePkg b/OpenCorePkg index d17192301..bc0b403c6 160000 --- a/OpenCorePkg +++ b/OpenCorePkg @@ -1 +1 @@ -Subproject commit d17192301a02083188e358cec281a072729a1d5e +Subproject commit bc0b403c614504c083c28c89f6a85494d5b492fd diff --git a/Protocols/DataHubDxe/DataHubDxe.inf b/Protocols/DataHubDxe/DataHubDxe.inf index 67d7ea759..338a114bc 100644 --- a/Protocols/DataHubDxe/DataHubDxe.inf +++ b/Protocols/DataHubDxe/DataHubDxe.inf @@ -67,7 +67,7 @@ BaseLib UefiLib UefiDriverEntryPoint - #OcDataHubLib + OcDataHubLib [Protocols] diff --git a/Qemu/launch_from_eclipse b/Qemu/launch_from_eclipse index efae0c145..a0e8d447c 100755 --- a/Qemu/launch_from_eclipse +++ b/Qemu/launch_from_eclipse @@ -39,6 +39,11 @@ then fi > ./serial0_qemu_out.log # empty file without erasing it. Useful for editor for refreshing and reloading. + if ! [ -f "$SCRIPT_DIR"/disk_image_gpt.img ] + then + unzip -o "$SCRIPT_DIR"/disk_image_gpt.img.zip + rm -rf "$SCRIPT_DIR"/__MACOSX + fi hdiutil attach ./disk_image_gpt.img || exit 1 shopt -s nocasematch @@ -67,6 +72,7 @@ then -device VGA,vgamem_mb=64,edid=on,xres=1024,yres=768 \ -device ahci,id=ahi \ -drive format=raw,id=hda,file=./disk_image_gpt.img \ + -cdrom "/JiefLand/3.Infos/3.Infos-Mac/MacOs/11.0.20A5343j Big Sur/BigSurInstall.iso" \ -usb \ -device usb-mouse,bus=usb-bus.0,port=2 \ -device usb-kbd,bus=usb-bus.0,port=1 \ diff --git a/rEFIt_UEFI/Platform/BootLog.cpp b/rEFIt_UEFI/Platform/BootLog.cpp index 3f8eba4f9..171e07494 100644 --- a/rEFIt_UEFI/Platform/BootLog.cpp +++ b/rEFIt_UEFI/Platform/BootLog.cpp @@ -57,7 +57,7 @@ PrintBytes(IN VOID *Bytes, IN UINTN Number) } } - +static EFI_FILE_PROTOCOL* gLogFile = NULL; EFI_FILE_PROTOCOL* GetDebugLogFile() { @@ -66,6 +66,8 @@ EFI_FILE_PROTOCOL* GetDebugLogFile() EFI_FILE_PROTOCOL *RootDir; EFI_FILE_PROTOCOL *LogFile; + if ( gLogFile ) return gLogFile; + // get RootDir from device we are loaded from Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage); if (EFI_ERROR(Status)) { @@ -77,13 +79,21 @@ EFI_FILE_PROTOCOL* GetDebugLogFile() } // Open log file from current root - Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG, - EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0); + Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0); + if ( GlobalConfig.ScratchDebugLogAtStart && Status == EFI_SUCCESS) + { + EFI_STATUS StatusDelete; + StatusDelete = LogFile->Delete(LogFile); + if ( StatusDelete == EFI_SUCCESS) { + Status = EFI_NOT_FOUND; // to get it created next. + }else{ + DebugLog(1, "Cannot delete log file %ls from current root : %s\n", DEBUG_LOG, efiStrError(StatusDelete)); + } + } // If the log file is not found try to create it if (Status == EFI_NOT_FOUND) { - Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG, - EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); + Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); } RootDir->Close(RootDir); RootDir = NULL; @@ -92,12 +102,20 @@ EFI_FILE_PROTOCOL* GetDebugLogFile() // try on first EFI partition Status = egFindESP(&RootDir); if (!EFI_ERROR(Status)) { - Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG, - EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0); + Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0); + if ( GlobalConfig.ScratchDebugLogAtStart && Status == EFI_SUCCESS) + { + EFI_STATUS StatusDelete; + StatusDelete = LogFile->Delete(LogFile); + if ( StatusDelete == EFI_SUCCESS) { + Status = EFI_NOT_FOUND; // to get it created next. + }else{ + DebugLog(1, "Cannot delete log file %ls from 1st EFI partition : %s\n", DEBUG_LOG, efiStrError(StatusDelete)); + } + } // If the log file is not found try to create it if (Status == EFI_NOT_FOUND) { - Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG, - EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); + Status = RootDir->Open(RootDir, &LogFile, DEBUG_LOG, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); } RootDir->Close(RootDir); RootDir = NULL; @@ -108,12 +126,14 @@ EFI_FILE_PROTOCOL* GetDebugLogFile() LogFile = NULL; } + gLogFile = LogFile; return LogFile; } VOID SaveMessageToDebugLogFile(IN CHAR8 *LastMessage) { + EFI_STATUS Status; STATIC BOOLEAN FirstTimeSave = TRUE; // STATIC UINTN Position = 0; CHAR8 *MemLogBuffer; @@ -134,7 +154,7 @@ VOID SaveMessageToDebugLogFile(IN CHAR8 *LastMessage) // Advance to the EOF so we append EFI_FILE_INFO *Info = EfiLibFileInfo(LogFile); if (Info) { - LogFile->SetPosition(LogFile, Info->FileSize); + Status = LogFile->SetPosition(LogFile, Info->FileSize); // If we haven't had root before this write out whole log if (FirstTimeSave) { Text = MemLogBuffer; @@ -142,9 +162,11 @@ VOID SaveMessageToDebugLogFile(IN CHAR8 *LastMessage) FirstTimeSave = FALSE; } // Write out this message - LogFile->Write(LogFile, &TextLen, Text); + Status = LogFile->Write(LogFile, &TextLen, Text); + Status = LogFile->Flush(LogFile); + (void)Status; } - LogFile->Close(LogFile); +// LogFile->Close(LogFile); } } @@ -228,3 +250,25 @@ EFI_STATUS SaveBooterLog(IN EFI_FILE_HANDLE BaseDir OPTIONAL, IN CONST CHAR16 *F return egSaveFile(BaseDir, FileName, (UINT8*)MemLogBuffer, MemLogLen); } + + + +/* + * Redirection of OpenCore log to Clover Log. + */ + +/* + * This function is called from OpenCore when there is a DEBUG ((expression)) + * Mapping from DEBUG to DebugLogForOC is made in OpenCoreFromClover.h + */ +VOID EFIAPI DebugLogForOC(IN INTN DebugLevel, IN CONST CHAR8 *FormatString, ...) +{ + VA_LIST Marker; + + if (FormatString == NULL ) return; + + // Print message to log buffer + VA_START(Marker, FormatString); + MemLogVA(TRUE, 1, FormatString, Marker); + VA_END(Marker); +} diff --git a/rEFIt_UEFI/Platform/BootLog.h b/rEFIt_UEFI/Platform/BootLog.h index 9384c5783..22c172545 100755 --- a/rEFIt_UEFI/Platform/BootLog.h +++ b/rEFIt_UEFI/Platform/BootLog.h @@ -10,12 +10,9 @@ extern "C" { #endif +#include #include // for EFI_FILE_HANDLE -#ifdef __cplusplus -} // extern "C" -#endif - //#define SAFE_LOG_SIZE 80 //#define MSG_LOG_SIZE (256 * 1024) @@ -60,4 +57,18 @@ PrintBytes ( IN UINTN Number ); + +/* + * OpenCore + */ +// This use the EDK format +VOID EFIAPI DebugLogForOC(IN INTN DebugLevel, IN CONST CHAR8 *FormatString, ...); + + + +#ifdef __cplusplus +} // extern "C" +#endif + + #endif diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index 1eeffa14e..3a21cbb43 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -852,7 +852,11 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, Prop = DictPointer->propertyForKey("OcKernelCache"); if (Prop != NULL || gBootChanged) { if ( Prop->isString() ) { - Patches->OcKernelCache = Prop->getString()->stringValue(); + if ( Prop->getString()->stringValue().notEmpty() ) { + Patches->OcKernelCache = Prop->getString()->stringValue(); + }else{ + Patches->OcKernelCache = "Auto"_XS8; + } }else{ MsgLog("MALFORMED PLIST : KernelAndKextPatches/KernelCache must be a string"); Patches->OcKernelCache = "Auto"_XS8; @@ -861,9 +865,11 @@ FillinKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Patches, { const TagDict* OcQuirksDict = DictPointer->dictPropertyForKey("OcQuirks"); +if ( !OcQuirksDict ) panic("Cannot find OcQuirks under KernelAndKextPatches (OC kernel quirks)"); if ( OcQuirksDict ) { Prop = OcQuirksDict->propertyForKey("AppleCpuPmCfgLock"); +if ( !Prop ) panic("Cannot find AppleCpuPmCfgLock in OcQuirks under KernelAndKextPatches (OC kernel quirks)"); if (Prop != NULL || gBootChanged) { Patches->OcKernelQuirks.AppleCpuPmCfgLock = IsPropertyNotNullAndTrue(Prop); } @@ -2258,7 +2264,21 @@ GetEarlyUserSettings ( } Prop = BootDict->propertyForKey("Debug"); - GlobalConfig.DebugLog = IsPropertyNotNullAndTrue(Prop); + if ( Prop ) { + if ( Prop->isString() ) { + if ( Prop->getString()->stringValue().equalIC("true") ) GlobalConfig.DebugLog = true; + else if ( Prop->getString()->stringValue().equalIC("false") ) GlobalConfig.DebugLog = false; + else if ( Prop->getString()->stringValue().equalIC("scratch") ) { + GlobalConfig.DebugLog = true; + GlobalConfig.ScratchDebugLogAtStart = true; + } + else MsgLog("MALFORMED config.plist : property Boot/Debug must be true, false, or scratch\n"); + }else if ( Prop->isBool() ) { + GlobalConfig.DebugLog = Prop->getBool()->boolValue(); + }else{ + MsgLog("MALFORMED config.plist : property Boot/Debug must be a string (true, false, or scratch) or or \n"); + } + } Prop = BootDict->propertyForKey("Fast"); GlobalConfig.FastBoot = IsPropertyNotNullAndTrue(Prop); @@ -2900,10 +2920,12 @@ GetEarlyUserSettings ( } } - const TagDict* OcQuirksDict = CfgDict->dictPropertyForKey("Quirks"); + const TagDict* OcQuirksDict = CfgDict->dictPropertyForKey("OcQuirks"); +if ( !OcQuirksDict ) panic("Cannot find OcQuirks under root (OC booter quirks)"); if (OcQuirksDict != NULL) { const TagStruct* Prop; Prop = OcQuirksDict->propertyForKey("AvoidRuntimeDefrag"); +if ( !Prop ) panic("Cannot find AvoidRuntimeDefrag in OcQuirks under root (OC booter quirks)"); gSettings.ocBooterQuirks.AvoidRuntimeDefrag = IsPropertyNotNullAndTrue(Prop); gSettings.QuirksMask |= gSettings.ocBooterQuirks.AvoidRuntimeDefrag? QUIRK_DEFRAG:0; Prop = OcQuirksDict->propertyForKey( "DevirtualiseMmio"); diff --git a/rEFIt_UEFI/Platform/Settings.h b/rEFIt_UEFI/Platform/Settings.h index fb8bebea0..ea75ef9f4 100644 --- a/rEFIt_UEFI/Platform/Settings.h +++ b/rEFIt_UEFI/Platform/Settings.h @@ -822,6 +822,7 @@ public: BOOLEAN LegacyFirst; BOOLEAN NoLegacy; BOOLEAN DebugLog; + BOOLEAN ScratchDebugLogAtStart; BOOLEAN FastBoot; BOOLEAN NeverHibernate; BOOLEAN StrictHibernate; @@ -867,7 +868,8 @@ public: }; * */ - REFIT_CONFIG() : Timeout(-1), DisableFlags(0), TextOnly(FALSE), Quiet(TRUE), LegacyFirst(FALSE), NoLegacy(FALSE), DebugLog(FALSE), FastBoot(FALSE), NeverHibernate(FALSE), StrictHibernate(FALSE), + REFIT_CONFIG() : Timeout(-1), DisableFlags(0), TextOnly(FALSE), Quiet(TRUE), LegacyFirst(FALSE), NoLegacy(FALSE), + DebugLog(FALSE), ScratchDebugLogAtStart(FALSE), FastBoot(FALSE), NeverHibernate(FALSE), StrictHibernate(FALSE), RtcHibernateAware(FALSE), HibernationFixup(FALSE), SignatureFixup(FALSE), Theme(), ScreenResolution(), ConsoleMode(0), CustomIcons(FALSE), IconFormat(ICON_FORMAT_DEF), NoEarlyProgress(FALSE), Timezone(0xFF), ShowOptimus(FALSE), Codepage(0xC0), CodepageSize(0xC0) {}; REFIT_CONFIG(const SIDELOAD_KEXT& other) = delete; // Can be defined if needed diff --git a/rEFIt_UEFI/refit.inf b/rEFIt_UEFI/refit.inf index e49102b2e..596623a70 100644 --- a/rEFIt_UEFI/refit.inf +++ b/rEFIt_UEFI/refit.inf @@ -353,7 +353,8 @@ BaseDebugPrintErrorLevelLib BaseSerialPortLib OpenCoreLib - OcDebugLogLib + #OcDebugLogLib + OcDebugLogLibOc2Clover [Guids] gEfiAcpiTableGuid diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index c6c67f856..cae4b94e7 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -1007,7 +1007,7 @@ extern "C" { #include #include #include -#include + extern OC_GLOBAL_CONFIG mOpenCoreConfiguration; extern OC_STORAGE_CONTEXT mOpenCoreStorage; extern OC_CPU_INFO mOpenCoreCpuInfo; @@ -1276,16 +1276,16 @@ VOID LOADER_ENTRY::StartLoader11() // DbgHeader("RestSetup macOS"); // -//// DBG("SetDevices\n"); -// SetDevices(this); -//// DBG("SetFSInjection\n"); -// //SetFSInjection(); -// //PauseForKey(L"SetFSInjection"); -//// DBG("SetVariablesForOSX\n"); -// SetVariablesForOSX(this); -//// DBG("SetVariablesForOSX\n"); -//// EventsInitialize(this); -//// DBG("FinalizeSmbios\n"); +// DBG("SetDevices\n"); + SetDevices(this); +// DBG("SetFSInjection\n"); + //SetFSInjection(); + //PauseForKey(L"SetFSInjection"); +// DBG("SetVariablesForOSX\n"); + SetVariablesForOSX(this); +// DBG("SetVariablesForOSX\n"); +// EventsInitialize(this); +// DBG("FinalizeSmbios\n"); FinalizeSmbios(); // // SetCPUProperties(); @@ -1364,7 +1364,7 @@ VOID LOADER_ENTRY::StartLoader11() // OcAppleDebugLogInstallProtocol(0); -//debugStartImageWithOC(); // ok BS_I +//debugStartImageWithOC(); DBG("Beginning OC\n"); UINT64 CPUFrequencyFromART; @@ -1396,9 +1396,9 @@ DBG("Beginning OC\n"); if ( GlobalConfig.DebugLog ) { mOpenCoreConfiguration.Misc.Debug.AppleDebug = true; mOpenCoreConfiguration.Misc.Debug.ApplePanic = true; - mOpenCoreConfiguration.Misc.Debug.DisableWatchDog = true; - mOpenCoreConfiguration.Misc.Debug.DisplayLevel = 2151678018; - mOpenCoreConfiguration.Misc.Debug.Target = 65; +// mOpenCoreConfiguration.Misc.Debug.DisableWatchDog = true; // already done by Clover ? + mOpenCoreConfiguration.Misc.Debug.DisplayLevel = 0x80400042; + mOpenCoreConfiguration.Misc.Debug.Target = 0x41; } OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Security.SecureBootModel, "Disabled"); @@ -2424,26 +2424,6 @@ RefitMain (IN EFI_HANDLE ImageHandle, construct_globals_objects(gImageHandle); // do this after SelfLoadedImage is initialized -// UINT64 CPUFrequencyFromART; -// InternalCalculateARTFrequencyIntel(&CPUFrequencyFromART, NULL, 1); -// -// EFI_LOADED_IMAGE* OcLoadedImage; -// Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &OcLoadedImage); -// EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem = LocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath); -// Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, L"EFI\\CLOVER", NULL); -// -// OcConfigureLogProtocol ( -// 9, -// 0, -// 2151678018, -// 2147483648, -// OPEN_CORE_LOG_PREFIX_PATH, -// mOpenCoreStorage.FileSystem -// ); -// DEBUG ((DEBUG_INFO, "OC: Log initialized...\n")); -// OcAppleDebugLogInstallProtocol(0); - - #ifdef JIEF_DEBUG // all_tests();