make defaults for HWTarget

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2022-02-05 15:57:08 +03:00
parent 79f048aa46
commit 4266f4ddf3
7 changed files with 79 additions and 80 deletions

View File

@ -47,7 +47,7 @@ export BUILDTHREADS=$(( NUMBER_OF_CPUS + 1 ))
export WORKSPACE=${WORKSPACE:-}
export CONF_PATH=${CONF_PATH:-}
#export NASM_PREFIX=
export PYTHON_COMMAND=python3
#export PYTHON_COMMAND=python3
# if building through Xcode, then TOOLCHAIN_DIR is not defined
# checking if it is where CloverGrowerPro put it

View File

@ -392,6 +392,10 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
SetNvramVariable(L"csr-active-config", &gEfiAppleBootGuid, Attributes, sizeof(gSettings.RtVariables.CsrActiveConfig), &gSettings.RtVariables.CsrActiveConfig);
}
if (gSettings.RtVariables.HWTarget.isEmpty()) {
gSettings.RtVariables.HWTarget = GetHWTarget(GlobalConfig.CurrentModel);
}
if (gSettings.RtVariables.HWTarget.notEmpty() && (Entry->LoaderType != OSTYPE_OSX_INSTALLER) ) {
SetNvramXString8(L"BridgeOSHardwareModel", &gEfiAppleNvramGuid, Attributes, gSettings.RtVariables.HWTarget);
} else {

View File

@ -84,7 +84,7 @@ GetEfiTimeInMs (
UINT64 TimeMs;
TimeMs = T->Year - 1900;
// is 64bit multiply workign in 32 bit?
// is 64bit multiply working in 32 bit?
TimeMs = MultU64x32 (TimeMs, 12) + T->Month;
TimeMs = MultU64x32 (TimeMs, 31) + T->Day; // counting with 31 day
TimeMs = MultU64x32 (TimeMs, 24) + T->Hour;
@ -109,7 +109,7 @@ void *GetNvramVariable(
//
UINTN IntDataSize = 0;
Status = gRT->GetVariable (VariableName, VendorGuid, Attributes, &IntDataSize, NULL);
Status = gRT->GetVariable(VariableName, VendorGuid, Attributes, &IntDataSize, NULL);
if (IntDataSize == 0) {
return NULL;
}
@ -123,7 +123,7 @@ void *GetNvramVariable(
//
// Read variable into the allocated buffer.
//
Status = gRT->GetVariable (VariableName, VendorGuid, Attributes, &IntDataSize, Data);
Status = gRT->GetVariable(VariableName, VendorGuid, Attributes, &IntDataSize, Data);
if (EFI_ERROR(Status)) {
FreePool(Data);
IntDataSize = 0;
@ -150,7 +150,7 @@ XString8 GetNvramVariableAsXString8(
//
UINTN IntDataSize = 0;
Status = gRT->GetVariable (VariableName, VendorGuid, Attributes, &IntDataSize, NULL);
Status = gRT->GetVariable(VariableName, VendorGuid, Attributes, &IntDataSize, NULL);
if (IntDataSize == 0) {
return NullXString8;
}
@ -186,7 +186,7 @@ SetNvramVariable (
UINTN OldDataSize = 0;
UINT32 OldAttributes = 0;
DBG("SetNvramVariable (%ls, guid, 0x%X, %lld):", VariableName, Attributes, DataSize);
DBG("SetNvramVariable (%ls, %s, 0x%X, %lld):", VariableName, strguid(VendorGuid), Attributes, DataSize);
OldData = (__typeof__(OldData))GetNvramVariable(VariableName, VendorGuid, &OldAttributes, &OldDataSize);
if (OldData != NULL) {
// var already exists - check if it equal to new value
@ -241,7 +241,7 @@ AddNvramVariable (
EFI_STATUS Status;
void *OldData;
DBG("AddNvramVariable (%ls, guid, 0x%X, %lld):", VariableName, Attributes, DataSize);
DBG("AddNvramVariable (%ls, %s, 0x%X, %lld):", VariableName, strguid(VendorGuid), Attributes, DataSize);
OldData = (__typeof__(OldData))GetNvramVariable(VariableName, VendorGuid, NULL, NULL);
if (OldData == NULL) {
// set new value
@ -267,8 +267,7 @@ AddNvramXString8(
}
/** Deletes NVRAM variable. */
EFI_STATUS
DeleteNvramVariable (
EFI_STATUS DeleteNvramVariable (
IN CONST CHAR16 *VariableName,
IN EFI_GUID *VendorGuid
)
@ -277,7 +276,7 @@ DeleteNvramVariable (
// Delete: attributes and data size = 0
Status = gRT->SetVariable (VariableName, VendorGuid, 0, 0, NULL);
DBG("DeleteNvramVariable (%ls, guid = %s):\n", VariableName, efiStrError(Status));
DBG("DeleteNvramVariable (%ls, %s):\n", VariableName, strguid(VendorGuid));
return Status;
}
@ -375,7 +374,7 @@ ResetNativeNvram ()
XBool Restart = true;
UINTN VolumeIndex;
REFIT_VOLUME *Volume;
EFI_FILE* FileHandle;
EFI_FILE *FileHandle;
//DbgHeader("ResetNativeNvram: cleanup NVRAM variables");
@ -700,8 +699,8 @@ BootVolumeDevicePathEqual (
if (ForceEqualNodes) {
// assume equal nodes
// DBG_DP (" - forcing equal nodes\n");
DevicePath1 = NextDevicePathNode (DevicePath1);
DevicePath2 = NextDevicePathNode (DevicePath2);
DevicePath1 = NextDevicePathNode(DevicePath1);
DevicePath2 = NextDevicePathNode(DevicePath2);
continue;
}
@ -742,7 +741,7 @@ BootVolumeDevicePathEqual (
break;
}
// DBG_DP (" - forcing equal nodes");
} else if (CompareMem (DevicePath1, DevicePath2, DevicePathNodeLength (DevicePath1)) != 0) {
} else if (CompareMem(DevicePath1, DevicePath2, DevicePathNodeLength (DevicePath1)) != 0) {
// Not equal
// DBG_DP (" - not equal\n");
break;
@ -752,8 +751,8 @@ BootVolumeDevicePathEqual (
//
// Advance to next node
//
DevicePath1 = NextDevicePathNode (DevicePath1);
DevicePath2 = NextDevicePathNode (DevicePath2);
DevicePath1 = NextDevicePathNode(DevicePath1);
DevicePath2 = NextDevicePathNode(DevicePath2);
}
return Equal;
@ -767,18 +766,18 @@ BootVolumeMediaDevicePathNodesEqual (
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2
)
{
DevicePath1 = Clover_FindDevicePathNodeWithType (DevicePath1, MEDIA_DEVICE_PATH, 0);
DevicePath1 = Clover_FindDevicePathNodeWithType(DevicePath1, MEDIA_DEVICE_PATH, 0);
if (DevicePath1 == NULL) {
return false;
}
DevicePath2 = Clover_FindDevicePathNodeWithType (DevicePath2, MEDIA_DEVICE_PATH, 0);
DevicePath2 = Clover_FindDevicePathNodeWithType(DevicePath2, MEDIA_DEVICE_PATH, 0);
if (DevicePath2 == NULL) {
return false;
}
return (DevicePathNodeLength (DevicePath1) == DevicePathNodeLength (DevicePath1))
&& (CompareMem (DevicePath1, DevicePath2, DevicePathNodeLength (DevicePath1)) == 0);
return (DevicePathNodeLength(DevicePath1) == DevicePathNodeLength(DevicePath1))
&& (CompareMem(DevicePath1, DevicePath2, DevicePathNodeLength(DevicePath1)) == 0);
}
@ -875,13 +874,13 @@ GetEfiBootDeviceFromNvram ()
// if gEfiBootVolume contains FilePathNode, then split them into gEfiBootVolume dev path and gEfiBootLoaderPath
//
gEfiBootLoaderPath = NULL;
FileDevPath = (FILEPATH_DEVICE_PATH *)Clover_FindDevicePathNodeWithType (gEfiBootVolume, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP);
FileDevPath = (FILEPATH_DEVICE_PATH *)Clover_FindDevicePathNodeWithType(gEfiBootVolume, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP);
if (FileDevPath != NULL) {
gEfiBootLoaderPath = (__typeof__(gEfiBootLoaderPath))AllocateCopyPool(StrSize(FileDevPath->PathName), FileDevPath->PathName);
// copy DevPath and write end of path node after in place of file path node
gEfiBootVolume = DuplicateDevicePath (gEfiBootVolume);
FileDevPath = (FILEPATH_DEVICE_PATH *)Clover_FindDevicePathNodeWithType (gEfiBootVolume, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP);
SetDevicePathEndNode (FileDevPath);
FileDevPath = (FILEPATH_DEVICE_PATH *)Clover_FindDevicePathNodeWithType(gEfiBootVolume, MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP);
SetDevicePathEndNode(FileDevPath);
// gEfiBootVolume now contains only Volume path
}
@ -892,9 +891,9 @@ GetEfiBootDeviceFromNvram ()
// if this is GPT disk, extract GUID
// gEfiBootDeviceGuid can be used as a flag for GPT disk then
//
Guid = FindGPTPartitionGuidInDevicePath (gEfiBootVolume);
Guid = FindGPTPartitionGuidInDevicePath(gEfiBootVolume);
if (Guid != NULL) {
gEfiBootDeviceGuid = (__typeof__(gEfiBootDeviceGuid))AllocatePool (sizeof(EFI_GUID));
gEfiBootDeviceGuid = (__typeof__(gEfiBootDeviceGuid))AllocatePool(sizeof(EFI_GUID));
if (gEfiBootDeviceGuid != NULL) {
CopyMem(gEfiBootDeviceGuid, Guid, sizeof(EFI_GUID));
DBG(" - Guid = %s\n", strguid(gEfiBootDeviceGuid));
@ -1014,7 +1013,7 @@ LoadLatestNvramPlist()
continue;
}
DBG(" Modified = ");
ModifTimeMs = GetEfiTimeInMs (&(FileInfo->ModificationTime));
ModifTimeMs = GetEfiTimeInMs(&(FileInfo->ModificationTime));
DBG("%d-%d-%d %d:%d:%d (%lld ms)\n",
FileInfo->ModificationTime.Year, FileInfo->ModificationTime.Month, FileInfo->ModificationTime.Day,
FileInfo->ModificationTime.Hour, FileInfo->ModificationTime.Minute, FileInfo->ModificationTime.Second,

View File

@ -64,9 +64,10 @@
Mac-CFF7D910A743CAAF (Monterey) iMac20,1
GFX0+IGPU+display
Mac-7BA5B2D9E42DDD94 iMacPro1,1
Mac-7BA5B2D9E42DDD94 iMacPro1,1 Vega 56, no IGPU
*/
// for HWTarget recommended values for T2 models (by Gradou)
/*
MacBookPro 15,1 (J680AP) 15,2 (J132AP) 15,3 (J780AP) & 15,4 (J213AP)
@ -80,7 +81,47 @@ iMacPro1,1 (J137AP)
MacPro7,1 (J160AP)
*/
//--------------------------
XString8 GetHWTarget(MacModel Model)
{
switch ( Model )
{
case iMacPro11:
return "J137AP"_XS8;
case MacMini81:
return "J174AP"_XS8;
case iMac201:
return "J185AP"_XS8;
case iMac202:
return "J185fAP"_XS8;
case MacPro71:
return "J160AP"_XS8;
case MacBookPro151:
return "J680AP"_XS8;
case MacBookPro152:
return "J132AP"_XS8;
case MacBookPro153:
return "J780AP"_XS8;
case MacBookPro154:
return "J213AP"_XS8;
case MacBookPro161:
return "J152fAP"_XS8;
case MacBookPro162:
return "J214kAP"_XS8;
case MacBookPro163:
return "J223AP"_XS8;
case MacBookPro164:
return "J215AP"_XS8;
case MacBookAir81:
return "J140kAP"_XS8;
case MacBookAir82:
return "J140aAP"_XS8;
case MacBookAir91:
return "J230kAP"_XS8;
default:
return ""_XS8; // disabled
}
}
constexpr PLATFORMDATA ApplePlatformDataArrayClass::m_ApplePlatformDataArrayClass[];
@ -134,14 +175,12 @@ uint32_t GetFwFeatures(MacModel Model)
case MacBookPro91:
case MacBookPro92:
return 0xC00DE137;
break;
case MacBookAir41:
case MacBookAir42:
case MacMini51:
case MacMini52:
case MacMini53:
return 0xD00DE137;
break;
case MacBookPro101:
case MacBookPro102:
case MacBookAir51:
@ -152,30 +191,24 @@ uint32_t GetFwFeatures(MacModel Model)
case iMac132:
case iMac133:
return 0xE00DE137;
break;
case MacMini81:
return 0xFD8FF467;
break;
case MacBookAir61:
case MacBookAir62:
case iMac141:
case iMac142:
case iMac143:
return 0xE00FE137;
break;
case MacBookPro111:
case MacBookPro112:
case MacBookPro113:
case MacBookPro114:
case MacBookPro115:
return 0xE80FE137;
break;
case iMac144:
return 0xF00FE177;
break;
case iMac151:
return 0xF80FE177;
break;
case MacBookPro131:
case MacBookPro132:
case MacBookPro141:
@ -185,40 +218,32 @@ uint32_t GetFwFeatures(MacModel Model)
case iMac182:
case iMac183:
return 0xFC0FE177;
break;
case MacBook91:
case MacBook101:
case MacBookPro133:
case MacBookPro143:
return 0xFC0FE17F;
break;
case iMacPro11:
return 0xFD8FF53F;
break;
case MacBookAir91:
return 0xFD8FF42F;
break;
case iMac191:
case iMac192:
case iMac201:
case iMac202:
return 0xFD8FF577;
break;
case MacBookPro162:
case MacBookPro163:
case MacBookPro164:
return 0xFDAFF067;
break;
// Verified list from Users
case MacBookAir31:
case MacBookAir32:
case MacMini41:
return 0xD00DE137;
break;
case MacBookAir71:
case MacBookAir72:
return 0xE00FE137;
break;
case iMac101:
case iMac111:
case iMac112:
@ -227,16 +252,12 @@ uint32_t GetFwFeatures(MacModel Model)
case iMac122:
case MacMini71:
return 0xE00DE137;
break;
case MacPro51:
return 0xE80FE137;
break;
case MacPro61:
return 0xE80FE177;
break;
case MacPro71:
return 0xFD8FF53F;
break;
case MacBookPro61:
case MacBookPro62:
case MacBookPro71:
@ -244,7 +265,6 @@ uint32_t GetFwFeatures(MacModel Model)
case MacBookPro82:
case MacBookPro83:
return 0xC00DE137;
break;
case MacBookPro121:
case MacBookPro151:
case MacBookPro152:
@ -256,15 +276,12 @@ uint32_t GetFwFeatures(MacModel Model)
case iMac161:
case iMac162:
return 0xFC0FE137;
break;
case MacBook61:
case MacBook71:
case MacBook81:
return 0xFC0FE13F;
break;
default:
return 0xE907F537; //unknown - use oem SMBIOS value to be default
break;
}
}
@ -290,13 +307,11 @@ uint64_t GetExtFwFeatures(MacModel Model)
case iMac202:
case iMacPro11:
return 0x8FC0FE177ull;
break;
case MacBook91:
case MacBook101:
case MacBookPro133:
case MacBookPro143:
return 0x8FC0FE17Eull;
break;
case MacBookPro121:
case MacBookPro151:
case MacBookPro152:
@ -314,20 +329,15 @@ uint64_t GetExtFwFeatures(MacModel Model)
case MacMini71:
case MacMini81:
return 0x8FC0FE137ull;
break;
case MacBook81:
return 0x8FC0FE13Full;
break;
case MacPro61:
return 0x8E80FE177ull;
break;
case MacPro71:
return 0x8FD8FF53Full;
break;
default:
return (uint64_t)GetFwFeatures(Model); //unknown - use oem SMBIOS value to be default
break;
}
}
@ -487,9 +497,9 @@ UINT64 GetPlatformFeature(MacModel Model)
case iMac181:
case iMac182:
case iMac183:
case MacPro71:
case iMac191:
case iMac192:
return 0x00;
break;
case MacMini61:
case MacMini62:
case iMac131:
@ -501,7 +511,6 @@ UINT64 GetPlatformFeature(MacModel Model)
case iMac144:
case iMac151:
return 0x01;
break;
case MacBookPro111:
case MacBookPro112:
case MacBookPro113:
@ -511,15 +520,12 @@ UINT64 GetPlatformFeature(MacModel Model)
case MacBookAir71:
case MacBookAir72:
return 0x02;
break;
case MacMini71:
case iMac161:
case iMac162:
return 0x03;
break;
case MacPro61:
return 0x04;
break;
case MacBook81:
case MacBook91:
case MacBook101:
@ -530,15 +536,12 @@ UINT64 GetPlatformFeature(MacModel Model)
case MacBookPro142:
case MacBookPro143:
return 0x1A;
break;
case iMacPro11:
case MacMini81:
case iMac191:
case iMac192:
case iMac201:
case iMac202:
case MacPro71:
return 0x20;
break;
case MacBookPro151:
case MacBookPro152:
case MacBookPro153:
@ -548,22 +551,13 @@ UINT64 GetPlatformFeature(MacModel Model)
case MacBookPro163:
case MacBookPro164:
return 0x32;
break;
case MacBookAir81:
case MacBookAir82:
case MacBookAir91:
return 0x3A;
break;
// It is nonsense, ASCII code сharacter "2" = 0x32 != 0x02. Don't use ioreg, so that not to be confused. Use dmidecode dump.
// Verified list from Users
// case MacBookPro153:
// case MacBookPro154:
// case MacBookPro161:
// gSettings.Smbios.gPlatformFeature = 0x02;
// break;
default:
return 0xFFFF; // disabled
break;
}
}
@ -806,6 +800,7 @@ XString8 GetReleaseDate(MacModel Model)
void SetDMISettingsForModel(MacModel Model, SETTINGS_DATA* settingsData)
{
GlobalConfig.CurrentModel = Model;
settingsData->Smbios.BiosVersion = ApplePlatformDataArray[Model].firmwareVersion;
settingsData->Smbios.BiosReleaseDate = GetReleaseDate(Model);
settingsData->Smbios.EfiVersion = ApplePlatformDataArray[Model].efiversion;

View File

@ -547,7 +547,7 @@ class ApplePlatformDataArrayClass
"iMac"_XS8, "1.0"_XS8, "C02D2HAC046M"_XS8, "iMac-Aluminum"_XS8,
0,0,0,0,0,0,""_XS8, "j185"_XS8, 0},
// 0x02, 0x47, 0x0f, 0, 0, 0x03, "j185f"_XS8, "j185f"_XS8, 0xf0d009 },
//iMacPro1,1 /iMac Pro (2017)
//iMacPro1,1 /iMac Pro (2017), Radeon Pro Vega 56, devID=0x6867
{ iMacPro11, "IMP11.88Z.F000.B00.2107050205"_XS8, "1715.0.57.0.0"_XS8, "Mac-7BA5B2D9E42DDD94"_XS8, // Intel Xeon W-2140B CPU @ 3.20 GHz
"iMac Pro"_XS8, "1.0"_XS8, "C02VVHACHX87"_XS8, "iMacPro-Aluminum"_XS8,
0, 0, 0, 0, 0, 0, ""_XS8, "j137"_XS8, 0 },
@ -621,6 +621,7 @@ uint64_t GetExtFwFeatures(MacModel Model);
uint64_t GetExtFwFeaturesMask(MacModel Model);
XBool GetMobile(MacModel Model);
UINT64 GetPlatformFeature(MacModel Model);
XString8 GetHWTarget(MacModel Model);
void getRBr(MacModel Model, UINT32 CPUModel, XBool isMobile, char RBr[8]);
void getRPlt(MacModel Model, UINT32 CPUModel, XBool isMobile, char RPlt[8]);

View File

@ -170,7 +170,7 @@ public:
decltype(CsrActiveConfig)::ValueType dgetCsrActiveConfig() const { return CsrActiveConfig.isDefined() ? CsrActiveConfig.value() : 0xFFFF; }; // 0xFFFF = not set
const decltype(BooterConfig)::ValueType& dgetBooterConfig() const { return BooterConfig.isDefined() ? BooterConfig.value() : BooterConfig.nullValue; };
const decltype(BooterCfg)::ValueType& dgetBooterCfgStr() const { return BooterCfg.isDefined() ? BooterCfg.value() : BooterCfg.nullValue; };
const decltype(HWTarget)::ValueType& dgetHWTarget() const { return HWTarget.isDefined() ? HWTarget.value() : HWTarget.nullValue; };// "j160"_XS8; };
const decltype(HWTarget)::ValueType& dgetHWTarget() const { return HWTarget.isDefined() ? HWTarget.value() : HWTarget.nullValue; };
};

View File

@ -591,7 +591,7 @@ public:
// {
// if ( !ProductName.isDefined() ) {
// // This must not happen in Clover because Clover set a defaultMacModel
// // This must ot happen in ccpv because ccpv doesn't call dget... methods
// // 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.
// }