Skip to content

Commit

Permalink
make FakeCPUID from SMBIOS
Browse files Browse the repository at this point in the history
Signed-off-by: Slice <sergey.slice@gmail.com>
  • Loading branch information
SergeySlice committed Jun 22, 2023
1 parent bff29f8 commit 2d14297
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 175 deletions.
4 changes: 4 additions & 0 deletions CloverPackage/CloverV2/EFI/CLOVER/config-sample.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,8 @@
<string>0x8FE001403</string>
<key>ExtendedFirmwareFeaturesMask?</key>
<string>0xFFFFFFFFFF</string>
<key>FakeCPUID</key>
<string>0x0406E1</string>
<key>Family?</key>
<string>iMac</string>
<key>FirmwareFeatures?</key>
Expand Down Expand Up @@ -1285,6 +1287,8 @@
<string>0xE00DE137</string>
<key>FirmwareFeaturesMask</key>
<string>0xFF1FFF3F</string>
<key>FakeCPUID</key>
<string>0x0406E1</string>
<key>LocationInChassis</key>
<string>Part Component</string>
<key>Manufacturer</key>
Expand Down
1 change: 1 addition & 0 deletions rEFIt_UEFI/Platform/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ XObjArray<ACPI_PATCHED_AML> ACPIPatchedAML;
CHAR16 *IconFormat = NULL;

SETTINGS_DATA gSettings;
UINT32 gFakeCPUID;

EFI_EDID_DISCOVERED_PROTOCOL *EdidDiscovered;

Expand Down
23 changes: 9 additions & 14 deletions rEFIt_UEFI/Platform/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2248,11 +2248,10 @@ printf("%s", "");

};

class SmbiosClass {
class SmbiosClass
{
public:



class SlotDeviceClass
{
public:
Expand Down Expand Up @@ -2386,7 +2385,7 @@ printf("%s", "");
XString8 ProductName = XString8();
XString8 SystemVersion = XString8();
XString8 SerialNr = XString8();
EFI_GUID SmUUID = EFI_GUID();
EFI_GUID SmUUID = EFI_GUID();
XString8 FamilyName = XString8();
// SMBIOS TYPE2
XString8 BoardManufactureName = XString8();
Expand All @@ -2401,6 +2400,7 @@ printf("%s", "");
XString8 ChassisManufacturer = XString8();
XString8 ChassisAssetTag = XString8();
// SMBIOS TYPE4
UINT32 SFakeCPU = UINT32();
// SMBIOS TYPE17
UINT16 SmbiosVersion = UINT16();
INT8 Attribute = INT8();
Expand Down Expand Up @@ -2456,6 +2456,8 @@ printf("%s", "");
if ( !(ChassisType == other.ChassisType) ) return false;
if ( !(ChassisManufacturer == other.ChassisManufacturer) ) return false;
if ( !(ChassisAssetTag == other.ChassisAssetTag) ) return false;
// SMBIOS TYPE4
if ( !(SFakeCPU == other.SFakeCPU) ) return false;
// SMBIOS TYPE17
if ( !(SmbiosVersion == other.SmbiosVersion) ) return false;
if ( !(Attribute == other.Attribute) ) return false;
Expand Down Expand Up @@ -2506,6 +2508,8 @@ printf("%s", "");
ChassisType = other.dgetChassisType();
ChassisManufacturer = other.dgetChassisManufacturer();
ChassisAssetTag = other.dgetChassisAssetTag();
// SMBIOS TYPE4
SFakeCPU = other.dgetFakeCPUID();
// SMBIOS TYPE17
SmbiosVersion = other.dgetSmbiosVersion();
Attribute = other.dgetAttribute();
Expand All @@ -2523,6 +2527,7 @@ printf("%s", "");
ExtendedFirmwareFeaturesMask = other.dgetExtendedFirmwareFeaturesMask();
RamSlotInfoArray.takeValueFrom(other.Memory);
SlotDevices.takeValueFrom(other.Slots);

}

};
Expand Down Expand Up @@ -2573,10 +2578,6 @@ printf("%s", "");
BootGraphicsClass BootGraphics = BootGraphicsClass();


//other
// UINT16 DropOEM_DSM; // not used anymore.
// XBool LpcTune; // never set to true.

SETTINGS_DATA() {}
// 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
Expand Down Expand Up @@ -2825,12 +2826,6 @@ SetBootCurrent(REFIT_MENU_ITEM_BOOTNUM *LoadedEntry);




//void
//GetDevices(void);



void afterGetUserSettings(SETTINGS_DATA& gSettings);

XStringW
Expand Down
6 changes: 0 additions & 6 deletions rEFIt_UEFI/Settings/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,12 +885,6 @@ EFI_STATUS ConfigManager::LoadConfig(const XStringW& ConfName)
}
}

