From c93da727143f8ac1d5ce8251ca41b307237c6494 Mon Sep 17 00:00:00 2001 From: SergeySlice Date: Sun, 21 Mar 2021 17:08:47 +0300 Subject: [PATCH] move self initialisation up Signed-off-by: SergeySlice --- Qemu/launch | 2 +- rEFIt_UEFI/Platform/BootLog.cpp | 24 +++++++++++++++++------- rEFIt_UEFI/entry_scan/loader.cpp | 2 +- rEFIt_UEFI/refit/main.cpp | 8 ++++---- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Qemu/launch b/Qemu/launch index d1336b207a..739e6695c9 100755 --- a/Qemu/launch +++ b/Qemu/launch @@ -75,7 +75,7 @@ then ./qemu_portable/qemu-system-x86_64 \ -L qemu_portable \ -m 2048 \ - -cpu core2duo \ + -cpu Penryn \ -bios ./bios.bin-1.13.0 \ -machine q35 \ -device ahci,id=ahi \ diff --git a/rEFIt_UEFI/Platform/BootLog.cpp b/rEFIt_UEFI/Platform/BootLog.cpp index 0749e64c9c..546e4b26a3 100644 --- a/rEFIt_UEFI/Platform/BootLog.cpp +++ b/rEFIt_UEFI/Platform/BootLog.cpp @@ -208,12 +208,6 @@ static UINTN GetDebugLogFile() EFI_FILE_PROTOCOL *RootDir; EFI_FILE_PROTOCOL *LogFile; - EFI_TIME Now; - Status = gRT->GetTime(&Now, NULL); - if ( debugLogFileName.isEmpty() ) { - debugLogFileName = S8Printf("misc\\%d-%d-%d_%d-%d_%ls.log", Now.Year, Now.Month, Now.Day, Now.Hour, Now.Minute, self.getCloverEfiFileName().wc_str()); - } - // get RootDir from device we are loaded from Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage); if (EFI_ERROR(Status)) { @@ -386,11 +380,28 @@ void EFIAPI DebugLog(IN INTN DebugMode, IN CONST CHAR8 *FormatString, ...) MemLogfVA(TRUE, DebugMode, FormatString, Marker); VA_END(Marker); } +#if NEW_LOG +void InitBooterLog(void) +{ + SetMemLogCallback(MemLogCallback); +} +#else void InitBooterLog(void) { + EFI_TIME Now; + EFI_STATUS Status; + + Status = gRT->GetTime(&Now, NULL); + if (!EFI_ERROR(Status)) { + debugLogFileName = SWPrintf("misc\\%d-%d-%d_%d-%d-%d_%ls.log", Now.Year, Now.Month, Now.Day, Now.Hour, Now.Minute, Now.Second, self.getCloverEfiFileName().wc_str()); + } else { + debugLogFileName = L"misc\\debug.log"_XSW; + } + SetMemLogCallback(MemLogCallback); } +#endif EFI_STATUS SetupBooterLog(BOOLEAN AllowGrownSize) { @@ -434,7 +445,6 @@ EFI_STATUS SaveBooterLog(const EFI_FILE* BaseDir OPTIONAL, IN CONST CHAR16 *File return egSaveFile(BaseDir, FileName, (UINT8*)MemLogBuffer, MemLogLen); } - void DbgHeader(CONST CHAR8 *str) { CHAR8 strLog[50]; diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index b9e060995e..5f87c43831 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -1008,7 +1008,7 @@ void LOADER_ENTRY::AddDefaultMenu() } - SubScreen->AddMenuEntry(&MenuEntryReturn, false); +// SubScreen->AddMenuEntry(&MenuEntryReturn, false); //one-way ticket to avoid confusion // DBG(" Added '%ls': OSType='%d', OSVersion='%s'\n",Title,LoaderType,OSVersion); } diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index f662894ae9..89caf3c18c 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -2714,6 +2714,10 @@ RefitMain (IN EFI_HANDLE ImageHandle, gRT->GetTime(&Now, NULL); + Status = InitRefitLib(gImageHandle); + if (EFI_ERROR(Status)) + return Status; + // firmware detection gFirmwareClover = StrCmp(gST->FirmwareVendor, L"CLOVER") == 0; if (!gFirmwareRevision) { @@ -2740,10 +2744,6 @@ RefitMain (IN EFI_HANDLE ImageHandle, - Status = InitRefitLib(gImageHandle); - if (EFI_ERROR(Status)) - return Status; - //dumping SETTING structure // if you change something in Platform.h, please uncomment and test that all offsets // are natural aligned i.e. pointers are 8 bytes aligned