Merge branch 'opencore_integration' of https://github.com/CloverHackyColor/CloverBootloader into opencore_integration

This commit is contained in:
SergeySlice 2020-09-26 22:42:54 +03:00
commit 999d1b1d6f
25 changed files with 297 additions and 178 deletions

View File

@ -155,7 +155,7 @@
gAppleFramebufferInfoProtocolGuid = {0xE316E100, 0x0751, 0x4C49, {0x90, 0x56, 0x48, 0x6C, 0x7E, 0x47, 0x29, 0x03}}
gAppleGraphConfigProtocolGuid = {0x03622D6D, 0x362A, 0x4E47, {0x97, 0x10, 0xC2, 0x38, 0xB2, 0x37, 0x55, 0xC1}}
gAppleImageCodecProtocolGuid = {0x0DFCE9F6, 0xC4E3, 0x45EE, {0xA0, 0x6A, 0xA8, 0x61, 0x3B, 0x98, 0xA5, 0x07}}
gAppleDevicePropertyProtocolGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}}
# gAppleDevicePropertyProtocolGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}}
gAppleFirmwarePasswordProtocolGuid = {0x8FFEEB3A, 0x4C98, 0x4630, {0x80, 0x3F, 0x74, 0x0F, 0x95, 0x67, 0x09, 0x1D}}
gAppleKeyStateProtocolGuid = {0x5B213447, 0x6E73, 0x4901, {0xA4, 0xF1, 0xB8, 0x64, 0xF3, 0xB7, 0xA1, 0x72}}
gAppleNetBootProtocolGuid = {0x78EE99FB, 0x6A5E, 0x4186, {0x97, 0xDE, 0xCD, 0x0A, 0xBA, 0x34, 0x5A, 0x74}}

View File

@ -747,7 +747,7 @@ EFI_STATUS
IN EFI_GUID *VendorGuid,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
IN JCONST VOID *Data
);

View File

@ -93,7 +93,7 @@
gEfiDiskIo2ProtocolGuid ## CONSUMES
gEfiConsoleControlProtocolGuid ## SOMETIMES_CONSUMES
gAppleFirmwarePasswordProtocolGuid ## SOMETIMES_CONSUMES
gAppleDevicePropertyProtocolGuid ## SOMETIMES_CONSUMES
#gAppleDevicePropertyProtocolGuid ## SOMETIMES_CONSUMES
gAppleFramebufferInfoProtocolGuid ## SOMETIMES_CONSUMES
gAppleKeyStateProtocolGuid ## SOMETIMES_CONSUMES
gAppleNetBootProtocolGuid ## SOMETIMES_CONSUMES

View File