// DBG("made entries SMBIOS:\n");
// for (size_t i=0; i<SmbiosList.size(); i++) {
// DBG("--- %ls\n", SmbiosList[i].wc_str());
// }


if ( smbiosPlist.getSMBIOS().isDefined() && smbiosPlist.getSMBIOS().getProductName().isDefined() ) {
GlobalConfig.CurrentModel = smbiosPlist.SMBIOS.dgetModel();
DBG("get model from smbios.plist\n");
Expand Down
3 changes: 2 additions & 1 deletion rEFIt_UEFI/Settings/ConfigPlist/ConfigPlistClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {
}
#include "../../Platform/cpu.h"

extern UINT8 default_NVCAP[]; // dependecy problem. TODO
extern UINT8 default_NVCAP[]; // dependency problem. TODO
extern const UINT8 default_dcfg_0[];
extern const UINT8 default_dcfg_1[];

Expand All @@ -48,6 +48,7 @@ extern const UINT8 default_dcfg_1[];
#include "ConfigPlistAbstract.h"
#include "SMBIOSPlist.h"

extern SETTINGS_DATA gSettings;

class ConfigPlistClass : public ConfigPlistAbstractClass
{
Expand Down
16 changes: 0 additions & 16 deletions rEFIt_UEFI/Settings/ConfigPlist/Config_KernelAndKextPatches.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,6 @@ class KernelAndKextPatches_Class : public XmlDict
XmlString8AllowEmpty MatchOS = XmlString8AllowEmpty(); // validation ?
XmlString8AllowEmpty MatchBuild = XmlString8AllowEmpty(); // validation ?

// XmlDictField m_fields[13] = {
// {"Comment", Comment},
// {"Disabled", Disabled},
// {"RangeFind", RangeFind},
// {"Skip", Skip},
// {"StartPattern", StartPattern},
// {"MaskStart", MaskStart},
// {"Find", Find},
// {"Replace", Replace},
// {"MaskFind", MaskFind},
// {"MaskReplace", MaskReplace},
// {"Count", Count},
// {"MatchOS", MatchOS},
// {"MatchBuild", MatchBuild},
// };

public:
// virtual void getFields(XmlDictField** fields, size_t* nb) override { *fields = m_fields; *nb = sizeof(m_fields)/sizeof(m_fields[0]); };
virtual void getFields(XmlDictField** fields, size_t* nb) override { panic("BUG: This cannot be called"); };
Expand Down
33 changes: 14 additions & 19 deletions rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "../../Platform/platformdata.h"
#include "../../Platform/smbios.h"
#include "../../Platform/VersionString.h" // for AsciiStrVersionToUint64
//#include "../../Platform/Settings.h"
//#include "../cpu.h"

#include "../../cpp_lib/undefinable.h"
Expand Down Expand Up @@ -51,7 +52,7 @@ extern XStringWArray SmbiosList;
extern INTN OldChosenTheme;
extern INTN OldChosenConfig;
extern INTN OldChosenSmbios;

extern UINT32 gFakeCPUID;


class SmbiosPlistClass : public ConfigPlistAbstractClass
Expand Down Expand Up @@ -149,7 +150,7 @@ class SmbiosPlistClass : public ConfigPlistAbstractClass
return MemoryTypeDdr;
}
// Cannot happen if validate has been done properly.
panic("invalid value");
panic("invalid DDRx value");
}
// XBool dgetInUse() const { return Size.isDefined() ? Size.value() > 0 : false; };

Expand Down Expand Up @@ -441,6 +442,7 @@ class SmbiosPlistClass : public ConfigPlistAbstractClass
XmlBool Trust = XmlBool();
XmlUInt64 PlatformFeature = XmlUInt64();
XmlBool NoRomInfo = XmlBool();
XmlUInt32 FakeCPUID = XmlUInt32();

