Separate ATI and NVIDIA card list.

Move MMIOWhiteList, ocBooterQuirks and QuirksMask in Quirks.
Remove MaxSlide as it already exist in ocBooterQuirks as
ProvideMaxSlide.
This commit is contained in:
jief666 2021-03-28 23:13:43 +03:00
parent e143fe8abd
commit 773f9bdaf7
8 changed files with 167 additions and 143 deletions

View File

@ -9,6 +9,7 @@
#include "../include/OSFlags.h" #include "../include/OSFlags.h"
#include "../include/OSTypes.h" #include "../include/OSTypes.h"
#include "../include/BootTypes.h" #include "../include/BootTypes.h"
#include "../include/QuirksCodes.h"
#include "../entry_scan/loader.h" #include "../entry_scan/loader.h"
#include "../Platform/BootLog.h" #include "../Platform/BootLog.h"
#include "../entry_scan/secureboot.h" #include "../entry_scan/secureboot.h"
@ -2451,6 +2452,7 @@ GetEDIDSettings(const TagDict* DictPointer, SETTINGS_DATA& gSettings)
} }
} }
// Jief : GetEarlyUserSettings is ready to disappear...
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wshadow"
EFI_STATUS GetEarlyUserSettings ( EFI_STATUS GetEarlyUserSettings (
@ -3208,15 +3210,7 @@ EFI_STATUS GetEarlyUserSettings (
} }
} }
gSettings.Quirks.mmioWhiteListArray.setEmpty();
//done until here
gSettings.mmioWhiteListArray.setEmpty();
// const TagDict* OcQuirksDict = CfgDict->dictPropertyForKey("OcQuirks"); // const TagDict* OcQuirksDict = CfgDict->dictPropertyForKey("OcQuirks");
//if ( OcQuirksDict ) panic("config.plist/OcQuirks has been renamed Quirks. Update your config.plist"); //if ( OcQuirksDict ) panic("config.plist/OcQuirks has been renamed Quirks. Update your config.plist");
@ -3226,59 +3220,59 @@ EFI_STATUS GetEarlyUserSettings (
const TagStruct* Prop; const TagStruct* Prop;
Prop = OcQuirksDict->propertyForKey("AvoidRuntimeDefrag"); Prop = OcQuirksDict->propertyForKey("AvoidRuntimeDefrag");
//if ( !Prop ) panic("Cannot find AvoidRuntimeDefrag in OcQuirks under root (OC booter quirks)"); //if ( !Prop ) panic("Cannot find AvoidRuntimeDefrag in OcQuirks under root (OC booter quirks)");
gSettings.ocBooterQuirks.AvoidRuntimeDefrag = !IsPropertyNotNullAndFalse(Prop); //true if absent so no panic gSettings.Quirks.ocBooterQuirks.AvoidRuntimeDefrag = !IsPropertyNotNullAndFalse(Prop); //true if absent so no panic
gSettings.QuirksMask |= gSettings.ocBooterQuirks.AvoidRuntimeDefrag? QUIRK_DEFRAG:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.AvoidRuntimeDefrag? QUIRK_DEFRAG:0;
Prop = OcQuirksDict->propertyForKey( "DevirtualiseMmio"); Prop = OcQuirksDict->propertyForKey( "DevirtualiseMmio");
gSettings.ocBooterQuirks.DevirtualiseMmio = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.DevirtualiseMmio = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.DevirtualiseMmio? QUIRK_MMIO:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.DevirtualiseMmio? QUIRK_MMIO:0;
Prop = OcQuirksDict->propertyForKey( "DisableSingleUser"); Prop = OcQuirksDict->propertyForKey( "DisableSingleUser");
gSettings.ocBooterQuirks.DisableSingleUser = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.DisableSingleUser = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.DisableSingleUser? QUIRK_SU:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.DisableSingleUser? QUIRK_SU:0;
Prop = OcQuirksDict->propertyForKey( "DisableVariableWrite"); Prop = OcQuirksDict->propertyForKey( "DisableVariableWrite");
gSettings.ocBooterQuirks.DisableVariableWrite = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.DisableVariableWrite = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.DisableVariableWrite? QUIRK_VAR:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.DisableVariableWrite? QUIRK_VAR:0;
Prop = OcQuirksDict->propertyForKey( "DiscardHibernateMap"); Prop = OcQuirksDict->propertyForKey( "DiscardHibernateMap");
gSettings.ocBooterQuirks.DiscardHibernateMap = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.DiscardHibernateMap = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.DiscardHibernateMap? QUIRK_HIBER:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.DiscardHibernateMap? QUIRK_HIBER:0;
Prop = OcQuirksDict->propertyForKey( "EnableSafeModeSlide"); Prop = OcQuirksDict->propertyForKey( "EnableSafeModeSlide");
gSettings.ocBooterQuirks.EnableSafeModeSlide = !IsPropertyNotNullAndFalse(Prop); gSettings.Quirks.ocBooterQuirks.EnableSafeModeSlide = !IsPropertyNotNullAndFalse(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.EnableSafeModeSlide? QUIRK_SAFE:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.EnableSafeModeSlide? QUIRK_SAFE:0;
Prop = OcQuirksDict->propertyForKey( "EnableWriteUnprotector"); Prop = OcQuirksDict->propertyForKey( "EnableWriteUnprotector");
gSettings.ocBooterQuirks.EnableWriteUnprotector = !IsPropertyNotNullAndFalse(Prop); gSettings.Quirks.ocBooterQuirks.EnableWriteUnprotector = !IsPropertyNotNullAndFalse(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.EnableWriteUnprotector? QUIRK_UNPROT:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.EnableWriteUnprotector? QUIRK_UNPROT:0;
Prop = OcQuirksDict->propertyForKey( "ForceExitBootServices"); Prop = OcQuirksDict->propertyForKey( "ForceExitBootServices");
gSettings.ocBooterQuirks.ForceExitBootServices = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.ForceExitBootServices = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.ForceExitBootServices? QUIRK_EXIT:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.ForceExitBootServices? QUIRK_EXIT:0;
Prop = OcQuirksDict->propertyForKey( "ProtectMemoryRegions"); Prop = OcQuirksDict->propertyForKey( "ProtectMemoryRegions");
gSettings.ocBooterQuirks.ProtectMemoryRegions = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.ProtectMemoryRegions = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.ProtectMemoryRegions? QUIRK_REGION:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.ProtectMemoryRegions? QUIRK_REGION:0;
Prop = OcQuirksDict->propertyForKey( "ProtectSecureBoot"); Prop = OcQuirksDict->propertyForKey( "ProtectSecureBoot");
gSettings.ocBooterQuirks.ProtectSecureBoot = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.ProtectSecureBoot = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.ProtectSecureBoot? QUIRK_SECURE:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.ProtectSecureBoot? QUIRK_SECURE:0;
Prop = OcQuirksDict->propertyForKey( "ProtectUefiServices"); Prop = OcQuirksDict->propertyForKey( "ProtectUefiServices");
gSettings.ocBooterQuirks.ProtectUefiServices = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.ProtectUefiServices = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.ProtectUefiServices? QUIRK_UEFI:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.ProtectUefiServices? QUIRK_UEFI:0;
//it is in GUI section //it is in GUI section
// Prop = OcQuirksDict->propertyForKey( "ProvideConsoleGopEnable"); // Prop = OcQuirksDict->propertyForKey( "ProvideConsoleGopEnable");
// settingsData.ProvideConsoleGop = !IsPropertyNotNullAndFalse(Prop); // settingsData.ProvideConsoleGop = !IsPropertyNotNullAndFalse(Prop);
Prop = OcQuirksDict->propertyForKey( "ProvideCustomSlide"); Prop = OcQuirksDict->propertyForKey( "ProvideCustomSlide");
gSettings.ocBooterQuirks.ProvideCustomSlide = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.ProvideCustomSlide = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.ProvideCustomSlide? QUIRK_CUSTOM:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.ProvideCustomSlide? QUIRK_CUSTOM:0;
Prop = OcQuirksDict->propertyForKey( "ProvideMaxSlide"); Prop = OcQuirksDict->propertyForKey( "ProvideMaxSlide");
gSettings.ocBooterQuirks.ProvideMaxSlide = (UINT8)GetPropertyAsInteger(Prop, 0); // cast will be safe when the new parser will ensure that the value is UINT8 gSettings.Quirks.ocBooterQuirks.ProvideMaxSlide = (UINT8)GetPropertyAsInteger(Prop, 0); // cast will be safe when the new parser will ensure that the value is UINT8
Prop = OcQuirksDict->propertyForKey( "RebuildAppleMemoryMap"); Prop = OcQuirksDict->propertyForKey( "RebuildAppleMemoryMap");
gSettings.ocBooterQuirks.RebuildAppleMemoryMap = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.RebuildAppleMemoryMap = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.RebuildAppleMemoryMap? QUIRK_MAP:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.RebuildAppleMemoryMap? QUIRK_MAP:0;
Prop = OcQuirksDict->propertyForKey( "SetupVirtualMap"); Prop = OcQuirksDict->propertyForKey( "SetupVirtualMap");
gSettings.ocBooterQuirks.SetupVirtualMap = !IsPropertyNotNullAndFalse(Prop); gSettings.Quirks.ocBooterQuirks.SetupVirtualMap = !IsPropertyNotNullAndFalse(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.SetupVirtualMap? QUIRK_VIRT:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.SetupVirtualMap? QUIRK_VIRT:0;
Prop = OcQuirksDict->propertyForKey( "SignalAppleOS"); Prop = OcQuirksDict->propertyForKey( "SignalAppleOS");
gSettings.ocBooterQuirks.SignalAppleOS = IsPropertyNotNullAndTrue(Prop); gSettings.Quirks.ocBooterQuirks.SignalAppleOS = IsPropertyNotNullAndTrue(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.SignalAppleOS? QUIRK_OS:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.SignalAppleOS? QUIRK_OS:0;
Prop = OcQuirksDict->propertyForKey( "SyncRuntimePermissions"); Prop = OcQuirksDict->propertyForKey( "SyncRuntimePermissions");
gSettings.ocBooterQuirks.SyncRuntimePermissions = !IsPropertyNotNullAndFalse(Prop); gSettings.Quirks.ocBooterQuirks.SyncRuntimePermissions = !IsPropertyNotNullAndFalse(Prop);
gSettings.QuirksMask |= gSettings.ocBooterQuirks.SyncRuntimePermissions? QUIRK_PERM:0; gSettings.Quirks.QuirksMask |= gSettings.Quirks.ocBooterQuirks.SyncRuntimePermissions? QUIRK_PERM:0;
gSettings.mmioWhiteListArray.setEmpty(); gSettings.Quirks.mmioWhiteListArray.setEmpty();
const TagArray* Dict2 = OcQuirksDict->arrayPropertyForKey("MmioWhitelist"); // array of dict const TagArray* Dict2 = OcQuirksDict->arrayPropertyForKey("MmioWhitelist"); // array of dict
if (Dict2 != NULL) { if (Dict2 != NULL) {
@ -3290,8 +3284,8 @@ EFI_STATUS GetEarlyUserSettings (
for (INTN i = 0; i < Count; i++) for (INTN i = 0; i < Count; i++)
{ {
const TagDict* Dict3 = Dict2->dictElementAt(i, "MmioWhitelist"_XS8); const TagDict* Dict3 = Dict2->dictElementAt(i, "MmioWhitelist"_XS8);
MMIOWhiteList* mmioWhiteListPtr = new MMIOWhiteList(); SETTINGS_DATA::QuirksClass::MMIOWhiteList* mmioWhiteListPtr = new SETTINGS_DATA::QuirksClass::MMIOWhiteList();
MMIOWhiteList& mmioWhiteList = *mmioWhiteListPtr; SETTINGS_DATA::QuirksClass::MMIOWhiteList& mmioWhiteList = *mmioWhiteListPtr;
const TagStruct* Prop2 = Dict3->propertyForKey("Comment"); const TagStruct* Prop2 = Dict3->propertyForKey("Comment");
if (Prop2 != NULL && Prop2->isString() && Prop2->getString()->stringValue().notEmpty()) { if (Prop2 != NULL && Prop2->isString() && Prop2->getString()->stringValue().notEmpty()) {
@ -3306,7 +3300,7 @@ EFI_STATUS GetEarlyUserSettings (
Prop2 = Dict3->propertyForKey("Enabled"); Prop2 = Dict3->propertyForKey("Enabled");
mmioWhiteList.enabled = IsPropertyNotNullAndTrue(Prop2); mmioWhiteList.enabled = IsPropertyNotNullAndTrue(Prop2);
} }
gSettings.mmioWhiteListArray.AddReference(mmioWhiteListPtr, true); gSettings.Quirks.mmioWhiteListArray.AddReference(mmioWhiteListPtr, true);
} }
} }
} }
@ -4418,7 +4412,6 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
gSettings.Boot.NeverDoRecovery = IsPropertyNotNullAndTrue(Prop); gSettings.Boot.NeverDoRecovery = IsPropertyNotNullAndTrue(Prop);
} }
//Graphics //Graphics
const TagDict* GraphicsDict = CfgDict->dictPropertyForKey("Graphics"); const TagDict* GraphicsDict = CfgDict->dictPropertyForKey("Graphics");
@ -4427,11 +4420,10 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
const TagStruct* Prop = GraphicsDict->propertyForKey("Inject"); const TagStruct* Prop = GraphicsDict->propertyForKey("Inject");
if (Prop != NULL) { if (Prop != NULL) {
if (IsPropertyNotNullAndTrue(Prop)) { if (IsPropertyNotNullAndTrue(Prop)) {
gSettings.Graphics.InjectAsBool = true; gSettings.Graphics.InjectAsDict.GraphicsInjector = TRUE;
// gSettings.GraphicsInjector = TRUE; gSettings.Graphics.InjectAsDict.InjectIntel = TRUE;
// gSettings.InjectIntel = TRUE; gSettings.Graphics.InjectAsDict.InjectATI = TRUE;
// gSettings.InjectATI = TRUE; gSettings.Graphics.InjectAsDict.InjectNVidia = TRUE;
// gSettings.InjectNVidia = TRUE;
} else if (Prop->isDict()) { } else if (Prop->isDict()) {
const TagDict* Dict2 = Prop->getDict(); const TagDict* Dict2 = Prop->getDict();
const TagStruct* Prop2 = Dict2->propertyForKey("Intel"); const TagStruct* Prop2 = Dict2->propertyForKey("Intel");
@ -4449,10 +4441,10 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
gSettings.Graphics.InjectAsDict.InjectNVidia = IsPropertyNotNullAndTrue(Prop2); gSettings.Graphics.InjectAsDict.InjectNVidia = IsPropertyNotNullAndTrue(Prop2);
} }
} else { } else {
// gSettings.GraphicsInjector = FALSE; gSettings.Graphics.InjectAsDict.GraphicsInjector = FALSE;
// gSettings.InjectIntel = FALSE; gSettings.Graphics.InjectAsDict.InjectIntel = FALSE;
// gSettings.InjectATI = FALSE; gSettings.Graphics.InjectAsDict.InjectATI = FALSE;
// gSettings.InjectNVidia = FALSE; gSettings.Graphics.InjectAsDict.InjectNVidia = FALSE;
} }
} }
@ -4536,8 +4528,18 @@ EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
Prop = GraphicsDict->propertyForKey("snb-platform-id"); Prop = GraphicsDict->propertyForKey("snb-platform-id");
gSettings.Graphics.IgPlatform = (UINT32)GetPropertyAsInteger(Prop, gSettings.Graphics.IgPlatform); gSettings.Graphics.IgPlatform = (UINT32)GetPropertyAsInteger(Prop, gSettings.Graphics.IgPlatform);
FillCardList(GraphicsDict); //#@ Getcardslist FillCardList(GraphicsDict, gSettings); //#@ Getcardslist
} }
//done until here
const TagDict* DevicesDict = CfgDict->dictPropertyForKey("Devices"); const TagDict* DevicesDict = CfgDict->dictPropertyForKey("Devices");
if (DevicesDict != NULL) { if (DevicesDict != NULL) {

View File

@ -18,24 +18,6 @@
#define CLOVER_SIGN SIGNATURE_32('C','l','v','r') #define CLOVER_SIGN SIGNATURE_32('C','l','v','r')
#define QUIRK_DEFRAG bit(0)
#define QUIRK_MMIO bit(1)
#define QUIRK_SU bit(2)
#define QUIRK_VAR bit(3)
#define QUIRK_HIBER bit(4)
#define QUIRK_SAFE bit(5)
#define QUIRK_UNPROT bit(6)
#define QUIRK_EXIT bit(7)
#define QUIRK_REGION bit(8)
#define QUIRK_SECURE bit(9)
#define QUIRK_UEFI bit(10)
#define QUIRK_CUSTOM bit(11)
#define QUIRK_MAP bit(12)
#define QUIRK_VIRT bit(13)
#define QUIRK_OS bit(14)
#define QUIRK_PERM bit(15)
//// SysVariables //// SysVariables
//typedef struct SYSVARIABLES SYSVARIABLES; //typedef struct SYSVARIABLES SYSVARIABLES;
//struct SYSVARIABLES //struct SYSVARIABLES
@ -408,21 +390,6 @@ public:
DEV_PROPERTY& operator=(const DEV_PROPERTY&) = delete; DEV_PROPERTY& operator=(const DEV_PROPERTY&) = delete;
}; };
class MMIOWhiteList
{
public :
UINTN address;
XString8 comment;
bool enabled;
MMIOWhiteList() : address(0), comment(), enabled(false) { }
// Not sure if default are valid. Delete them. If needed, proper ones can be created
MMIOWhiteList(const MMIOWhiteList&) = delete;
MMIOWhiteList& operator=(const MMIOWhiteList&) = delete;
};
/** /**
Set of Search & replace bytes for VideoBiosPatchBytes(). Set of Search & replace bytes for VideoBiosPatchBytes().
this is supposed to be a replacement of VBIOS_PATCH_BYTES, but that would need VbiosPatchLibrary to be update to C++. Quite easy, but need cpp_fundation to become a library. TODO this is supposed to be a replacement of VBIOS_PATCH_BYTES, but that would need VbiosPatchLibrary to be update to C++. Quite easy, but need cpp_fundation to become a library. TODO
@ -674,6 +641,7 @@ public:
class InjectAsDictClass { class InjectAsDictClass {
public: public:
bool GraphicsInjector = bool();
bool InjectIntel = bool(); bool InjectIntel = bool();
bool InjectATI = bool(); bool InjectATI = bool();
bool InjectNVidia = bool(); bool InjectNVidia = bool();
@ -692,7 +660,7 @@ public:
bool PatchVBios = bool(); bool PatchVBios = bool();
PatchVBiosBytesNewClass PatchVBiosBytes = PatchVBiosBytesNewClass(); PatchVBiosBytesNewClass PatchVBiosBytes = PatchVBiosBytesNewClass();
undefinable_bool InjectAsBool = undefinable_bool(); // undefinable_bool InjectAsBool = undefinable_bool();
bool RadeonDeInit = bool(); bool RadeonDeInit = bool();
bool LoadVBios = bool(); bool LoadVBios = bool();
UINT64 VRAM = bool(); UINT64 VRAM = bool();
@ -709,13 +677,14 @@ public:
UINT32 IgPlatform = UINT32(); //could also be snb-platform-id UINT32 IgPlatform = UINT32(); //could also be snb-platform-id
EDIDClass EDID = EDIDClass(); EDIDClass EDID = EDIDClass();
InjectAsDictClass InjectAsDict = InjectAsDictClass(); InjectAsDictClass InjectAsDict = InjectAsDictClass();
XObjArray<GRAPHIC_CARD> gCardList = XObjArray<GRAPHIC_CARD>(); XObjArray<GRAPHIC_CARD> ATICardList = XObjArray<GRAPHIC_CARD>();
XObjArray<GRAPHIC_CARD> NVIDIACardList = XObjArray<GRAPHIC_CARD>();
//bool getGraphicsInjector() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.GraphicsInjector; } //bool getGraphicsInjector() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.GraphicsInjector; }
bool InjectIntel() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectIntel; } //bool InjectIntel() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectIntel; }
bool InjectATI() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectATI; } //bool InjectATI() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectATI; }
bool InjectNVidia() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectNVidia; } //bool InjectNVidia() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectNVidia; }
}; };
@ -731,11 +700,23 @@ public:
class QuirksClass { class QuirksClass {
public: public:
class MMIOWhiteList
{
public :
UINTN address = 0;
XString8 comment = XString8();
bool enabled = 0;
};
bool FuzzyMatch = bool(); bool FuzzyMatch = bool();
XString8 OcKernelCache = XString8(); XString8 OcKernelCache = XString8();
// UINTN MaxSlide;
OC_KERNEL_QUIRKS OcKernelQuirks = OC_KERNEL_QUIRKS(); OC_KERNEL_QUIRKS OcKernelQuirks = OC_KERNEL_QUIRKS();
OC_BOOTER_QUIRKS ocBooterQuirks = OC_BOOTER_QUIRKS();
XObjArray<MMIOWhiteList> mmioWhiteListArray = XObjArray<MMIOWhiteList>();
UINT32 QuirksMask;
}; };
class RtVariablesClass { class RtVariablesClass {
public: public:
class RT_VARIABLES class RT_VARIABLES
@ -947,12 +928,6 @@ public:
DEV_PROPERTY *ArbProperties; DEV_PROPERTY *ArbProperties;
UINT32 QuirksMask;
UINTN MaxSlide;
OC_BOOTER_QUIRKS ocBooterQuirks;
XObjArray<MMIOWhiteList> mmioWhiteListArray;
SETTINGS_DATA() : VendorName(), RomVersion(), EfiVersion(), ReleaseDate(), ManufactureName(), ProductName(), VersionNr(), SerialNr(), SmUUID(), SETTINGS_DATA() : VendorName(), RomVersion(), EfiVersion(), ReleaseDate(), ManufactureName(), ProductName(), VersionNr(), SerialNr(), SmUUID(),
@ -973,7 +948,7 @@ public:
ForceHPET(0), DisableFunctions(0), SlpWak(0), UseIntelHDMI(0), ForceHPET(0), DisableFunctions(0), SlpWak(0), UseIntelHDMI(0),
AFGLowPowerState(0), NrAddProperties(0), AddProperties(0), BlockKexts{0}, AFGLowPowerState(0), NrAddProperties(0), AddProperties(0), BlockKexts{0},
IntelMaxValue(0), OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0}, IntelMaxValue(0), OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0},
ArbProperties(0), QuirksMask(0), MaxSlide(0), ocBooterQuirks{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, mmioWhiteListArray() ArbProperties(0)
{}; {};
SETTINGS_DATA(const SETTINGS_DATA& other) = delete; // Can be defined if needed SETTINGS_DATA(const SETTINGS_DATA& other) = delete; // Can be defined if needed
const SETTINGS_DATA& operator = ( const SETTINGS_DATA & ) = delete; // Can be defined if needed const SETTINGS_DATA& operator = ( const SETTINGS_DATA & ) = delete; // Can be defined if needed

View File

@ -82,8 +82,14 @@
const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* FindCardWithIds(UINT32 Id, UINT32 SubId) const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* FindCardWithIds(UINT32 Id, UINT32 SubId)
{ {
for ( size_t idx = 0; idx < gSettings.Graphics.gCardList.size(); ++idx ) { for ( size_t idx = 0; idx < gSettings.Graphics.ATICardList.size(); ++idx ) {
const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD& entry = gSettings.Graphics.gCardList[idx]; const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD& entry = gSettings.Graphics.ATICardList[idx];
if(entry.Id == Id) {
return &entry;
}
}
for ( size_t idx = 0; idx < gSettings.Graphics.NVIDIACardList.size(); ++idx ) {
const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD& entry = gSettings.Graphics.NVIDIACardList[idx];
if(entry.Id == Id) { if(entry.Id == Id) {
return &entry; return &entry;
} }
@ -91,10 +97,19 @@ const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* FindCardWithIds(UINT32 Id, UIN
return NULL; return NULL;
} }
void FillCardList(const TagDict* CfgDict) /*
* To ease copy/paste and text replacement from GetUserSettings, the parameter has the same name as the global
* and is passed by non-const reference.
* This temporary during the refactoring
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
void FillCardList(const TagDict* CfgDict, SETTINGS_DATA& gSettings)
{ {
if (gSettings.Graphics.gCardList.isEmpty() && (CfgDict != NULL)) { #pragma GCC diagnostic pop
CONST CHAR8 *VEN[] = { "NVIDIA", "ATI" }; if (gSettings.Graphics.ATICardList.isEmpty() && gSettings.Graphics.NVIDIACardList.isEmpty() && (CfgDict != NULL)) {
CONST CHAR8 *VEN[] = { "ATI", "NVIDIA" };
XObjArray<SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD>* cardlist[] = { &gSettings.Graphics.ATICardList, &gSettings.Graphics.NVIDIACardList };
size_t Count = sizeof(VEN) / sizeof(VEN[0]); size_t Count = sizeof(VEN) / sizeof(VEN[0]);
for (size_t Index = 0; Index < Count; Index++) { for (size_t Index = 0; Index < Count; Index++) {
@ -120,13 +135,13 @@ void FillCardList(const TagDict* CfgDict)
// BOOLEAN LoadVBios = FALSE; // BOOLEAN LoadVBios = FALSE;
element = &prop->arrayContent()[i]; element = &prop->arrayContent()[i];
if ( !element->isDict()) { if ( !element->isDict()) {
MsgLog("MALFORMED PLIST in FillCardList() : element is not a dict"); MsgLog("MALFORMED PLIST in FillCardList() : element[%lld] is not a dict\n", i);
continue; continue;
} }
const TagDict* dictElement = element->getDict(); const TagDict* dictElement = element->getDict();
prop2 = dictElement->propertyForKey("Model"); prop2 = dictElement->propertyForKey("Model");
if ( prop2->isString() && prop2->getString()->stringValue().notEmpty() ) { if ( prop2 && prop2->isString() && prop2->getString()->stringValue().notEmpty() ) {
new_card->Model = prop2->getString()->stringValue(); new_card->Model = prop2->getString()->stringValue();
} else { } else {
new_card->Model = "VideoCard"_XS8; new_card->Model = "VideoCard"_XS8;
@ -159,7 +174,7 @@ void FillCardList(const TagDict* CfgDict)
// new_card->VideoPorts = VideoPorts; // new_card->VideoPorts = VideoPorts;
// new_card->LoadVBios = LoadVBios; // new_card->LoadVBios = LoadVBios;
// new_card->Model.takeValueFrom(model_name); // new_card->Model.takeValueFrom(model_name);
gSettings.Graphics.gCardList.AddReference(new_card, true); cardlist[Index]->AddReference(new_card, true);
} }
} }
} }

View File

@ -14,10 +14,7 @@
#define CARDLIST_SIGNATURE SIGNATURE_32('C','A','R','D') #define CARDLIST_SIGNATURE SIGNATURE_32('C','A','R','D')
void void FillCardList(const TagDict* CfgDict, SETTINGS_DATA& gSettings);
FillCardList (
const TagDict* CfgDict
);
const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD* const SETTINGS_DATA::GraphicsClass::GRAPHIC_CARD*
FindCardWithIds ( FindCardWithIds (

View File

@ -0,0 +1,33 @@
/*
* QuirksCodes.h
*
* Created on: Mar 28, 2021
* Author: jief
*/
#ifndef INCLUDE_QUIRKSCODES_H_
#define INCLUDE_QUIRKSCODES_H_
#define QUIRK_DEFRAG bit(0)
#define QUIRK_MMIO bit(1)
#define QUIRK_SU bit(2)
#define QUIRK_VAR bit(3)
#define QUIRK_HIBER bit(4)
#define QUIRK_SAFE bit(5)
#define QUIRK_UNPROT bit(6)
#define QUIRK_EXIT bit(7)
#define QUIRK_REGION bit(8)
#define QUIRK_SECURE bit(9)
#define QUIRK_UEFI bit(10)
#define QUIRK_CUSTOM bit(11)
#define QUIRK_MAP bit(12)
#define QUIRK_VIRT bit(13)
#define QUIRK_OS bit(14)
#define QUIRK_PERM bit(15)
#endif /* INCLUDE_QUIRKSCODES_H_ */

