Merge branch 'CloverHackyColor:master' into master

This commit is contained in:
LAbyOne 2021-07-04 13:12:08 +02:00 committed by GitHub
commit 1e2fc06666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 76 deletions

View File

@ -141,8 +141,7 @@ void *GetNvramVariable(
XString8 GetNvramVariableAsXString8( XString8 GetNvramVariableAsXString8(
IN CONST CHAR16 *VariableName, IN CONST CHAR16 *VariableName,
IN EFI_GUID *VendorGuid, IN EFI_GUID *VendorGuid,
OUT UINT32 *Attributes OPTIONAL, OUT UINT32 *Attributes OPTIONAL)
OUT UINTN *DataSize OPTIONAL)
{ {
EFI_STATUS Status; EFI_STATUS Status;
XString8 returnValue; XString8 returnValue;
@ -166,9 +165,6 @@ XString8 GetNvramVariableAsXString8(
returnValue.setEmpty(); returnValue.setEmpty();
} }
} }
if (DataSize != NULL) {
*DataSize = IntDataSize;
}
returnValue.dataSized(IntDataSize+1)[IntDataSize] = 0; returnValue.dataSized(IntDataSize+1)[IntDataSize] = 0;
returnValue.updateSize(); returnValue.updateSize();
return returnValue; return returnValue;
@ -334,6 +330,39 @@ IsDeletableVariable (
return FALSE; 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 // Reset Native NVRAM by vit9696, reworked and implemented by Sherlocks
EFI_STATUS EFI_STATUS
ResetNativeNvram () ResetNativeNvram ()

View File

@ -35,8 +35,7 @@ void
XString8 GetNvramVariableAsXString8( XString8 GetNvramVariableAsXString8(
IN CONST CHAR16 *VariableName, IN CONST CHAR16 *VariableName,
IN EFI_GUID *VendorGuid, IN EFI_GUID *VendorGuid,
OUT UINT32 *Attributes OPTIONAL, OUT UINT32 *Attributes OPTIONAL
OUT UINTN *DataSize OPTIONAL
); );
EFI_STATUS EFI_STATUS
@ -119,4 +118,10 @@ RemoveStartupDiskVolume (void);
UINT64 UINT64
GetEfiTimeInMs (IN EFI_TIME *T); GetEfiTimeInMs (IN EFI_TIME *T);
#ifdef JIEF_DEBUG
EFI_STATUS DumpNvram();
#endif
#endif /* PLATFORM_NVRAM_H_ */ #endif /* PLATFORM_NVRAM_H_ */

View File

@ -79,7 +79,7 @@ static EFI_FILE_PROTOCOL* gLogFile = NULL;
int g_OpeningLogFile = 0; 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. // Just instanciante this, the destructor will restore the callback.
class SuspendMemLogCallback class SuspendMemLogCallback
{ {
@ -249,6 +249,7 @@ void EFIAPI MemLogCallback(IN INTN DebugMode, IN CHAR8 *LastMessage)
} }
if ((DebugMode >= 1) && gSettings.Boot.DebugLog) { if ((DebugMode >= 1) && gSettings.Boot.DebugLog) {
SuspendMemLogCallback smc;
SaveMessageToDebugLogFile(LastMessage); SaveMessageToDebugLogFile(LastMessage);
} }
} }

View File

