Skip to content

Commit

Permalink
Allow SmbiosDictClass to work without ProductName defined (using a
Browse files Browse the repository at this point in the history
defaultMacModel member that has to be assigned before).
Move BiosVersion, BiosReleaseDate and EfiVersion checks in
SmbiosDictClass. Create warnings for incorrect values.
Rename MaxMachineType to MaxMacModel.
Remove GlobalConfig->BiosVersionUsed, ReleaseDateUsed and
EfiVersionUsed.
  • Loading branch information
jief666 committed Oct 19, 2021
1 parent 2988fb4 commit 710b2dc
Show file tree
Hide file tree
Showing 17 changed files with 332 additions and 226 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
9A3BA374261E7A3F009E8B0F /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA9E50025CD2FF400BD5E8B /* Utils.cpp */; };
9A3BA375261E7A5E009E8B0F /* guid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA923C325CD5B1F00BD5E8B /* guid.cpp */; };
9A3BA376261E7AF7009E8B0F /* b64cdecode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A36E51E24F3B82A007A1107 /* b64cdecode.cpp */; };
9A3E3A50271F35C40077F37E /* VersionString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3E3A4F271F35C40077F37E /* VersionString.cpp */; };
9A4185C02439F73A00BEAFB8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */; };
9A4FFA7E2451C8330050B38B /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4FFA7C2451C8330050B38B /* XString.cpp */; };
9A7D518424FC32F700FA1CC3 /* XBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A7D518124FC32F700FA1CC3 /* XBuffer.cpp */; };
Expand Down Expand Up @@ -100,6 +101,8 @@
9A36E4E324F3B537007A1107 /* xml.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xml.h; sourceTree = "<group>"; };
9A36E51D24F3B82A007A1107 /* b64cdecode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b64cdecode.h; sourceTree = "<group>"; };
9A36E51E24F3B82A007A1107 /* b64cdecode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = b64cdecode.cpp; sourceTree = "<group>"; };
9A3E3A4E271F35C40077F37E /* VersionString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionString.h; sourceTree = "<group>"; };
9A3E3A4F271F35C40077F37E /* VersionString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VersionString.cpp; sourceTree = "<group>"; };
9A4147662604F82900440186 /* undefinable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = undefinable.h; sourceTree = "<group>"; };
9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringArray.cpp; sourceTree = "<group>"; };
9A4185BF2439F73A00BEAFB8 /* XStringArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringArray.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -321,6 +324,8 @@
9A28CCAC241B816400F3D247 /* Platform */ = {
isa = PBXGroup;
children = (
9A3E3A4F271F35C40077F37E /* VersionString.cpp */,
9A3E3A4E271F35C40077F37E /* VersionString.h */,
9A27557D263A02600095D456 /* CloverVersion.cpp */,
9A27557E263A02600095D456 /* CloverVersion.h */,
9A36E51E24F3B82A007A1107 /* b64cdecode.cpp */,
Expand Down Expand Up @@ -757,6 +762,7 @@
9A071C49261A44080007CC44 /* XmlLiteDictTypes.cpp in Sources */,
9A8792F7261886F6000B9362 /* abort.cpp in Sources */,
9A9AEB8D243F73CE00FBD7D8 /* unicode_conversions.cpp in Sources */,
9A3E3A50271F35C40077F37E /* VersionString.cpp in Sources */,
9A3BA375261E7A5E009E8B0F /* guid.cpp in Sources */,
9A3BA372261E7931009E8B0F /* platformdata.cpp in Sources */,
9A2755752639E0500095D456 /* Config_Quirks.cpp in Sources */,
Expand Down
11 changes: 7 additions & 4 deletions Xcode/CloverConfigPlistValidator/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern "C" int main(int argc, const char * argv[])
path = "config-nowarning-noerror.plist";
path = "config-test2.plist";
path = "/Volumes/CL_EFI_VMDK/EFI/CLOVER/config.plist";
//path = "/Volumes/CL_EFI_VMDK/EFI/CLOVER/smbios.plist";
#endif

if ( !path ) {
Expand Down Expand Up @@ -98,15 +99,17 @@ extern "C" int main(int argc, const char * argv[])
xmlLiteParser.init(buf, st.st_size);

b = configPlistTest.parse(&xmlLiteParser, LString8(""));
for ( size_t idx = 0 ; idx < xmlLiteParser.getErrorsAndWarnings().size() ; idx++ ) {
const XmlParserMessage& xmlMsg = xmlLiteParser.getErrorsAndWarnings()[idx];
printf("%s: %s\n", xmlMsg.isError ? "Error" : "Warning", xmlMsg.msg.c_str());
for ( size_t idx = 0 ; idx < xmlLiteParser.getXmlParserMessageArray().size() ; idx++ ) {
const XmlParserMessage& xmlMsg = xmlLiteParser.getXmlParserMessageArray()[idx];
if ( xmlMsg.type != XmlParserMessageType::info ) {
printf("%s\n", xmlMsg.getFormattedMsg().c_str());
}
}
if ( b ) {
// if ( xmlLiteParser.getErrorsAndWarnings().size() > 0 ) {
// printf("parse return true, but there is error and warnings! BUG !!");
// }
if ( xmlLiteParser.getErrorsAndWarnings().size() == 0 ) {
if ( xmlLiteParser.getXmlParserMessageArray().size() == 0 ) {
printf("Your plist looks so wonderful. Well done!\n");
}
return 0;
Expand Down
8 changes: 8 additions & 0 deletions Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
9A2755482639DF1B0095D456 /* xml_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A8787B826186896000B9362 /* xml_lite-test.cpp */; };
9A2755492639DF1B0095D456 /* xml_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A8787B826186896000B9362 /* xml_lite-test.cpp */; };
9A27554A2639DF1C0095D456 /* xml_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A8787B826186896000B9362 /* xml_lite-test.cpp */; };
9A3E3A4C271E2FAE0077F37E /* xml_lite-reapeatingdict-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3E3A4A271E2FAD0077F37E /* xml_lite-reapeatingdict-test.cpp */; };
9A3E3A4D271E2FAE0077F37E /* xml_lite-reapeatingdict-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A3E3A4B271E2FAE0077F37E /* xml_lite-reapeatingdict-test.h */; };
9A63C6CB24EBEF78000EB836 /* Version.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A63C6CA24EBEF78000EB836 /* Version.h */; };
9A7D2E922636B4F300187064 /* CloverVersion.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A7D2E902636B4F200187064 /* CloverVersion.h */; };
9A7D2E932636B4F300187064 /* CloverVersion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A7D2E912636B4F300187064 /* CloverVersion.cpp */; };
Expand Down Expand Up @@ -1098,6 +1100,8 @@
9A2754E626396F2A0095D456 /* SmbiosFillPatchingValues.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmbiosFillPatchingValues.cpp; sourceTree = "<group>"; };
9A2754E726396F2B0095D456 /* SmbiosFillPatchingValues.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmbiosFillPatchingValues.h; sourceTree = "<group>"; };
9A2754EE263985A90095D456 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
9A3E3A4A271E2FAD0077F37E /* xml_lite-reapeatingdict-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "xml_lite-reapeatingdict-test.cpp"; sourceTree = "<group>"; };
9A3E3A4B271E2FAE0077F37E /* xml_lite-reapeatingdict-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "xml_lite-reapeatingdict-test.h"; sourceTree = "<group>"; };
9A63C6CA24EBEF78000EB836 /* Version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Version.h; path = ../../Version.h; sourceTree = "<group>"; };
9A7D2E902636B4F200187064 /* CloverVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CloverVersion.h; sourceTree = "<group>"; };
9A7D2E912636B4F300187064 /* CloverVersion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CloverVersion.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1617,6 +1621,8 @@
9A8787B326186896000B9362 /* XArray_tests.h */,
9A8787AE26186896000B9362 /* XBuffer_tests.cpp */,
9A8787AC26186896000B9362 /* XBuffer_tests.h */,
9A3E3A4A271E2FAD0077F37E /* xml_lite-reapeatingdict-test.cpp */,
9A3E3A4B271E2FAE0077F37E /* xml_lite-reapeatingdict-test.h */,
9A8787B826186896000B9362 /* xml_lite-test.cpp */,
9A8787B026186896000B9362 /* xml_lite-test.h */,
9A8787C526186896000B9362 /* XObjArray_tests.cpp */,
Expand Down Expand Up @@ -2057,6 +2063,7 @@
9A878C2726186898000B9362 /* loader.h in Headers */,
9A878C9326186898000B9362 /* XStringAbstract.h in Headers */,
9A878A6B26186897000B9362 /* BasicIO.h in Headers */,
9A3E3A4D271E2FAE0077F37E /* xml_lite-reapeatingdict-test.h in Headers */,
9A8789F326186897000B9362 /* gma.h in Headers */,
9A87895A26186897000B9362 /* xml_lite-test.h in Headers */,
9A878B8B26186898000B9362 /* XTheme.h in Headers */,
Expand Down Expand Up @@ -2794,6 +2801,7 @@
9A878C6326186898000B9362 /* screen.cpp in Sources */,
9A87899C26186897000B9362 /* XArray_tests.cpp in Sources */,
9A878A1426186897000B9362 /* TagDate.cpp in Sources */,
9A3E3A4C271E2FAE0077F37E /* xml_lite-reapeatingdict-test.cpp in Sources */,
9A87891E26186897000B9362 /* BootLog.cpp in Sources */,
9AF4D943263004E200487D15 /* XmlLiteSimpleTypes.cpp in Sources */,
9A878B8826186898000B9362 /* text.cpp in Sources */,
Expand Down
6 changes: 1 addition & 5 deletions rEFIt_UEFI/Platform/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2864,13 +2864,9 @@ class REFIT_CONFIG
// KernelAndKextPatches
XBool KextPatchesAllowed = true;
XBool KernelPatchesAllowed = true; //From GUI: Only for user patches, not internal Clover