View File

@ -47,6 +47,7 @@
include/XToolsConf.h include/XToolsConf.h
include/OC.h include/OC.h
include/printf_lite-test-cpp_conf.h include/printf_lite-test-cpp_conf.h
include/QuirksCodes.h
include/BootTypes.h include/BootTypes.h
include/OSTypes.h include/OSTypes.h
include/OSFlags.h include/OSFlags.h

View File

@ -976,7 +976,7 @@ void LOADER_ENTRY::StartLoader()
#ifndef USE_OC_SECTION_Booter #ifndef USE_OC_SECTION_Booter
mOpenCoreConfiguration.Booter.MmioWhitelist.Count = (UINT32)gSettings.mmioWhiteListArray.size(); mOpenCoreConfiguration.Booter.MmioWhitelist.Count = (UINT32)gSettings.Quirks.mmioWhiteListArray.size();
mOpenCoreConfiguration.Booter.MmioWhitelist.AllocCount = mOpenCoreConfiguration.Booter.MmioWhitelist.Count; mOpenCoreConfiguration.Booter.MmioWhitelist.AllocCount = mOpenCoreConfiguration.Booter.MmioWhitelist.Count;
mOpenCoreConfiguration.Booter.MmioWhitelist.ValueSize = sizeof(__typeof_am__(**mOpenCoreConfiguration.Booter.MmioWhitelist.Values)); // sizeof(OC_KERNEL_ADD_ENTRY) == 680 mOpenCoreConfiguration.Booter.MmioWhitelist.ValueSize = sizeof(__typeof_am__(**mOpenCoreConfiguration.Booter.MmioWhitelist.Values)); // sizeof(OC_KERNEL_ADD_ENTRY) == 680
if ( mOpenCoreConfiguration.Booter.MmioWhitelist.Count > 0 ) { if ( mOpenCoreConfiguration.Booter.MmioWhitelist.Count > 0 ) {
@ -984,8 +984,8 @@ void LOADER_ENTRY::StartLoader()
}else{ }else{
mOpenCoreConfiguration.Booter.MmioWhitelist.Values = NULL; mOpenCoreConfiguration.Booter.MmioWhitelist.Values = NULL;
} }
for ( size_t idx = 0 ; idx < gSettings.mmioWhiteListArray.size() ; idx++ ) { for ( size_t idx = 0 ; idx < gSettings.Quirks.mmioWhiteListArray.size() ; idx++ ) {
const MMIOWhiteList& entry = gSettings.mmioWhiteListArray[idx]; const SETTINGS_DATA::QuirksClass::MMIOWhiteList& entry = gSettings.Quirks.mmioWhiteListArray[idx];
DBG("Bridge mmioWhiteList[%zu] to OC : comment=%s\n", idx, entry.comment.c_str()); DBG("Bridge mmioWhiteList[%zu] to OC : comment=%s\n", idx, entry.comment.c_str());
mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx] = (__typeof_am__(*mOpenCoreConfiguration.Booter.MmioWhitelist.Values))AllocatePool(mOpenCoreConfiguration.Booter.MmioWhitelist.ValueSize); mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx] = (__typeof_am__(*mOpenCoreConfiguration.Booter.MmioWhitelist.Values))AllocatePool(mOpenCoreConfiguration.Booter.MmioWhitelist.ValueSize);
mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Address = entry.address; mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Address = entry.address;
@ -993,8 +993,8 @@ void LOADER_ENTRY::StartLoader()
mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Enabled = entry.enabled; mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Enabled = entry.enabled;
} }
static_assert(sizeof(gSettings.ocBooterQuirks) == sizeof(mOpenCoreConfiguration.Booter.Quirks), "sizeof(gSettings.ocBooterQuirks) == sizeof(mOpenCoreConfiguration.Booter.Quirks)"); static_assert(sizeof(gSettings.Quirks.ocBooterQuirks) == sizeof(mOpenCoreConfiguration.Booter.Quirks), "sizeof(gSettings.Quirks.ocBooterQuirks) == sizeof(mOpenCoreConfiguration.Booter.Quirks)");
memcpy(&mOpenCoreConfiguration.Booter.Quirks, &gSettings.ocBooterQuirks, sizeof(mOpenCoreConfiguration.Booter.Quirks)); memcpy(&mOpenCoreConfiguration.Booter.Quirks, &gSettings.Quirks.ocBooterQuirks, sizeof(mOpenCoreConfiguration.Booter.Quirks));
#endif #endif