@ -548,7 +548,7 @@ return Status;
} }
/* /*
* Load a plist into configPlist global object, "transfer" the settings into gSettings and call afterGetUserSettings() * Load a plist into configPlist global object
* ConfName : name of the file, without .plist extension. File will be searched in OEM or main folder * ConfName : name of the file, without .plist extension. File will be searched in OEM or main folder
*/ */
EFI_STATUS ConfigManager::LoadConfigPlist(const XStringW& ConfName) EFI_STATUS ConfigManager::LoadConfigPlist(const XStringW& ConfName)
@ -559,7 +559,7 @@ EFI_STATUS ConfigManager::LoadConfigPlist(const XStringW& ConfName)
} }
/* /*
* Load a plist into smbiosPlist global object, "transfer" the settings into gSettings and call afterGetUserSettings() * Load a plist into smbiosPlist global object
* ConfName : name of the file, without .plist extension. File will be searched in OEM or main folder * ConfName : name of the file, without .plist extension. File will be searched in OEM or main folder
*/ */
EFI_STATUS ConfigManager::LoadSMBIOSPlist(const XStringW& ConfName) EFI_STATUS ConfigManager::LoadSMBIOSPlist(const XStringW& ConfName)
@ -740,9 +740,6 @@ void ConfigManager::applySettings() const
} }
//gSettings.CPU.Turbo = gCPUStructure.Turbo; //gSettings.CPU.Turbo = gCPUStructure.Turbo;
if (configPlist.CPU.dgetSavingMode() != 0xFF) { //means not set
gSettings.CPU.SavingMode = configPlist.CPU.dgetSavingMode();
}
if ( gCPUStructure.Model >= CPU_MODEL_SKYLAKE_D ) if ( gCPUStructure.Model >= CPU_MODEL_SKYLAKE_D )
{ {
if ( !configPlist.CPU.getUseARTFreq().isDefined() ) if ( !configPlist.CPU.getUseARTFreq().isDefined() )
@ -886,7 +883,7 @@ EFI_STATUS ConfigManager::LoadConfig(const XStringW& ConfName)
EFI_STATUS Status = LoadConfigPlist(ConfName); EFI_STATUS Status = LoadConfigPlist(ConfName);
if ( EFI_ERROR(Status) ) { if ( EFI_ERROR(Status) ) {
DBG("LoadConfigPlist return %s. Config not loaded\n", efiStrError(Status)); DBG("LoadConfigPlist return %s. Config not loaded\n", efiStrError(Status));
return Status; //return Status; // Let's try to continue with default values.
} }
/*Status = */ LoadSMBIOSPlist(L"smbios"_XSW); // we don't need Status. If not loaded correctly, smbiosPlist is !defined and will be ignored by AssignOldNewSettings() /*Status = */ LoadSMBIOSPlist(L"smbios"_XSW); // we don't need Status. If not loaded correctly, smbiosPlist is !defined and will be ignored by AssignOldNewSettings()
@ -900,8 +897,9 @@ EFI_STATUS ConfigManager::LoadConfig(const XStringW& ConfName)
Model = GetDefaultModel(); Model = GetDefaultModel();
} }
// if ( !EFI_ERROR(Status) ) { if ( !EFI_ERROR(Status) ) {
// gSettings.takeValueFrom(configPlist); gSettings.takeValueFrom(configPlist); // if load failed, keep default value.
}
// TODO improve this (avoid to delete settings to re-import them !) // TODO improve this (avoid to delete settings to re-import them !)
// restore default value for SMBIOS (delete values from configPlist) // restore default value for SMBIOS (delete values from configPlist)
SetDMISettingsForModel(Model, &gSettings, &GlobalConfig); SetDMISettingsForModel(Model, &gSettings, &GlobalConfig);
@ -911,8 +909,6 @@ EFI_STATUS ConfigManager::LoadConfig(const XStringW& ConfName)
// import values from smbiosPlist if they are defined // import values from smbiosPlist if they are defined
FillSmbiosWithDefaultValue(Model, smbiosPlist.SMBIOS); FillSmbiosWithDefaultValue(Model, smbiosPlist.SMBIOS);
} }
// }
gSettings.takeValueFrom(configPlist);
applySettings(); applySettings();
return Status; return Status;
@ -1014,7 +1010,7 @@ EFI_STATUS ConfigManager::InitialisePlatform()
GetCPUProperties(); GetCPUProperties();
DiscoverDevices(); DiscoverDevices();
// GetMacAddress(&gConf.LanCardArrayNonConst);
//SavingMode //SavingMode
if ( g_SmbiosDiscoveredSettings.EnabledCores ) { if ( g_SmbiosDiscoveredSettings.EnabledCores ) {
@ -1026,45 +1022,13 @@ EFI_STATUS ConfigManager::InitialisePlatform()
selfOem.initialize("config"_XS8, gFirmwareClover, GlobalConfig.OEMBoardFromSmbios, GlobalConfig.OEMProductFromSmbios, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega)), gConf.LanCardArray); selfOem.initialize("config"_XS8, gFirmwareClover, GlobalConfig.OEMBoardFromSmbios, GlobalConfig.OEMProductFromSmbios, (INT32)(DivU64x32(gCPUStructure.CPUFrequency, Mega)), gConf.LanCardArray);
Status = gConf.LoadConfig(L"config"_XSW); Status = gConf.LoadConfig(L"config"_XSW);
GlobalConfig.C3Latency = gSettings.ACPI.SSDT._C3Latency;
GlobalConfig.KPKernelPm = gSettings.KernelAndKextPatches._KPKernelPm;
for ( size_t idx = 0 ; idx < GfxPropertiesArrayNonConst.size() ; ++idx ) { for ( size_t idx = 0 ; idx < GfxPropertiesArrayNonConst.size() ; ++idx ) {
GfxPropertiesArrayNonConst[idx].LoadVBios = gSettings.Graphics.LoadVBios; GfxPropertiesArrayNonConst[idx].LoadVBios = gSettings.Graphics.LoadVBios;
} }
// /* populate GfxPropertiesArrayNonConst */
// GfxPropertiesArrayNonConst.setEmpty();
// for ( size_t idx = 0 ; idx < m_Discoverer.GfxPropertiesArray.size() ; ++idx ) {
// GfxProperties* gfx = new GfxProperties;
// *gfx = GfxPropertiesArray[idx];
// (*gfx).LoadVBios = gSettings.Graphics.LoadVBios;
// GfxPropertiesArrayNonConst.AddReference(gfx, true);
// }
//
// /* populate HdaPropertiesArrayNonConst */
// HdaPropertiesArrayNonConst.setEmpty();
// for ( size_t idx = 0 ; idx < m_Discoverer.HdaPropertiesArray.size() ; ++idx ) {
// HdaProperties* hda = new HdaProperties;
// *hda = HdaPropertiesArray[idx];
// HdaPropertiesArrayNonConst.AddReference(hda, true);
// }
//
// /* populate LanCardArrayNonConst */
// LanCardArrayNonConst.setEmpty();
// GetUEFIMacAddress();
//// if ( LanCardArrayNonConst.size() == 0 /*&& gSettings.RtVariables.GetLegacyLanAddress()*/ ) {
// for ( size_t idx = 0 ; idx < m_Discoverer.LanCardArray.size() ; ++idx ) {
// if ( !LanCardArrayNonConst.containsMacAddress(m_Discoverer.LanCardArray[idx].Mac)) {
// LanCardClass* lan = new LanCardClass;
// memcpy(&lan->MacAddress, m_Discoverer.LanCardArray[idx].Mac, sizeof(lan->MacAddress));
// LanCardArrayNonConst.AddReference(lan, true);
// }
// }
//// }
// // Why this overrides ? Should we remove the setting from config.plist ?
// gSettings.GUI.Mouse.PointerEnabled = TRUE;
// gSettings.GUI.Mouse.PointerSpeed = 2;
// gSettings.GUI.Mouse.DoubleClickTime = 500; //TODO - make it constant as nobody change it
if (gSettings.Devices.Audio.ResetHDA) ResetHDA(); if (gSettings.Devices.Audio.ResetHDA) ResetHDA();
#ifdef ENABLE_SECURE_BOOT #ifdef ENABLE_SECURE_BOOT