XString8 BiosVersionUsed = XString8();
XString8 EfiVersionUsed = XString8();
XString8 ReleaseDateUsed = XString8();

UINT8 flagstate[32] = {0};
MacModel CurrentModel = MaxMachineType;
MacModel CurrentModel = MaxMacModel;

UINT32 IgPlatform = UINT32(); //could also be snb-platform-id

Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/Platform/VersionString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ UINT64 AsciiStrVersionToUint64(const XString8& Version_, UINT8 MaxDigitByPart, U
part_value = max_part_value;
}
else if (Version[idx] == '.') {
result = MultU64x64(result, part_mult) + part_value;
result = (result * part_mult) + part_value;
part_value = 0;
MaxParts--;
}
idx++;
}

while (MaxParts--) {
result = MultU64x64(result, part_mult) + part_value;
result = (result * part_mult) + part_value;
part_value = 0; // part_value is only used at first pass
}

Expand Down
1 change: 1 addition & 0 deletions rEFIt_UEFI/Platform/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@ UINT16 GetAdvancedCpuType()
return GetStandardCpuType();
}

// GetDefaultModel() MUST NOT return MaxMacModel
MacModel GetDefaultModel()
{
MacModel DefaultType = iMac132;
Expand Down
18 changes: 9 additions & 9 deletions rEFIt_UEFI/Platform/platformdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ constexpr bool ApplePlatformDataArrayClass::asserts()

const PLATFORMDATA& ApplePlatformDataArrayClass::operator [] (MacModel m)
{
if ( m >= MaxMachineType ) {
log_technical_bug("ApplePlatformDataArrayClass : m >= MaxMachineType");
if ( m >= MaxMacModel ) {
log_technical_bug("ApplePlatformDataArrayClass : m >= MaxMacModel");
return ApplePlatformDataArrayClass::m_ApplePlatformDataArrayClass[getDefaultModel()];
}
for ( size_t idx = 0 ; idx < sizeof(m_ApplePlatformDataArrayClass)/sizeof(m_ApplePlatformDataArrayClass[0]) ; idx++ ) {
Expand Down Expand Up @@ -436,7 +436,7 @@ XBool GetMobile(MacModel Model)
case Xserve21:
case Xserve31:
return false;
case MaxMachineType: // currently a copy of iMac132
case MaxMacModel: // currently a copy of iMac132
return false;
default: // bug, unknown Apple model
log_technical_bug("%s : cannot find model %d\n", __PRETTY_FUNCTION__, Model);
Expand Down Expand Up @@ -773,11 +773,11 @@ XString8 GetReleaseDate(MacModel Model)
return returnValue;
}

void SetDMISettingsForModel(MacModel Model, SETTINGS_DATA* settingsData, REFIT_CONFIG* liveConfig)
void SetDMISettingsForModel(MacModel Model, SETTINGS_DATA* settingsData)
{
liveConfig->BiosVersionUsed = ApplePlatformDataArray[Model].firmwareVersion;
liveConfig->ReleaseDateUsed = GetReleaseDate(Model); // AppleReleaseDate
liveConfig->EfiVersionUsed.takeValueFrom(ApplePlatformDataArray[Model].efiversion);
settingsData->Smbios.BiosVersion = ApplePlatformDataArray[Model].firmwareVersion;
settingsData->Smbios.BiosReleaseDate = GetReleaseDate(Model);
settingsData->Smbios.EfiVersion = ApplePlatformDataArray[Model].efiversion;

settingsData->Smbios.BiosVendor = AppleBiosVendor;
settingsData->Smbios.ManufactureName = settingsData->Smbios.BiosVendor;
Expand Down Expand Up @@ -810,13 +810,13 @@ MacModel GetModelFromString(const XString8& ProductName)
{
MacModel i;

for (i = (MacModel)(0); i < MaxMachineType; i = (MacModel)(i + 1)) {
for (i = (MacModel)(0); i < MaxMacModel; i = (MacModel)(i + 1)) {
if ( ProductName == MachineModelName[i] ) {
return i;
}
}
// return ending enum as "not found"
return MaxMachineType;
return MaxMacModel;
}

uint8_t GetChassisTypeFromModel(MacModel Model)
Expand Down
8 changes: 2 additions & 6 deletions rEFIt_UEFI/Platform/platformdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef enum {
#include "PlatformdataModels.h"
#undef DEFINE_ENUM

MaxMachineType
MaxMacModel

} MacModel;

Expand Down Expand Up @@ -591,10 +591,6 @@ class ApplePlatformDataArrayClass
{ Xserve31, "XS31.88Z.0081.B06.0908061300"_XS8, ""_XS8, "Mac-F223BEC8"_XS8, // Intel Xeon E5520 @ 2.26 GHz
"Xserve"_XS8, "1.0"_XS8, "CK933YJ16HS"_XS8, "Xserve"_XS8,
0x01, 0x43, 0x0f, 0, 0, 0x04, "NA"_XS8, "NA"_XS8, 0x79001 }, // need rBR RPlt EPCI
// //MaxMachineType : default to iMac132
// { iMac132, "IM131.88Z.F000.B00.2004121616"_XS8, "291.0.0.0.0"_XS8, "Mac-FC02E91DDD3FA6A4"_XS8, // Intel Core i5-3470 @ 3.20 GHz
// "iMac"_XS8, "1.0"_XS8, "C02JB041DNCW"_XS8, "iMac-Aluminum"_XS8,
// 0x02, 0x11, 0x0f, 0, 0, 0x16, "d8"_XS8, "d8"_XS8, 0x79006 },
};
static constexpr const size_t ApplePlatformData_priv_size = sizeof(m_ApplePlatformDataArrayClass)/sizeof(m_ApplePlatformDataArrayClass[0]);
static constexpr bool hasPlatformData(size_t idx, MacModel m)
Expand All @@ -613,7 +609,7 @@ class ApplePlatformDataArrayClass

extern ApplePlatformDataArrayClass ApplePlatformDataArray;

void SetDMISettingsForModel(MacModel Model, SETTINGS_DATA* settingsData, REFIT_CONFIG* liveConfig);
void SetDMISettingsForModel(MacModel Model, SETTINGS_DATA* settingsData);
MacModel GetModelFromString (const XString8& ProductName);

XBool isReleaseDateWithYear20(MacModel Model);
Expand Down

0 comments on commit 710b2dc

Please sign in to comment.