@ -83,7 +83,7 @@ EFI_GUID gVendorGuid = {0xe62111ab, 0xcf4d, 0x4137, {0x87, 0x5c, 0x88, 0xde, 0xe
EFI_GUID gEfiConsoleControlProtocolGuid = {0xF42F7782, 0x012E, 0x4C12, {0x99, 0x56, 0x49, 0xF9, 0x43, 0x04, 0xF7, 0x21}};
EFI_GUID gAppleFirmwarePasswordProtocolGuid = {0x8FFEEB3A, 0x4C98, 0x4630, {0x80, 0x3F, 0x74, 0x0F, 0x95, 0x67, 0x09, 0x1D}};
EFI_GUID gEfiGlobalVarGuid = {0x8BE4DF61, 0x93CA, 0x11D2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C}};
EFI_GUID gDevicePropertiesGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}};
EFI_GUID gEfiDevicePathPropertyDatabaseProtocolGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}};
EFI_GUID gEfiAppleBootGuid = {0x7C436110, 0xAB2A, 0x4BBB, {0xA8, 0x80, 0xFE, 0x41, 0x99, 0x5C, 0x9F, 0x82}};
EFI_GUID gEfiAppleNvramGuid = {0x4D1EDE05, 0x38C7, 0x4A6A, {0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14}};
EFI_GUID gAppleFramebufferInfoProtocolGuid = {0xE316E100, 0x0751, 0x4C49, {0x90, 0x56, 0x48, 0x6C, 0x7E, 0x47, 0x29, 0x03}};
@ -119,7 +119,7 @@ MAP_EFI_GUID_STR EfiGuidStrMap[] = {
{&gEfiConsoleControlProtocolGuid, L"gEfiConsoleControlProtocolGuid"},
{&gAppleFirmwarePasswordProtocolGuid, L"gAppleFirmwarePasswordProtocolGuid"},
{&gEfiGlobalVarGuid, L"gEfiGlobalVarGuid"},
{&gDevicePropertiesGuid, L"gDevicePropertiesGuid"},
{&gEfiDevicePathPropertyDatabaseProtocolGuid, L"gEfiDevicePathPropertyDatabaseProtocolGuid"},
{&gEfiAppleBootGuid, L"gEfiAppleBootGuid"},
{&gEfiAppleNvramGuid, L"gEfiAppleNvramGuid"},
{&gAppleFramebufferInfoProtocolGuid, L"gAppleFramebufferInfoProtocolGuid"},

View File

@ -83,7 +83,7 @@ EFI_GUID gVendorGuid = {0xe62111ab, 0xcf4d, 0x4137, {0x87, 0x5c, 0x88, 0xde, 0xe
EFI_GUID gEfiConsoleControlProtocolGuid = {0xF42F7782, 0x012E, 0x4C12, {0x99, 0x56, 0x49, 0xF9, 0x43, 0x04, 0xF7, 0x21}};
EFI_GUID gAppleFirmwarePasswordProtocolGuid = {0x8FFEEB3A, 0x4C98, 0x4630, {0x80, 0x3F, 0x74, 0x0F, 0x95, 0x67, 0x09, 0x1D}};
EFI_GUID gEfiGlobalVarGuid = {0x8BE4DF61, 0x93CA, 0x11D2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C}};
EFI_GUID gDevicePropertiesGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}};
EFI_GUID gEfiDevicePathPropertyDatabaseProtocolGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}};
EFI_GUID gEfiAppleBootGuid = {0x7C436110, 0xAB2A, 0x4BBB, {0xA8, 0x80, 0xFE, 0x41, 0x99, 0x5C, 0x9F, 0x82}};
EFI_GUID gEfiAppleNvramGuid = {0x4D1EDE05, 0x38C7, 0x4A6A, {0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14}};
EFI_GUID gAppleFramebufferInfoProtocolGuid = {0xE316E100, 0x0751, 0x4C49, {0x90, 0x56, 0x48, 0x6C, 0x7E, 0x47, 0x29, 0x03}};
@ -119,7 +119,7 @@ MAP_EFI_GUID_STR EfiGuidStrMap[] = {
{&gEfiConsoleControlProtocolGuid, L"gEfiConsoleControlProtocolGuid"},
{&gAppleFirmwarePasswordProtocolGuid, L"gAppleFirmwarePasswordProtocolGuid"},
{&gEfiGlobalVarGuid, L"gEfiGlobalVarGuid"},
{&gDevicePropertiesGuid, L"gDevicePropertiesGuid"},
{&gEfiDevicePathPropertyDatabaseProtocolGuid, L"gEfiDevicePathPropertyDatabaseProtocolGuid"},
{&gEfiAppleBootGuid, L"gEfiAppleBootGuid"},
{&gEfiAppleNvramGuid, L"gEfiAppleNvramGuid"},
{&gAppleFramebufferInfoProtocolGuid, L"gAppleFramebufferInfoProtocolGuid"},

@ -1 +1 @@
Subproject commit bc0b403c614504c083c28c89f6a85494d5b492fd
Subproject commit d134b6051728c0493c2f1127e586a07fe77a052f

View File

@ -138,7 +138,7 @@ DumpUefiCallsEntrypoint (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
#ifdef DEBUG_ON_SERIAL_PORT
{
EFI_LOADED_IMAGE* LoadedImage;
EFI_STATUS Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
@ -155,6 +155,7 @@ DumpUefiCallsEntrypoint (
SerialPortWrite((UINT8*)buf, AsciiStrLen(buf));
}
}
#endif
//
// Override StartImage

View File

@ -47,7 +47,7 @@ EFI_GUID *APFSPartitionUUIDExtract(
}
if (DevicePathType(DevicePath) == MEDIA_DEVICE_PATH && DevicePathSubType (DevicePath) == MEDIA_VENDOR_DP) {
//Check that vendor-assigned GUID defines APFS Container Partition
if ( GuidLEToXString8((EFI_GUID *)((UINT8 *)DevicePath+0x04)).equalIC(ApfsSignatureUUID) ) {
if ( GuidLEToXString8(*(EFI_GUID *)((UINT8 *)DevicePath+0x04)).equalIC(ApfsSignatureUUID) ) {
return (EFI_GUID *)((UINT8 *)DevicePath+0x14);
}
}
@ -65,7 +65,7 @@ XString8 APFSPartitionUUIDExtractAsXString8(
)
{
EFI_GUID* uuid = APFSPartitionUUIDExtract(DevicePath);
if ( uuid ) return GuidLEToXString8(uuid);
if ( uuid ) return GuidLEToXString8(*uuid);
return ""_XS8;
}

View File

@ -18,7 +18,7 @@ constexpr LString8 ApfsSignatureUUID = "BE74FCF7-0B7C-49F3-9147-01F4042E6842";
* OUT: EFI_GUID
* returns null if it is not APFS part
*/
EFI_GUID *APFSPartitionUUIDExtract(
EFI_GUID* APFSPartitionUUIDExtract(
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
);

View File

@ -97,7 +97,7 @@ typedef struct {
UINT32 EFIAPI
CopyRecord(IN PLATFORM_DATA_RECORD *Rec,
IN CONST CHAR16 *Name,
IN VOID *Val,
IN const VOID *Val,
IN UINT32 ValLen)
{
CopyMem(&Rec->Hdr, &mCpuDataRecordHeader, sizeof(EFI_SUBCLASS_TYPE1_HEADER));
@ -114,7 +114,7 @@ CopyRecord(IN PLATFORM_DATA_RECORD *Rec,
EFI_STATUS EFIAPI
LogDataHub(IN EFI_GUID *TypeGuid,
IN CONST CHAR16 *Name,
IN VOID *Data,
IN const VOID *Data,
IN UINT32 DataSize)
{
UINT32 RecordSize;
@ -214,6 +214,9 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
UINT64 os_version = AsciiOSVersionToUint64(Entry->OSVersion);
CHAR8 *PlatformLang;
EFI_GUID uuid;
gSettings.getUUID(&uuid);
//
// firmware Variables
//
@ -225,8 +228,8 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
SetNvramVariable(L"system-id",
&gEfiAppleNvramGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof(gUuid),
&gUuid);
sizeof(uuid),
&uuid);
Attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
@ -241,12 +244,12 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
gSettings.RtMLB);
}
if (gSettings.RtROM != NULL) {
if (gSettings.RtROM.notEmpty()) {
SetNvramVariable(L"ROM",
&gEfiAppleNvramGuid,
Attributes,
gSettings.RtROMLen,
gSettings.RtROM);
gSettings.RtROM.size(),
gSettings.RtROM.vdata());
}
SetNvramVariable(L"FirmwareFeatures",
@ -310,11 +313,11 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
// we should have two UUID: platform and system
// NO! Only Platform is the best solution
if (!gSettings.InjectSystemID) {
if (gSettings.SmUUIDConfig) {
SetNvramVariable(L"platform-uuid", &gEfiAppleBootGuid, Attributes, 16, &gUuid);
if (!gSettings.ShouldInjectSystemID()) {
if (gSettings.SmUUID.notEmpty()) {
SetNvramVariable(L"platform-uuid", &gEfiAppleBootGuid, Attributes, sizeof(uuid), &uuid);
} else {
AddNvramVariable(L"platform-uuid", &gEfiAppleBootGuid, Attributes, 16, &gUuid);
AddNvramVariable(L"platform-uuid", &gEfiAppleBootGuid, Attributes, sizeof(uuid), &uuid);
}
}
@ -507,8 +510,10 @@ SetupDataForOSX(BOOLEAN Hibernate)
LogDataHubXStringW(&gEfiMiscSubClassGuid, L"Model", ProductName);
LogDataHubXStringW(&gEfiMiscSubClassGuid, L"SystemSerialNumber", SerialNumber);
if (gSettings.InjectSystemID) {
LogDataHub(&gEfiMiscSubClassGuid, L"system-id", &gUuid, sizeof(EFI_GUID));
if (gSettings.ShouldInjectSystemID()) {
EFI_GUID uuid;
gSettings.getUUID(&uuid);
LogDataHub(&gEfiMiscSubClassGuid, L"system-id", &uuid, sizeof(uuid));
}
LogDataHub(&gEfiProcessorSubClassGuid, L"clovergui-revision", &Revision, sizeof(UINT32));

View File

@ -5243,6 +5243,8 @@ VOID RenameDevices(UINT8* table)
CHAR8 *Replace;
CHAR8 *Find;
if ( gSettings.DeviceRenameCount <= 0 ) return; // to avoid message "0 replacement"
INTN i;
INTN k=0; // Cland complain about possible use uninitialised. Not true, but I don't like warnings.
UINTN index;

View File

@ -394,7 +394,7 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
// find sleep image entry from plist
Status = egLoadFile(Volume->RootDir, PrefName, &PrefBuffer, &PrefBufferLen);
if (EFI_ERROR(Status)) {
XStringW PrefName3 = SWPrintf("\\Library\\Preferences\\com.apple.PowerManagement.%ls.plist", GuidBeToStr(&gUuid).wc_str());
XStringW PrefName3 = SWPrintf("\\Library\\Preferences\\com.apple.PowerManagement.%s.plist", gSettings.getUUID().c_str());
Status = egLoadFile(Volume->RootDir, PrefName3.wc_str(), &PrefBuffer, &PrefBufferLen);
if (EFI_ERROR(Status)) {
Status = egLoadFile(Volume->RootDir, PrefName2, &PrefBuffer, &PrefBufferLen);
@ -920,7 +920,7 @@ IsOsxHibernated (IN LOADER_ENTRY *Entry)
if (EFI_ERROR(Status)) {
DBG(" cant convert Str %ls to GUID\n", Ptr);
} else {
XStringW TmpStr = GuidLEToXStringW(&TmpGuid);
XStringW TmpStr = GuidLEToXStringW(TmpGuid);
//DBG("got the guid %ls\n", TmpStr);
memcpy((VOID*)Ptr, TmpStr.wc_str(), TmpStr.sizeInBytes());
}

View File

@ -37,19 +37,8 @@
#define DBG(...) DebugLog(DEBUG_PRO, __VA_ARGS__)
#endif
EFI_GUID gDevicePropertiesGuid = {
0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}
};
/*
EFI_GUID gAppleFramebufferInfoProtocolGuid = {
0xe316e100, 0x0751, 0x4c49, {0x90, 0x56, 0x48, 0x6c, 0x7e, 0x47, 0x29, 0x03}
}; */
// gEfiKeyboardInfoProtocolGuid
// {0xE82A0A1E, 0x0E4D, 0x45AC, {0xA6, 0xDC, 0x2A, 0xE0, 0x58, 0x00, 0xD3, 0x11}}
// C5C5DA95-7D5C-45E6-B2F1-3FD52BB10077 - EfiOSInfo
// 03622D6D-362A-4E47-9710-C238B23755C1 - GraphConfig
extern EFI_GUID gEfiDevicePathPropertyDatabaseProtocolGuid;
extern EFI_GUID gAppleFramebufferInfoProtocolGuid;
extern BOOLEAN gProvideConsoleGopEnable;
@ -376,7 +365,7 @@ SetPrivateVarProto(VOID)
EFI_STATUS Status;
//This must be independent install
// optional protocols
/*Status = */gBS->InstallMultipleProtocolInterfaces (&gImageHandle,
Status = gBS->InstallMultipleProtocolInterfaces (&gImageHandle,
&gAppleFramebufferInfoProtocolGuid,
&mScreenInfo,
// &gEfiOSInfoProtocolGuid,
@ -391,7 +380,7 @@ SetPrivateVarProto(VOID)
);
//obligatory protocol
Status = gBS->InstallProtocolInterface (&gImageHandle,
&gDevicePropertiesGuid,
&gEfiDevicePathPropertyDatabaseProtocolGuid,
EFI_NATIVE_INTERFACE,
&mDeviceProperties
);

View File

@ -236,7 +236,7 @@ AddNvramVariable (
IN EFI_GUID *VendorGuid,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
IN const VOID *Data
)
{
VOID *OldData;
@ -1232,7 +1232,7 @@ FindStartupDiskVolume (
EFI_DEVICE_PATH *MediaPath = Clover_FindDevicePathNodeWithType(DevicePath, MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP);
if (MediaPath) {
EFI_GUID *MediaPathGuid = (EFI_GUID *)&((VENDOR_DEVICE_PATH_WITH_DATA*)MediaPath)->VendorDefinedData;
XStringW MediaPathGuidStr = GuidLEToXStringW(MediaPathGuid);
XStringW MediaPathGuidStr = GuidLEToXStringW(*MediaPathGuid);
// DBG(" checking '%ls'\n", MediaPathGuidStr.wc_str());
if (StrStr(gEfiBootLoaderPath, MediaPathGuidStr.wc_str())) {
DBG(" - found entry %lld. '%ls', Volume '%ls', '%ls'\n", Index, LoaderEntry.Title.s(), Volume->VolName.wc_str(), LoaderPath.wc_str());

View File

@ -45,7 +45,7 @@ AddNvramVariable (
IN EFI_GUID *VendorGuid,
IN UINT32 Attributes,
IN UINTN DataSize,
IN VOID *Data
IN const VOID *Data
);
EFI_STATUS
AddNvramXString8 (

View File

@ -25,9 +25,12 @@ static void panic_(const char* format, VA_LIST va)
#endif
;
extern void egSetGraphicsModeEnabled(BOOLEAN);
#define FATAL_ERROR_MSG "\nA fatal error happened. System halted.\n"
static void panic_(const char* format, VA_LIST va)
{
egSetGraphicsModeEnabled(false);
if ( format ) {
vprintf(format, va);
#ifdef DEBUG_ON_SERIAL_PORT

View File

@ -135,8 +135,6 @@ CONST CHAR8* gFirmwareBuildDate = "unknown";
CONST CHAR8* gBuildInfo = NULL;
#endif
EFI_GUID gUuid;
EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl = NULL;
extern BOOLEAN NeedPMfix;
@ -4297,8 +4295,7 @@ ParseSMBIOSSettings(
MsgLog("ATTENTION : property not string in SmUUID\n");
}else{
if (IsValidGuidAsciiString(Prop->getString()->stringValue())) {
StrToGuidLE(Prop->getString()->stringValue(), &gSettings.SmUUID);
gSettings.SmUUIDConfig = TRUE;
gSettings.SmUUID = Prop->getString()->stringValue();
} else {
DBG("Error: invalid SmUUID '%s' - should be in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n", Prop->getString()->stringValue().c_str());
}
@ -5863,29 +5860,23 @@ GetUserSettings(const TagDict* CfgDict)
}
// RtVariables
gSettings.RtROM.setEmpty();
const TagDict* RtVariablesDict = CfgDict->dictPropertyForKey("RtVariables");
if (RtVariablesDict != NULL) {
// ROM: <data>bin data</data> or <string>base 64 encoded bin data</string>
const TagStruct* Prop = RtVariablesDict->propertyForKey("ROM");
if (Prop != NULL) {
if ( Prop->isString() && Prop->getString()->stringValue().equalIC("UseMacAddr0") ) {
gSettings.RtROM = &gLanMac[0][0];
gSettings.RtROMLen = 6;
gSettings.RtROM.ncpy(&gLanMac[0][0], 6);
} else if ( Prop->isString() && Prop->getString()->stringValue().equalIC("UseMacAddr1") ) {
gSettings.RtROM = &gLanMac[1][0];
gSettings.RtROMLen = 6;
gSettings.RtROM.ncpy(&gLanMac[1][0], 6);
} else if ( Prop->isString() || Prop->isData() ) { // GetDataSetting accept both
UINTN ROMLength = 0;
gSettings.RtROM = GetDataSetting(RtVariablesDict, "ROM", &ROMLength);
gSettings.RtROMLen = ROMLength;
VOID* ROM = GetDataSetting(RtVariablesDict, "ROM", &ROMLength);
gSettings.RtROM.ncpy(ROM, ROMLength);
} else {
MsgLog("MALFORMED PLIST : property not string or data in RtVariables/ROM\n");
}
if (gSettings.RtROM == NULL || gSettings.RtROMLen == 0) {
gSettings.RtROM = NULL;
gSettings.RtROMLen = 0;
}
}
// MLB: <string>some value</string>
@ -5972,9 +5963,10 @@ GetUserSettings(const TagDict* CfgDict)
}
}
if (gSettings.RtROM == NULL) {
gSettings.RtROM = (UINT8*)&gSettings.SmUUID.Data4[2];
gSettings.RtROMLen = 6;
if (gSettings.RtROM.isEmpty()) {
EFI_GUID uuid;
StrToGuidLE(gSettings.SmUUID, &uuid);
gSettings.RtROM.ncpy(&uuid.Data4[2], 6);
}
if (gSettings.RtMLB.isEmpty()) {
@ -5984,8 +5976,7 @@ GetUserSettings(const TagDict* CfgDict)
// if CustomUUID and InjectSystemID are not specified
// then use InjectSystemID=TRUE and SMBIOS UUID
// to get Chameleon's default behaviour (to make user's life easier)
CopyMem((VOID*)&gUuid, (VOID*)&gSettings.SmUUID, sizeof(EFI_GUID));
gSettings.InjectSystemID = TRUE;
// CopyMem((VOID*)&gUuid, (VOID*)&gSettings.SmUUID, sizeof(EFI_GUID));
// SystemParameters again - values that can depend on previous params
const TagDict* SystemParametersDict = CfgDict->dictPropertyForKey("SystemParameters");
@ -6002,30 +5993,39 @@ GetUserSettings(const TagDict* CfgDict)
if ( !Prop->isString() ) {
MsgLog("ATTENTION : property not string in SystemParameters/CustomUUID\n");
}else{
BOOLEAN IsValidCustomUUID = FALSE;
if (IsValidGuidAsciiString(Prop->getString()->stringValue())) {
gSettings.CustomUuid = Prop->getString()->stringValue();
DBG("Converted CustomUUID %ls\n", gSettings.CustomUuid.wc_str());
Status = StrToGuidLE(gSettings.CustomUuid, &gUuid);
if (!EFI_ERROR(Status)) {
IsValidCustomUUID = TRUE;
// if CustomUUID specified, then default for InjectSystemID=FALSE
// to stay compatibile with previous Clover behaviour
gSettings.InjectSystemID = FALSE;
DBG("The UUID is valid\n");
}
}
if (!IsValidCustomUUID) {
gSettings.CustomUuid = Prop->getString()->stringValue();
// if CustomUUID specified, then default for InjectSystemID=FALSE
// to stay compatibile with previous Clover behaviour
DBG("The UUID is valid\n");
}else{
DBG("Error: invalid CustomUUID '%s' - should be in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n", Prop->getString()->stringValue().c_str());
gSettings.CustomUuid = {0};
}
}
}
//else gUuid value from SMBIOS
// DBG("Finally use %s\n", strguid(&gUuid));
gSettings.InjectSystemID_ = 2;
Prop = SystemParametersDict->propertyForKey("InjectSystemID");
gSettings.InjectSystemID = gSettings.InjectSystemID ? !IsPropertyNotNullAndFalse(Prop) : IsPropertyNotNullAndTrue(Prop);
if ( Prop ) {
if ( Prop->isBool() ) gSettings.InjectSystemID_ = Prop->getBool()->boolValue();
else if ( Prop->isString() ) {
// TODO a function that takes a string and return if it's true or false
if ( Prop->getString()->stringValue().equalIC("true") ) gSettings.InjectSystemID_ = 1;
else if ( Prop->getString()->stringValue()[0] == 'y' ) gSettings.InjectSystemID_ = 1;
else if ( Prop->getString()->stringValue()[0] == 'Y' ) gSettings.InjectSystemID_ = 1;
else if ( Prop->getString()->stringValue().equalIC("false") ) gSettings.InjectSystemID_ = 0;
else if ( Prop->getString()->stringValue().equalIC("n") ) gSettings.InjectSystemID_ = 0;
else if ( Prop->getString()->stringValue().equalIC("N") ) gSettings.InjectSystemID_ = 0;
else {
DBG("MALFORMED PLIST : SMBIOS/InjectSystemID must be true, yes, false, no, or non existant");
}
}else{
DBG("MALFORMED PLIST : SMBIOS/InjectSystemID must be <true/>, <false/> or non existant");
}
}
Prop = SystemParametersDict->propertyForKey("NvidiaWeb");
gSettings.NvidiaWeb = IsPropertyNotNullAndTrue(Prop);
@ -8230,7 +8230,7 @@ checkOffset(RomVersion);
WriteOldFixLengthString(VersionNr, 64);
WriteOldFixLengthString(SerialNr, 64);
xb.ncat(&SmUUID, sizeof(SmUUID));
xb.cat(SmUUIDConfig);
xb.cat((BOOLEAN)SmUUID.notEmpty());
xb.ncat(&pad0, sizeof(pad0));
//CHAR8 Uuid[64]);
//CHAR8 SKUNumber[64]);
@ -8290,7 +8290,7 @@ checkOffset(BootArgs);
WriteOldFixLengthString(BootArgs, 256);
xb.memsetAtPos(xb.size(), 0, 1);
checkOffset(CustomUuid);
WriteOldFixLengthString(CustomUuid, 40);
WriteOldFixLengthString(XStringW(CustomUuid), 40);
xb.ncat(&pad20, sizeof(pad20));
checkOffset(DefaultVolume);
xb.cat(uintptr_t(0)); //DefaultVolume was CHAR16*
@ -8362,7 +8362,7 @@ checkOffset(FixMCFG);
xb.cat(DeviceRename);
//Injections
xb.cat(StringInjector);
xb.cat(InjectSystemID);
xb.cat(InjectSystemID_);
xb.cat(NoDefaultProperties);
xb.cat(ReuseFFFF);
@ -8480,9 +8480,12 @@ checkOffset(CustomBoot);
// SysVariables
xb.ncat(&pad30, sizeof(pad30));
checkOffset(RtMLB);
xb.cat(uintptr_t(0)); // RtMLB was CHAR8*
xb.cat(RtROM);
xb.cat(RtROMLen);
xb.cat(uintptr_t(0)); // RtROM was UINT8*
checkOffset(RtROMLen);
xb.cat(RtROM.size());
checkOffset(CsrActiveConfig);
xb.cat(CsrActiveConfig);
xb.cat(BooterConfig);
WriteOldFixLengthString(BooterCfgStr, 64);
@ -8638,3 +8641,25 @@ checkOffset(OptionsBits);
// MsgLog("%s\n", s.c_str());
//}
//
EFI_GUID nullUUID = {0};
const XString8& SETTINGS_DATA::getUUID()
{
if ( CustomUuid.notEmpty() ) return CustomUuid;
return SmUUID;
}
const XString8& SETTINGS_DATA::getUUID(EFI_GUID *uuid)
{
if ( CustomUuid.notEmpty() ) {
EFI_STATUS Status = StrToGuidLE(CustomUuid, uuid);
if ( EFI_ERROR(Status) ) panic("CustomUuid(%s) is not valid", CustomUuid.c_str()); // we panic, because it's a bug. Validity is checked when imported from settings
return CustomUuid;
}
EFI_STATUS Status = StrToGuidLE(SmUUID, uuid);
if ( EFI_ERROR(Status) ) panic("CustomUuid(%s) is not valid", CustomUuid.c_str()); // same as before
return SmUUID;
}

View File

@ -252,8 +252,7 @@ public:
XString8 ProductName;
XString8 VersionNr;
XString8 SerialNr;
EFI_GUID SmUUID;
BOOLEAN SmUUIDConfig;
XString8 SmUUID;
CHAR8 pad0[7];
//CHAR8 Uuid;
//CHAR8 SKUNumber;
@ -311,7 +310,7 @@ public:
XString8 Language;
XString8 BootArgs;
INT8 pad19[2];
XStringW CustomUuid;
XString8 CustomUuid;
INT8 pad20[6];
XStringW DefaultVolume;
@ -382,7 +381,7 @@ public:
ACPI_NAME_LIST *DeviceRename;
//Injections
BOOLEAN StringInjector;
BOOLEAN InjectSystemID;
UINT8 InjectSystemID_; // 0=false, 1=true, other value = default.
BOOLEAN NoDefaultProperties;
BOOLEAN ReuseFFFF;
@ -502,8 +501,7 @@ public:
// SysVariables
UINT8 pad30[4];
XString8 RtMLB;
UINT8 *RtROM;
UINTN RtROMLen;
XBuffer<UINT8> RtROM;
UINT32 CsrActiveConfig;
UINT16 BooterConfig;
@ -609,8 +607,8 @@ public:
XObjArray<MMIOWhiteList> mmioWhiteListArray;
SETTINGS_DATA() : VendorName(), RomVersion(), EfiVersion(), ReleaseDate(), ManufactureName(), ProductName(), VersionNr(), SerialNr(), SmUUID({0,0,0,{0}}),
SmUUIDConfig(0), pad0{0}, FamilyName(), OEMProduct(), OEMVendor(), BoardManufactureName(), BoardSerialNumber(), BoardNumber(), LocationInChassis(),
SETTINGS_DATA() : VendorName(), RomVersion(), EfiVersion(), ReleaseDate(), ManufactureName(), ProductName(), VersionNr(), SerialNr(), SmUUID(),
pad0{0}, FamilyName(), OEMProduct(), OEMVendor(), BoardManufactureName(), BoardSerialNumber(), BoardNumber(), LocationInChassis(),
BoardVersion(), OEMBoard(), BoardType(0), pad1(0), Mobile(0), ChassisType(0), ChassisManufacturer(), ChassisAssetTag(), CpuFreqMHz(0),
BusSpeed(0), Turbo(0), EnabledCores(0), UserChange(0), QEMU(0), SmbiosVersion(0), Attribute(0), pad17{0}, MemoryManufacturer(),
MemorySerialNumber(), MemoryPartNumber(), MemorySpeed(), CpuType(0), QPI(0), SetTable132(0), TrustSMBIOS(0), InjectMemoryTables(0), XMPDetection(0),
@ -620,7 +618,7 @@ public:
DropSSDT(0), NoOemTableId(0), NoDynamicExtract(0), AutoMerge(0), GeneratePStates(0), GenerateCStates(0), GenerateAPSN(0), GenerateAPLF(0), GeneratePluginType(0),
PLimitDict(0), UnderVoltStep(0), DoubleFirstState(0), SuspendOverride(0), EnableC2(0), EnableC4(0), EnableC6(0), EnableISS(0), SlpSmiEnable(0),
FixHeaders(0), C3Latency(0), smartUPS(0), PatchNMI(0), EnableC7(0), SavingMode(0), DsdtName(), FixDsdt(0), MinMultiplier(0),
MaxMultiplier(0), PluginType(0), FixMCFG(0), DeviceRenameCount(0), DeviceRename(0), StringInjector(0), InjectSystemID(0), NoDefaultProperties(0), ReuseFFFF(0),
MaxMultiplier(0), PluginType(0), FixMCFG(0), DeviceRenameCount(0), DeviceRename(0), StringInjector(0), InjectSystemID_(0), NoDefaultProperties(0), ReuseFFFF(0),
FakeATI(0), FakeNVidia(0), FakeIntel(0), FakeLAN(0), FakeWIFI(0), FakeSATA(0), FakeXHCI(0), FakeIMEI(0), GraphicsInjector(0),
InjectIntel(0), InjectATI(0), InjectNVidia(0), DeInit(0), LoadVBios(0), PatchVBios(0), PatchVBiosBytes(0), PatchVBiosBytesCount(0), InjectEDID(0),
LpcTune(0), DropOEM_DSM(0), CustomEDID(0), CustomEDIDsize(0), EdidFixHorizontalSyncPulseWidth(0), EdidFixVideoInputSignal(0), FBName(), VideoPorts(0), NvidiaGeneric(0),
@ -629,7 +627,7 @@ public:
HDALayoutId(0), USBInjection(0), USBFixOwnership(0), InjectClockID(0), HighCurrent(0), NameEH00(0), NameXH00(0), LANInjection(0), HDMIInjection(0),
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),
RefCLK(0), RtMLB(), RtROM(), CsrActiveConfig(0), BooterConfig(0), BooterCfgStr(), DisableCloverHotkeys(0), NeverDoRecovery(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),
@ -644,6 +642,16 @@ public:
~SETTINGS_DATA() {}
const XString8& getUUID();
const XString8& getUUID(EFI_GUID* efiGuid);
bool ShouldInjectSystemID() {
if ( CustomUuid.notEmpty() ){
if ( InjectSystemID_ == 2 ) return false;
else return InjectSystemID_;
}
if ( SmUUID.notEmpty() && InjectSystemID_ == 2 ) return false;
return InjectSystemID_;
}
};
//#pragma GCC diagnostic ignored "-Wpadded"
@ -803,8 +811,6 @@ extern CONST CHAR8* gBuildInfo;
extern BOOLEAN ResumeFromCoreStorage;
extern BOOLEAN gRemapSmBiosIsRequire; // syscl: pass argument for Dell SMBIOS here
extern EFI_GUID gUuid;
extern EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl;

View File

@ -11,7 +11,7 @@
//EFI_GUID gAppleFirmwarePasswordProtocolGuid = {0x8FFEEB3A, 0x4C98, 0x4630, {0x80, 0x3F, 0x74, 0x0F, 0x95, 0x67, 0x09, 0x1D}};
//gEfiGlobalVariableGuid
//EFI_GUID gEfiGlobalVarGuid = {0x8BE4DF61, 0x93CA, 0x11D2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C}};
//EFI_GUID gAppleDevicePropertyProtocolGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}};
//EFI_GUID gEfiDevicePathPropertyDatabaseProtocolGuid = {0x91BD12FE, 0xF6C3, 0x44FB, {0xA5, 0xB7, 0x51, 0x22, 0xAB, 0x30, 0x3A, 0xE0}};
//EFI_GUID gEfi AppleBootGuid = {0x7C436110, 0xAB2A, 0x4BBB, {0xA8, 0x80, 0xFE, 0x41, 0x99, 0x5C, 0x9F, 0x82}}; //gAppleBootVariableGuid
//EFI_GUID gEfiAppleNvramGuid = {0x4D1EDE05, 0x38C7, 0x4A6A, {0x9C, 0xC6, 0x4B, 0xCC, 0xA8, 0xB3, 0x8C, 0x14}}; //gAppleVendorVariableGuid
//EFI_GUID gAppleFramebufferInfoProtocolGuid = {0xE316E100, 0x0751, 0x4C49, {0x90, 0x56, 0x48, 0x6C, 0x7E, 0x47, 0x29, 0x03}};
@ -143,9 +143,9 @@ F0 00 00 00 | ....
//Slice - I need GuidBEToStr :(
XStringW GuidBeToStr(EFI_GUID *Guid)
XStringW GuidBeToStr(const EFI_GUID& Guid)
{
UINT8 *GuidData = (UINT8 *)Guid;
UINT8 *GuidData = (UINT8 *)&Guid;
XStringW Str = SWPrintf("%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
GuidData[3], GuidData[2], GuidData[1], GuidData[0],
GuidData[5], GuidData[4],
@ -156,21 +156,21 @@ XStringW GuidBeToStr(EFI_GUID *Guid)
}
XStringW GuidLEToXStringW(EFI_GUID *Guid)
XStringW GuidLEToXStringW(const EFI_GUID& Guid)
{
XStringW returnValue;
returnValue.SWPrintf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
Guid->Data1, Guid->Data2, Guid->Data3, Guid->Data4[0], Guid->Data4[1],
Guid->Data4[2], Guid->Data4[3], Guid->Data4[4], Guid->Data4[5], Guid->Data4[6], Guid->Data4[7]);
Guid.Data1, Guid.Data2, Guid.Data3, Guid.Data4[0], Guid.Data4[1],
Guid.Data4[2], Guid.Data4[3], Guid.Data4[4], Guid.Data4[5], Guid.Data4[6], Guid.Data4[7]);
return returnValue;
}
XString8 GuidLEToXString8(EFI_GUID *Guid)
XString8 GuidLEToXString8(const EFI_GUID& Guid)
{
XString8 returnValue;
returnValue.S8Printf("%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
Guid->Data1, Guid->Data2, Guid->Data3, Guid->Data4[0], Guid->Data4[1],
Guid->Data4[2], Guid->Data4[3], Guid->Data4[4], Guid->Data4[5], Guid->Data4[6], Guid->Data4[7]);
Guid.Data1, Guid.Data2, Guid.Data3, Guid.Data4[0], Guid.Data4[1],
Guid.Data4[2], Guid.Data4[3], Guid.Data4[4], Guid.Data4[5], Guid.Data4[6], Guid.Data4[7]);
return returnValue;
}

View File

@ -14,26 +14,28 @@
extern "C" EFI_GUID gEfiMiscSubClassGuid;
constexpr const LString8 nullGuid = "00000000-0000-0000-0000-000000000000";
/** Returns TRUE is Str is ascii Guid in format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx */
template <typename T, enable_if( is___String(T) )>
BOOLEAN IsValidGuidAsciiString(const T& Str)
{
UINTN Index;
UINTN Index4IsValidGuidAsciiString; // stupid name to avoid warning : Declaration shadows a variable in the global namespace
if ( Str.length() != 36 ) {
return FALSE;
}
for (Index = 0; Index < 36; Index++) {
if (Index == 8 || Index == 13 || Index == 18 || Index == 23) {
if (Str[Index] != '-') {
for (Index4IsValidGuidAsciiString = 0; Index4IsValidGuidAsciiString < 36; Index4IsValidGuidAsciiString++) {
if (Index4IsValidGuidAsciiString == 8 || Index4IsValidGuidAsciiString == 13 || Index4IsValidGuidAsciiString == 18 || Index4IsValidGuidAsciiString == 23) {
if (Str[Index4IsValidGuidAsciiString] != '-') {
return FALSE;
}
} else {
if (!(
(Str[Index] >= '0' && Str[Index] <= '9')
|| (Str[Index] >= 'a' && Str[Index] <= 'f')
|| (Str[Index] >= 'A' && Str[Index] <= 'F')
(Str[Index4IsValidGuidAsciiString] >= '0' && Str[Index4IsValidGuidAsciiString] <= '9')
|| (Str[Index4IsValidGuidAsciiString] >= 'a' && Str[Index4IsValidGuidAsciiString] <= 'f')
|| (Str[Index4IsValidGuidAsciiString] >= 'A' && Str[Index4IsValidGuidAsciiString] <= 'F')
)
)
{
@ -54,7 +56,7 @@ StrHToBuf (
const T& t
)
{
UINTN Index;
UINTN Index4IsValidGuidAsciiString; // stupid name to avoid warning : Declaration shadows a variable in the global namespace
UINTN StrLength;
UINT8 Digit;
UINT8 Byte;
@ -67,14 +69,14 @@ StrHToBuf (
//
StrLength = BufferLength * sizeof (CHAR16);
for(Index = 0; Index < StrLength; Index++) {
for(Index4IsValidGuidAsciiString = 0; Index4IsValidGuidAsciiString < StrLength; Index4IsValidGuidAsciiString++) {
if ((Str[Index] >= (__typeof__(*Str))'a') && (Str[Index] <= (__typeof__(*Str))'f')) {
Digit = (UINT8) (Str[Index] - (__typeof__(*Str))'a' + 0x0A);
} else if ((Str[Index] >= (__typeof__(*Str))'A') && (Str[Index] <= (__typeof__(*Str))'F')) {
Digit = (UINT8) (Str[Index] - L'A' + 0x0A);
} else if ((Str[Index] >= (__typeof__(*Str))'0') && (Str[Index] <= (__typeof__(*Str))'9')) {
Digit = (UINT8) (Str[Index] - (__typeof__(*Str))'0');
if ((Str[Index4IsValidGuidAsciiString] >= (__typeof__(*Str))'a') && (Str[Index4IsValidGuidAsciiString] <= (__typeof__(*Str))'f')) {
Digit = (UINT8) (Str[Index4IsValidGuidAsciiString] - (__typeof__(*Str))'a' + 0x0A);
} else if ((Str[Index4IsValidGuidAsciiString] >= (__typeof__(*Str))'A') && (Str[Index4IsValidGuidAsciiString] <= (__typeof__(*Str))'F')) {
Digit = (UINT8) (Str[Index4IsValidGuidAsciiString] - L'A' + 0x0A);
} else if ((Str[Index4IsValidGuidAsciiString] >= (__typeof__(*Str))'0') && (Str[Index4IsValidGuidAsciiString] <= (__typeof__(*Str))'9')) {
Digit = (UINT8) (Str[Index4IsValidGuidAsciiString] - (__typeof__(*Str))'0');
} else {
return EFI_INVALID_PARAMETER;
}
@ -83,15 +85,15 @@ StrHToBuf (
// For odd characters, write the upper nibble for each buffer byte,
// and for even characters, the lower nibble.
//
if ((Index & 1) == 0) {
if ((Index4IsValidGuidAsciiString & 1) == 0) {
Byte = (UINT8) (Digit << 4);
} else {
Byte = Buf[Index / 2];
Byte = Buf[Index4IsValidGuidAsciiString / 2];
Byte &= 0xF0;
Byte = (UINT8) (Byte | Digit);
}
Buf[Index / 2] = Byte;
Buf[Index4IsValidGuidAsciiString / 2] = Byte;
}
return EFI_SUCCESS;
@ -173,9 +175,9 @@ StrToGuidLE (
}
XStringW GuidBeToStr(EFI_GUID *Guid);
XString8 GuidLEToXString8(EFI_GUID *Guid);
XStringW GuidLEToXStringW(EFI_GUID *Guid);
XStringW GuidBeToStr(const EFI_GUID& Guid);
XString8 GuidLEToXString8(const EFI_GUID& Guid);
XStringW GuidLEToXStringW(const EFI_GUID& Guid);

View File

@ -7,6 +7,7 @@
#include "smbios.h"
#include "cpu.h"
#include "Nvram.h"
#include "guid.h"
/* Machine Default Data */
@ -1398,10 +1399,9 @@ VOID GetDefaultSettings()
gSettings.BacklightLevelConfig = FALSE;
gSettings.TrustSMBIOS = TRUE;
gSettings.SmUUIDConfig = FALSE;
gSettings.SmUUID = nullGuid;
gSettings.DefaultBackgroundColor = 0x80000000; //the value to delete the variable
gSettings.RtROM = NULL;
gSettings.RtROMLen = 0;
gSettings.RtROM.setEmpty();
gSettings.CsrActiveConfig = 0xFFFF;
gSettings.BooterConfig = 0;
// MemSet(gSettings.BooterCfgStr, 64, 0);

View File

@ -24,6 +24,7 @@
#include "cpu.h"
#include "platformdata.h"
#include "AcpiPatcher.h"
#include "guid.h"
#ifdef __cplusplus
extern "C" {
@ -494,7 +495,7 @@ VOID GetTableType1()
return;
}
CopyMem((VOID*)&gSettings.SmUUID, (VOID*)&SmbiosTable.Type1->Uuid, 16);
gSettings.SmUUID = GuidLEToXString8(SmbiosTable.Type1->Uuid);
s = GetSmbiosString(SmbiosTable, SmbiosTable.Type1->ProductName);
gSettings.OEMProduct.strncpy(s, iStrLen(s, 64)); //strncpy take care of ending zero
@ -525,8 +526,10 @@ VOID PatchTableType1()
newSmbiosTable.Type1->WakeUpType = SystemWakeupTypePowerSwitch;
Once = TRUE;
if((gSettings.SmUUID.Data3 & 0xF000) != 0) {
CopyMem((VOID*)&newSmbiosTable.Type1->Uuid, (VOID*)&gSettings.SmUUID, 16);
EFI_GUID SmUUID;
StrToGuidLE(gSettings.SmUUID, &SmUUID);
if((SmUUID.Data3 & 0xF000) != 0) {
CopyMem((VOID*)&newSmbiosTable.Type1->Uuid, (VOID*)&SmUUID, sizeof(SmUUID));
}
gSettings.ManufactureName.trim();

View File

@ -71,7 +71,7 @@ const XIcon& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI
DevicePath = NextDevicePathNode(DevicePath);
}
if (DevicePathType(DevicePath) == MEDIA_DEVICE_PATH && DevicePathSubType (DevicePath) == MEDIA_VENDOR_DP) {
if ( GuidLEToXString8((EFI_GUID *)((UINT8 *)DevicePath+0x04)).equalIC(ApfsSignatureUUID) ) {
if ( GuidLEToXString8(*(EFI_GUID *)((UINT8 *)DevicePath+0x04)).equalIC(ApfsSignatureUUID) ) {
IconNum = BUILTIN_ICON_VOL_INTERNAL_APFS;
}
} else {

View File

@ -446,7 +446,7 @@
gEfiSecurityArchProtocolGuid
gEfiSecurity2ArchProtocolGuid
gAppleDevicePropertyProtocolGuid
# gEfiDevicePathPropertyDatabaseProtocolGuid
gAppleFramebufferInfoProtocolGuid
gEfiConsoleControlProtocolGuid
gAppleGraphConfigProtocolGuid

View File

@ -1287,21 +1287,21 @@ VOID LOADER_ENTRY::StartLoader11()
// EventsInitialize(this);
// DBG("FinalizeSmbios\n");
FinalizeSmbios();
//
// SetCPUProperties();
//
// if (OSFLAG_ISSET(Flags, OSFLAG_HIBERNATED)) {
// DoHibernateWake = PrepareHibernation(Volume);
// }
// SetupDataForOSX(DoHibernateWake);
//
//
// if ( gDriversFlags.AptioFixLoaded &&
// !DoHibernateWake &&
// !LoadOptions.containsStartWithIC("slide=") ) {
// // Add slide=0 argument for ML+ if not present
// LoadOptions.AddID("slide=0"_XS8);
// }
SetCPUProperties();
if (OSFLAG_ISSET(Flags, OSFLAG_HIBERNATED)) {
DoHibernateWake = PrepareHibernation(Volume);
}
SetupDataForOSX(DoHibernateWake);
if ( gDriversFlags.AptioFixLoaded &&
!DoHibernateWake &&
!LoadOptions.containsStartWithIC("slide=") ) {
// Add slide=0 argument for ML+ if not present
LoadOptions.AddID("slide=0"_XS8);
}
if (gSettings.LastBootedVolume) {
if ( APFSTargetUUID.notEmpty() ) {
@ -1375,23 +1375,81 @@ DBG("Beginning OC\n");
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem = LocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath);
Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, L"EFI\\CLOVER", NULL);
/*
* Define READ_FROM_OC to have mOpenCoreConfiguration initialized from config-oc.plist
* The boot should work.
* Next, comment out the next lines one by one. Once the boot failed, we got the section that
* holds the setting that makes a difference.
*/
//#define USE_OC_SECTION_Acpi
//#define USE_OC_SECTION_Booter
//#define USE_OC_SECTION_DeviceProperties
//#define USE_OC_SECTION_Kernel
//#define USE_OC_SECTION_Misc
//#define USE_OC_SECTION_Nvram
//#define USE_OC_SECTION_PlatformInfo
//#define USE_OC_SECTION_Uefi
#ifdef JIEF_DEBUG
// Status = ClOcReadConfigurationFile(&mOpenCoreStorage, L"config-oc.plist", &mOpenCoreConfiguration);
// if ( EFI_ERROR(Status) ) panic("ClOcReadConfigurationFile");
/* memset(&mOpenCoreConfiguration, 0, sizeof(mOpenCoreConfiguration)); */
// memset(&mOpenCoreConfiguration.Acpi, 0, sizeof(mOpenCoreConfiguration.Acpi));
// memset(&mOpenCoreConfiguration.Booter, 0, sizeof(mOpenCoreConfiguration.Booter));
// memset(&mOpenCoreConfiguration.DeviceProperties, 0, sizeof(mOpenCoreConfiguration.DeviceProperties));
// memset(&mOpenCoreConfiguration.Kernel, 0, sizeof(mOpenCoreConfiguration.Kernel));
// memset(&mOpenCoreConfiguration.Misc, 0, sizeof(mOpenCoreConfiguration.Misc));
// memset(&mOpenCoreConfiguration.Nvram, 0, sizeof(mOpenCoreConfiguration.Nvram));
// memset(&mOpenCoreConfiguration.PlatformInfo, 0, sizeof(mOpenCoreConfiguration.PlatformInfo));
// memset(&mOpenCoreConfiguration.Uefi, 0, sizeof(mOpenCoreConfiguration.Uefi));
#endif
#if !defined(USE_OC_SECTION_Acpi) && !defined(USE_OC_SECTION_Booter) && !defined(USE_OC_SECTION_DeviceProperties) && !defined(USE_OC_SECTION_Kernel) && !defined(USE_OC_SECTION_Misc) && \
!defined(USE_OC_SECTION_Nvram) && !defined(USE_OC_SECTION_PlatformInfo) && !defined(USE_OC_SECTION_Uefi)
memset(&mOpenCoreConfiguration, 0, sizeof(mOpenCoreConfiguration));
DBG("config-oc.plist isn't use at all\n");
#else
Status = ClOcReadConfigurationFile(&mOpenCoreStorage, L"config-oc.plist", &mOpenCoreConfiguration);
if ( EFI_ERROR(Status) ) panic("ClOcReadConfigurationFile");
#ifndef USE_OC_SECTION_Acpi
memset(&mOpenCoreConfiguration.Acpi, 0, sizeof(mOpenCoreConfiguration.Acpi));
DBG("Erase mOpenCoreConfiguration.Acpi\n");
#else
DBG("Keep mOpenCoreConfiguration.Acpi\n");
#endif
#ifndef USE_OC_SECTION_Booter
memset(&mOpenCoreConfiguration.Booter, 0, sizeof(mOpenCoreConfiguration.Booter));
DBG("Erase mOpenCoreConfiguration.Booter\n");
#else
DBG("Keep mOpenCoreConfiguration.Booter\n");
#endif
#ifndef USE_OC_SECTION_DeviceProperties
memset(&mOpenCoreConfiguration.DeviceProperties, 0, sizeof(mOpenCoreConfiguration.DeviceProperties));
DBG("Erase mOpenCoreConfiguration.DeviceProperties\n");
#else
DBG("Keep mOpenCoreConfiguration.DeviceProperties\n");
#endif
#ifndef USE_OC_SECTION_Kernel
memset(&mOpenCoreConfiguration.Kernel, 0, sizeof(mOpenCoreConfiguration.Kernel));
DBG("Erase mOpenCoreConfiguration.Kernel\n");
#else
DBG("Keep mOpenCoreConfiguration.Kernel\n");
#endif
#ifndef USE_OC_SECTION_Misc
memset(&mOpenCoreConfiguration.Misc, 0, sizeof(mOpenCoreConfiguration.Misc));
DBG("Erase mOpenCoreConfiguration.Misc\n");
#else
DBG("Keep mOpenCoreConfiguration.Misc\n");
#endif
#ifndef USE_OC_SECTION_Nvram
memset(&mOpenCoreConfiguration.Nvram, 0, sizeof(mOpenCoreConfiguration.Nvram));
DBG("Erase mOpenCoreConfiguration.Nvram\n");
#else
DBG("Keep mOpenCoreConfiguration.Nvram\n");
#endif
#ifndef USE_OC_SECTION_PlatformInfo
memset(&mOpenCoreConfiguration.PlatformInfo, 0, sizeof(mOpenCoreConfiguration.PlatformInfo));
DBG("Erase mOpenCoreConfiguration.PlatformInfo\n");
#else
DBG("Keep mOpenCoreConfiguration.PlatformInfo\n");
#endif
#ifndef USE_OC_SECTION_Uefi
memset(&mOpenCoreConfiguration.Uefi, 0, sizeof(mOpenCoreConfiguration.Uefi));
DBG("Erase mOpenCoreConfiguration.Uefi\n");
#else
DBG("Keep mOpenCoreConfiguration.Uefi\n");
#endif
#endif
if ( GlobalConfig.DebugLog ) {
mOpenCoreConfiguration.Misc.Debug.AppleDebug = true;
@ -1399,11 +1457,22 @@ DBG("Beginning OC\n");
// mOpenCoreConfiguration.Misc.Debug.DisableWatchDog = true; // already done by Clover ?
mOpenCoreConfiguration.Misc.Debug.DisplayLevel = 0x80400042;
mOpenCoreConfiguration.Misc.Debug.Target = 0x41;
}else{
#ifdef JIEF_DEBUG
egSetGraphicsModeEnabled(false);
mOpenCoreConfiguration.Misc.Debug.ApplePanic = true;
mOpenCoreConfiguration.Misc.Debug.DisplayLevel = 0x80000042;
mOpenCoreConfiguration.Misc.Debug.Target = 0x3;
#endif
}
OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Security.SecureBootModel, "Disabled");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Security.Vault, "Optional");
#ifdef JIEF_DEBUG
mOpenCoreConfiguration.Nvram.WriteFlash = true;
#endif
#ifndef USE_OC_SECTION_Booter
mOpenCoreConfiguration.Booter.MmioWhitelist.Count = (UINT32)gSettings.mmioWhiteListArray.size();
mOpenCoreConfiguration.Booter.MmioWhitelist.AllocCount = mOpenCoreConfiguration.Booter.MmioWhitelist.Count;
@ -1425,11 +1494,15 @@ DBG("Beginning OC\n");
static_assert(sizeof(gSettings.ocBooterQuirks) == sizeof(mOpenCoreConfiguration.Booter.Quirks), "sizeof(gSettings.ocBooterQuirks) == sizeof(mOpenCoreConfiguration.Booter.Quirks)");
memcpy(&mOpenCoreConfiguration.Booter.Quirks, &gSettings.ocBooterQuirks, sizeof(mOpenCoreConfiguration.Booter.Quirks));
//
//// if OC is NOT initialized with OcMain, we need the following
//// OcLoadBooterUefiSupport(&mOpenCoreConfiguration);
//// OcLoadKernelSupport(&mOpenCoreStorage, &mOpenCoreConfiguration, &mOpenCoreCpuInfo);
//// OcImageLoaderInit ();
#endif
// if OC is NOT initialized with OcMain, we need the following
// OcLoadBooterUefiSupport(&mOpenCoreConfiguration);
// OcLoadKernelSupport(&mOpenCoreStorage, &mOpenCoreConfiguration, &mOpenCoreCpuInfo);
// OcImageLoaderInit ();
#ifndef USE_OC_SECTION_Kernel
XObjArray<SIDELOAD_KEXT> kextArray;
if (!DoHibernateWake) {
@ -1438,7 +1511,7 @@ DBG("Beginning OC\n");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Scheme.KernelArch, "X86_64");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Scheme.KernelArch, "x86_64");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Scheme.KernelCache, gSettings.KernelAndKextPatches.OcKernelCache.c_str());
mOpenCoreConfiguration.Kernel.Scheme.FuzzyMatch = gSettings.KernelAndKextPatches.FuzzyMatch;
memcpy(&mOpenCoreConfiguration.Kernel.Quirks, &gSettings.KernelAndKextPatches.OcKernelQuirks, sizeof(mOpenCoreConfiguration.Kernel.Quirks));
@ -1446,7 +1519,8 @@ DBG("Beginning OC\n");
mOpenCoreConfiguration.Kernel.Add.Count = (UINT32)kextArray.size();
mOpenCoreConfiguration.Kernel.Add.AllocCount = mOpenCoreConfiguration.Kernel.Add.Count;
mOpenCoreConfiguration.Kernel.Add.ValueSize = sizeof(__typeof_am__(**mOpenCoreConfiguration.Kernel.Add.Values)); // sizeof(OC_KERNEL_ADD_ENTRY) == 680
mOpenCoreConfiguration.Kernel.Add.Values = (OC_KERNEL_ADD_ENTRY**)AllocatePool(mOpenCoreConfiguration.Kernel.Add.AllocCount*sizeof(*mOpenCoreConfiguration.Kernel.Add.Values)); // sizeof(OC_KERNEL_ADD_ENTRY) == 680
mOpenCoreConfiguration.Kernel.Add.Values = (OC_KERNEL_ADD_ENTRY**)malloc(mOpenCoreConfiguration.Kernel.Add.AllocCount*sizeof(*mOpenCoreConfiguration.Kernel.Add.Values)); // sizeof(OC_KERNEL_ADD_ENTRY*) == sizeof(ptr)
memset(mOpenCoreConfiguration.Kernel.Add.Values, 0, mOpenCoreConfiguration.Kernel.Add.AllocCount*sizeof(*mOpenCoreConfiguration.Kernel.Add.Values));
// Seems that Lilu must be first.
size_t pos = setKextAtPos(&kextArray, "Lilu.kext"_XS8, 0);
@ -1463,15 +1537,20 @@ DBG("Beginning OC\n");
{
const SIDELOAD_KEXT& KextEntry = kextArray[kextIdx];
DBG("Bridge kext to OC : Path=%ls\n", KextEntry.FileName.wc_str());
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Add.Values))AllocatePool(mOpenCoreConfiguration.Kernel.Add.ValueSize);
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Add.Values))malloc(mOpenCoreConfiguration.Kernel.Add.ValueSize);
memset(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx], 0, mOpenCoreConfiguration.Kernel.Add.ValueSize);
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->Enabled = 1;
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->Arch, "Any");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->Arch, OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch));
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->Comment, "");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->MaxKernel, "");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->MinKernel, "");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->Identifier, "");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath, S8Printf("%ls\\%ls", KextEntry.KextDirNameUnderOEMPath.wc_str(), KextEntry.FileName.wc_str()).c_str()); // do NOT delete kextArray, or make a copy.
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, S8Printf("Contents\\MacOS\\%ls", KextEntry.FileName.subString(0, KextEntry.FileName.rindexOf(".")).wc_str()).c_str());
XStringW execpath = S8Printf("Contents\\MacOS\\%ls", KextEntry.FileName.subString(0, KextEntry.FileName.rindexOf(".")).wc_str());
XStringW fullPath = SWPrintf("%ls\\Kexts\\%s\\%ls", OEMPath.wc_str(), OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath), execpath.wc_str());
if ( FileExists(SelfRootDir, fullPath) ) {
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, S8Printf("Contents\\MacOS\\%ls", KextEntry.FileName.subString(0, KextEntry.FileName.rindexOf(".")).wc_str()).c_str());
}
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Contents/Info.plist"); // TODO : is always Contents/Info.plist ?
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ImageData = NULL;
mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ImageDataSize = 0;
@ -1488,13 +1567,14 @@ DBG("Beginning OC\n");
mOpenCoreConfiguration.Kernel.Patch.Count = (UINT32)selectedPathArray.size();
mOpenCoreConfiguration.Kernel.Patch.AllocCount = mOpenCoreConfiguration.Kernel.Patch.Count;
mOpenCoreConfiguration.Kernel.Patch.ValueSize = sizeof(__typeof_am__(**mOpenCoreConfiguration.Kernel.Patch.Values));
mOpenCoreConfiguration.Kernel.Patch.Values = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Patch.Values)*)AllocatePool(mOpenCoreConfiguration.Kernel.Add.AllocCount*sizeof(__typeof_am__(*mOpenCoreConfiguration.Kernel.Patch.Values)));
mOpenCoreConfiguration.Kernel.Patch.Values = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Patch.Values)*)malloc(mOpenCoreConfiguration.Kernel.Patch.AllocCount*sizeof(__typeof_am__(*mOpenCoreConfiguration.Kernel.Patch.Values)));
memset(mOpenCoreConfiguration.Kernel.Patch.Values, 0, mOpenCoreConfiguration.Kernel.Patch.AllocCount*sizeof(*mOpenCoreConfiguration.Kernel.Patch.Values));
for (size_t kextPatchIdx = 0 ; kextPatchIdx < selectedPathArray.size() ; kextPatchIdx++ )
{
const KEXT_PATCH& kextPatch = selectedPathArray[kextPatchIdx];
DBG("Bridge kext patch to OC : %s\n", kextPatch.Label.c_str());
mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Patch.Values))AllocateZeroPool(mOpenCoreConfiguration.Kernel.Patch.ValueSize); // sizeof(OC_KERNEL_ADD_ENTRY) == 680
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Arch, "Any");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Arch, OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch));
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Base, "");
OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Comment, kextPatch.Label.c_str());
mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Count = 0;
@ -1515,9 +1595,11 @@ DBG("Beginning OC\n");
const XStringW& forceKext = KernelAndKextPatches.ForceKexts[forceKextIdx];
DBG("TODO !!!!!!!! Bridge force kext to OC : %ls\n", forceKext.wc_str());
}
#endif
// mOpenCoreConfiguration.Uefi.Output.ProvideConsoleGop = true;
OC_STRING_ASSIGN(mOpenCoreConfiguration.Uefi.Output.Resolution, XString8(GlobalConfig.ScreenResolution).c_str());
OcMain(&mOpenCoreStorage, NULL);
@ -2416,7 +2498,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if ( !EFI_ERROR(Status) ) DBG("Clover : Image base = 0x%llX\n", (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by grep to feed the debugger
#ifdef JIEF_DEBUG
gBS->Stall(3500000); // to give time to gdb to connect
gBS->Stall(1500000); // to give time to gdb to connect
// gBS->Stall(0500000); // to give time to gdb to connect
// PauseForKey(L"press\n");
#endif
@ -2507,6 +2589,8 @@ RefitMain (IN EFI_HANDLE ImageHandle,
//debugStartImageWithOC(); // ok BS_I
GetDefaultSettings(); // do this before PrepatchSmbios() because PrepatchSmbios() change gSettings.SmUUID.
// TODO : there is a mixup between SmUUID read from the platform and the SmUUID set by the user. They should be read in 2 different vars.
PrepatchSmbios();
//replace / with _
@ -2516,7 +2600,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
GetCPUProperties();
GetDevices();
GetDefaultSettings();
// LoadOptions Parsing
DBG("Clover load options size = %d bytes\n", SelfLoadedImage->LoadOptionsSize);