View File

@ -21,7 +21,7 @@
#define DBG(...) DebugLog(DEBUG_SELF, __VA_ARGS__) #define DBG(...) DebugLog(DEBUG_SELF, __VA_ARGS__)
#endif #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; EFI_STATUS Status;
@ -51,7 +51,7 @@ EFI_STATUS Self::__initialize(EFI_HANDLE SelfImageHandle, EFI_LOADED_IMAGE** Sel
EFI_FILE* SelfVolumeRootDir = *SelfVolumeRootDirPtr; EFI_FILE* SelfVolumeRootDir = *SelfVolumeRootDirPtr;
#ifdef JIEF_DEBUG #ifdef JIEF_DEBUG
DBG("SelfVolumeRootDir = %lld\n", uintptr_t(SelfVolumeRootDir)); if ( debugMsg ) DBG("SelfVolumeRootDir = %lld\n", uintptr_t(SelfVolumeRootDir));
#endif #endif
// find the current directory // find the current directory
@ -69,8 +69,10 @@ EFI_STATUS Self::__initialize(EFI_HANDLE SelfImageHandle, EFI_LOADED_IMAGE** Sel
*efiFileNamePtr = CloverDirFullPath.basename(); *efiFileNamePtr = CloverDirFullPath.basename();
#ifdef JIEF_DEBUG #ifdef JIEF_DEBUG
if ( debugMsg ) {
XStringW& efiFileName = *efiFileNamePtr; XStringW& efiFileName = *efiFileNamePtr;
DBG("efiFileName=%ls\n", efiFileName.wc_str()); DBG("efiFileName=%ls\n", efiFileName.wc_str());
}
#endif #endif
// History : if this Clover was started as BootX64.efi, redirect to /EFI/CLOVER // 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 ! if ( i != SIZE_T_MAX && i > 0 ) CloverDirFullPath.deleteCharsAtPos(i, SIZE_T_MAX); // keep getCloverDir() in sync !
#ifdef JIEF_DEBUG #ifdef JIEF_DEBUG
if ( debugMsg ) {
DBG("SelfDirPath = %ls\n", CloverDirFullPath.wc_str()); DBG("SelfDirPath = %ls\n", CloverDirFullPath.wc_str());
}
#endif #endif
Status = SelfVolumeRootDir->Open(SelfVolumeRootDir, CloverDirPtr, CloverDirFullPath.wc_str(), EFI_FILE_MODE_READ, 0); 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; return RETURN_LOAD_ERROR;
} }
#ifdef JIEF_DEBUG #ifdef JIEF_DEBUG
if ( debugMsg ) {
EFI_FILE* CloverDir = *CloverDirPtr; EFI_FILE* CloverDir = *CloverDirPtr;
DBG("CloverDir = %lld\n", uintptr_t(CloverDir)); DBG("CloverDir = %lld\n", uintptr_t(CloverDir));
}
#endif #endif
return EFI_SUCCESS; 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. XStringW CloverDirFullPath; // full path of folder containing this efi.
EFI_FILE* CloverDir; // opened 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 ( efiFileName->isEmpty() ) {
if ( CloverDir != NULL ) CloverDir->Close(CloverDir); if ( CloverDir != NULL ) CloverDir->Close(CloverDir);
return NULL; return NULL;
@ -143,7 +149,7 @@ EFI_STATUS Self::_initialize()
{ {
// EFI_STATUS Status; // 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 == NULL ) log_technical_bug("Cannot get SelfLoadedImage");
if ( m_SelfLoadedImage->DeviceHandle == NULL ) log_technical_bug("m_SelfLoadedImage->DeviceHandle == NULL"); if ( m_SelfLoadedImage->DeviceHandle == NULL ) log_technical_bug("m_SelfLoadedImage->DeviceHandle == NULL");
if ( m_SelfSimpleVolume == NULL ) log_technical_bug("Cannot get m_SelfSimpleVolume"); if ( m_SelfSimpleVolume == NULL ) log_technical_bug("Cannot get m_SelfSimpleVolume");

View File

@ -20,7 +20,7 @@ class Self
{ {
// Class method, usable even without any instance of Self. // Class method, usable even without any instance of Self.
protected: 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: public:
static const EFI_FILE_PROTOCOL* getCloverDirAndEfiFileName(EFI_HANDLE ImageHandle, XStringW* efiFileName); static const EFI_FILE_PROTOCOL* getCloverDirAndEfiFileName(EFI_HANDLE ImageHandle, XStringW* efiFileName);

View File

@ -921,7 +921,7 @@ public:
} }
void updateSize() { void updateSize() {
#ifdef XSTRING_CACHING_OF_SIZE #ifdef XSTRING_CACHING_OF_SIZE
super::__m_size = 0; super::__m_size = 0; // Jief, TODO
#endif #endif
} }
// //

View File

@ -2878,6 +2878,11 @@ RefitMain (IN EFI_HANDLE ImageHandle,
gConf.InitialisePlatform(); gConf.InitialisePlatform();
// DBG("5: GlobalConfig.C3Latency=%x\n", GlobalConfig.C3Latency); // DBG("5: GlobalConfig.C3Latency=%x\n", GlobalConfig.C3Latency);
#ifdef JIEF_DEBUG
DumpNvram();
#endif
/* /*
* saving debug.log works from here * saving debug.log works from here
*/ */
@ -2955,8 +2960,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
GetListOfConfigs(); GetListOfConfigs();
} }
// DBG("0: GlobalConfig.C3Latency=%x\n", gSettings.ACPI.SSDT._C3Latency); // DBG("0: GlobalConfig.C3Latency=%x\n", gSettings.ACPI.SSDT._C3Latency);
GlobalConfig.C3Latency = gSettings.ACPI.SSDT._C3Latency;
GlobalConfig.KPKernelPm = gSettings.KernelAndKextPatches._KPKernelPm;
// DBG("0: gSettings.CPU.SavingMode=%x\n", gSettings.CPU.SavingMode); // DBG("0: gSettings.CPU.SavingMode=%x\n", gSettings.CPU.SavingMode);
// ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings // ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings
{ {