View File

@ -56,6 +56,7 @@
#include "../Platform/Nvram.h" #include "../Platform/Nvram.h"
#include "../include/DsdtFixList.h" #include "../include/DsdtFixList.h"
#include "../include/Devices.h" #include "../include/Devices.h"
#include "../include/QuirksCodes.h"
#include "../Platform/boot.h" #include "../Platform/boot.h"
#include "../Platform/Injectors.h" #include "../Platform/Injectors.h"
#include "../Platform/KextList.h" #include "../Platform/KextList.h"
@ -389,7 +390,7 @@ void FillInputs(BOOLEAN New)
InputItems[InputItemsCount].ItemType = Hex; //100 InputItems[InputItemsCount].ItemType = Hex; //100
InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeXHCI); InputItems[InputItemsCount++].SValue.SWPrintf("0x%08X", gSettings.FakeXHCI);
InputItems[InputItemsCount].ItemType = CheckBit; //101 - Quirks InputItems[InputItemsCount].ItemType = CheckBit; //101 - Quirks
InputItems[InputItemsCount++].IValue = gSettings.QuirksMask; // InputItems[InputItemsCount++].IValue = gSettings.Quirks.QuirksMask; //
InputItems[InputItemsCount].ItemType = BoolValue; //102 InputItems[InputItemsCount].ItemType = BoolValue; //102
InputItems[InputItemsCount++].BValue = gSettings.ACPI.DSDT.DebugDSDT; InputItems[InputItemsCount++].BValue = gSettings.ACPI.DSDT.DebugDSDT;
@ -442,7 +443,7 @@ void FillInputs(BOOLEAN New)
InputItems[InputItemsCount].ItemType = BoolValue; //121 InputItems[InputItemsCount].ItemType = BoolValue; //121
InputItems[InputItemsCount++].BValue = gSettings.KernelAndKextPatches.KPPanicNoKextDump; InputItems[InputItemsCount++].BValue = gSettings.KernelAndKextPatches.KPPanicNoKextDump;
InputItems[InputItemsCount].ItemType = Decimal; //122 InputItems[InputItemsCount].ItemType = Decimal; //122
InputItems[InputItemsCount++].SValue.SWPrintf("%04lld", gSettings.MaxSlide); InputItems[InputItemsCount++].SValue.SWPrintf("%04hhu", gSettings.Quirks.ocBooterQuirks.ProvideMaxSlide);
InputItems[InputItemsCount].ItemType = BoolValue; //123 InputItems[InputItemsCount].ItemType = BoolValue; //123
InputItems[InputItemsCount++].BValue = gSettings.GUI.ProvideConsoleGop; InputItems[InputItemsCount++].BValue = gSettings.GUI.ProvideConsoleGop;
@ -907,24 +908,24 @@ void ApplyInputs(void)
i++; //101 - Quirks i++; //101 - Quirks
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.QuirksMask = InputItems[i].IValue; gSettings.Quirks.QuirksMask = InputItems[i].IValue;
gSettings.ocBooterQuirks.AvoidRuntimeDefrag = ((gSettings.QuirksMask & QUIRK_DEFRAG) != 0); //1 gSettings.Quirks.ocBooterQuirks.AvoidRuntimeDefrag = ((gSettings.Quirks.QuirksMask & QUIRK_DEFRAG) != 0); //1
gSettings.ocBooterQuirks.DevirtualiseMmio = ((gSettings.QuirksMask & QUIRK_MMIO) != 0); //0 gSettings.Quirks.ocBooterQuirks.DevirtualiseMmio = ((gSettings.Quirks.QuirksMask & QUIRK_MMIO) != 0); //0
gSettings.ocBooterQuirks.DisableSingleUser = ((gSettings.QuirksMask & QUIRK_SU) != 0); //0 gSettings.Quirks.ocBooterQuirks.DisableSingleUser = ((gSettings.Quirks.QuirksMask & QUIRK_SU) != 0); //0
gSettings.ocBooterQuirks.DisableVariableWrite = ((gSettings.QuirksMask & QUIRK_VAR) != 0); //0 gSettings.Quirks.ocBooterQuirks.DisableVariableWrite = ((gSettings.Quirks.QuirksMask & QUIRK_VAR) != 0); //0
gSettings.ocBooterQuirks.DiscardHibernateMap = ((gSettings.QuirksMask & QUIRK_HIBER) != 0); //0 gSettings.Quirks.ocBooterQuirks.DiscardHibernateMap = ((gSettings.Quirks.QuirksMask & QUIRK_HIBER) != 0); //0
gSettings.ocBooterQuirks.EnableSafeModeSlide = ((gSettings.QuirksMask & QUIRK_SAFE) != 0); //1 gSettings.Quirks.ocBooterQuirks.EnableSafeModeSlide = ((gSettings.Quirks.QuirksMask & QUIRK_SAFE) != 0); //1
gSettings.ocBooterQuirks.EnableWriteUnprotector = ((gSettings.QuirksMask & QUIRK_UNPROT) != 0); //1 gSettings.Quirks.ocBooterQuirks.EnableWriteUnprotector = ((gSettings.Quirks.QuirksMask & QUIRK_UNPROT) != 0); //1
gSettings.ocBooterQuirks.ForceExitBootServices = ((gSettings.QuirksMask & QUIRK_EXIT) != 0); //0 gSettings.Quirks.ocBooterQuirks.ForceExitBootServices = ((gSettings.Quirks.QuirksMask & QUIRK_EXIT) != 0); //0
gSettings.ocBooterQuirks.ProtectMemoryRegions = ((gSettings.QuirksMask & QUIRK_REGION) != 0); //0 gSettings.Quirks.ocBooterQuirks.ProtectMemoryRegions = ((gSettings.Quirks.QuirksMask & QUIRK_REGION) != 0); //0
gSettings.ocBooterQuirks.ProtectSecureBoot = ((gSettings.QuirksMask & QUIRK_SECURE) != 0); //0 gSettings.Quirks.ocBooterQuirks.ProtectSecureBoot = ((gSettings.Quirks.QuirksMask & QUIRK_SECURE) != 0); //0
gSettings.ocBooterQuirks.ProtectUefiServices = ((gSettings.QuirksMask & QUIRK_UEFI) != 0); //0 gSettings.Quirks.ocBooterQuirks.ProtectUefiServices = ((gSettings.Quirks.QuirksMask & QUIRK_UEFI) != 0); //0
gSettings.ocBooterQuirks.ProvideCustomSlide = ((gSettings.QuirksMask & QUIRK_CUSTOM) != 0); //1 gSettings.Quirks.ocBooterQuirks.ProvideCustomSlide = ((gSettings.Quirks.QuirksMask & QUIRK_CUSTOM) != 0); //1
gSettings.ocBooterQuirks.RebuildAppleMemoryMap = ((gSettings.QuirksMask & QUIRK_MAP) != 0); //0 gSettings.Quirks.ocBooterQuirks.RebuildAppleMemoryMap = ((gSettings.Quirks.QuirksMask & QUIRK_MAP) != 0); //0
gSettings.ocBooterQuirks.SetupVirtualMap = ((gSettings.QuirksMask & QUIRK_VIRT) != 0); //1 gSettings.Quirks.ocBooterQuirks.SetupVirtualMap = ((gSettings.Quirks.QuirksMask & QUIRK_VIRT) != 0); //1
gSettings.ocBooterQuirks.SignalAppleOS = ((gSettings.QuirksMask & QUIRK_OS) != 0); //0 gSettings.Quirks.ocBooterQuirks.SignalAppleOS = ((gSettings.Quirks.QuirksMask & QUIRK_OS) != 0); //0
gSettings.ocBooterQuirks.SyncRuntimePermissions = ((gSettings.QuirksMask & QUIRK_PERM) != 0); //1 gSettings.Quirks.ocBooterQuirks.SyncRuntimePermissions = ((gSettings.Quirks.QuirksMask & QUIRK_PERM) != 0); //1
DBG("applied Quirks mask:%x\n", gSettings.QuirksMask); //default is 0xA861 DBG("applied Quirks mask:%x\n", gSettings.Quirks.QuirksMask); //default is 0xA861
} }
i++; //102 i++; //102
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
@ -1056,8 +1057,8 @@ void ApplyInputs(void)
} }
i++; //122 i++; //122
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
gSettings.MaxSlide = (UINTN)StrDecimalToUintn(InputItems[i].SValue.wc_str()); gSettings.Quirks.ocBooterQuirks.ProvideMaxSlide = (UINTN)StrDecimalToUintn(InputItems[i].SValue.wc_str());
DBG(" set MaxSlide = %lld\n", gSettings.MaxSlide); DBG(" set MaxSlide = %hhu\n", gSettings.Quirks.ocBooterQuirks.ProvideMaxSlide);
} }
i++; //123 i++; //123
if (InputItems[i].Valid) { if (InputItems[i].Valid) {
@ -2445,7 +2446,7 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuQuirks()
// create the entry in the main menu // create the entry in the main menu
Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_QUIRKS, NullXString8); Entry = newREFIT_MENU_ITEM_OPTIONS(&SubScreen, ActionEnter, SCREEN_QUIRKS, NullXString8);
Entry->Title.SWPrintf("Quirks mask [0x%04x]->", gSettings.QuirksMask); Entry->Title.SWPrintf("Quirks mask [0x%04x]->", gSettings.Quirks.QuirksMask);
// submenu description // submenu description
SubScreen->AddMenuInfoLine_f("Choose options to fix memory"); SubScreen->AddMenuInfoLine_f("Choose options to fix memory");