Skip to content

Commit

Permalink
DumpNvram().
Browse files Browse the repository at this point in the history
Debug messages in Self.
Typo in BootLog.cpp
Comment in XStringAbstract.h
  • Loading branch information
jief666 committed Jul 2, 2021
1 parent e6617e3 commit a634a82
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 19 deletions.
39 changes: 34 additions & 5 deletions rEFIt_UEFI/Platform/Nvram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -166,9 +165,6 @@ XString8 GetNvramVariableAsXString8(
returnValue.setEmpty();
}
}
if (DataSize != NULL) {
*DataSize = IntDataSize;
}
returnValue.dataSized(IntDataSize+1)[IntDataSize] = 0;
returnValue.updateSize();
return returnValue;
Expand Down Expand Up @@ -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 ()
Expand Down
9 changes: 7 additions & 2 deletions rEFIt_UEFI/Platform/Nvram.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -119,4 +118,10 @@ RemoveStartupDiskVolume (void);
UINT64
GetEfiTimeInMs (IN EFI_TIME *T);

#ifdef JIEF_DEBUG
EFI_STATUS DumpNvram();
#endif



#endif /* PLATFORM_NVRAM_H_ */
2 changes: 1 addition & 1 deletion rEFIt_UEFI/PlatformEFI/BootLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
24 changes: 15 additions & 9 deletions rEFIt_UEFI/Settings/Self.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/Settings/Self.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/cpp_foundation/XStringAbstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ class XStringAbstract : public __String<T, ThisXStringClass>
}
void updateSize() {
#ifdef XSTRING_CACHING_OF_SIZE
super::__m_size = 0;
super::__m_size = 0; // Jief, TODO
#endif
}
//
Expand Down
5 changes: 5 additions & 0 deletions rEFIt_UEFI/refit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit a634a82

Please sign in to comment.