Refactor BlackList as XStringWArray and rename to DisabledDriverArray.

This commit is contained in:
jief666 2020-08-31 12:00:52 +03:00
parent da29292e22
commit 2447e1fea7
4 changed files with 20 additions and 23 deletions

View File

@ -1508,12 +1508,12 @@ VOID SaveOemDsdt(BOOLEAN FullPatch)
PathDsdt.SWPrintf("\\%ls", gSettings.DsdtName.wc_str());
if (FileExists(SelfRootDir, SWPrintf("%ls%ls", AcpiOemPath.wc_str(), PathDsdt.wc_str()))) {
DBG("DSDT found in Clover volume OEM folder: %ls%ls\n", AcpiOemPath.wc_str(), PathDsdt.wc_str());
DBG("SaveOemDsdt: DSDT found in Clover volume OEM folder: %ls%ls\n", AcpiOemPath.wc_str(), PathDsdt.wc_str());
Status = egLoadFile(SelfRootDir, SWPrintf("%ls%ls", AcpiOemPath.wc_str(), PathDsdt.wc_str()).wc_str(), &buffer, &DsdtLen);
}
if (EFI_ERROR(Status) && FileExists(SelfRootDir, SWPrintf("%ls%ls", PathPatched.wc_str(), PathDsdt.wc_str()))) {
DBG("DSDT found in Clover volume common folder: %ls%ls\n", PathPatched.wc_str(), PathDsdt.wc_str());
DBG("SaveOemDsdt: DSDT found in Clover volume common folder: %ls%ls\n", PathPatched.wc_str(), PathDsdt.wc_str());
Status = egLoadFile(SelfRootDir, SWPrintf("%ls%ls", PathPatched.wc_str(), PathDsdt.wc_str()).wc_str(), &buffer, &DsdtLen);
}

View File

@ -2767,8 +2767,7 @@ GetEarlyUserSettings (
INTN i;
INTN Count = DisableDriversArray->arrayContent().size();
if (Count > 0) {
gSettings.BlackListCount = 0;
gSettings.BlackList = (__typeof__(gSettings.BlackList))AllocateZeroPool(Count * sizeof(CHAR16 *));
gSettings.DisabledDriverArray.setEmpty();
for (i = 0; i < Count; i++) {
const TagStruct* Prop = &DisableDriversArray->arrayContent()[i];
@ -2776,7 +2775,7 @@ GetEarlyUserSettings (
MsgLog("MALFORMED PLIST : DisableDrivers must be an array of string");
continue;
}
gSettings.BlackList[gSettings.BlackListCount++] = SWPrintf("%s", Prop->getString()->stringValue().c_str()).forgetDataWithoutFreeing();
gSettings.DisabledDriverArray.Add(Prop->getString()->stringValue());
}
}
}
@ -5384,7 +5383,11 @@ GetUserSettings(const TagDict* CfgDict)
Prop = DevicesDict->propertyForKey("AirportBridgeDeviceName");
if (Prop && (Prop->isString())) {
gSettings.AirportBridgeDeviceName = Prop->getString()->stringValue();
if ( Prop->getString()->stringValue().length() != 4 ) {
MsgLog("ERROR IN PLIST : AirportBridgeDeviceName must 4 chars long");
}else{
gSettings.AirportBridgeDeviceName = Prop->getString()->stringValue();
}
}
const TagDict* AudioDict = DevicesDict->dictPropertyForKey("Audio");
@ -8370,8 +8373,8 @@ checkOffset(CustomBoot);
xb.cat(uintptr_t(0)); // MainConfigName was a CHAR16*
//Drivers
xb.cat(BlackListCount);
xb.cat(BlackList);
xb.cat(DisabledDriverArray.size()); // BlackListCount
xb.cat(uintptr_t(0)); // BlackList was a pointer
//SMC keys
xb.ncat(&RPlt, sizeof(RPlt));

View File

