diff --git a/rEFIt_UEFI/Platform/Nvram.cpp b/rEFIt_UEFI/Platform/Nvram.cpp index 5774c15a9f..ce1f021e37 100755 --- a/rEFIt_UEFI/Platform/Nvram.cpp +++ b/rEFIt_UEFI/Platform/Nvram.cpp @@ -141,8 +141,7 @@ void *GetNvramVariable( XString8 GetNvramVariableAsXString8( IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, - OUT UINT32 *Attributes OPTIONAL, - OUT UINTN *DataSize OPTIONAL) + OUT UINT32 *Attributes OPTIONAL) { EFI_STATUS Status; XString8 returnValue; @@ -166,9 +165,6 @@ XString8 GetNvramVariableAsXString8( returnValue.setEmpty(); } } - if (DataSize != NULL) { - *DataSize = IntDataSize; - } returnValue.dataSized(IntDataSize+1)[IntDataSize] = 0; returnValue.updateSize(); return returnValue; @@ -334,6 +330,39 @@ IsDeletableVariable ( return FALSE; } +#ifdef JIEF_DEBUG +EFI_STATUS +DumpNvram() +{ + EFI_STATUS Status = EFI_NOT_FOUND; + EFI_GUID Guid; + XStringW Name = L""_XSW; + UINTN Size; + + DbgHeader("DumpNvram"); + + ZeroMem (&Guid, sizeof(Guid)); + + do { + Size = Name.sizeInBytes(); + Status = gRT->GetNextVariableName(&Size, Name.dataSized(Size+1), &Guid); + if (Status == EFI_BUFFER_TOO_SMALL) { + Status = gRT->GetNextVariableName (&Size, Name.dataSized(Size+1), &Guid); + } + + if ( !EFI_ERROR(Status) ) { + XString8 s = GetNvramVariableAsXString8(Name.wc_str(), &Guid, NULL); + DBG("NVRAM : %s,%ls = '%s'\n", GuidLEToXString8(Guid).c_str(), Name.wc_str(), s.c_str()); + }else if ( Status != EFI_NOT_FOUND ) { + DBG("GetNextVariableName returns '%s'\n", efiStrError(Status)); + break; + } + } while( Status != EFI_NOT_FOUND ); + return Status; +} + +#endif + // Reset Native NVRAM by vit9696, reworked and implemented by Sherlocks EFI_STATUS ResetNativeNvram () diff --git a/rEFIt_UEFI/Platform/Nvram.h b/rEFIt_UEFI/Platform/Nvram.h index 7acf0af1c5..819ac7a959 100644 --- a/rEFIt_UEFI/Platform/Nvram.h +++ b/rEFIt_UEFI/Platform/Nvram.h @@ -35,8 +35,7 @@ void XString8 GetNvramVariableAsXString8( IN CONST CHAR16 *VariableName, IN EFI_GUID *VendorGuid, - OUT UINT32 *Attributes OPTIONAL, - OUT UINTN *DataSize OPTIONAL + OUT UINT32 *Attributes OPTIONAL ); EFI_STATUS @@ -119,4 +118,10 @@ RemoveStartupDiskVolume (void); UINT64 GetEfiTimeInMs (IN EFI_TIME *T); +#ifdef JIEF_DEBUG +EFI_STATUS DumpNvram(); +#endif + + + #endif /* PLATFORM_NVRAM_H_ */ diff --git a/rEFIt_UEFI/PlatformEFI/BootLog.cpp b/rEFIt_UEFI/PlatformEFI/BootLog.cpp index a572791710..f2c9199394 100644 --- a/rEFIt_UEFI/PlatformEFI/BootLog.cpp +++ b/rEFIt_UEFI/PlatformEFI/BootLog.cpp @@ -79,7 +79,7 @@ static EFI_FILE_PROTOCOL* gLogFile = NULL; int g_OpeningLogFile = 0; -// Avoid debug looping. TO be able to call DBG from inside function that DBG calls, we need to suspend callback to avoid a loop. +// Avoid debug looping. To be able to call DBG from inside function that DBG calls, we need to suspend callback to avoid a loop. // Just instanciante this, the destructor will restore the callback. class SuspendMemLogCallback { diff --git a/rEFIt_UEFI/Settings/Self.cpp b/rEFIt_UEFI/Settings/Self.cpp index c70caa29b2..81ef95a117 100644 --- a/rEFIt_UEFI/Settings/Self.cpp +++ b/rEFIt_UEFI/Settings/Self.cpp @@ -21,7 +21,7 @@ #define DBG(...) DebugLog(DEBUG_SELF, __VA_ARGS__) #endif -EFI_STATUS Self::__initialize(EFI_HANDLE SelfImageHandle, EFI_LOADED_IMAGE** SelfLoadedImagePtr, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL** SelfSimpleVolumePtr, EFI_FILE** SelfVolumeRootDirPtr, XStringW* CloverDirFullPathPtr, XStringW* efiFileNamePtr, EFI_FILE** CloverDirPtr) +EFI_STATUS Self::__initialize(bool debugMsg, EFI_HANDLE SelfImageHandle, EFI_LOADED_IMAGE** SelfLoadedImagePtr, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL** SelfSimpleVolumePtr, EFI_FILE** SelfVolumeRootDirPtr, XStringW* CloverDirFullPathPtr, XStringW* efiFileNamePtr, EFI_FILE** CloverDirPtr) { EFI_STATUS Status; @@ -51,7 +51,7 @@ EFI_STATUS Self::__initialize(EFI_HANDLE SelfImageHandle, EFI_LOADED_IMAGE** Sel EFI_FILE* SelfVolumeRootDir = *SelfVolumeRootDirPtr; #ifdef JIEF_DEBUG -// DBG("SelfVolumeRootDir = %lld\n", uintptr_t(SelfVolumeRootDir)); + if ( debugMsg ) DBG("SelfVolumeRootDir = %lld\n", uintptr_t(SelfVolumeRootDir)); #endif // find the current directory @@ -69,8 +69,10 @@ EFI_STATUS Self::__initialize(EFI_HANDLE SelfImageHandle, EFI_LOADED_IMAGE** Sel *efiFileNamePtr = CloverDirFullPath.basename(); #ifdef JIEF_DEBUG -// XStringW& efiFileName = *efiFileNamePtr; -// DBG("efiFileName=%ls\n", efiFileName.wc_str()); + if ( debugMsg ) { + XStringW& efiFileName = *efiFileNamePtr; + DBG("efiFileName=%ls\n", efiFileName.wc_str()); + } #endif // History : if this Clover was started as BootX64.efi, redirect to /EFI/CLOVER @@ -87,7 +89,9 @@ EFI_STATUS Self::__initialize(EFI_HANDLE SelfImageHandle, EFI_LOADED_IMAGE** Sel if ( i != SIZE_T_MAX && i > 0 ) CloverDirFullPath.deleteCharsAtPos(i, SIZE_T_MAX); // keep getCloverDir() in sync ! #ifdef JIEF_DEBUG -// DBG("SelfDirPath = %ls\n", CloverDirFullPath.wc_str()); + if ( debugMsg ) { + DBG("SelfDirPath = %ls\n", CloverDirFullPath.wc_str()); + } #endif Status = SelfVolumeRootDir->Open(SelfVolumeRootDir, CloverDirPtr, CloverDirFullPath.wc_str(), EFI_FILE_MODE_READ, 0); @@ -96,8 +100,10 @@ EFI_STATUS Self::__initialize(EFI_HANDLE SelfImageHandle, EFI_LOADED_IMAGE** Sel return RETURN_LOAD_ERROR; } #ifdef JIEF_DEBUG -// EFI_FILE* CloverDir = *CloverDirPtr; -// DBG("CloverDir = %lld\n", uintptr_t(CloverDir)); + if ( debugMsg ) { + EFI_FILE* CloverDir = *CloverDirPtr; + DBG("CloverDir = %lld\n", uintptr_t(CloverDir)); + } #endif return EFI_SUCCESS; @@ -111,7 +117,7 @@ const EFI_FILE_PROTOCOL* Self::getCloverDirAndEfiFileName(EFI_HANDLE ImageHandle XStringW CloverDirFullPath; // full path of folder containing this efi. EFI_FILE* CloverDir; // opened folder containing this efi - /*EFI_STATUS Status = */__initialize(ImageHandle, &SelfLoadedImage, &SelfSimpleVolume, &SelfVolumeRootDir, &CloverDirFullPath, efiFileName, &CloverDir); + /*EFI_STATUS Status = */__initialize(false, ImageHandle, &SelfLoadedImage, &SelfSimpleVolume, &SelfVolumeRootDir, &CloverDirFullPath, efiFileName, &CloverDir); if ( efiFileName->isEmpty() ) { if ( CloverDir != NULL ) CloverDir->Close(CloverDir); return NULL; @@ -143,7 +149,7 @@ EFI_STATUS Self::_initialize() { // EFI_STATUS Status; - /*Status = */__initialize(m_SelfImageHandle, &m_SelfLoadedImage, &m_SelfSimpleVolume, &m_SelfVolumeRootDir, &m_CloverDirFullPath, &m_efiFileName, &m_CloverDir); + /*Status = */__initialize(true, m_SelfImageHandle, &m_SelfLoadedImage, &m_SelfSimpleVolume, &m_SelfVolumeRootDir, &m_CloverDirFullPath, &m_efiFileName, &m_CloverDir); if ( m_SelfLoadedImage == NULL ) log_technical_bug("Cannot get SelfLoadedImage"); if ( m_SelfLoadedImage->DeviceHandle == NULL ) log_technical_bug("m_SelfLoadedImage->DeviceHandle == NULL"); if ( m_SelfSimpleVolume == NULL ) log_technical_bug("Cannot get m_SelfSimpleVolume"); diff --git a/rEFIt_UEFI/Settings/Self.h b/rEFIt_UEFI/Settings/Self.h index ba5d6d24d5..6f882cb723 100644 --- a/rEFIt_UEFI/Settings/Self.h +++ b/rEFIt_UEFI/Settings/Self.h @@ -20,7 +20,7 @@ class Self { // Class method, usable even without any instance of Self. protected: - static EFI_STATUS __initialize(EFI_HANDLE m_SelfImageHandle, EFI_LOADED_IMAGE** m_SelfLoadedImage, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL** m_SelfSimpleVolumePtr, EFI_FILE** m_SelfVolumeRootDirPtr, XStringW* m_CloverDirFullPathPtr, XStringW* m_efiFileNamePtr, EFI_FILE** m_CloverDirPtr); + static EFI_STATUS __initialize(bool debugMsg, EFI_HANDLE m_SelfImageHandle, EFI_LOADED_IMAGE** m_SelfLoadedImage, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL** m_SelfSimpleVolumePtr, EFI_FILE** m_SelfVolumeRootDirPtr, XStringW* m_CloverDirFullPathPtr, XStringW* m_efiFileNamePtr, EFI_FILE** m_CloverDirPtr); public: static const EFI_FILE_PROTOCOL* getCloverDirAndEfiFileName(EFI_HANDLE ImageHandle, XStringW* efiFileName); diff --git a/rEFIt_UEFI/cpp_foundation/XStringAbstract.h b/rEFIt_UEFI/cpp_foundation/XStringAbstract.h index ae9222d1d6..5807288105 100644 --- a/rEFIt_UEFI/cpp_foundation/XStringAbstract.h +++ b/rEFIt_UEFI/cpp_foundation/XStringAbstract.h @@ -921,7 +921,7 @@ class XStringAbstract : public __String } void updateSize() { #ifdef XSTRING_CACHING_OF_SIZE - super::__m_size = 0; + super::__m_size = 0; // Jief, TODO #endif } // diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 16b6157f64..4c9af1c382 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -2878,6 +2878,11 @@ RefitMain (IN EFI_HANDLE ImageHandle, gConf.InitialisePlatform(); // DBG("5: GlobalConfig.C3Latency=%x\n", GlobalConfig.C3Latency); + +#ifdef JIEF_DEBUG + DumpNvram(); +#endif + /* * saving debug.log works from here */