XmlUInt32 FirmwareFeatures = XmlUInt32(); // gFwFeatures
XmlUInt32 FirmwareFeaturesMask = XmlUInt32();
Expand All @@ -452,7 +454,7 @@ class SmbiosPlistClass : public ConfigPlistAbstractClass
MemoryDictClass Memory = MemoryDictClass();
SlotDeviceArrayClass Slots = SlotDeviceArrayClass();

XmlDictField m_fields[31] = { //31
XmlDictField m_fields[32] = { //32 up to FakeCPUID
{"Trust", Trust},
{"MemoryRank", MemoryRank},
{"Memory", Memory},
Expand Down Expand Up @@ -484,6 +486,7 @@ class SmbiosPlistClass : public ConfigPlistAbstractClass
{"ChassisAssetTag", ChassisAssetTag},
{"ChassisType", ChassisType},
{"NoRomInfo", NoRomInfo},
{"FakeCPUID", FakeCPUID},
};

virtual void getFields(XmlDictField** fields, size_t* nb) override { *fields = m_fields; *nb = sizeof(m_fields)/sizeof(m_fields[0]); };
Expand Down Expand Up @@ -580,23 +583,9 @@ class SmbiosPlistClass : public ConfigPlistAbstractClass
const decltype(ChassisAssetTag)& getChassisAssetTag() const { return ChassisAssetTag; }
const decltype(ChassisType)& getChassisType() const { return ChassisType; }
const decltype(NoRomInfo)& getNoRomInfo() const { return NoRomInfo; }
// const decltype(FakeCPUID)& getFakeCPUID() const { return FakeCPUID.isDefined() ? FakeCPUID.value() : gSettings.KernelAndKextPatches.FakeCPUID; };


// /*
// * DO NOT call this if !ProductName.isDefined()
// */
// MacModel getModel() const
// {
// if ( !ProductName.isDefined() ) {
// // This must not happen in Clover because Clover set a defaultMacModel
// // This must not happen in ccpv because ccpv doesn't call dget... methods
// log_technical_bug("%s : !ProductName.isDefined()", __PRETTY_FUNCTION__);
// return iMac132; // cannot return GetDefaultModel() because we don't want to link runtime configuration to the xml reading layer.
// }
// return GetModelFromString(ProductName.value()); // ProductName has been validated, so Model CANNOT be MaxMacModel
// }
// XBool hasModel() const { return ProductName.isDefined(); }

MacModel dgetModel() const
{
if ( ProductName.isDefined() ) return GetModelFromString(ProductName.value());
Expand Down Expand Up @@ -742,6 +731,7 @@ class SmbiosPlistClass : public ConfigPlistAbstractClass
return GetPlatformFeature(dgetModel());
};
const decltype(NoRomInfo)::ValueType& dgetNoRomInfo() const { return NoRomInfo.isDefined() ? NoRomInfo.value() : NoRomInfo.nullValue; };
const decltype(FakeCPUID)::ValueType& dgetFakeCPUID() const { return FakeCPUID.isDefined() ? FakeCPUID.value() : gFakeCPUID; };
decltype(FirmwareFeatures)::ValueType dgetFirmwareFeatures() const {
if ( FirmwareFeatures.isDefined() ) return FirmwareFeatures.value();
return GetFwFeatures(dgetModel());
Expand All @@ -757,7 +747,12 @@ class SmbiosPlistClass : public ConfigPlistAbstractClass
decltype(ExtendedFirmwareFeaturesMask)::ValueType dgetExtendedFirmwareFeaturesMask() const {
if ( ExtendedFirmwareFeaturesMask.isDefined() ) return ExtendedFirmwareFeaturesMask.value();
return GetExtFwFeaturesMask(dgetModel());
}
};
// decltype(FirmwareFeatures)::ValueType dgetFirmwareFeatures() const {
// if ( FirmwareFeatures.isDefined() ) return FirmwareFeatures.value();
// return GetFwFeatures(dgetModel());
// };


};

Expand Down
Loading

0 comments on commit 2d14297

Please sign in to comment.