@ -503,8 +503,7 @@ public:
// XString8 MainConfigName;
//Drivers
INTN BlackListCount;
CHAR16 **BlackList;
XStringWArray DisabledDriverArray;
//SMC keys
CHAR8 RPlt[8];
@ -614,7 +613,7 @@ public:
LegacyBoot(), LegacyBiosDefaultEntry(0), HWP(0), TDP(0), HWPValue(0), HVHideStrings(), KernelAndKextPatches(), KextPatchesAllowed(0),
KernelPatchesAllowed(0), AirportBridgeDeviceName(), KbdPrevLang(0), PointerEnabled(0), PointerSpeed(0), DoubleClickTime(0), PointerMirror(0), CustomBoot(0), CustomLogo(0),
RefCLK(0), RtMLB(), RtROM(0), RtROMLen(0), CsrActiveConfig(0), BooterConfig(0), BooterCfgStr(), DisableCloverHotkeys(0), NeverDoRecovery(0),
ConfigName{0}, /*MainConfigName(0),*/ BlackListCount(0), BlackList(0), RPlt{0}, RBr{0}, EPCI{0}, REV{0}, Rtc8Allowed(0),
ConfigName{0}, /*MainConfigName(0),*/ /*BlackListCount(0),*/ DisabledDriverArray(), RPlt{0}, RBr{0}, EPCI{0}, REV{0}, Rtc8Allowed(0),
ForceHPET(0), ResetHDA(0), PlayAsync(0), DisableFunctions(0), DSDTPatchArray(), DebugDSDT(0), SlpWak(0), UseIntelHDMI(0),
AFGLowPowerState(0), PNLF_UID(0), ACPIDropTables(0), DisableEntryScan(0), DisableToolScan(0), KernelScan(0), LinuxScan(0), CustomEntries(0),
CustomLegacy(0), CustomTool(0), NrAddProperties(0), AddProperties(0), BlockKexts{0}, SortedACPICount(0), SortedACPI(0), DisabledAMLCount(0), DisabledAML(0),

View File

@ -1081,7 +1081,6 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
UINTN DriversArrSize;
UINTN DriversArrNum;
EFI_HANDLE *DriversArr;
INTN i;
BOOLEAN Skip;
UINT8 AptioBlessed;
STATIC CHAR16 CONST * CONST AptioNames[] = {
@ -1106,10 +1105,11 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
//only one driver with highest priority will obtain status "Loaded"
DirIterOpen(SelfRootDir, Path, &DirIter);
#define BOOLEAN_AT_INDEX(k) (*(BOOLEAN*)((UINTN)&gDriversFlags + AptioIndices[(k)]))
for (i = 0; i != ARRAY_SIZE(AptioIndices); ++i)
for (size_t i = 0; i != ARRAY_SIZE(AptioIndices); ++i)
BOOLEAN_AT_INDEX(i) = FALSE;
AptioBlessed = (UINT8) ARRAY_SIZE(AptioNames);
while (DirIterNext(&DirIter, 2, L"*.efi", &DirEntry)) {
size_t i;
for (i = 0; i != ARRAY_SIZE(AptioNames); ++i)
if (StrStr(DirEntry->FileName, AptioNames[i]) != NULL)
break;
@ -1125,8 +1125,8 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
DirIterOpen(SelfRootDir, Path, &DirIter);
while (DirIterNext(&DirIter, 2, L"*.efi", &DirEntry)) {
Skip = (DirEntry->FileName[0] == L'.');
for (i=0; i<gSettings.BlackListCount; i++) {
if (StrStr(DirEntry->FileName, gSettings.BlackList[i]) != NULL) {
for (size_t i=0; i<gSettings.DisabledDriverArray.size(); i++) {
if (StrStr(DirEntry->FileName, gSettings.DisabledDriverArray[i].wc_str()) != NULL) {
Skip = TRUE; // skip this
break;
}
@ -1134,7 +1134,8 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
if (Skip) {
continue;
}
{
size_t i;
// either AptioMem, AptioFix* or LowMemFix exclusively
for (i = 0; i != ARRAY_SIZE(AptioNames); ++i)
if (StrStr(DirEntry->FileName, AptioNames[i]) != NULL)
@ -1146,6 +1147,7 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
BOOLEAN_AT_INDEX(AptioBlessed) = TRUE;
AptioBlessed = (UINT8) ARRAY_SIZE(AptioNames);
}
}
#undef BOOLEAN_AT_INDEX
snwprintf(FileName, 512, "%ls\\%ls", Path, DirEntry->FileName);
@ -1201,13 +1203,6 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
*DriversToConnectNum = DriversArrNum;
*DriversToConnect = DriversArr;
}
//release memory for BlackList
for (i=0; i<gSettings.BlackListCount; i++) {
if (gSettings.BlackList[i]) {
FreePool(gSettings.BlackList[i]);
gSettings.BlackList[i] = NULL;
}
}
}