diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0466f38c7e..8677237e76 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -60,3 +60,4 @@ jobs: CloverV2*.zip CLOVERX64.efi.zip Clover_r*.pkg + generate_release_notes: true diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index fc32fa6afb..d5f7d130ce 100644 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -2088,7 +2088,7 @@ DEFINE GCC5_AARCH64_ASLDLINK_FLAGS = DEF(GCC49_AARCH64_ASLDLINK_FLAGS) DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto DEFINE GCC53_IA32_CC_FLAGS = DEF(GCC49_IA32_CC_FLAGS) -DEFINE GCC53_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-incompatible-ms-struct -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions +DEFINE GCC53_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions DEFINE GCC53_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x240,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds DEFINE GCC53_IA32_X64_ASLDLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable @@ -2099,7 +2099,7 @@ DEFINE GCC53_X64_DLINK_FLAGS = DEF(GCC53_IA32_X64_DLINK_FLAGS),-melf_x86 DEFINE GCC53_ASM_FLAGS = DEF(GCC49_ASM_FLAGS) -DEFINE GCC131_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-incompatible-ms-struct -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions +DEFINE GCC131_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions DEFINE GCC131_IA32_X64_DLINK_COMMON = -nostdlib -Wl,--no-warn-rwx-segments,--gc-sections,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x240,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds DEFINE GCC131_IA32_X64_ASLDLINK_FLAGS = DEF(GCC131_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable DEFINE GCC131_IA32_X64_DLINK_FLAGS = DEF(GCC131_IA32_X64_DLINK_COMMON),--entry,$(IMAGE_ENTRY_POINT),-u,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map @@ -2118,14 +2118,14 @@ DEFINE GCC131_AARCH64_DLINK2_FLAGS = DEF(GCC49_AARCH64_DLINK2_FLAGS) -Wno-er DEFINE GCC131_ARM_ASLDLINK_FLAGS = DEF(GCC49_ARM_ASLDLINK_FLAGS) DEFINE GCC131_AARCH64_ASLDLINK_FLAGS = DEF(GCC49_AARCH64_ASLDLINK_FLAGS) -DEFINE GCC151_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-incompatible-ms-struct -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions +DEFINE GCC151_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions DEFINE GCC151_IA32_X64_DLINK_COMMON = -nostdlib -Wl,--no-warn-rwx-segments,--gc-sections,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x240,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds DEFINE GCC151_IA32_X64_ASLDLINK_FLAGS = DEF(GCC151_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable DEFINE GCC151_IA32_X64_DLINK_FLAGS = DEF(GCC151_IA32_X64_DLINK_COMMON),--entry,$(IMAGE_ENTRY_POINT),-u,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map DEFINE GCC151_X64_DLINK_FLAGS = DEF(GCC151_IA32_X64_DLINK_FLAGS),-melf_x86_64,-znoexecstack,--oformat=elf64-x86-64,-pie DEFINE GCC151_ASM_FLAGS = DEF(GCC49_ASM_FLAGS) -DEFINE GCC152_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-incompatible-ms-struct -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions +DEFINE GCC152_X64_CC_FLAGS = DEF(GCC49_X64_CC_FLAGS) -fno-unwind-tables -Wno-misleading-indentation -mms-bitfields -fno-ms-extensions -ffreestanding -fno-exceptions DEFINE GCC152_IA32_X64_DLINK_COMMON = -nostdlib -Wl,--no-warn-rwx-segments,--gc-sections,-n,-q,--gc-sections,-z,common-page-size=0x40,--defsym=PECOFF_HEADER_SIZE=0x240,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds DEFINE GCC152_IA32_X64_ASLDLINK_FLAGS = DEF(GCC152_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable DEFINE GCC152_IA32_X64_DLINK_FLAGS = DEF(GCC152_IA32_X64_DLINK_COMMON),--entry,$(IMAGE_ENTRY_POINT),-u,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map diff --git a/rEFIt_UEFI/Platform/Settings.h b/rEFIt_UEFI/Platform/Settings.h index 39f13bf502..4d46665b16 100644 --- a/rEFIt_UEFI/Platform/Settings.h +++ b/rEFIt_UEFI/Platform/Settings.h @@ -1,192 +1,201 @@ #ifndef __SETTINGS_H__ #define __SETTINGS_H__ -#include +#include "../Platform/guid.h" +#include "../Platform/plist/plist.h" +#include "../cpp_lib/undefinable.h" +#include "../entry_scan/loader.h" // for KERNEL_SCAN_xxx constants #include "../gui/menu_items/menu_items.h" // TODO: break that dependency +#include "../include/Languages.h" #include "../include/OSFlags.h" #include "../include/OSTypes.h" -#include "../include/Languages.h" -#include "../Platform/plist/plist.h" -#include "../Platform/guid.h" -#include "MacOsVersion.h" -#include "KERNEL_AND_KEXT_PATCHES.h" #include "../libeg/XIcon.h" -#include "../cpp_lib/undefinable.h" -#include "../entry_scan/loader.h" // for KERNEL_SCAN_xxx constants -//#include "../Platform/smbios.h" -#include "../Platform/platformdata.h" -#include "../Settings/ConfigPlist/ConfigPlistClass.h" -#include "../Platform/guid.h" +#include "KERNEL_AND_KEXT_PATCHES.h" +#include "MacOsVersion.h" +#include +// #include "../Platform/smbios.h" #include "../Platform/SettingsUtils.h" +#include "../Platform/guid.h" #include "../Platform/hda.h" +#include "../Platform/platformdata.h" #include "../Settings/ConfigManager.h" +#include "../Settings/ConfigPlist/ConfigPlistClass.h" -#define CLOVER_SIGN SIGNATURE_32('C','l','v','r') +#define CLOVER_SIGN SIGNATURE_32('C', 'l', 'v', 'r') -extern CONST CHAR8 *AudioOutputNames[]; -extern XBool gFirmwareClover; +extern CONST CHAR8 *AudioOutputNames[]; +extern XBool gFirmwareClover; -class HDA_OUTPUTS -{ +class HDA_OUTPUTS { public: - XStringW Name; - UINT8 Index; - EFI_HANDLE Handle = NULL; + XStringW Name; + UINT8 Index; + EFI_HANDLE Handle = NULL; EFI_AUDIO_IO_PROTOCOL_DEVICE Device = EfiAudioIoDeviceOther; HDA_OUTPUTS() : Name(), Index(0) {} - HDA_OUTPUTS(const HDA_OUTPUTS& other) = delete; // Can be defined if needed - const HDA_OUTPUTS& operator = ( const HDA_OUTPUTS & ) = delete; // Can be defined if needed + HDA_OUTPUTS(const HDA_OUTPUTS &other) = delete; // Can be defined if needed + const HDA_OUTPUTS & + operator=(const HDA_OUTPUTS &) = delete; // Can be defined if needed ~HDA_OUTPUTS() {} }; typedef struct { - HRDW_MANUFACTERER Vendor; - UINT8 Ports; - UINT16 DeviceID; - UINT16 Family; -//UINT16 Width; -//UINT16 Height; - CHAR8 Model[64]; - CHAR8 Config[64]; - XBool LoadVBios; -//XBool PatchVBios; - UINTN Segment; - UINTN Bus; - UINTN Device; - UINTN Function; - EFI_HANDLE Handle; - UINT8 *Mmio; - UINT32 Connectors; - XBool ConnChanged; + HRDW_MANUFACTERER Vendor; + UINT8 Ports; + UINT16 DeviceID; + UINT16 Family; + // UINT16 Width; + // UINT16 Height; + CHAR8 Model[64]; + CHAR8 Config[64]; + XBool LoadVBios; + // XBool PatchVBios; + UINTN Segment; + UINTN Bus; + UINTN Device; + UINTN Function; + EFI_HANDLE Handle; + UINT8 *Mmio; + UINT32 Connectors; + XBool ConnChanged; } GFX_PROPERTIES; typedef struct { - HRDW_MANUFACTERER Vendor; - UINT16 controller_vendor_id; - UINT16 controller_device_id; - CHAR16 *controller_name; -// -- Codec Info -- // -// UINT16 codec_vendor_id; -// UINT16 codec_device_id; -// UINT8 codec_revision_id; -// UINT8 codec_stepping_id; -// UINT8 codec_maj_rev; -// UINT8 codec_min_rev; -// UINT8 codec_num_function_groups; -// CHAR16 *codec_name; + HRDW_MANUFACTERER Vendor; + UINT16 controller_vendor_id; + UINT16 controller_device_id; + CHAR16 *controller_name; + // -- Codec Info -- // + // UINT16 codec_vendor_id; + // UINT16 codec_device_id; + // UINT8 codec_revision_id; + // UINT8 codec_stepping_id; + // UINT8 codec_maj_rev; + // UINT8 codec_min_rev; + // UINT8 codec_num_function_groups; + // CHAR16 *codec_name; } HDA_PROPERTIES; -class ACPI_NAME -{ +class ACPI_NAME { public: XString8 Name = XString8(); - + #if __cplusplus > 201703L - XBool operator == (const ACPI_NAME&) const = default; + XBool operator==(const ACPI_NAME &) const = default; #endif - XBool isEqual(const ACPI_NAME& other) const - { - if ( !(Name == other.Name) ) return false; + XBool isEqual(const ACPI_NAME &other) const { + if (!(Name == other.Name)) + return false; return true; } XString8Array getSplittedName() const { XString8Array splittedName = Split(Name, "."); - for ( size_t idx = 0 ; idx < splittedName.size() ; ++idx) { - XString8& name = splittedName[idx]; - while ( name.length() > 4 ) name.deleteCharsAtPos(name.length()-1); - while ( name.length() < 4 ) name.strcat('_'); + for (size_t idx = 0; idx < splittedName.size(); ++idx) { + XString8 &name = splittedName[idx]; + while (name.length() > 4) + name.deleteCharsAtPos(name.length() - 1); + while (name.length() < 4) + name.strcat('_'); } - for ( size_t idx = 1 ; idx < splittedName.size() ; ++idx) { - splittedName.insertReferenceAtPos(splittedName.ExtractFromPos(idx), 0, true); // A swap method in XObjARray would be slightly better to avoid memcpy in XObjArray when an object is removed. + for (size_t idx = 1; idx < splittedName.size(); ++idx) { + splittedName.insertReferenceAtPos( + splittedName.ExtractFromPos(idx), 0, + true); // A swap method in XObjARray would be slightly better to avoid + // memcpy in XObjArray when an object is removed. } return splittedName; } }; -class ACPI_RENAME_DEVICE -{ +class ACPI_RENAME_DEVICE { public: ACPI_NAME acpiName = ACPI_NAME(); XString8 renameTo = XString8(); - + #if __cplusplus > 201703L - XBool operator == (const ACPI_RENAME_DEVICE&) const = default; + XBool operator==(const ACPI_RENAME_DEVICE &) const = default; #endif - XBool isEqual(const ACPI_RENAME_DEVICE& other) const - { - if ( !acpiName.isEqual(other.acpiName) ) return false; - if ( !(renameTo == other.renameTo) ) return false; + XBool isEqual(const ACPI_RENAME_DEVICE &other) const { + if (!acpiName.isEqual(other.acpiName)) + return false; + if (!(renameTo == other.renameTo)) + return false; return true; } - void takeValueFrom(const XmlAddKey& other) - { + void takeValueFrom(const XmlAddKey &other) { acpiName.Name = other.key(); renameTo = other.value(); } XString8 getRenameTo() const { - if ( renameTo.length() == 4 ) return renameTo; - XString8 newName = renameTo; - while ( newName.length() > 4 ) newName.deleteCharsAtPos(newName.length()-1); - while ( newName.length() < 4 ) newName.strcat('_'); + if (renameTo.length() == 4) + return renameTo; + XString8 newName = renameTo; + while (newName.length() > 4) + newName.deleteCharsAtPos(newName.length() - 1); + while (newName.length() < 4) + newName.strcat('_'); return newName; } - }; -class ACPI_DROP_TABLE -{ +class ACPI_DROP_TABLE { public: union { - UINT32 Signature = 0; - char SignatureAs4Chars[4]; + UINT32 Signature = 0; + char SignatureAs4Chars[4]; }; - UINT32 Length = 0; - UINT64 TableId = 0; - INPUT_ITEM MenuItem = INPUT_ITEM(); - XBool OtherOS = false; + UINT32 Length = 0; + UINT64 TableId = 0; + INPUT_ITEM MenuItem = INPUT_ITEM(); + XBool OtherOS = false; ACPI_DROP_TABLE() {} - ACPI_DROP_TABLE(const ACPI_DROP_TABLE& other) = default; - ACPI_DROP_TABLE& operator = ( const ACPI_DROP_TABLE & ) = default; + ACPI_DROP_TABLE(const ACPI_DROP_TABLE &other) = default; + ACPI_DROP_TABLE &operator=(const ACPI_DROP_TABLE &) = default; ~ACPI_DROP_TABLE() {} }; class CUSTOM_LOADER_SUBENTRY_SETTINGS; class CUSTOM_LOADER_SUBENTRY; - -class CUSTOM_LOADER_SUBENTRY_SETTINGS -{ +class CUSTOM_LOADER_SUBENTRY_SETTINGS { public: - XBool Disabled = false; + XBool Disabled = false; + public: // temporary, must be protected: - // member defined with _ prefix should not be accessed from outside. I left them public for now for CompareCustomEntries() - undefinable_XString8 _Arguments = undefinable_XString8(); - XString8 _AddArguments = XString8(); + // member defined with _ prefix should not be accessed from outside. I left + // them public for now for CompareCustomEntries() + undefinable_XString8 _Arguments = undefinable_XString8(); + XString8 _AddArguments = XString8(); - undefinable_XString8 _FullTitle = undefinable_XString8(); - undefinable_XString8 _Title = undefinable_XString8(); + undefinable_XString8 _FullTitle = undefinable_XString8(); + undefinable_XString8 _Title = undefinable_XString8(); + + undefinable_bool _NoCaches = undefinable_bool(); - undefinable_bool _NoCaches = undefinable_bool(); - #if __cplusplus > 201703L - XBool operator == (const CUSTOM_LOADER_SUBENTRY_SETTINGS&) const = default; + XBool operator==(const CUSTOM_LOADER_SUBENTRY_SETTINGS &) const = default; #endif - XBool isEqual(const CUSTOM_LOADER_SUBENTRY_SETTINGS& other) const - { - if ( !(Disabled == other.Disabled) ) return false; - if ( !(_Arguments == other._Arguments) ) return false; - if ( !(_AddArguments == other._AddArguments) ) return false; - if ( !(_FullTitle == other._FullTitle) ) return false; - if ( !(_Title == other._Title) ) return false; - if ( !(_NoCaches == other._NoCaches) ) return false; + XBool isEqual(const CUSTOM_LOADER_SUBENTRY_SETTINGS &other) const { + if (!(Disabled == other.Disabled)) + return false; + if (!(_Arguments == other._Arguments)) + return false; + if (!(_AddArguments == other._AddArguments)) + return false; + if (!(_FullTitle == other._FullTitle)) + return false; + if (!(_Title == other._Title)) + return false; + if (!(_NoCaches == other._NoCaches)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_SubEntry_Class& other) - { + void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Custom_Class:: + GUI_Custom_SubEntry_Class &other) { Disabled = other.dgetDisabled(); _Arguments = other.dget_Arguments(); _AddArguments = other.dget_AddArguments(); @@ -194,24 +203,25 @@ class CUSTOM_LOADER_SUBENTRY_SETTINGS _Title = other.dget_Title(); _NoCaches = other.dget_NoCaches(); } - }; class CUSTOM_LOADER_ENTRY; -class CUSTOM_LOADER_SUBENTRY -{ +class CUSTOM_LOADER_SUBENTRY { public: - const CUSTOM_LOADER_ENTRY& parent; - const CUSTOM_LOADER_SUBENTRY_SETTINGS& settings = CUSTOM_LOADER_SUBENTRY_SETTINGS(); + const CUSTOM_LOADER_ENTRY &parent; + const CUSTOM_LOADER_SUBENTRY_SETTINGS &settings = + CUSTOM_LOADER_SUBENTRY_SETTINGS(); + + CUSTOM_LOADER_SUBENTRY(const CUSTOM_LOADER_ENTRY &_customLoaderEntry, + const CUSTOM_LOADER_SUBENTRY_SETTINGS &_settings) + : parent(_customLoaderEntry), settings(_settings) {} - CUSTOM_LOADER_SUBENTRY(const CUSTOM_LOADER_ENTRY& _customLoaderEntry, const CUSTOM_LOADER_SUBENTRY_SETTINGS& _settings) : parent(_customLoaderEntry), settings(_settings) {} - XString8Array getLoadOptions() const; UINT8 getFlags(XBool NoCachesDefault) const; - const XString8& getTitle() const; - const XString8& getFullTitle() const; + const XString8 &getTitle() const; + const XString8 &getFullTitle() const; }; class CUSTOM_LOADER_ENTRY_SETTINGS; @@ -222,98 +232,145 @@ extern const XStringW defaultRecoveryImagePath; extern const XStringW defaultRecoveryDriveImagePath; /* - * Wrapper class to bring some syntaxic sugar : initialisation at construction, assignment, == operator, etc. + * Wrapper class to bring some syntaxic sugar : initialisation at construction, + * assignment, == operator, etc. */ -class EFI_GRAPHICS_OUTPUT_BLT_PIXELClass : public EFI_GRAPHICS_OUTPUT_BLT_PIXEL -{ +class EFI_GRAPHICS_OUTPUT_BLT_PIXELClass + : public EFI_GRAPHICS_OUTPUT_BLT_PIXEL { public: - EFI_GRAPHICS_OUTPUT_BLT_PIXELClass() { Blue = 0; Green = 0; Red = 0; Reserved = 0; } - - EFI_GRAPHICS_OUTPUT_BLT_PIXELClass(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& other) { Blue = other.Blue; Green = other.Green; Red = other.Red; Reserved = other.Reserved; } - - XBool operator == (const EFI_GRAPHICS_OUTPUT_BLT_PIXELClass& other) const { - if ( !(Blue == other.Blue) ) return false; - if ( !(Green == other.Green) ) return false; - if ( !(Red == other.Red) ) return false; - if ( !(Reserved == other.Reserved) ) return false; + EFI_GRAPHICS_OUTPUT_BLT_PIXELClass() { + Blue = 0; + Green = 0; + Red = 0; + Reserved = 0; + } + + EFI_GRAPHICS_OUTPUT_BLT_PIXELClass( + const EFI_GRAPHICS_OUTPUT_BLT_PIXEL &other) { + Blue = other.Blue; + Green = other.Green; + Red = other.Red; + Reserved = other.Reserved; + } + + XBool operator==(const EFI_GRAPHICS_OUTPUT_BLT_PIXELClass &other) const { + if (!(Blue == other.Blue)) + return false; + if (!(Green == other.Green)) + return false; + if (!(Red == other.Red)) + return false; + if (!(Reserved == other.Reserved)) + return false; return true; } }; -class CUSTOM_LOADER_ENTRY_SETTINGS -{ +class CUSTOM_LOADER_ENTRY_SETTINGS { public: - XBool Disabled = false; - XBuffer ImageData = XBuffer(); - XBuffer DriveImageData = XBuffer(); - XStringW Volume = XStringW(); - XStringW Path = XStringW(); - undefinable_XString8 Arguments = undefinable_XString8(); - XString8 AddArguments = XString8(); - XString8 FullTitle = XStringW(); - XStringW Settings = XStringW(); // path of a config.plist that'll be read at the beginning of startloader - char32_t Hotkey = 0; - XBool CommonSettings = false; -// UINT8 Flags = 0; - XBool Hidden = false; - XBool AlwaysHidden = false; - UINT8 Type = 0; - UINT8 VolumeType = 0; - UINT8 KernelScan = KERNEL_SCAN_ALL; - XString8 CustomLogoAsXString8 = XString8(); - XBuffer CustomLogoAsData = XBuffer(); - EFI_GRAPHICS_OUTPUT_BLT_PIXELClass BootBgColor = EFI_GRAPHICS_OUTPUT_BLT_PIXELClass(); - INT8 InjectKexts = -1; - undefinable_bool NoCaches = undefinable_bool(); - XObjArrayWithTakeValueFromXmlArray - SubEntriesSettings = XObjArrayWithTakeValueFromXmlArray(); + XBool Disabled = false; + XBuffer ImageData = XBuffer(); + XBuffer DriveImageData = XBuffer(); + XStringW Volume = XStringW(); + XStringW Path = XStringW(); + undefinable_XString8 Arguments = undefinable_XString8(); + XString8 AddArguments = XString8(); + XString8 FullTitle = XStringW(); + XStringW Settings = XStringW(); // path of a config.plist that'll be read at + // the beginning of startloader + char32_t Hotkey = 0; + XBool CommonSettings = false; + // UINT8 Flags = 0; + XBool Hidden = false; + XBool AlwaysHidden = false; + UINT8 Type = 0; + UINT8 VolumeType = 0; + UINT8 KernelScan = KERNEL_SCAN_ALL; + XString8 CustomLogoAsXString8 = XString8(); + XBuffer CustomLogoAsData = XBuffer(); + EFI_GRAPHICS_OUTPUT_BLT_PIXELClass BootBgColor = + EFI_GRAPHICS_OUTPUT_BLT_PIXELClass(); + INT8 InjectKexts = -1; + undefinable_bool NoCaches = undefinable_bool(); + XObjArrayWithTakeValueFromXmlArray< + CUSTOM_LOADER_SUBENTRY_SETTINGS, + ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_SubEntry_Class> + SubEntriesSettings = XObjArrayWithTakeValueFromXmlArray< + CUSTOM_LOADER_SUBENTRY_SETTINGS, + ConfigPlistClass::GUI_Class::GUI_Custom_Class:: + GUI_Custom_SubEntry_Class>(); public: // temporary, must be protected: - XStringW m_DriveImagePath = XStringW(); - XString8 m_Title = XStringW(); - UINT8 CustomLogoTypeSettings = 0; - XStringW m_ImagePath = XStringW(); + XStringW m_DriveImagePath = XStringW(); + XString8 m_Title = XStringW(); + UINT8 CustomLogoTypeSettings = 0; + XStringW m_ImagePath = XStringW(); - XBool ForceTextMode = false; // 2021-04-22 + XBool ForceTextMode = false; // 2021-04-22 public: - #if __cplusplus > 201703L - XBool operator == (const CUSTOM_LOADER_ENTRY_SETTINGS&) const = default; + XBool operator==(const CUSTOM_LOADER_ENTRY_SETTINGS &) const = default; #endif - XBool isEqual(const CUSTOM_LOADER_ENTRY_SETTINGS& other) const - { - if ( !(Disabled == other.Disabled) ) return false; - if ( !(ImageData == other.ImageData) ) return false; - if ( !(DriveImageData == other.DriveImageData) ) return false; - if ( !(Volume == other.Volume) ) return false; - if ( !(Path == other.Path) ) return false; - if ( !(Arguments == other.Arguments) ) return false; - if ( !(AddArguments == other.AddArguments) ) return false; - if ( !(FullTitle == other.FullTitle) ) return false; - if ( !(Settings == other.Settings) ) return false; - if ( !(Hotkey == other.Hotkey) ) return false; - if ( !(CommonSettings == other.CommonSettings) ) return false; - if ( !(Hidden == other.Hidden) ) return false; - if ( !(AlwaysHidden == other.AlwaysHidden) ) return false; - if ( !(Type == other.Type) ) return false; - if ( !(VolumeType == other.VolumeType) ) return false; - if ( !(KernelScan == other.KernelScan) ) return false; - if ( !(CustomLogoAsXString8 == other.CustomLogoAsXString8) ) return false; - if ( !(CustomLogoAsData == other.CustomLogoAsData) ) return false; - if ( memcmp(&BootBgColor, &other.BootBgColor, sizeof(BootBgColor)) != 0 ) return false; - if ( !(InjectKexts == other.InjectKexts) ) return false; - if ( !(NoCaches == other.NoCaches) ) return false; - if ( !SubEntriesSettings.isEqual(other.SubEntriesSettings) ) return false; - if ( !(m_DriveImagePath == other.m_DriveImagePath) ) return false; - if ( !(m_Title == other.m_Title) ) return false; - if ( !(CustomLogoTypeSettings == other.CustomLogoTypeSettings) ) return false; - if ( !(m_ImagePath == other.m_ImagePath) ) return false; - if ( !(ForceTextMode == other.ForceTextMode) ) return false; + XBool isEqual(const CUSTOM_LOADER_ENTRY_SETTINGS &other) const { + if (!(Disabled == other.Disabled)) + return false; + if (!(ImageData == other.ImageData)) + return false; + if (!(DriveImageData == other.DriveImageData)) + return false; + if (!(Volume == other.Volume)) + return false; + if (!(Path == other.Path)) + return false; + if (!(Arguments == other.Arguments)) + return false; + if (!(AddArguments == other.AddArguments)) + return false; + if (!(FullTitle == other.FullTitle)) + return false; + if (!(Settings == other.Settings)) + return false; + if (!(Hotkey == other.Hotkey)) + return false; + if (!(CommonSettings == other.CommonSettings)) + return false; + if (!(Hidden == other.Hidden)) + return false; + if (!(AlwaysHidden == other.AlwaysHidden)) + return false; + if (!(Type == other.Type)) + return false; + if (!(VolumeType == other.VolumeType)) + return false; + if (!(KernelScan == other.KernelScan)) + return false; + if (!(CustomLogoAsXString8 == other.CustomLogoAsXString8)) + return false; + if (!(CustomLogoAsData == other.CustomLogoAsData)) + return false; + if (memcmp(&BootBgColor, &other.BootBgColor, sizeof(BootBgColor)) != 0) + return false; + if (!(InjectKexts == other.InjectKexts)) + return false; + if (!(NoCaches == other.NoCaches)) + return false; + if (!SubEntriesSettings.isEqual(other.SubEntriesSettings)) + return false; + if (!(m_DriveImagePath == other.m_DriveImagePath)) + return false; + if (!(m_Title == other.m_Title)) + return false; + if (!(CustomLogoTypeSettings == other.CustomLogoTypeSettings)) + return false; + if (!(m_ImagePath == other.m_ImagePath)) + return false; + if (!(ForceTextMode == other.ForceTextMode)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_Entry_Class& other) - { + void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Custom_Class:: + GUI_Custom_Entry_Class &other) { Disabled = other.dgetDisabled(); ImageData = other.dgetImageData(); DriveImageData = other.dgetDriveImageData(); @@ -343,9 +400,9 @@ class CUSTOM_LOADER_ENTRY_SETTINGS ForceTextMode = other.dgetForceTextMode(); } - - const XString8& dgetTitle() const { - if ( m_Title.notEmpty() ) return m_Title; + const XString8 &dgetTitle() const { + if (m_Title.notEmpty()) + return m_Title; if (OSTYPE_IS_OSX_RECOVERY(Type)) { return defaultRecoveryTitle; } else if (OSTYPE_IS_OSX_INSTALLER(Type)) { @@ -354,96 +411,118 @@ class CUSTOM_LOADER_ENTRY_SETTINGS return NullXString8; } - const XStringW& dgetImagePath() const { - if ( m_ImagePath.notEmpty() ) return m_ImagePath; - if ( ImageData.notEmpty() ) return NullXStringW; - if (OSTYPE_IS_OSX_RECOVERY(Type)) return defaultRecoveryImagePath; + const XStringW &dgetImagePath() const { + if (m_ImagePath.notEmpty()) + return m_ImagePath; + if (ImageData.notEmpty()) + return NullXStringW; + if (OSTYPE_IS_OSX_RECOVERY(Type)) + return defaultRecoveryImagePath; return NullXStringW; } - const XStringW& dgetDriveImagePath() const { - if ( m_DriveImagePath.notEmpty() ) return m_DriveImagePath; - if ( DriveImageData.notEmpty() ) return NullXStringW; - if (OSTYPE_IS_OSX_RECOVERY(Type)) return defaultRecoveryDriveImagePath; + const XStringW &dgetDriveImagePath() const { + if (m_DriveImagePath.notEmpty()) + return m_DriveImagePath; + if (DriveImageData.notEmpty()) + return NullXStringW; + if (OSTYPE_IS_OSX_RECOVERY(Type)) + return defaultRecoveryDriveImagePath; return NullXStringW; } - }; -class CUSTOM_LOADER_ENTRY -{ +class CUSTOM_LOADER_ENTRY { public: - const CUSTOM_LOADER_ENTRY_SETTINGS& settings = CUSTOM_LOADER_ENTRY_SETTINGS(); - XObjArray SubEntries = XObjArray(); - XIcon Image = XIcon(); - XIcon DriveImage = XIcon(); - XImage CustomLogoImage = XImage(); // Todo : remove from settings. - UINT8 CustomLogoType = 0; + const CUSTOM_LOADER_ENTRY_SETTINGS &settings = CUSTOM_LOADER_ENTRY_SETTINGS(); + XObjArray SubEntries = + XObjArray(); + XIcon Image = XIcon(); + XIcon DriveImage = XIcon(); + XImage CustomLogoImage = XImage(); // Todo : remove from settings. + UINT8 CustomLogoType = 0; KERNEL_AND_KEXT_PATCHES KernelAndKextPatches = KERNEL_AND_KEXT_PATCHES(); - CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY_SETTINGS& _settings); + CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY_SETTINGS &_settings); XString8Array getLoadOptions() const; - + UINT8 getFlags(XBool NoCachesDefault) const { UINT8 Flags = 0; - if ( settings.Arguments.isDefined() ) Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTARGS); - if ( settings.AlwaysHidden ) Flags = OSFLAG_SET(Flags, OSFLAG_DISABLED); - if ( settings.Type == OSTYPE_LIN ) Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTARGS); - if (OSTYPE_IS_OSX(settings.Type) || OSTYPE_IS_OSX_RECOVERY(settings.Type) || OSTYPE_IS_OSX_INSTALLER(settings.Type)) { + if (settings.Arguments.isDefined()) + Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTARGS); + if (settings.AlwaysHidden) + Flags = OSFLAG_SET(Flags, OSFLAG_DISABLED); + if (settings.Type == OSTYPE_LIN) + Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTARGS); + if (OSTYPE_IS_OSX(settings.Type) || OSTYPE_IS_OSX_RECOVERY(settings.Type) || + OSTYPE_IS_OSX_INSTALLER(settings.Type)) { Flags = OSFLAG_UNSET(Flags, OSFLAG_NOCACHES); } - if ( settings.NoCaches.isDefined() ) { - if ( settings.NoCaches ) Flags = OSFLAG_SET(Flags, OSFLAG_NOCACHES); - }else{ + if (settings.NoCaches.isDefined()) { + if (settings.NoCaches) + Flags = OSFLAG_SET(Flags, OSFLAG_NOCACHES); + } else { if (NoCachesDefault) { Flags = OSFLAG_SET(Flags, OSFLAG_NOCACHES); } } - if ( SubEntries.notEmpty() ) Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTMENU); + if (SubEntries.notEmpty()) + Flags = OSFLAG_SET(Flags, OSFLAG_NODEFAULTMENU); return Flags; } }; -class CUSTOM_LEGACY_ENTRY_SETTINGS -{ +class CUSTOM_LEGACY_ENTRY_SETTINGS { public: - XBool Disabled = false; - XStringW ImagePath = XStringW(); - XBuffer ImageData = XBuffer(); - XStringW DriveImagePath = XStringW(); - XBuffer DriveImageData = XBuffer(); - XStringW Volume = XStringW(); - XStringW FullTitle = XStringW(); - XStringW Title = XStringW(); - char32_t Hotkey = 0; -// UINT8 Flags = 0; - XBool Hidden = false; - XBool AlwaysHidden = false; - UINT8 Type = 0; - UINT8 VolumeType = 0; + XBool Disabled = false; + XStringW ImagePath = XStringW(); + XBuffer ImageData = XBuffer(); + XStringW DriveImagePath = XStringW(); + XBuffer DriveImageData = XBuffer(); + XStringW Volume = XStringW(); + XStringW FullTitle = XStringW(); + XStringW Title = XStringW(); + char32_t Hotkey = 0; + // UINT8 Flags = 0; + XBool Hidden = false; + XBool AlwaysHidden = false; + UINT8 Type = 0; + UINT8 VolumeType = 0; #if __cplusplus > 201703L - XBool operator == (const CUSTOM_LEGACY_ENTRY_SETTINGS&) const = default; + XBool operator==(const CUSTOM_LEGACY_ENTRY_SETTINGS &) const = default; #endif - XBool isEqual(const CUSTOM_LEGACY_ENTRY_SETTINGS& other) const - { - if ( !(Disabled == other.Disabled) ) return false; - if ( !(ImagePath == other.ImagePath) ) return false; - if ( !(ImageData == other.ImageData) ) return false; - if ( !(DriveImagePath == other.DriveImagePath) ) return false; - if ( !(DriveImageData == other.DriveImageData) ) return false; - if ( !(Volume == other.Volume) ) return false; - if ( !(FullTitle == other.FullTitle) ) return false; - if ( !(Title == other.Title) ) return false; - if ( !(Hotkey == other.Hotkey) ) return false; - if ( !(Hidden == other.Hidden) ) return false; - if ( !(AlwaysHidden == other.AlwaysHidden) ) return false; - if ( !(Type == other.Type) ) return false; - if ( !(VolumeType == other.VolumeType) ) return false; + XBool isEqual(const CUSTOM_LEGACY_ENTRY_SETTINGS &other) const { + if (!(Disabled == other.Disabled)) + return false; + if (!(ImagePath == other.ImagePath)) + return false; + if (!(ImageData == other.ImageData)) + return false; + if (!(DriveImagePath == other.DriveImagePath)) + return false; + if (!(DriveImageData == other.DriveImageData)) + return false; + if (!(Volume == other.Volume)) + return false; + if (!(FullTitle == other.FullTitle)) + return false; + if (!(Title == other.Title)) + return false; + if (!(Hotkey == other.Hotkey)) + return false; + if (!(Hidden == other.Hidden)) + return false; + if (!(AlwaysHidden == other.AlwaysHidden)) + return false; + if (!(Type == other.Type)) + return false; + if (!(VolumeType == other.VolumeType)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_Legacy_Class& other) - { + void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Custom_Class:: + GUI_Custom_Legacy_Class &other) { Disabled = other.dgetDisabled(); ImagePath = other.dgetImagePath(); ImageData = other.dgetImageData(); @@ -460,73 +539,86 @@ class CUSTOM_LEGACY_ENTRY_SETTINGS } }; -class CUSTOM_LEGACY_ENTRY -{ +class CUSTOM_LEGACY_ENTRY { public: - const CUSTOM_LEGACY_ENTRY_SETTINGS& settings = CUSTOM_LEGACY_ENTRY_SETTINGS(); - XIcon Image = XIcon(); - XIcon DriveImage = XIcon(); - - CUSTOM_LEGACY_ENTRY(const CUSTOM_LEGACY_ENTRY_SETTINGS& _settings, const EFI_FILE& ThemeDir) : settings(_settings) - { - if ( settings.ImagePath.notEmpty() ) { + const CUSTOM_LEGACY_ENTRY_SETTINGS &settings = CUSTOM_LEGACY_ENTRY_SETTINGS(); + XIcon Image = XIcon(); + XIcon DriveImage = XIcon(); + + CUSTOM_LEGACY_ENTRY(const CUSTOM_LEGACY_ENTRY_SETTINGS &_settings, + const EFI_FILE &ThemeDir) + : settings(_settings) { + if (settings.ImagePath.notEmpty()) { Image.LoadXImage(&ThemeDir, settings.ImagePath); - }else if ( settings.ImageData.notEmpty() ) { + } else if (settings.ImageData.notEmpty()) { Image.Image.FromPNG(settings.ImageData.data(), settings.ImageData.size()); } - if ( settings.DriveImagePath.notEmpty() ) { + if (settings.DriveImagePath.notEmpty()) { DriveImage.LoadXImage(&ThemeDir, settings.DriveImagePath); - }else if ( settings.DriveImageData.notEmpty() ) { - DriveImage.Image.FromPNG(settings.DriveImageData.data(), settings.DriveImageData.size()); + } else if (settings.DriveImageData.notEmpty()) { + DriveImage.Image.FromPNG(settings.DriveImageData.data(), + settings.DriveImageData.size()); } } - + UINT8 getFlags() const { UINT8 Flags = 0; - if ( settings.Disabled || settings.AlwaysHidden ) Flags = OSFLAG_SET(Flags, OSFLAG_DISABLED); + if (settings.Disabled || settings.AlwaysHidden) + Flags = OSFLAG_SET(Flags, OSFLAG_DISABLED); return Flags; } }; -class CUSTOM_TOOL_ENTRY_SETTINGS -{ +class CUSTOM_TOOL_ENTRY_SETTINGS { public: - XBool Disabled = false; - XStringW ImagePath = XStringW(); - XBuffer ImageData = XBuffer(); - XStringW Volume = XStringW(); - XStringW Path = XStringW(); -// XString8Array LoadOptions = XString8Array(); - XString8 Arguments = XString8(); - XStringW FullTitle = XStringW(); - XStringW Title = XStringW(); - char32_t Hotkey = 0; -// UINT8 Flags = 0; - XBool Hidden = false; - XBool AlwaysHidden = false; - UINT8 VolumeType = 0; - + XBool Disabled = false; + XStringW ImagePath = XStringW(); + XBuffer ImageData = XBuffer(); + XStringW Volume = XStringW(); + XStringW Path = XStringW(); + // XString8Array LoadOptions = XString8Array(); + XString8 Arguments = XString8(); + XStringW FullTitle = XStringW(); + XStringW Title = XStringW(); + char32_t Hotkey = 0; + // UINT8 Flags = 0; + XBool Hidden = false; + XBool AlwaysHidden = false; + UINT8 VolumeType = 0; + #if __cplusplus > 201703L - XBool operator == (const CUSTOM_TOOL_ENTRY_SETTINGS&) const = default; + XBool operator==(const CUSTOM_TOOL_ENTRY_SETTINGS &) const = default; #endif - XBool isEqual(const CUSTOM_TOOL_ENTRY_SETTINGS& other) const - { - if ( !(Disabled == other.Disabled) ) return false; - if ( !(ImagePath == other.ImagePath) ) return false; - if ( !(ImageData == other.ImageData) ) return false; - if ( !(Volume == other.Volume) ) return false; - if ( !(Path == other.Path) ) return false; - if ( !(Arguments == other.Arguments) ) return false; - if ( !(FullTitle == other.FullTitle) ) return false; - if ( !(Title == other.Title) ) return false; - if ( !(Hotkey == other.Hotkey) ) return false; - if ( !(Hidden == other.Hidden) ) return false; - if ( !(AlwaysHidden == other.AlwaysHidden) ) return false; - if ( !(VolumeType == other.VolumeType) ) return false; + XBool isEqual(const CUSTOM_TOOL_ENTRY_SETTINGS &other) const { + if (!(Disabled == other.Disabled)) + return false; + if (!(ImagePath == other.ImagePath)) + return false; + if (!(ImageData == other.ImageData)) + return false; + if (!(Volume == other.Volume)) + return false; + if (!(Path == other.Path)) + return false; + if (!(Arguments == other.Arguments)) + return false; + if (!(FullTitle == other.FullTitle)) + return false; + if (!(Title == other.Title)) + return false; + if (!(Hotkey == other.Hotkey)) + return false; + if (!(Hidden == other.Hidden)) + return false; + if (!(AlwaysHidden == other.AlwaysHidden)) + return false; + if (!(VolumeType == other.VolumeType)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_Tool_Class& other) - { + void takeValueFrom( + const ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_Tool_Class + &other) { Disabled = other.dgetDisabled(); ImagePath = other.dgetImagePath(); ImageData = other.dgetImageData(); @@ -540,27 +632,27 @@ class CUSTOM_TOOL_ENTRY_SETTINGS AlwaysHidden = other.dgetAlwaysHidden(); VolumeType = other.dgetVolumeType(); } - }; -class CUSTOM_TOOL_ENTRY -{ +class CUSTOM_TOOL_ENTRY { public: - XIcon Image = XIcon(); + XIcon Image = XIcon(); + + const CUSTOM_TOOL_ENTRY_SETTINGS &settings = CUSTOM_TOOL_ENTRY_SETTINGS(); - const CUSTOM_TOOL_ENTRY_SETTINGS& settings = CUSTOM_TOOL_ENTRY_SETTINGS(); - - CUSTOM_TOOL_ENTRY(const CUSTOM_TOOL_ENTRY_SETTINGS& _settings, const EFI_FILE& ThemeDir) : settings(_settings) - { - if ( settings.ImagePath.notEmpty() ) { + CUSTOM_TOOL_ENTRY(const CUSTOM_TOOL_ENTRY_SETTINGS &_settings, + const EFI_FILE &ThemeDir) + : settings(_settings) { + if (settings.ImagePath.notEmpty()) { Image.LoadXImage(&ThemeDir, settings.ImagePath); - } else if ( settings.ImageData.notEmpty() ) { + } else if (settings.ImageData.notEmpty()) { Image.Image.FromPNG(settings.ImageData.data(), settings.ImageData.size()); } } UINT8 getFlags() const { UINT8 Flags = 0; - if ( settings.Disabled || settings.AlwaysHidden ) Flags = OSFLAG_SET(Flags, OSFLAG_DISABLED); + if (settings.Disabled || settings.AlwaysHidden) + Flags = OSFLAG_SET(Flags, OSFLAG_DISABLED); return Flags; } XString8Array getLoadOptions() const { @@ -570,35 +662,38 @@ class CUSTOM_TOOL_ENTRY /* * From config.plist, - * /Devices/Properties will construct a XObjArray, stored in ArbProperties - * /Devices/Arbitrary/CustomProperties will construct a XObjArray, stored in ArbProperties + * /Devices/Properties will construct a XObjArray, stored in + * ArbProperties /Devices/Arbitrary/CustomProperties will construct a + * XObjArray, stored in ArbProperties */ -// 2021-04 Jief : this is the old structure. Kept here for be able to compare old and new code. -class DEV_PROPERTY -{ +// 2021-04 Jief : this is the old structure. Kept here for be able to compare +// old and new code. +class DEV_PROPERTY { public: - UINT32 Device = 0; - EFI_DEVICE_PATH_PROTOCOL* DevicePath = NULL; - CHAR8 *Key = 0; - UINT8 *Value = 0; - UINTN ValueLen = 0; - DEV_PROPERTY *Next = 0; //next device or next property - DEV_PROPERTY *Child = 0; // property list of the device - CHAR8 *Label = 0; - INPUT_ITEM MenuItem = INPUT_ITEM(); - TAG_TYPE ValueType = kTagTypeNone; - - DEV_PROPERTY() { } - - // Not sure if default are valid. Delete them. If needed, proper ones can be created - DEV_PROPERTY(const DEV_PROPERTY&) { panic("nope"); } - DEV_PROPERTY& operator=(const DEV_PROPERTY&) = delete; + UINT32 Device = 0; + EFI_DEVICE_PATH_PROTOCOL *DevicePath = NULL; + CHAR8 *Key = 0; + UINT8 *Value = 0; + UINTN ValueLen = 0; + DEV_PROPERTY *Next = 0; // next device or next property + DEV_PROPERTY *Child = 0; // property list of the device + CHAR8 *Label = 0; + INPUT_ITEM MenuItem = INPUT_ITEM(); + TAG_TYPE ValueType = kTagTypeNone; + + DEV_PROPERTY() {} + + // Not sure if default are valid. Delete them. If needed, proper ones can be + // created + DEV_PROPERTY(const DEV_PROPERTY &) { panic("nope"); } + DEV_PROPERTY &operator=(const DEV_PROPERTY &) = delete; }; - /** 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 **/ class VBIOS_PATCH { public: @@ -606,627 +701,765 @@ class VBIOS_PATCH { XBuffer Replace = XBuffer(); #if __cplusplus > 201703L - XBool operator == (const VBIOS_PATCH&) const = default; + XBool operator==(const VBIOS_PATCH &) const = default; #endif - XBool isEqual(const VBIOS_PATCH& other) const - { - if ( !(Find == other.Find) ) return false; - if ( !(Replace == other.Replace) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::Graphics_Class::Graphics_PatchVBiosBytes_Class& other) - { - Find = other.dgetFind(); - Replace = other.dgetReplace(); - } + XBool isEqual(const VBIOS_PATCH &other) const { + if (!(Find == other.Find)) + return false; + if (!(Replace == other.Replace)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::Graphics_Class::Graphics_PatchVBiosBytes_Class + &other) { + Find = other.dgetFind(); + Replace = other.dgetReplace(); + } }; -class PatchVBiosBytesNewClass : public XObjArrayWithTakeValueFromXmlArray -{ - mutable XArray VBIOS_PATCH_BYTES_array = XArray(); +class PatchVBiosBytesNewClass + : public XObjArrayWithTakeValueFromXmlArray< + VBIOS_PATCH, + ConfigPlistClass::Graphics_Class::Graphics_PatchVBiosBytes_Class> { + mutable XArray VBIOS_PATCH_BYTES_array = + XArray(); + public: - #if __cplusplus > 201703L - XBool operator == (const PatchVBiosBytesNewClass& other) const { return XObjArray::operator ==(other); } + XBool operator==(const PatchVBiosBytesNewClass &other) const { + return XObjArray::operator==(other); + } #endif // Temporary bridge to old struct. - const VBIOS_PATCH_BYTES* getVBIOS_PATCH_BYTES() const { + const VBIOS_PATCH_BYTES *getVBIOS_PATCH_BYTES() const { VBIOS_PATCH_BYTES_array.setSize(size()); - for ( size_t idx = 0 ; idx < size() ; ++idx ) { + for (size_t idx = 0; idx < size(); ++idx) { VBIOS_PATCH_BYTES_array[idx].Find = ElementAt(idx).Find.vdata(); VBIOS_PATCH_BYTES_array[idx].Replace = ElementAt(idx).Replace.vdata(); - VBIOS_PATCH_BYTES_array[idx].NumberOfBytes = ElementAt(idx).Replace.size(); + VBIOS_PATCH_BYTES_array[idx].NumberOfBytes = + ElementAt(idx).Replace.size(); } return VBIOS_PATCH_BYTES_array; } - size_t getVBIOS_PATCH_BYTES_count() const { - return size(); - } + size_t getVBIOS_PATCH_BYTES_count() const { return size(); } - XBool isEqual(const PatchVBiosBytesNewClass& other) const - { + XBool isEqual(const PatchVBiosBytesNewClass &other) const { return XObjArray::isEqual(other); } - }; - class SETTINGS_DATA; class ConfigPlistClass; class TagDict; -//XBool CompareOldNewSettings(const SETTINGS_DATA& , const ConfigPlistClass& ); -//EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings); +// XBool CompareOldNewSettings(const SETTINGS_DATA& , const ConfigPlistClass& ); +// EFI_STATUS GetUserSettings(const TagDict* CfgDict, SETTINGS_DATA& gSettings); class SETTINGS_DATA { public: - class BootClass { - public: - INTN Timeout = -1; - XBool SkipHibernateTimeout = false; - XBool DisableCloverHotkeys = false; - XString8 BootArgs = XString8(); - XBool NeverDoRecovery = false; - XBool LastBootedVolume = false; - XStringW DefaultVolume = XStringW(); - bool BootFirstAvailable = false; - XStringW DefaultLoader = XStringW(); - XBool DebugLog = false; - XBool FastBoot = false; - XBool NoEarlyProgress = false; - XBool NeverHibernate = false; - XBool StrictHibernate = false; - XBool RtcHibernateAware = false; - XBool HibernationFixup = false; - XBool SignatureFixup = false; - INT8 SecureSetting = 0; // 0 == false, 1 == true, -1 == undefined - //UINT8 SecureBoot = 0; - //UINT8 SecureBootSetupMode = 0; - UINT8 SecureBootPolicy = 0; - // Secure boot white/black list - XStringWArray SecureBootWhiteList = XStringWArray(); - XStringWArray SecureBootBlackList = XStringWArray(); - INT8 XMPDetection = 0; - // LegacyBoot - XStringW LegacyBoot = XStringW(); - UINT16 LegacyBiosDefaultEntry = 0; - UINT8 CustomLogoType = 0; - XString8 CustomLogoAsXString8 = XString8(); - XBuffer CustomLogoAsData = XBuffer(); - + public: + INTN Timeout = -1; + XBool SkipHibernateTimeout = false; + XBool DisableCloverHotkeys = false; + XString8 BootArgs = XString8(); + XBool NeverDoRecovery = false; + XBool LastBootedVolume = false; + XStringW DefaultVolume = XStringW(); + bool BootFirstAvailable = false; + XStringW DefaultLoader = XStringW(); + XBool DebugLog = false; + XBool FastBoot = false; + XBool NoEarlyProgress = false; + XBool NeverHibernate = false; + XBool StrictHibernate = false; + XBool RtcHibernateAware = false; + XBool HibernationFixup = false; + XBool SignatureFixup = false; + INT8 SecureSetting = 0; // 0 == false, 1 == true, -1 == undefined + // UINT8 SecureBoot = 0; + // UINT8 SecureBootSetupMode = 0; + UINT8 SecureBootPolicy = 0; + // Secure boot white/black list + XStringWArray SecureBootWhiteList = XStringWArray(); + XStringWArray SecureBootBlackList = XStringWArray(); + INT8 XMPDetection = 0; + // LegacyBoot + XStringW LegacyBoot = XStringW(); + UINT16 LegacyBiosDefaultEntry = 0; + UINT8 CustomLogoType = 0; + XString8 CustomLogoAsXString8 = XString8(); + XBuffer CustomLogoAsData = XBuffer(); + #if __cplusplus > 201703L - XBool operator == (const BootClass&) const = default; + XBool operator==(const BootClass &) const = default; #endif - XBool isEqual(const BootClass& other) const - { - if ( !(Timeout == other.Timeout) ) return false; - if ( !(SkipHibernateTimeout == other.SkipHibernateTimeout) ) return false; - if ( !(DisableCloverHotkeys == other.DisableCloverHotkeys) ) return false; - if ( !(BootArgs == other.BootArgs) ) return false; - if ( !(NeverDoRecovery == other.NeverDoRecovery) ) return false; - if ( !(LastBootedVolume == other.LastBootedVolume) ) return false; - if ( !(DefaultVolume == other.DefaultVolume) ) return false; - if ( !(DefaultLoader == other.DefaultLoader) ) return false; - if ( !(DebugLog == other.DebugLog) ) return false; - if ( !(FastBoot == other.FastBoot) ) return false; - if ( !(NoEarlyProgress == other.NoEarlyProgress) ) return false; - if ( !(NeverHibernate == other.NeverHibernate) ) return false; - if ( !(StrictHibernate == other.StrictHibernate) ) return false; - if ( !(RtcHibernateAware == other.RtcHibernateAware) ) return false; - if ( !(HibernationFixup == other.HibernationFixup) ) return false; - if ( !(SignatureFixup == other.SignatureFixup) ) return false; - if ( !(SecureSetting == other.SecureSetting) ) return false; - if ( !(SecureBootPolicy == other.SecureBootPolicy) ) return false; - if ( !(SecureBootWhiteList == other.SecureBootWhiteList) ) return false; - if ( !(SecureBootBlackList == other.SecureBootBlackList) ) return false; - if ( !(XMPDetection == other.XMPDetection) ) return false; - if ( !(LegacyBoot == other.LegacyBoot) ) return false; - if ( !(LegacyBiosDefaultEntry == other.LegacyBiosDefaultEntry) ) return false; - if ( !(CustomLogoType == other.CustomLogoType) ) return false; - if ( !(CustomLogoAsXString8 == other.CustomLogoAsXString8) ) return false; - if ( !(CustomLogoAsData == other.CustomLogoAsData) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::Boot_Class& other) - { - Timeout = other.dgetTimeout(); - SkipHibernateTimeout = other.dgetSkipHibernateTimeout(); - DisableCloverHotkeys = other.dgetDisableCloverHotkeys(); - BootArgs = other.dgetBootArgs(); - NeverDoRecovery = other.dgetNeverDoRecovery(); - LastBootedVolume = other.dgetLastBootedVolume(); - DefaultVolume = other.dgetDefaultVolume(); - BootFirstAvailable = other.dgetBootFirstAvailable(); - DefaultLoader = other.dgetDefaultLoader(); - DebugLog = other.dgetDebugLog(); - FastBoot = other.dgetFastBoot(); - NoEarlyProgress = other.dgetNoEarlyProgress(); - NeverHibernate = other.dgetNeverHibernate(); - StrictHibernate = other.dgetStrictHibernate(); - RtcHibernateAware = other.dgetRtcHibernateAware(); - HibernationFixup = other.dgetHibernationFixup(); - SignatureFixup = other.dgetSignatureFixup(); - SecureSetting = other.dgetSecureSetting(); - SecureBootPolicy = other.dgetSecureBootPolicy(); - SecureBootWhiteList = other.dgetSecureBootWhiteList(); - SecureBootBlackList = other.dgetSecureBootBlackList(); - XMPDetection = other.dgetXMPDetection(); - LegacyBoot = other.dgetLegacyBoot(gFirmwareClover); - LegacyBiosDefaultEntry = other.dgetLegacyBiosDefaultEntry(); - CustomLogoType = other.dgetCustomLogoType(); - CustomLogoAsXString8 = other.dgetCustomLogoAsXString8(); - CustomLogoAsData = other.dgetCustomLogoAsData(); - } + XBool isEqual(const BootClass &other) const { + if (!(Timeout == other.Timeout)) + return false; + if (!(SkipHibernateTimeout == other.SkipHibernateTimeout)) + return false; + if (!(DisableCloverHotkeys == other.DisableCloverHotkeys)) + return false; + if (!(BootArgs == other.BootArgs)) + return false; + if (!(NeverDoRecovery == other.NeverDoRecovery)) + return false; + if (!(LastBootedVolume == other.LastBootedVolume)) + return false; + if (!(DefaultVolume == other.DefaultVolume)) + return false; + if (!(DefaultLoader == other.DefaultLoader)) + return false; + if (!(DebugLog == other.DebugLog)) + return false; + if (!(FastBoot == other.FastBoot)) + return false; + if (!(NoEarlyProgress == other.NoEarlyProgress)) + return false; + if (!(NeverHibernate == other.NeverHibernate)) + return false; + if (!(StrictHibernate == other.StrictHibernate)) + return false; + if (!(RtcHibernateAware == other.RtcHibernateAware)) + return false; + if (!(HibernationFixup == other.HibernationFixup)) + return false; + if (!(SignatureFixup == other.SignatureFixup)) + return false; + if (!(SecureSetting == other.SecureSetting)) + return false; + if (!(SecureBootPolicy == other.SecureBootPolicy)) + return false; + if (!(SecureBootWhiteList == other.SecureBootWhiteList)) + return false; + if (!(SecureBootBlackList == other.SecureBootBlackList)) + return false; + if (!(XMPDetection == other.XMPDetection)) + return false; + if (!(LegacyBoot == other.LegacyBoot)) + return false; + if (!(LegacyBiosDefaultEntry == other.LegacyBiosDefaultEntry)) + return false; + if (!(CustomLogoType == other.CustomLogoType)) + return false; + if (!(CustomLogoAsXString8 == other.CustomLogoAsXString8)) + return false; + if (!(CustomLogoAsData == other.CustomLogoAsData)) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::Boot_Class &other) { + Timeout = other.dgetTimeout(); + SkipHibernateTimeout = other.dgetSkipHibernateTimeout(); + DisableCloverHotkeys = other.dgetDisableCloverHotkeys(); + BootArgs = other.dgetBootArgs(); + NeverDoRecovery = other.dgetNeverDoRecovery(); + LastBootedVolume = other.dgetLastBootedVolume(); + DefaultVolume = other.dgetDefaultVolume(); + BootFirstAvailable = other.dgetBootFirstAvailable(); + DefaultLoader = other.dgetDefaultLoader(); + DebugLog = other.dgetDebugLog(); + FastBoot = other.dgetFastBoot(); + NoEarlyProgress = other.dgetNoEarlyProgress(); + NeverHibernate = other.dgetNeverHibernate(); + StrictHibernate = other.dgetStrictHibernate(); + RtcHibernateAware = other.dgetRtcHibernateAware(); + HibernationFixup = other.dgetHibernationFixup(); + SignatureFixup = other.dgetSignatureFixup(); + SecureSetting = other.dgetSecureSetting(); + SecureBootPolicy = other.dgetSecureBootPolicy(); + SecureBootWhiteList = other.dgetSecureBootWhiteList(); + SecureBootBlackList = other.dgetSecureBootBlackList(); + XMPDetection = other.dgetXMPDetection(); + LegacyBoot = other.dgetLegacyBoot(gFirmwareClover); + LegacyBiosDefaultEntry = other.dgetLegacyBiosDefaultEntry(); + CustomLogoType = other.dgetCustomLogoType(); + CustomLogoAsXString8 = other.dgetCustomLogoAsXString8(); + CustomLogoAsData = other.dgetCustomLogoAsData(); + } }; - - class ACPIClass - { + + class ACPIClass { + public: + class ACPIDropTablesClass { public: - class ACPIDropTablesClass - { - public: - union { - UINT32 Signature = 0; - char SignatureAs4Chars[4]; - }; - UINT64 TableId = 0; - UINT32 TabLength = 0; - XBool OtherOS = false; - -#if __cplusplus > 201703L - XBool operator == (const ACPIDropTablesClass&) const = default; -#endif - XBool isEqual(const ACPIDropTablesClass& other) const - { - if ( !(Signature == other.Signature) ) return false; - if ( !(TableId == other.TableId) ) return false; - if ( !(TabLength == other.TabLength) ) return false; - if ( !(OtherOS == other.OtherOS) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::ACPI_Class::ACPI_DropTables_Class& other) - { - Signature = other.dgetSignature(); - TableId = other.dgetTableId(); - TabLength = other.dgetTabLength(); - OtherOS = other.dgetOtherOS(); - } + union { + UINT32 Signature = 0; + char SignatureAs4Chars[4]; }; - - class DSDTClass - { - public: - class DSDT_Patch - { - public : - XBool Disabled = XBool(); - XString8 PatchDsdtLabel = XString8(); - XBuffer PatchDsdtFind = XBuffer(); - XBuffer PatchDsdtReplace = XBuffer(); - XBuffer PatchDsdtTgt = XBuffer(); - INPUT_ITEM PatchDsdtMenuItem = INPUT_ITEM(); // Not read from config.plist. Should be moved out. - uint64_t Skip = 0; - int Count = 0; + UINT64 TableId = 0; + UINT32 TabLength = 0; + XBool OtherOS = false; #if __cplusplus > 201703L - XBool operator == (const DSDT_Patch&) const = default; + XBool operator==(const ACPIDropTablesClass &) const = default; #endif - XBool isEqual(const DSDT_Patch& other) const - { - if ( !(Disabled == other.Disabled) ) return false; - if ( !(PatchDsdtLabel == other.PatchDsdtLabel) ) return false; - if ( !(PatchDsdtFind == other.PatchDsdtFind) ) return false; - if ( !(PatchDsdtReplace == other.PatchDsdtReplace) ) return false; - if ( !(PatchDsdtTgt == other.PatchDsdtTgt) ) return false; - if ( !(PatchDsdtMenuItem == other.PatchDsdtMenuItem) ) return false; - if ( !(Skip == other.Skip) ) return false; - if (!(Count == other.Count)) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::ACPI_Class::DSDT_Class::ACPI_DSDT_Patch_Class& other) - { - Disabled = other.dgetDisabled(); - PatchDsdtLabel = other.dgetPatchDsdtLabel(); - PatchDsdtFind = other.dgetPatchDsdtFind(); - PatchDsdtReplace = other.dgetPatchDsdtReplace(); - PatchDsdtTgt = other.dgetPatchDsdtTgt(); - PatchDsdtMenuItem.BValue = !other.dgetDisabled(); - Skip = other.dgetSkip(); - Count = other.dgetCount(); - } - }; - - XStringW DsdtName = XStringW(); - XBool DebugDSDT = false; - XBool Rtc8Allowed = false; - UINT8 PNLF_UID = 0; - UINT32 FixDsdt = 0; - XBool ReuseFFFF = false; - XBool SuspendOverride = false; - XObjArrayWithTakeValueFromXmlArray - DSDTPatchArray = XObjArrayWithTakeValueFromXmlArray(); + XBool isEqual(const ACPIDropTablesClass &other) const { + if (!(Signature == other.Signature)) + return false; + if (!(TableId == other.TableId)) + return false; + if (!(TabLength == other.TabLength)) + return false; + if (!(OtherOS == other.OtherOS)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::ACPI_Class::ACPI_DropTables_Class &other) { + Signature = other.dgetSignature(); + TableId = other.dgetTableId(); + TabLength = other.dgetTabLength(); + OtherOS = other.dgetOtherOS(); + } + }; + + class DSDTClass { + public: + class DSDT_Patch { + public: + XBool Disabled = XBool(); + XString8 PatchDsdtLabel = XString8(); + XBuffer PatchDsdtFind = XBuffer(); + XBuffer PatchDsdtReplace = XBuffer(); + XBuffer PatchDsdtTgt = XBuffer(); + INPUT_ITEM PatchDsdtMenuItem = + INPUT_ITEM(); // Not read from config.plist. Should be moved out. + uint64_t Skip = 0; + int Count = 0; #if __cplusplus > 201703L - XBool operator == (const DSDTClass&) const = default; + XBool operator==(const DSDT_Patch &) const = default; #endif - XBool isEqual(const DSDTClass& other) const - { - if ( !(DsdtName == other.DsdtName) ) return false; - if ( !(DebugDSDT == other.DebugDSDT) ) return false; - if ( !(Rtc8Allowed == other.Rtc8Allowed) ) return false; - if ( !(PNLF_UID == other.PNLF_UID) ) return false; - if ( !(FixDsdt == other.FixDsdt) ) return false; - if ( !(ReuseFFFF == other.ReuseFFFF) ) return false; - if ( !(SuspendOverride == other.SuspendOverride) ) return false; - if ( !DSDTPatchArray.isEqual(other.DSDTPatchArray) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::ACPI_Class::DSDT_Class& other) - { - DsdtName = other.dgetDsdtName(); - DebugDSDT = other.dgetDebugDSDT(); - Rtc8Allowed = other.dgetRtc8Allowed(); - PNLF_UID = other.dgetPNLF_UID(); - FixDsdt = other.dgetFixDsdt(); - ReuseFFFF = other.dgetReuseFFFF(); - SuspendOverride = other.dgetSuspendOverride(); - DSDTPatchArray.takeValueFrom(other.Patches); - } + XBool isEqual(const DSDT_Patch &other) const { + if (!(Disabled == other.Disabled)) + return false; + if (!(PatchDsdtLabel == other.PatchDsdtLabel)) + return false; + if (!(PatchDsdtFind == other.PatchDsdtFind)) + return false; + if (!(PatchDsdtReplace == other.PatchDsdtReplace)) + return false; + if (!(PatchDsdtTgt == other.PatchDsdtTgt)) + return false; + if (!(PatchDsdtMenuItem == other.PatchDsdtMenuItem)) + return false; + if (!(Skip == other.Skip)) + return false; + if (!(Count == other.Count)) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::ACPI_Class::DSDT_Class:: + ACPI_DSDT_Patch_Class &other) { + Disabled = other.dgetDisabled(); + PatchDsdtLabel = other.dgetPatchDsdtLabel(); + PatchDsdtFind = other.dgetPatchDsdtFind(); + PatchDsdtReplace = other.dgetPatchDsdtReplace(); + PatchDsdtTgt = other.dgetPatchDsdtTgt(); + PatchDsdtMenuItem.BValue = !other.dgetDisabled(); + Skip = other.dgetSkip(); + Count = other.dgetCount(); + } }; - - class SSDTClass - { - public: - class GenerateClass - { - public: - XBool GeneratePStates = false; - XBool GenerateCStates = false; - XBool GenerateAPSN = false; - XBool GenerateAPLF = false; - XBool GeneratePluginType = false; + + XStringW DsdtName = XStringW(); + XBool DebugDSDT = false; + XBool Rtc8Allowed = false; + UINT8 PNLF_UID = 0; + UINT32 FixDsdt = 0; + XBool ReuseFFFF = false; + XBool SuspendOverride = false; + XObjArrayWithTakeValueFromXmlArray< + DSDT_Patch, + ConfigPlistClass::ACPI_Class::DSDT_Class::ACPI_DSDT_Patch_Class> + DSDTPatchArray = XObjArrayWithTakeValueFromXmlArray< + DSDT_Patch, ConfigPlistClass::ACPI_Class::DSDT_Class:: + ACPI_DSDT_Patch_Class>(); #if __cplusplus > 201703L - XBool operator == (const GenerateClass&) const = default; + XBool operator==(const DSDTClass &) const = default; #endif - XBool isEqual(const GenerateClass& other) const - { - if ( !(GeneratePStates == other.GeneratePStates) ) return false; - if ( !(GenerateCStates == other.GenerateCStates) ) return false; - if ( !(GenerateAPSN == other.GenerateAPSN) ) return false; - if ( !(GenerateAPLF == other.GenerateAPLF) ) return false; - if ( !(GeneratePluginType == other.GeneratePluginType) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::ACPI_Class::SSDT_Class::XmlUnionGenerate& other) - { - GeneratePStates = other.dgetGeneratePStates(); - GenerateCStates = other.dgetGenerateCStates(); - GenerateAPSN = other.dgetGenerateAPSN(); - GenerateAPLF = other.dgetGenerateAPLF(); - GeneratePluginType = other.dgetGeneratePluginType(); - } - }; - - XBool DropSSDTSetting = false; - XBool NoOemTableId = false; - XBool NoDynamicExtract = false; - XBool EnableISS = false; - XBool EnableC7 = false; - XBool _EnableC6 = false; - XBool _EnableC4 = false; - XBool _EnableC2 = false; - UINT16 _C3Latency = 0; - UINT8 PLimitDict = 0; - UINT8 UnderVoltStep = 0; - XBool DoubleFirstState = false; - UINT8 MinMultiplier = 0; - UINT8 MaxMultiplier = 0; - UINT8 PluginType = 0; - GenerateClass Generate = GenerateClass(); - + XBool isEqual(const DSDTClass &other) const { + if (!(DsdtName == other.DsdtName)) + return false; + if (!(DebugDSDT == other.DebugDSDT)) + return false; + if (!(Rtc8Allowed == other.Rtc8Allowed)) + return false; + if (!(PNLF_UID == other.PNLF_UID)) + return false; + if (!(FixDsdt == other.FixDsdt)) + return false; + if (!(ReuseFFFF == other.ReuseFFFF)) + return false; + if (!(SuspendOverride == other.SuspendOverride)) + return false; + if (!DSDTPatchArray.isEqual(other.DSDTPatchArray)) + return false; + return true; + } + void + takeValueFrom(const ConfigPlistClass::ACPI_Class::DSDT_Class &other) { + DsdtName = other.dgetDsdtName(); + DebugDSDT = other.dgetDebugDSDT(); + Rtc8Allowed = other.dgetRtc8Allowed(); + PNLF_UID = other.dgetPNLF_UID(); + FixDsdt = other.dgetFixDsdt(); + ReuseFFFF = other.dgetReuseFFFF(); + SuspendOverride = other.dgetSuspendOverride(); + DSDTPatchArray.takeValueFrom(other.Patches); + } + }; + + class SSDTClass { + public: + class GenerateClass { + public: + XBool GeneratePStates = false; + XBool GenerateCStates = false; + XBool GenerateAPSN = false; + XBool GenerateAPLF = false; + XBool GeneratePluginType = false; + #if __cplusplus > 201703L - XBool operator == (const SSDTClass&) const = default; + XBool operator==(const GenerateClass &) const = default; #endif - XBool isEqual(const SSDTClass& other) const - { - if ( !(DropSSDTSetting == other.DropSSDTSetting) ) return false; - if ( !(NoOemTableId == other.NoOemTableId) ) return false; - if ( !(NoDynamicExtract == other.NoDynamicExtract) ) return false; - if ( !(EnableISS == other.EnableISS) ) return false; - if ( !(EnableC7 == other.EnableC7) ) return false; - if ( !(_EnableC6 == other._EnableC6) ) return false; - if ( !(_EnableC4 == other._EnableC4) ) return false; - if ( !(_EnableC2 == other._EnableC2) ) return false; - if ( !(_C3Latency == other._C3Latency) ) return false; - if ( !(PLimitDict == other.PLimitDict) ) return false; - if ( !(UnderVoltStep == other.UnderVoltStep) ) return false; - if ( !(DoubleFirstState == other.DoubleFirstState) ) return false; - if ( !(MinMultiplier == other.MinMultiplier) ) return false; - if ( !(MaxMultiplier == other.MaxMultiplier) ) return false; - if ( !(PluginType == other.PluginType) ) return false; - if ( !Generate.isEqual(other.Generate) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::ACPI_Class::SSDT_Class& other) - { - DropSSDTSetting = other.dgetDropSSDTSetting(); - NoOemTableId = other.dgetNoOemTableId(); - NoDynamicExtract = other.dgetNoDynamicExtract(); - EnableISS = other.dgetEnableISS(); - EnableC7 = other.dgetEnableC7(); - _EnableC6 = other.dget_EnableC6(); - _EnableC4 = other.dget_EnableC4(); - _EnableC2 = other.dget_EnableC2(); - _C3Latency = other.dget_C3Latency(); - PLimitDict = other.dgetPLimitDict(); - UnderVoltStep = other.dgetUnderVoltStep(); - DoubleFirstState = other.dgetDoubleFirstState(); - MinMultiplier = other.dgetMinMultiplier(); - MaxMultiplier = other.dgetMaxMultiplier(); - PluginType = other.dgetPluginType(); - Generate.takeValueFrom(other.Generate); - } + XBool isEqual(const GenerateClass &other) const { + if (!(GeneratePStates == other.GeneratePStates)) + return false; + if (!(GenerateCStates == other.GenerateCStates)) + return false; + if (!(GenerateAPSN == other.GenerateAPSN)) + return false; + if (!(GenerateAPLF == other.GenerateAPLF)) + return false; + if (!(GeneratePluginType == other.GeneratePluginType)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::ACPI_Class::SSDT_Class::XmlUnionGenerate + &other) { + GeneratePStates = other.dgetGeneratePStates(); + GenerateCStates = other.dgetGenerateCStates(); + GenerateAPSN = other.dgetGenerateAPSN(); + GenerateAPLF = other.dgetGenerateAPLF(); + GeneratePluginType = other.dgetGeneratePluginType(); + } }; - UINT64 ResetAddr = 0; - UINT8 ResetVal = 0; - XBool SlpSmiEnable = false; - XBool FixHeaders = false; - XBool FixMCFG = false; - XBool NoASPM = false; - XBool smartUPS = false; - XBool PatchNMI = false; - XBool AutoMerge = false; - XStringWArray DisabledAML = XStringWArray(); - XString8Array SortedACPI = XString8Array(); -// XObjArray DeviceRename = XObjArray(); -// XObjArrayWithTakeValueFrom -// DeviceRename = XObjArrayWithTakeValueFrom(); - class DeviceRename_Array : public XObjArray { - public: - void takeValueFrom(const ConfigPlistClass::ACPI_Class::ACPI_RenamesDevices_Class& other) - { - size_t idx; - for ( idx = 0 ; idx < other.size() ; ++idx ) { - if ( idx < size() ) ElementAt(idx).takeValueFrom(other.getAtIndex(idx)); - else { - ACPI_RENAME_DEVICE* s = new ACPI_RENAME_DEVICE; - s->takeValueFrom(other.getAtIndex(idx)); - AddReference(s, true); - } - } - while ( idx < size() ) RemoveAtIndex(idx); - } - } DeviceRename = DeviceRename_Array(); - XObjArrayWithTakeValueFromXmlArray - ACPIDropTablesArray = XObjArrayWithTakeValueFromXmlArray(); - DSDTClass DSDT = DSDTClass(); - SSDTClass SSDT = SSDTClass(); - + XBool DropSSDTSetting = false; + XBool NoOemTableId = false; + XBool NoDynamicExtract = false; + XBool EnableISS = false; + XBool EnableC7 = false; + XBool _EnableC6 = false; + XBool _EnableC4 = false; + XBool _EnableC2 = false; + UINT16 _C3Latency = 0; + UINT8 PLimitDict = 0; + UINT8 UnderVoltStep = 0; + XBool DoubleFirstState = false; + UINT8 MinMultiplier = 0; + UINT8 MaxMultiplier = 0; + UINT8 PluginType = 0; + GenerateClass Generate = GenerateClass(); + #if __cplusplus > 201703L - XBool operator == (const ACPIClass&) const = default; + XBool operator==(const SSDTClass &) const = default; #endif - XBool isEqual(const ACPIClass& other) const - { - if ( !(ResetAddr == other.ResetAddr) ) return false; - if ( !(ResetVal == other.ResetVal) ) return false; - if ( !(SlpSmiEnable == other.SlpSmiEnable) ) return false; - if ( !(FixHeaders == other.FixHeaders) ) return false; - if ( !(FixMCFG == other.FixMCFG) ) return false; - if ( !(NoASPM == other.NoASPM) ) return false; - if ( !(smartUPS == other.smartUPS) ) return false; - if ( !(PatchNMI == other.PatchNMI) ) return false; - if ( !(AutoMerge == other.AutoMerge) ) return false; - if ( !(DisabledAML == other.DisabledAML) ) return false; - if ( !(SortedACPI == other.SortedACPI) ) return false; - if ( !DeviceRename.isEqual(other.DeviceRename) ) return false; - if ( !ACPIDropTablesArray.isEqual(other.ACPIDropTablesArray) ) return false; - if ( !DSDT.isEqual(other.DSDT) ) return false; - if ( !SSDT.isEqual(other.SSDT) ) return false; + XBool isEqual(const SSDTClass &other) const { + if (!(DropSSDTSetting == other.DropSSDTSetting)) + return false; + if (!(NoOemTableId == other.NoOemTableId)) + return false; + if (!(NoDynamicExtract == other.NoDynamicExtract)) + return false; + if (!(EnableISS == other.EnableISS)) + return false; + if (!(EnableC7 == other.EnableC7)) + return false; + if (!(_EnableC6 == other._EnableC6)) + return false; + if (!(_EnableC4 == other._EnableC4)) + return false; + if (!(_EnableC2 == other._EnableC2)) + return false; + if (!(_C3Latency == other._C3Latency)) + return false; + if (!(PLimitDict == other.PLimitDict)) + return false; + if (!(UnderVoltStep == other.UnderVoltStep)) + return false; + if (!(DoubleFirstState == other.DoubleFirstState)) + return false; + if (!(MinMultiplier == other.MinMultiplier)) + return false; + if (!(MaxMultiplier == other.MaxMultiplier)) + return false; + if (!(PluginType == other.PluginType)) + return false; + if (!Generate.isEqual(other.Generate)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::ACPI_Class& other) - { - ResetAddr = other.dgetResetAddr(); - ResetVal = other.dgetResetVal(); - SlpSmiEnable = other.dgetSlpSmiEnable(); - FixHeaders = other.dgetFixHeaders() || other.DSDT.Fixes.dgetFixHeaders(); - FixMCFG = other.dgetFixMCFG(); - NoASPM = other.dgetNoASPM(); - smartUPS = other.dgetsmartUPS(); - PatchNMI = other.dgetPatchNMI(); - AutoMerge = other.dgetAutoMerge(); - DisabledAML = other.dgetDisabledAML(); - SortedACPI = other.dgetSortedACPI(); - DeviceRename.takeValueFrom(other.RenameDevices); - ACPIDropTablesArray.takeValueFrom(other.ACPIDropTablesArray); - DSDT.takeValueFrom(other.DSDT); - SSDT.takeValueFrom(other.SSDT); + void + takeValueFrom(const ConfigPlistClass::ACPI_Class::SSDT_Class &other) { + DropSSDTSetting = other.dgetDropSSDTSetting(); + NoOemTableId = other.dgetNoOemTableId(); + NoDynamicExtract = other.dgetNoDynamicExtract(); + EnableISS = other.dgetEnableISS(); + EnableC7 = other.dgetEnableC7(); + _EnableC6 = other.dget_EnableC6(); + _EnableC4 = other.dget_EnableC4(); + _EnableC2 = other.dget_EnableC2(); + _C3Latency = other.dget_C3Latency(); + PLimitDict = other.dgetPLimitDict(); + UnderVoltStep = other.dgetUnderVoltStep(); + DoubleFirstState = other.dgetDoubleFirstState(); + MinMultiplier = other.dgetMinMultiplier(); + MaxMultiplier = other.dgetMaxMultiplier(); + PluginType = other.dgetPluginType(); + Generate.takeValueFrom(other.Generate); + } + }; + + UINT64 ResetAddr = 0; + UINT8 ResetVal = 0; + XBool SlpSmiEnable = false; + XBool FixHeaders = false; + XBool FixMCFG = false; + XBool NoASPM = false; + XBool smartUPS = false; + XBool PatchNMI = false; + XBool AutoMerge = false; + XStringWArray DisabledAML = XStringWArray(); + XString8Array SortedACPI = XString8Array(); + // XObjArray DeviceRename = + // XObjArray(); + // XObjArrayWithTakeValueFrom + // DeviceRename = + // XObjArrayWithTakeValueFrom(); + class DeviceRename_Array : public XObjArray { + public: + void takeValueFrom( + const ConfigPlistClass::ACPI_Class::ACPI_RenamesDevices_Class + &other) { + size_t idx; + for (idx = 0; idx < other.size(); ++idx) { + if (idx < size()) + ElementAt(idx).takeValueFrom(other.getAtIndex(idx)); + else { + ACPI_RENAME_DEVICE *s = new ACPI_RENAME_DEVICE; + s->takeValueFrom(other.getAtIndex(idx)); + AddReference(s, true); + } + } + while (idx < size()) + RemoveAtIndex(idx); } + } DeviceRename = DeviceRename_Array(); + XObjArrayWithTakeValueFromXmlArray< + ACPIDropTablesClass, + ConfigPlistClass::ACPI_Class::ACPI_DropTables_Class> + ACPIDropTablesArray = XObjArrayWithTakeValueFromXmlArray< + ACPIDropTablesClass, + ConfigPlistClass::ACPI_Class::ACPI_DropTables_Class>(); + DSDTClass DSDT = DSDTClass(); + SSDTClass SSDT = SSDTClass(); + +#if __cplusplus > 201703L + XBool operator==(const ACPIClass &) const = default; +#endif + XBool isEqual(const ACPIClass &other) const { + if (!(ResetAddr == other.ResetAddr)) + return false; + if (!(ResetVal == other.ResetVal)) + return false; + if (!(SlpSmiEnable == other.SlpSmiEnable)) + return false; + if (!(FixHeaders == other.FixHeaders)) + return false; + if (!(FixMCFG == other.FixMCFG)) + return false; + if (!(NoASPM == other.NoASPM)) + return false; + if (!(smartUPS == other.smartUPS)) + return false; + if (!(PatchNMI == other.PatchNMI)) + return false; + if (!(AutoMerge == other.AutoMerge)) + return false; + if (!(DisabledAML == other.DisabledAML)) + return false; + if (!(SortedACPI == other.SortedACPI)) + return false; + if (!DeviceRename.isEqual(other.DeviceRename)) + return false; + if (!ACPIDropTablesArray.isEqual(other.ACPIDropTablesArray)) + return false; + if (!DSDT.isEqual(other.DSDT)) + return false; + if (!SSDT.isEqual(other.SSDT)) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::ACPI_Class &other) { + ResetAddr = other.dgetResetAddr(); + ResetVal = other.dgetResetVal(); + SlpSmiEnable = other.dgetSlpSmiEnable(); + FixHeaders = other.dgetFixHeaders() || other.DSDT.Fixes.dgetFixHeaders(); + FixMCFG = other.dgetFixMCFG(); + NoASPM = other.dgetNoASPM(); + smartUPS = other.dgetsmartUPS(); + PatchNMI = other.dgetPatchNMI(); + AutoMerge = other.dgetAutoMerge(); + DisabledAML = other.dgetDisabledAML(); + SortedACPI = other.dgetSortedACPI(); + DeviceRename.takeValueFrom(other.RenameDevices); + ACPIDropTablesArray.takeValueFrom(other.ACPIDropTablesArray); + DSDT.takeValueFrom(other.DSDT); + SSDT.takeValueFrom(other.SSDT); + } }; class GUIClass { + public: + class MouseClass { public: - class MouseClass { - public: - INTN PointerSpeed = 0; - XBool PointerEnabled = false; - UINT64 DoubleClickTime = 0; - XBool PointerMirror = false; - -#if __cplusplus > 201703L - XBool operator == (const MouseClass&) const = default; -#endif - XBool isEqual(const MouseClass& other) const - { - if ( !(PointerSpeed == other.PointerSpeed) ) return false; - if ( !(PointerEnabled == other.PointerEnabled) ) return false; - if ( !(DoubleClickTime == other.DoubleClickTime) ) return false; - if ( !(PointerMirror == other.PointerMirror) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Mouse_Class& other) - { - PointerSpeed = other.dgetPointerSpeed(); - PointerEnabled = other.dgetPointerEnabled(); - DoubleClickTime = other.dgetDoubleClickTime(); - PointerMirror = other.dgetPointerMirror(); - } - } ; - class ScanClass { - public: - XBool DisableEntryScan = false; - XBool DisableToolScan = false; - UINT8 KernelScan = 0; - XBool LinuxScan = false; - XBool LegacyFirst = false; - XBool NoLegacy = false; - + INTN PointerSpeed = 0; + XBool PointerEnabled = false; + UINT64 DoubleClickTime = 0; + XBool PointerMirror = false; + #if __cplusplus > 201703L - XBool operator == (const ScanClass&) const = default; + XBool operator==(const MouseClass &) const = default; #endif - XBool isEqual(const ScanClass& other) const - { - if ( !(DisableEntryScan == other.DisableEntryScan) ) return false; - if ( !(DisableToolScan == other.DisableToolScan) ) return false; - if ( !(KernelScan == other.KernelScan) ) return false; - if ( !(LinuxScan == other.LinuxScan) ) return false; - if ( !(LegacyFirst == other.LegacyFirst) ) return false; - if ( !(NoLegacy == other.NoLegacy) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Scan_Class& other) - { - DisableEntryScan = other.dgetDisableEntryScan(); - DisableToolScan = other.dgetDisableToolScan(); - KernelScan = other.dgetKernelScan(); - LinuxScan = other.dgetLinuxScan(); - LegacyFirst = other.dgetLegacyFirst(); - NoLegacy = other.dgetNoLegacy(); - } - }; + XBool isEqual(const MouseClass &other) const { + if (!(PointerSpeed == other.PointerSpeed)) + return false; + if (!(PointerEnabled == other.PointerEnabled)) + return false; + if (!(DoubleClickTime == other.DoubleClickTime)) + return false; + if (!(PointerMirror == other.PointerMirror)) + return false; + return true; + } + void + takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Mouse_Class &other) { + PointerSpeed = other.dgetPointerSpeed(); + PointerEnabled = other.dgetPointerEnabled(); + DoubleClickTime = other.dgetDoubleClickTime(); + PointerMirror = other.dgetPointerMirror(); + } + }; + class ScanClass { + public: + XBool DisableEntryScan = false; + XBool DisableToolScan = false; + UINT8 KernelScan = 0; + XBool LinuxScan = false; + XBool LegacyFirst = false; + XBool NoLegacy = false; - INT32 Timezone = 0xFF; - XStringW Theme = XStringW(); - //XBool DarkEmbedded = 0; - XString8 EmbeddedThemeType = XString8(); - XBool PlayAsync = false; - XBool CustomIcons = false; - XBool TextOnly = false; - XBool ShowOptimus = false; - XStringW ScreenResolution = XStringW(); - XBool ProvideConsoleGop = false; - INTN ConsoleMode = 0; - XString8 Language = XString8(); - LanguageCode languageCode = english; - XBool KbdPrevLang = false; - XString8Array HVHideStrings = XString8Array(); - ScanClass Scan = ScanClass(); - MouseClass Mouse = MouseClass(); - XObjArrayWithTakeValueFromXmlArray - CustomEntriesSettings = XObjArrayWithTakeValueFromXmlArray(); - XObjArrayWithTakeValueFromXmlArray - CustomLegacySettings = XObjArrayWithTakeValueFromXmlArray(); - XObjArrayWithTakeValueFromXmlArray - CustomToolSettings = XObjArrayWithTakeValueFromXmlArray(); - - XBool getDarkEmbedded(XBool isDaylight) const; - #if __cplusplus > 201703L - XBool operator == (const GUIClass&) const = default; + XBool operator==(const ScanClass &) const = default; #endif - XBool isEqual(const GUIClass& other) const - { - if ( !(Timezone == other.Timezone) ) return false; - if ( !(Theme == other.Theme) ) return false; - if ( !(EmbeddedThemeType == other.EmbeddedThemeType) ) return false; - if ( !(PlayAsync == other.PlayAsync) ) return false; - if ( !(CustomIcons == other.CustomIcons) ) return false; - if ( !(TextOnly == other.TextOnly) ) return false; - if ( !(ShowOptimus == other.ShowOptimus) ) return false; - if ( !(ScreenResolution == other.ScreenResolution) ) return false; - if ( !(ProvideConsoleGop == other.ProvideConsoleGop) ) return false; - if ( !(ConsoleMode == other.ConsoleMode) ) return false; - if ( !(Language == other.Language) ) return false; - if ( !(languageCode == other.languageCode) ) return false; - if ( !(KbdPrevLang == other.KbdPrevLang) ) return false; - if ( !(HVHideStrings == other.HVHideStrings) ) return false; - if ( !Scan.isEqual(other.Scan) ) return false; - if ( !Mouse.isEqual(other.Mouse) ) return false; - if ( !CustomEntriesSettings.isEqual(other.CustomEntriesSettings) ) return false; - if ( !CustomLegacySettings.isEqual(other.CustomLegacySettings) ) return false; - if ( !CustomToolSettings.isEqual(other.CustomToolSettings) ) return false; + XBool isEqual(const ScanClass &other) const { + if (!(DisableEntryScan == other.DisableEntryScan)) + return false; + if (!(DisableToolScan == other.DisableToolScan)) + return false; + if (!(KernelScan == other.KernelScan)) + return false; + if (!(LinuxScan == other.LinuxScan)) + return false; + if (!(LegacyFirst == other.LegacyFirst)) + return false; + if (!(NoLegacy == other.NoLegacy)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::GUI_Class& other) - { - Timezone = other.dgetTimezone(); - Theme = other.dgetTheme(); - EmbeddedThemeType = other.dgetEmbeddedThemeType(); - PlayAsync = other.dgetPlayAsync(); - CustomIcons = other.dgetCustomIcons(); - TextOnly = other.dgetTextOnly(); - ShowOptimus = other.dgetShowOptimus(); - ScreenResolution = other.dgetScreenResolution(); - ProvideConsoleGop = other.dgetProvideConsoleGop(); - ConsoleMode = other.dgetConsoleMode(); - Language = other.dgetLanguage(); - languageCode = other.dgetlanguageCode(); - KbdPrevLang = other.dgetKbdPrevLang(); - HVHideStrings = other.dgetHVHideStrings(); - Scan.takeValueFrom(other.Scan); - Mouse.takeValueFrom(other.Mouse); - CustomEntriesSettings.takeValueFrom(other.Custom.Entries); - CustomLegacySettings.takeValueFrom(other.Custom.Legacy); - CustomToolSettings.takeValueFrom(other.Custom.Tool); + void + takeValueFrom(const ConfigPlistClass::GUI_Class::GUI_Scan_Class &other) { + DisableEntryScan = other.dgetDisableEntryScan(); + DisableToolScan = other.dgetDisableToolScan(); + KernelScan = other.dgetKernelScan(); + LinuxScan = other.dgetLinuxScan(); + LegacyFirst = other.dgetLegacyFirst(); + NoLegacy = other.dgetNoLegacy(); } + }; + + INT32 Timezone = 0xFF; + XStringW Theme = XStringW(); + // XBool DarkEmbedded = 0; + XString8 EmbeddedThemeType = XString8(); + XBool PlayAsync = false; + XBool CustomIcons = false; + XBool TextOnly = false; + XBool ShowOptimus = false; + XStringW ScreenResolution = XStringW(); + XBool ProvideConsoleGop = false; + INTN ConsoleMode = 0; + XString8 Language = XString8(); + LanguageCode languageCode = english; + XBool KbdPrevLang = false; + XString8Array HVHideStrings = XString8Array(); + ScanClass Scan = ScanClass(); + MouseClass Mouse = MouseClass(); + XObjArrayWithTakeValueFromXmlArray< + CUSTOM_LOADER_ENTRY_SETTINGS, + ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_Entry_Class> + CustomEntriesSettings = XObjArrayWithTakeValueFromXmlArray< + CUSTOM_LOADER_ENTRY_SETTINGS, + ConfigPlistClass::GUI_Class::GUI_Custom_Class:: + GUI_Custom_Entry_Class>(); + XObjArrayWithTakeValueFromXmlArray< + CUSTOM_LEGACY_ENTRY_SETTINGS, + ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_Legacy_Class> + CustomLegacySettings = XObjArrayWithTakeValueFromXmlArray< + CUSTOM_LEGACY_ENTRY_SETTINGS, + ConfigPlistClass::GUI_Class::GUI_Custom_Class:: + GUI_Custom_Legacy_Class>(); + XObjArrayWithTakeValueFromXmlArray< + CUSTOM_TOOL_ENTRY_SETTINGS, + ConfigPlistClass::GUI_Class::GUI_Custom_Class::GUI_Custom_Tool_Class> + CustomToolSettings = XObjArrayWithTakeValueFromXmlArray< + CUSTOM_TOOL_ENTRY_SETTINGS, + ConfigPlistClass::GUI_Class::GUI_Custom_Class:: + GUI_Custom_Tool_Class>(); + + XBool getDarkEmbedded(XBool isDaylight) const; +#if __cplusplus > 201703L + XBool operator==(const GUIClass &) const = default; +#endif + XBool isEqual(const GUIClass &other) const { + if (!(Timezone == other.Timezone)) + return false; + if (!(Theme == other.Theme)) + return false; + if (!(EmbeddedThemeType == other.EmbeddedThemeType)) + return false; + if (!(PlayAsync == other.PlayAsync)) + return false; + if (!(CustomIcons == other.CustomIcons)) + return false; + if (!(TextOnly == other.TextOnly)) + return false; + if (!(ShowOptimus == other.ShowOptimus)) + return false; + if (!(ScreenResolution == other.ScreenResolution)) + return false; + if (!(ProvideConsoleGop == other.ProvideConsoleGop)) + return false; + if (!(ConsoleMode == other.ConsoleMode)) + return false; + if (!(Language == other.Language)) + return false; + if (!(languageCode == other.languageCode)) + return false; + if (!(KbdPrevLang == other.KbdPrevLang)) + return false; + if (!(HVHideStrings == other.HVHideStrings)) + return false; + if (!Scan.isEqual(other.Scan)) + return false; + if (!Mouse.isEqual(other.Mouse)) + return false; + if (!CustomEntriesSettings.isEqual(other.CustomEntriesSettings)) + return false; + if (!CustomLegacySettings.isEqual(other.CustomLegacySettings)) + return false; + if (!CustomToolSettings.isEqual(other.CustomToolSettings)) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::GUI_Class &other) { + Timezone = other.dgetTimezone(); + Theme = other.dgetTheme(); + EmbeddedThemeType = other.dgetEmbeddedThemeType(); + PlayAsync = other.dgetPlayAsync(); + CustomIcons = other.dgetCustomIcons(); + TextOnly = other.dgetTextOnly(); + ShowOptimus = other.dgetShowOptimus(); + ScreenResolution = other.dgetScreenResolution(); + ProvideConsoleGop = other.dgetProvideConsoleGop(); + ConsoleMode = other.dgetConsoleMode(); + Language = other.dgetLanguage(); + languageCode = other.dgetlanguageCode(); + KbdPrevLang = other.dgetKbdPrevLang(); + HVHideStrings = other.dgetHVHideStrings(); + Scan.takeValueFrom(other.Scan); + Mouse.takeValueFrom(other.Mouse); + CustomEntriesSettings.takeValueFrom(other.Custom.Entries); + CustomLegacySettings.takeValueFrom(other.Custom.Legacy); + CustomToolSettings.takeValueFrom(other.Custom.Tool); + } }; class CPUClass { - public: - UINT16 QPI = 0; - UINT32 CpuFreqMHz = 0; - UINT16 CpuType = 0; - XBool QEMU = false; - XBool UseARTFreq = false; - UINT32 BusSpeed = 0; //in kHz - XBool UserChange = false; - UINT8 SavingMode = 0; - XBool HWPEnable = false; - undefinable_uint32 HWPValue = undefinable_uint32(); - UINT8 TDP = 0; - XBool TurboDisabled = false; - undefinable_bool _EnableC6 = undefinable_bool(); - undefinable_bool _EnableC4 = undefinable_bool(); - undefinable_bool _EnableC2 = undefinable_bool(); - + public: + UINT16 QPI = 0; + UINT32 CpuFreqMHz = 0; + UINT16 CpuType = 0; + XBool QEMU = false; + XBool UseARTFreq = false; + UINT32 BusSpeed = 0; // in kHz + XBool UserChange = false; + UINT8 SavingMode = 0; + XBool HWPEnable = false; + undefinable_uint32 HWPValue = undefinable_uint32(); + UINT8 TDP = 0; + XBool TurboDisabled = false; + undefinable_bool _EnableC6 = undefinable_bool(); + undefinable_bool _EnableC4 = undefinable_bool(); + undefinable_bool _EnableC2 = undefinable_bool(); + #if __cplusplus > 201703L - XBool operator == (const CPUClass&) const = default; + XBool operator==(const CPUClass &) const = default; #endif - XBool isEqual(const CPUClass& other) const - { - if ( !(QPI == other.QPI) ) return false; - if ( !(CpuFreqMHz == other.CpuFreqMHz) ) return false; - if ( !(CpuType == other.CpuType) ) return false; - if ( !(QEMU == other.QEMU) ) return false; - if ( !(UseARTFreq == other.UseARTFreq) ) return false; - if ( !(BusSpeed == other.BusSpeed) ) return false; - if ( !(UserChange == other.UserChange) ) return false; - if ( !(SavingMode == other.SavingMode) ) return false; - if ( !(HWPEnable == other.HWPEnable) ) return false; - if ( !(HWPValue == other.HWPValue) ) return false; - if ( !(TDP == other.TDP) ) return false; - if ( !(TurboDisabled == other.TurboDisabled) ) return false; - if ( !(_EnableC6 == other._EnableC6) ) return false; - if ( !(_EnableC4 == other._EnableC4) ) return false; - if ( !(_EnableC2 == other._EnableC2) ) return false; + XBool isEqual(const CPUClass &other) const { + if (!(QPI == other.QPI)) + return false; + if (!(CpuFreqMHz == other.CpuFreqMHz)) + return false; + if (!(CpuType == other.CpuType)) + return false; + if (!(QEMU == other.QEMU)) + return false; + if (!(UseARTFreq == other.UseARTFreq)) + return false; + if (!(BusSpeed == other.BusSpeed)) + return false; + if (!(UserChange == other.UserChange)) + return false; + if (!(SavingMode == other.SavingMode)) + return false; + if (!(HWPEnable == other.HWPEnable)) + return false; + if (!(HWPValue == other.HWPValue)) + return false; + if (!(TDP == other.TDP)) + return false; + if (!(TurboDisabled == other.TurboDisabled)) + return false; + if (!(_EnableC6 == other._EnableC6)) + return false; + if (!(_EnableC4 == other._EnableC4)) + return false; + if (!(_EnableC2 == other._EnableC2)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::CPU_Class& other) - { + void takeValueFrom(const ConfigPlistClass::CPU_Class &other) { QPI = other.dgetQPI(); CpuFreqMHz = other.dgetCpuFreqMHz(); CpuType = other.dgetCpuType(); @@ -1246,550 +1479,675 @@ class SETTINGS_DATA { }; class SystemParametersClass { - public: - XBool WithKexts = true; - XBool WithKextsIfNoFakeSMC = false; - XBool NoCaches = false; - uint16_t BacklightLevel = 0xFFFF; - XBool BacklightLevelConfig = false; - EFI_GUID CustomUuid = EFI_GUID(); - public: // temporary, must be protected: - UINT8 _InjectSystemID = 2; // 0=false, 1=true, other value = default. - public: - XBool NvidiaWeb = false; + public: + XBool WithKexts = true; + XBool WithKextsIfNoFakeSMC = false; + XBool NoCaches = false; + uint16_t BacklightLevel = 0xFFFF; + XBool BacklightLevelConfig = false; + EFI_GUID CustomUuid = EFI_GUID(); + + public: // temporary, must be protected: + UINT8 _InjectSystemID = 2; // 0=false, 1=true, other value = default. + public: + XBool NvidiaWeb = false; #if __cplusplus > 201703L - XBool operator == (const SystemParametersClass&) const = default; + XBool operator==(const SystemParametersClass &) const = default; #endif - XBool isEqual(const SystemParametersClass& other) const - { - if ( !(WithKexts == other.WithKexts) ) return false; - if ( !(WithKextsIfNoFakeSMC == other.WithKextsIfNoFakeSMC) ) return false; - if ( !(NoCaches == other.NoCaches) ) return false; - if ( !(BacklightLevel == other.BacklightLevel) ) return false; - if ( !(BacklightLevelConfig == other.BacklightLevelConfig) ) return false; - if ( !(CustomUuid == other.CustomUuid) ) return false; - if ( !(_InjectSystemID == other._InjectSystemID) ) return false; - if ( !(NvidiaWeb == other.NvidiaWeb) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::SystemParameters_Class& other) - { - WithKexts = other.dgetWithKexts(); - WithKextsIfNoFakeSMC = other.dgetWithKextsIfNoFakeSMC(); - NoCaches = other.dgetNoCaches(); - BacklightLevel = other.dgetBacklightLevel(); - BacklightLevelConfig = other.dgetBacklightLevelConfig(); - CustomUuid = other.dgetCustomUuid(); - _InjectSystemID = other.dget_InjectSystemID(); - NvidiaWeb = other.dgetNvidiaWeb(); - } + XBool isEqual(const SystemParametersClass &other) const { + if (!(WithKexts == other.WithKexts)) + return false; + if (!(WithKextsIfNoFakeSMC == other.WithKextsIfNoFakeSMC)) + return false; + if (!(NoCaches == other.NoCaches)) + return false; + if (!(BacklightLevel == other.BacklightLevel)) + return false; + if (!(BacklightLevelConfig == other.BacklightLevelConfig)) + return false; + if (!(CustomUuid == other.CustomUuid)) + return false; + if (!(_InjectSystemID == other._InjectSystemID)) + return false; + if (!(NvidiaWeb == other.NvidiaWeb)) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::SystemParameters_Class &other) { + WithKexts = other.dgetWithKexts(); + WithKextsIfNoFakeSMC = other.dgetWithKextsIfNoFakeSMC(); + NoCaches = other.dgetNoCaches(); + BacklightLevel = other.dgetBacklightLevel(); + BacklightLevelConfig = other.dgetBacklightLevelConfig(); + CustomUuid = other.dgetCustomUuid(); + _InjectSystemID = other.dget_InjectSystemID(); + NvidiaWeb = other.dgetNvidiaWeb(); + } }; class GraphicsClass { + public: + class EDIDClass { public: - class EDIDClass { - public: - XBool InjectEDID = XBool(); - XBuffer CustomEDID = XBuffer (); - UINT16 VendorEDID = UINT16(); - UINT16 ProductEDID = UINT16(); - UINT16 EdidFixHorizontalSyncPulseWidth = UINT16(); - UINT8 EdidFixVideoInputSignal = UINT8(); - -#if __cplusplus > 201703L - XBool operator == (const EDIDClass&) const = default; -#endif - XBool isEqual(const EDIDClass& other) const - { - if ( !(InjectEDID == other.InjectEDID) ) return false; - if ( !(CustomEDID == other.CustomEDID) ) return false; - if ( !(VendorEDID == other.VendorEDID) ) return false; - if ( !(ProductEDID == other.ProductEDID) ) return false; - if ( !(EdidFixHorizontalSyncPulseWidth == other.EdidFixHorizontalSyncPulseWidth) ) return false; - if ( !(EdidFixVideoInputSignal == other.EdidFixVideoInputSignal) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::Graphics_Class::Graphics_EDID_Class& other) - { - InjectEDID = other.dgetInjectEDID(); - CustomEDID = other.dgetCustomEDID(); - VendorEDID = other.dgetVendorEDID(); - ProductEDID = other.dgetProductEDID(); - EdidFixHorizontalSyncPulseWidth = other.dgetEdidFixHorizontalSyncPulseWidth(); - EdidFixVideoInputSignal = other.dgetEdidFixVideoInputSignal(); - } - }; - - class InjectAsDictClass { - public: - XBool GraphicsInjector = XBool(); - XBool InjectIntel = XBool(); - XBool InjectATI = XBool(); - XBool InjectNVidia = XBool(); - + XBool InjectEDID = XBool(); + XBuffer CustomEDID = XBuffer(); + UINT16 VendorEDID = UINT16(); + UINT16 ProductEDID = UINT16(); + UINT16 EdidFixHorizontalSyncPulseWidth = UINT16(); + UINT8 EdidFixVideoInputSignal = UINT8(); + #if __cplusplus > 201703L - XBool operator == (const InjectAsDictClass&) const = default; + XBool operator==(const EDIDClass &) const = default; #endif - XBool isEqual(const InjectAsDictClass& other) const - { - if ( !(GraphicsInjector == other.GraphicsInjector) ) return false; - if ( !(InjectIntel == other.InjectIntel) ) return false; - if ( !(InjectATI == other.InjectATI) ) return false; - if ( !(InjectNVidia == other.InjectNVidia) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::Graphics_Class::XmlInjectUnion& other) - { - GraphicsInjector = other.dgetGraphicsInjector(); - InjectIntel = other.dgetInjectIntel(); - InjectATI = other.dgetInjectATI(); - InjectNVidia = other.dgetInjectNVidia(); - } - }; + XBool isEqual(const EDIDClass &other) const { + if (!(InjectEDID == other.InjectEDID)) + return false; + if (!(CustomEDID == other.CustomEDID)) + return false; + if (!(VendorEDID == other.VendorEDID)) + return false; + if (!(ProductEDID == other.ProductEDID)) + return false; + if (!(EdidFixHorizontalSyncPulseWidth == + other.EdidFixHorizontalSyncPulseWidth)) + return false; + if (!(EdidFixVideoInputSignal == other.EdidFixVideoInputSignal)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::Graphics_Class::Graphics_EDID_Class &other) { + InjectEDID = other.dgetInjectEDID(); + CustomEDID = other.dgetCustomEDID(); + VendorEDID = other.dgetVendorEDID(); + ProductEDID = other.dgetProductEDID(); + EdidFixHorizontalSyncPulseWidth = + other.dgetEdidFixHorizontalSyncPulseWidth(); + EdidFixVideoInputSignal = other.dgetEdidFixVideoInputSignal(); + } + }; + + class InjectAsDictClass { + public: + XBool GraphicsInjector = XBool(); + XBool InjectIntel = XBool(); + XBool InjectATI = XBool(); + XBool InjectNVidia = XBool(); - class GRAPHIC_CARD { - public: - UINT32 Signature = 0; - XString8 Model = XString8(); - UINT32 Id = 0; - UINT32 SubId = 0; - UINT64 VideoRam = 0; - UINTN VideoPorts = 0; - XBool LoadVBios = false; - #if __cplusplus > 201703L - XBool operator == (const GRAPHIC_CARD&) const = default; + XBool operator==(const InjectAsDictClass &) const = default; #endif - XBool isEqual(const GRAPHIC_CARD& other) const - { - if ( !(Signature == other.Signature) ) return false; - if ( !(Model == other.Model) ) return false; - if ( !(Id == other.Id) ) return false; - if ( !(SubId == other.SubId) ) return false; - if ( !(VideoRam == other.VideoRam) ) return false; - if ( !(VideoPorts == other.VideoPorts) ) return false; - if ( !(LoadVBios == other.LoadVBios) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::Graphics_Class::Graphics_ATI_NVIDIA_Class& other) - { - Signature = other.dgetSignature(); - Model = other.dgetModel(); - Id = other.dgetId(); - SubId = other.dgetSubId(); - VideoRam = other.dgetVideoRam(); - VideoPorts = other.dgetVideoPorts(); - LoadVBios = other.dgetLoadVBios(); - } - }; - - XBool PatchVBios = XBool(); - PatchVBiosBytesNewClass PatchVBiosBytes = PatchVBiosBytesNewClass(); -// undefinable_bool InjectAsBool = undefinable_bool(); - XBool RadeonDeInit = XBool(); - XBool LoadVBios = XBool(); - UINT64 VRAM = XBool(); - UINT32 RefCLK = UINT32(); - XStringW FBName = XStringW(); - UINT16 VideoPorts = UINT16(); - XBool NvidiaGeneric = XBool(); - XBool NvidiaNoEFI = XBool(); - XBool NvidiaSingle = XBool(); - XArray Dcfg = XArray(); - XArray NVCAP = XArray(); - INT8 BootDisplay = INT8(); - UINT32 DualLink = UINT32(); - UINT32 _IgPlatform = UINT32(); //could also be snb-platform-id - EDIDClass EDID = EDIDClass(); - InjectAsDictClass InjectAsDict = InjectAsDictClass(); - XObjArrayWithTakeValueFromXmlArray ATICardList = XObjArrayWithTakeValueFromXmlArray(); - XObjArrayWithTakeValueFromXmlArray NVIDIACardList = XObjArrayWithTakeValueFromXmlArray(); - - GraphicsClass() { - Dcfg.setSize(8); - memset(Dcfg.data(), 0, 8); - NVCAP.setSize(20); - memset(NVCAP.data(), 0, 20); + XBool isEqual(const InjectAsDictClass &other) const { + if (!(GraphicsInjector == other.GraphicsInjector)) + return false; + if (!(InjectIntel == other.InjectIntel)) + return false; + if (!(InjectATI == other.InjectATI)) + return false; + if (!(InjectNVidia == other.InjectNVidia)) + return false; + return true; } - + void takeValueFrom( + const ConfigPlistClass::Graphics_Class::XmlInjectUnion &other) { + GraphicsInjector = other.dgetGraphicsInjector(); + InjectIntel = other.dgetInjectIntel(); + InjectATI = other.dgetInjectATI(); + InjectNVidia = other.dgetInjectNVidia(); + } + }; + + class GRAPHIC_CARD { + public: + UINT32 Signature = 0; + XString8 Model = XString8(); + UINT32 Id = 0; + UINT32 SubId = 0; + UINT64 VideoRam = 0; + UINTN VideoPorts = 0; + XBool LoadVBios = false; + #if __cplusplus > 201703L - XBool operator == (const GraphicsClass&) const = default; + XBool operator==(const GRAPHIC_CARD &) const = default; #endif - XBool isEqual(const GraphicsClass& other) const - { - if ( !(PatchVBios == other.PatchVBios) ) return false; - if ( !PatchVBiosBytes.isEqual(other.PatchVBiosBytes) ) return false; - if ( !(RadeonDeInit == other.RadeonDeInit) ) return false; - if ( !(LoadVBios == other.LoadVBios) ) return false; - if ( !(VRAM == other.VRAM) ) return false; - if ( !(RefCLK == other.RefCLK) ) return false; - if ( !(FBName == other.FBName) ) return false; - if ( !(VideoPorts == other.VideoPorts) ) return false; - if ( !(NvidiaGeneric == other.NvidiaGeneric) ) return false; - if ( !(NvidiaNoEFI == other.NvidiaNoEFI) ) return false; - if ( !(NvidiaSingle == other.NvidiaSingle) ) return false; - if ( !(Dcfg == other.Dcfg) ) return false; - if ( !(NVCAP == other.NVCAP) ) return false; - if ( !(BootDisplay == other.BootDisplay) ) return false; - if ( !(DualLink == other.DualLink) ) return false; - if ( !(_IgPlatform == other._IgPlatform) ) return false; - if ( !EDID.isEqual(other.EDID) ) return false; - if ( !InjectAsDict.isEqual(other.InjectAsDict) ) return false; - if ( !ATICardList.isEqual(other.ATICardList) ) return false; - if ( !NVIDIACardList.isEqual(other.NVIDIACardList) ) return false; + XBool isEqual(const GRAPHIC_CARD &other) const { + if (!(Signature == other.Signature)) + return false; + if (!(Model == other.Model)) + return false; + if (!(Id == other.Id)) + return false; + if (!(SubId == other.SubId)) + return false; + if (!(VideoRam == other.VideoRam)) + return false; + if (!(VideoPorts == other.VideoPorts)) + return false; + if (!(LoadVBios == other.LoadVBios)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::Graphics_Class& other) - { - PatchVBios = other.dgetPatchVBios(); - PatchVBiosBytes.takeValueFrom(other.PatchVBiosBytesArray); - RadeonDeInit = other.dgetRadeonDeInit(); - LoadVBios = other.dgetLoadVBios(); - VRAM = other.dgetVRAM(); - RefCLK = other.dgetRefCLK(); - FBName = other.dgetFBName(); + void takeValueFrom( + const ConfigPlistClass::Graphics_Class::Graphics_ATI_NVIDIA_Class + &other) { + Signature = other.dgetSignature(); + Model = other.dgetModel(); + Id = other.dgetId(); + SubId = other.dgetSubId(); + VideoRam = other.dgetVideoRam(); VideoPorts = other.dgetVideoPorts(); - NvidiaGeneric = other.dgetNvidiaGeneric(); - NvidiaNoEFI = other.dgetNvidiaNoEFI(); - NvidiaSingle = other.dgetNvidiaSingle(); - Dcfg = other.dgetDcfg(); - NVCAP = other.dgetNVCAP(); - BootDisplay = other.dgetBootDisplay(); - DualLink = other.dgetDualLink(); - _IgPlatform = other.dget_IgPlatform(); - EDID.takeValueFrom(other.EDID); - InjectAsDict.takeValueFrom(other.Inject); - ATICardList.takeValueFrom(other.ATI); - NVIDIACardList.takeValueFrom(other.NVIDIA); + LoadVBios = other.dgetLoadVBios(); } + }; + + XBool PatchVBios = XBool(); + PatchVBiosBytesNewClass PatchVBiosBytes = PatchVBiosBytesNewClass(); + // undefinable_bool InjectAsBool = undefinable_bool(); + XBool RadeonDeInit = XBool(); + XBool LoadVBios = XBool(); + UINT64 VRAM = XBool(); + UINT32 RefCLK = UINT32(); + XStringW FBName = XStringW(); + UINT16 VideoPorts = UINT16(); + XBool NvidiaGeneric = XBool(); + XBool NvidiaNoEFI = XBool(); + XBool NvidiaSingle = XBool(); + XArray Dcfg = XArray(); + XArray NVCAP = XArray(); + INT8 BootDisplay = INT8(); + UINT32 DualLink = UINT32(); + UINT32 _IgPlatform = UINT32(); // could also be snb-platform-id + EDIDClass EDID = EDIDClass(); + InjectAsDictClass InjectAsDict = InjectAsDictClass(); + XObjArrayWithTakeValueFromXmlArray< + GRAPHIC_CARD, + ConfigPlistClass::Graphics_Class::Graphics_ATI_NVIDIA_Class> + ATICardList = XObjArrayWithTakeValueFromXmlArray< + GRAPHIC_CARD, + ConfigPlistClass::Graphics_Class::Graphics_ATI_NVIDIA_Class>(); + XObjArrayWithTakeValueFromXmlArray< + GRAPHIC_CARD, + ConfigPlistClass::Graphics_Class::Graphics_ATI_NVIDIA_Class> + NVIDIACardList = XObjArrayWithTakeValueFromXmlArray< + GRAPHIC_CARD, + ConfigPlistClass::Graphics_Class::Graphics_ATI_NVIDIA_Class>(); + + GraphicsClass() { + Dcfg.setSize(8); + memset(Dcfg.data(), 0, 8); + NVCAP.setSize(20); + memset(NVCAP.data(), 0, 20); + } - //XBool getGraphicsInjector() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.GraphicsInjector; } - //XBool InjectIntel() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectIntel; } - //XBool InjectATI() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectATI; } - //XBool InjectNVidia() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectNVidia; } +#if __cplusplus > 201703L + XBool operator==(const GraphicsClass &) const = default; +#endif + XBool isEqual(const GraphicsClass &other) const { + if (!(PatchVBios == other.PatchVBios)) + return false; + if (!PatchVBiosBytes.isEqual(other.PatchVBiosBytes)) + return false; + if (!(RadeonDeInit == other.RadeonDeInit)) + return false; + if (!(LoadVBios == other.LoadVBios)) + return false; + if (!(VRAM == other.VRAM)) + return false; + if (!(RefCLK == other.RefCLK)) + return false; + if (!(FBName == other.FBName)) + return false; + if (!(VideoPorts == other.VideoPorts)) + return false; + if (!(NvidiaGeneric == other.NvidiaGeneric)) + return false; + if (!(NvidiaNoEFI == other.NvidiaNoEFI)) + return false; + if (!(NvidiaSingle == other.NvidiaSingle)) + return false; + if (!(Dcfg == other.Dcfg)) + return false; + if (!(NVCAP == other.NVCAP)) + return false; + if (!(BootDisplay == other.BootDisplay)) + return false; + if (!(DualLink == other.DualLink)) + return false; + if (!(_IgPlatform == other._IgPlatform)) + return false; + if (!EDID.isEqual(other.EDID)) + return false; + if (!InjectAsDict.isEqual(other.InjectAsDict)) + return false; + if (!ATICardList.isEqual(other.ATICardList)) + return false; + if (!NVIDIACardList.isEqual(other.NVIDIACardList)) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::Graphics_Class &other) { + PatchVBios = other.dgetPatchVBios(); + PatchVBiosBytes.takeValueFrom(other.PatchVBiosBytesArray); + RadeonDeInit = other.dgetRadeonDeInit(); + LoadVBios = other.dgetLoadVBios(); + VRAM = other.dgetVRAM(); + RefCLK = other.dgetRefCLK(); + FBName = other.dgetFBName(); + VideoPorts = other.dgetVideoPorts(); + NvidiaGeneric = other.dgetNvidiaGeneric(); + NvidiaNoEFI = other.dgetNvidiaNoEFI(); + NvidiaSingle = other.dgetNvidiaSingle(); + Dcfg = other.dgetDcfg(); + NVCAP = other.dgetNVCAP(); + BootDisplay = other.dgetBootDisplay(); + DualLink = other.dgetDualLink(); + _IgPlatform = other.dget_IgPlatform(); + EDID.takeValueFrom(other.EDID); + InjectAsDict.takeValueFrom(other.Inject); + ATICardList.takeValueFrom(other.ATI); + NVIDIACardList.takeValueFrom(other.NVIDIA); + } + // XBool getGraphicsInjector() const { return InjectAsBool.isDefined() ? + // InjectAsBool.value() : InjectAsDict.GraphicsInjector; } XBool + // InjectIntel() const { return InjectAsBool.isDefined() ? + // InjectAsBool.value() : InjectAsDict.InjectIntel; } XBool InjectATI() + // const { return InjectAsBool.isDefined() ? InjectAsBool.value() : + // InjectAsDict.InjectATI; } XBool InjectNVidia() const { return + // InjectAsBool.isDefined() ? InjectAsBool.value() : + // InjectAsDict.InjectNVidia; } }; - + class DevicesClass { + public: + class AudioClass { public: - - class AudioClass { - public: - XBool ResetHDA = XBool(); - XBool HDAInjection = XBool(); - INT32 HDALayoutId = INT32(); - XBool AFGLowPowerState = XBool(); - + XBool ResetHDA = XBool(); + XBool HDAInjection = XBool(); + INT32 HDALayoutId = INT32(); + XBool AFGLowPowerState = XBool(); + #if __cplusplus > 201703L - XBool operator == (const AudioClass&) const = default; + XBool operator==(const AudioClass &) const = default; #endif - XBool isEqual(const AudioClass& other) const - { - if ( !(ResetHDA == other.ResetHDA) ) return false; - if ( !(HDAInjection == other.HDAInjection) ) return false; - if ( !(HDALayoutId == other.HDALayoutId) ) return false; - if ( !(AFGLowPowerState == other.AFGLowPowerState) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::Devices_Audio_Class& other) - { - ResetHDA = other.dgetResetHDA(); - HDAInjection = other.dgetHDAInjection(); - HDALayoutId = other.dgetHDALayoutId(); - AFGLowPowerState = other.dgetAFGLowPowerState(); - } - }; - class USBClass { - public: - XBool USBInjection = XBool(); - XBool USBFixOwnership = XBool(); - XBool InjectClockID = XBool(); - XBool HighCurrent = XBool(); - XBool NameEH00 = XBool(); - XBool NameXH00 = XBool(); // is it used? - + XBool isEqual(const AudioClass &other) const { + if (!(ResetHDA == other.ResetHDA)) + return false; + if (!(HDAInjection == other.HDAInjection)) + return false; + if (!(HDALayoutId == other.HDALayoutId)) + return false; + if (!(AFGLowPowerState == other.AFGLowPowerState)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::DevicesClass::Devices_Audio_Class &other) { + ResetHDA = other.dgetResetHDA(); + HDAInjection = other.dgetHDAInjection(); + HDALayoutId = other.dgetHDALayoutId(); + AFGLowPowerState = other.dgetAFGLowPowerState(); + } + }; + class USBClass { + public: + XBool USBInjection = XBool(); + XBool USBFixOwnership = XBool(); + XBool InjectClockID = XBool(); + XBool HighCurrent = XBool(); + XBool NameEH00 = XBool(); + XBool NameXH00 = XBool(); // is it used? + #if __cplusplus > 201703L - XBool operator == (const USBClass&) const = default; + XBool operator==(const USBClass &) const = default; #endif - XBool isEqual(const USBClass& other) const - { - if ( !(USBInjection == other.USBInjection) ) return false; - if ( !(USBFixOwnership == other.USBFixOwnership) ) return false; - if ( !(InjectClockID == other.InjectClockID) ) return false; - if ( !(HighCurrent == other.HighCurrent) ) return false; - if ( !(NameEH00 == other.NameEH00) ) return false; - if ( !(NameXH00 == other.NameXH00) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::Devices_USB_Class& other) - { - USBInjection = other.dgetUSBInjection(); - USBFixOwnership = other.dgetUSBFixOwnership(); - InjectClockID = other.dgetInjectClockID(); - HighCurrent = other.dgetHighCurrent(); - NameEH00 = other.dgetNameEH00(); - //NameXH00 = other.dgetNameXH00(); - } - }; + XBool isEqual(const USBClass &other) const { + if (!(USBInjection == other.USBInjection)) + return false; + if (!(USBFixOwnership == other.USBFixOwnership)) + return false; + if (!(InjectClockID == other.InjectClockID)) + return false; + if (!(HighCurrent == other.HighCurrent)) + return false; + if (!(NameEH00 == other.NameEH00)) + return false; + if (!(NameXH00 == other.NameXH00)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::DevicesClass::Devices_USB_Class &other) { + USBInjection = other.dgetUSBInjection(); + USBFixOwnership = other.dgetUSBFixOwnership(); + InjectClockID = other.dgetInjectClockID(); + HighCurrent = other.dgetHighCurrent(); + NameEH00 = other.dgetNameEH00(); + // NameXH00 = other.dgetNameXH00(); + } + }; - class AddPropertyClass - { - public: - uint32_t Device = 0; - XString8 Key = XString8(); - XBuffer Value = XBuffer(); - TAG_TYPE ValueType = kTagTypeNone; - INPUT_ITEM MenuItem = INPUT_ITEM(); -// XString8 DevicePathAsString = XString8(); -// XString8 Label = XString8(); - - AddPropertyClass() {} + class AddPropertyClass { + public: + uint32_t Device = 0; + XString8 Key = XString8(); + XBuffer Value = XBuffer(); + TAG_TYPE ValueType = kTagTypeNone; + INPUT_ITEM MenuItem = INPUT_ITEM(); + // XString8 DevicePathAsString = XString8(); + // XString8 Label = XString8(); + + AddPropertyClass() {} #if __cplusplus > 201703L - XBool operator == (const AddPropertyClass&) const = default; + XBool operator==(const AddPropertyClass &) const = default; #endif - XBool isEqual(const AddPropertyClass& other) const - { - if ( !(Device == other.Device) ) return false; - if ( !(Key == other.Key) ) return false; - if ( !(Value == other.Value) ) return false; - if ( !(ValueType == other.ValueType) ) return false; - if ( !(MenuItem == other.MenuItem) ) return false; -// if ( !(DevicePathAsString == other.DevicePathAsString) ) return false; -// if ( !(Label == other.Label) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::Devices_AddProperties_Dict_Class& other) - { - Device = other.dgetDevice(); - Key = other.dgetKey(); - Value = other.dgetValue(); - ValueType = other.dgetValueType(); - MenuItem.BValue = !other.dgetDisabled(); -// DevicePathAsString = other.dgetDevicePathAsString(); -// Label = other.dgetLabel(); - } - }; + XBool isEqual(const AddPropertyClass &other) const { + if (!(Device == other.Device)) + return false; + if (!(Key == other.Key)) + return false; + if (!(Value == other.Value)) + return false; + if (!(ValueType == other.ValueType)) + return false; + if (!(MenuItem == other.MenuItem)) + return false; + // if ( !(DevicePathAsString == other.DevicePathAsString) ) + // return false; if ( !(Label == other.Label) ) return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::DevicesClass::Devices_AddProperties_Dict_Class + &other) { + Device = other.dgetDevice(); + Key = other.dgetKey(); + Value = other.dgetValue(); + ValueType = other.dgetValueType(); + MenuItem.BValue = !other.dgetDisabled(); + // DevicePathAsString = other.dgetDevicePathAsString(); + // Label = other.dgetLabel(); + } + }; - // This is shared by PropertiesClass and ArbitraryClass - class SimplePropertyClass - { - public: - XString8 Key = XString8(); - XBuffer Value = XBuffer(); - TAG_TYPE ValueType = kTagTypeNone; // only used in CreateMenuProps() - INPUT_ITEM MenuItem = INPUT_ITEM(); // Will get the Disabled value - - SimplePropertyClass() {} + // This is shared by PropertiesClass and ArbitraryClass + class SimplePropertyClass { + public: + XString8 Key = XString8(); + XBuffer Value = XBuffer(); + TAG_TYPE ValueType = kTagTypeNone; // only used in CreateMenuProps() + INPUT_ITEM MenuItem = INPUT_ITEM(); // Will get the Disabled value + + SimplePropertyClass() {} #if __cplusplus > 201703L - XBool operator == (const SimplePropertyClass&) const = default; + XBool operator==(const SimplePropertyClass &) const = default; #endif - XBool isEqual(const SimplePropertyClass& other) const - { - if ( !(Key == other.Key) ) return false; - if ( !(Value == other.Value) ) return false; - if ( !(ValueType == other.ValueType) ) return false; - if ( !(MenuItem == other.MenuItem) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::SimplePropertyClass_Class& other) - { - Key = other.dgetKey(); - Value = other.dgetValue(); - ValueType = other.dgetValueType(); - MenuItem.BValue = !other.dgetDisabled(); - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::PropertiesUnion::Property& other) - { - Key = other.dgetKey(); - Value = other.dgetValue(); - ValueType = other.dgetValueType(); - MenuItem.BValue = other.dgetBValue(); - } - }; - - // Property don't have Device. Before it was always Device = 0 to differentiate from Arbitrary properties. - class PropertiesClass { - public: - - class PropertyClass - { - public: - - XBool Enabled = true; - XStringW DevicePathAsString = XStringW(); - // XString8 Label = XString8(); // Label is the same as DevicePathAsString, so it's not needed. - XObjArrayWithTakeValueFromXmlRepeatingDict propertiesArray = XObjArrayWithTakeValueFromXmlRepeatingDict(); + XBool isEqual(const SimplePropertyClass &other) const { + if (!(Key == other.Key)) + return false; + if (!(Value == other.Value)) + return false; + if (!(ValueType == other.ValueType)) + return false; + if (!(MenuItem == other.MenuItem)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::DevicesClass::SimplePropertyClass_Class + &other) { + Key = other.dgetKey(); + Value = other.dgetValue(); + ValueType = other.dgetValueType(); + MenuItem.BValue = !other.dgetDisabled(); + } + void takeValueFrom( + const ConfigPlistClass::DevicesClass::PropertiesUnion::Property + &other) { + Key = other.dgetKey(); + Value = other.dgetValue(); + ValueType = other.dgetValueType(); + MenuItem.BValue = other.dgetBValue(); + } + }; - PropertyClass() {} + // Property don't have Device. Before it was always Device = 0 to + // differentiate from Arbitrary properties. + class PropertiesClass { + public: + class PropertyClass { + public: + XBool Enabled = true; + XStringW DevicePathAsString = XStringW(); + // XString8 Label = XString8(); // Label is the same + // as DevicePathAsString, so it's not needed. + XObjArrayWithTakeValueFromXmlRepeatingDict< + SimplePropertyClass, + ConfigPlistClass::DevicesClass::PropertiesUnion::Property> + propertiesArray = XObjArrayWithTakeValueFromXmlRepeatingDict< + SimplePropertyClass, + ConfigPlistClass::DevicesClass::PropertiesUnion::Property>(); + + PropertyClass() {} #if !defined(DONT_DEFINE_GLOBALS) - EFI_DEVICE_PATH_PROTOCOL* getDevicePath() const - { - EFI_DEVICE_PATH_PROTOCOL* DevicePath; - if ( DevicePathAsString.isEqualIC("PrimaryGPU") && gConf.GfxPropertiesArray.size() > 0 ) { - DevicePath = DevicePathFromHandle(gConf.GfxPropertiesArray[0].Handle); // first gpu - } else if ( DevicePathAsString.isEqualIC("SecondaryGPU") && gConf.GfxPropertiesArray.size() > 1 ) { - DevicePath = DevicePathFromHandle(gConf.GfxPropertiesArray[1].Handle); // second gpu - } else { - DevicePath = ConvertTextToDevicePath(DevicePathAsString.wc_str()); //TODO - } - return DevicePath; - } + EFI_DEVICE_PATH_PROTOCOL *getDevicePath() const { + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + if (DevicePathAsString.isEqualIC("PrimaryGPU") && + gConf.GfxPropertiesArray.size() > 0) { + DevicePath = DevicePathFromHandle( + gConf.GfxPropertiesArray[0].Handle); // first gpu + } else if (DevicePathAsString.isEqualIC("SecondaryGPU") && + gConf.GfxPropertiesArray.size() > 1) { + DevicePath = DevicePathFromHandle( + gConf.GfxPropertiesArray[1].Handle); // second gpu + } else { + DevicePath = + ConvertTextToDevicePath(DevicePathAsString.wc_str()); // TODO + } + return DevicePath; + } #endif #if __cplusplus > 201703L - XBool operator == (const PropertyClass&) const = default; + XBool operator==(const PropertyClass &) const = default; #endif - XBool isEqual(const PropertyClass& other) const - { - if ( !(Enabled == other.Enabled) ) return false; - if ( !(DevicePathAsString == other.DevicePathAsString) ) return false; -// if ( !(Label == other.Label) ) return false; - if ( !propertiesArray.isEqual(other.propertiesArray) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::PropertiesUnion::Properties4DeviceClass& other) - { - Enabled = other.dgetEnabled(); - DevicePathAsString = other.dgetDevicePathAsString(); -// Label = other.dgetLabel(); - propertiesArray.takeValueFrom(other); - } - }; - - XString8 propertiesAsString = XString8(); - XObjArrayWithTakeValueFromXmlRepeatingDict PropertyArray = XObjArrayWithTakeValueFromXmlRepeatingDict(); - + XBool isEqual(const PropertyClass &other) const { + if (!(Enabled == other.Enabled)) + return false; + if (!(DevicePathAsString == other.DevicePathAsString)) + return false; + // if ( !(Label == other.Label) ) return false; + if (!propertiesArray.isEqual(other.propertiesArray)) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::DevicesClass:: + PropertiesUnion::Properties4DeviceClass &other) { + Enabled = other.dgetEnabled(); + DevicePathAsString = other.dgetDevicePathAsString(); + // Label = other.dgetLabel(); + propertiesArray.takeValueFrom(other); + } + }; + + XString8 propertiesAsString = XString8(); + XObjArrayWithTakeValueFromXmlRepeatingDict< + PropertyClass, ConfigPlistClass::DevicesClass::PropertiesUnion:: + Properties4DeviceClass> + PropertyArray = XObjArrayWithTakeValueFromXmlRepeatingDict< + PropertyClass, ConfigPlistClass::DevicesClass::PropertiesUnion:: + Properties4DeviceClass>(); + #if __cplusplus > 201703L - XBool operator == (const PropertiesClass&) const = default; + XBool operator==(const PropertiesClass &) const = default; #endif - XBool isEqual(const PropertiesClass& other) const - { - if ( !(propertiesAsString == other.propertiesAsString) ) return false; - if ( !PropertyArray.isEqual(other.PropertyArray) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::PropertiesUnion& other) - { - propertiesAsString = other.dgetpropertiesAsString(); - PropertyArray.takeValueFrom(other.PropertiesAsDict); - } - }; + XBool isEqual(const PropertiesClass &other) const { + if (!(propertiesAsString == other.propertiesAsString)) + return false; + if (!PropertyArray.isEqual(other.PropertyArray)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::DevicesClass::PropertiesUnion &other) { + propertiesAsString = other.dgetpropertiesAsString(); + PropertyArray.takeValueFrom(other.PropertiesAsDict); + } + }; - class ArbitraryPropertyClass { - public: - uint32_t Device = 0; - XString8 Label = XString8(); - XObjArrayWithTakeValueFromXmlArray CustomPropertyArray = XObjArrayWithTakeValueFromXmlArray(); - - ArbitraryPropertyClass() {} + class ArbitraryPropertyClass { + public: + uint32_t Device = 0; + XString8 Label = XString8(); + XObjArrayWithTakeValueFromXmlArray< + SimplePropertyClass, + ConfigPlistClass::DevicesClass::SimplePropertyClass_Class> + CustomPropertyArray = XObjArrayWithTakeValueFromXmlArray< + SimplePropertyClass, + ConfigPlistClass::DevicesClass::SimplePropertyClass_Class>(); + + ArbitraryPropertyClass() {} #if __cplusplus > 201703L - XBool operator == (const ArbitraryPropertyClass&) const = default; + XBool operator==(const ArbitraryPropertyClass &) const = default; #endif - XBool isEqual(const ArbitraryPropertyClass& other) const - { - if ( !(Device == other.Device) ) return false; - if ( !(Label == other.Label) ) return false; - if ( !CustomPropertyArray.isEqual(other.CustomPropertyArray) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::Devices_Arbitrary_Class& other) - { - Device = other.dgetDevice(); - Label = other.dgetLabel(); - CustomPropertyArray.takeValueFrom(other.CustomProperties); - } - }; + XBool isEqual(const ArbitraryPropertyClass &other) const { + if (!(Device == other.Device)) + return false; + if (!(Label == other.Label)) + return false; + if (!CustomPropertyArray.isEqual(other.CustomPropertyArray)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::DevicesClass::Devices_Arbitrary_Class + &other) { + Device = other.dgetDevice(); + Label = other.dgetLabel(); + CustomPropertyArray.takeValueFrom(other.CustomProperties); + } + }; + + class FakeIDClass { + public: + // PCI devices + UINT32 FakeATI = UINT32(); // 97 + UINT32 FakeNVidia = UINT32(); + UINT32 FakeIntel = UINT32(); + UINT32 FakeLAN = UINT32(); // 100 + UINT32 FakeWIFI = UINT32(); + UINT32 FakeSATA = UINT32(); + UINT32 FakeXHCI = UINT32(); // 103 + UINT32 FakeIMEI = UINT32(); // 106 - class FakeIDClass { - public: - //PCI devices - UINT32 FakeATI = UINT32(); //97 - UINT32 FakeNVidia = UINT32(); - UINT32 FakeIntel = UINT32(); - UINT32 FakeLAN = UINT32(); //100 - UINT32 FakeWIFI = UINT32(); - UINT32 FakeSATA = UINT32(); - UINT32 FakeXHCI = UINT32(); //103 - UINT32 FakeIMEI = UINT32(); //106 - #if __cplusplus > 201703L - XBool operator == (const FakeIDClass&) const = default; + XBool operator==(const FakeIDClass &) const = default; #endif - XBool isEqual(const FakeIDClass& other) const - { - if ( !(FakeATI == other.FakeATI) ) return false; - if ( !(FakeNVidia == other.FakeNVidia) ) return false; - if ( !(FakeIntel == other.FakeIntel) ) return false; - if ( !(FakeLAN == other.FakeLAN) ) return false; - if ( !(FakeWIFI == other.FakeWIFI) ) return false; - if ( !(FakeSATA == other.FakeSATA) ) return false; - if ( !(FakeXHCI == other.FakeXHCI) ) return false; - if ( !(FakeIMEI == other.FakeIMEI) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::DevicesClass::Devices_FakeID_Class& other) - { - FakeATI = other.dgetFakeATI(); - FakeNVidia = other.dgetFakeNVidia(); - FakeIntel = other.dgetFakeIntel(); - FakeLAN = other.dgetFakeLAN(); - FakeWIFI = other.dgetFakeWIFI(); - FakeSATA = other.dgetFakeSATA(); - FakeXHCI = other.dgetFakeXHCI(); - FakeIMEI = other.dgetFakeIMEI(); - } - }; + XBool isEqual(const FakeIDClass &other) const { + if (!(FakeATI == other.FakeATI)) + return false; + if (!(FakeNVidia == other.FakeNVidia)) + return false; + if (!(FakeIntel == other.FakeIntel)) + return false; + if (!(FakeLAN == other.FakeLAN)) + return false; + if (!(FakeWIFI == other.FakeWIFI)) + return false; + if (!(FakeSATA == other.FakeSATA)) + return false; + if (!(FakeXHCI == other.FakeXHCI)) + return false; + if (!(FakeIMEI == other.FakeIMEI)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::DevicesClass::Devices_FakeID_Class &other) { + FakeATI = other.dgetFakeATI(); + FakeNVidia = other.dgetFakeNVidia(); + FakeIntel = other.dgetFakeIntel(); + FakeLAN = other.dgetFakeLAN(); + FakeWIFI = other.dgetFakeWIFI(); + FakeSATA = other.dgetFakeSATA(); + FakeXHCI = other.dgetFakeXHCI(); + FakeIMEI = other.dgetFakeIMEI(); + } + }; + + XBool StringInjector = XBool(); + XBool IntelMaxBacklight = XBool(); + XBool IntelBacklight = XBool(); + UINT32 IntelMaxValue = UINT32(); + XBool LANInjection = XBool(); + XBool HDMIInjection = XBool(); + XBool NoDefaultProperties = XBool(); + XBool UseIntelHDMI = XBool(); + XBool ForceHPET = XBool(); + UINT32 DisableFunctions = UINT32(); + XString8 AirportBridgeDeviceName = XString8(); + AudioClass Audio = AudioClass(); + USBClass USB = USBClass(); + FakeIDClass FakeID = FakeIDClass(); + + XObjArrayWithTakeValueFromXmlArray< + AddPropertyClass, + ConfigPlistClass::DevicesClass::Devices_AddProperties_Dict_Class> + AddPropertyArray = XObjArrayWithTakeValueFromXmlArray< + AddPropertyClass, + ConfigPlistClass::DevicesClass::Devices_AddProperties_Dict_Class>(); + PropertiesClass Properties = PropertiesClass(); + XObjArrayWithTakeValueFromXmlArray< + ArbitraryPropertyClass, + ConfigPlistClass::DevicesClass::Devices_Arbitrary_Class> + ArbitraryArray = XObjArrayWithTakeValueFromXmlArray< + ArbitraryPropertyClass, + ConfigPlistClass::DevicesClass::Devices_Arbitrary_Class>(); - XBool StringInjector = XBool(); - XBool IntelMaxBacklight = XBool(); - XBool IntelBacklight = XBool(); - UINT32 IntelMaxValue = UINT32(); - XBool LANInjection = XBool(); - XBool HDMIInjection = XBool(); - XBool NoDefaultProperties = XBool(); - XBool UseIntelHDMI = XBool(); - XBool ForceHPET = XBool(); - UINT32 DisableFunctions = UINT32(); - XString8 AirportBridgeDeviceName = XString8(); - AudioClass Audio = AudioClass(); - USBClass USB = USBClass(); - FakeIDClass FakeID = FakeIDClass(); - - XObjArrayWithTakeValueFromXmlArray AddPropertyArray = XObjArrayWithTakeValueFromXmlArray(); - PropertiesClass Properties = PropertiesClass(); - XObjArrayWithTakeValueFromXmlArray ArbitraryArray = XObjArrayWithTakeValueFromXmlArray(); - - #if __cplusplus > 201703L - XBool operator == (const DevicesClass&) const = default; + XBool operator==(const DevicesClass &) const = default; #endif - XBool isEqual(const DevicesClass& other) const - { - if ( !(StringInjector == other.StringInjector) ) return false; - if ( !(IntelMaxBacklight == other.IntelMaxBacklight) ) return false; - if ( !(IntelBacklight == other.IntelBacklight) ) return false; - if ( !(IntelMaxValue == other.IntelMaxValue) ) return false; - if ( !(LANInjection == other.LANInjection) ) return false; - if ( !(HDMIInjection == other.HDMIInjection) ) return false; - if ( !(NoDefaultProperties == other.NoDefaultProperties) ) return false; - if ( !(UseIntelHDMI == other.UseIntelHDMI) ) return false; - if ( !(ForceHPET == other.ForceHPET) ) return false; - if ( !(DisableFunctions == other.DisableFunctions) ) return false; - if ( !(AirportBridgeDeviceName == other.AirportBridgeDeviceName) ) return false; - if ( !Audio.isEqual(other.Audio) ) return false; - if ( !USB.isEqual(other.USB) ) return false; - if ( !FakeID.isEqual(other.FakeID) ) return false; - if ( !AddPropertyArray.isEqual(other.AddPropertyArray) ) return false; - if ( !Properties.isEqual(other.Properties) ) return false; - if ( !ArbitraryArray.isEqual(other.ArbitraryArray) ) return false; + XBool isEqual(const DevicesClass &other) const { + if (!(StringInjector == other.StringInjector)) + return false; + if (!(IntelMaxBacklight == other.IntelMaxBacklight)) + return false; + if (!(IntelBacklight == other.IntelBacklight)) + return false; + if (!(IntelMaxValue == other.IntelMaxValue)) + return false; + if (!(LANInjection == other.LANInjection)) + return false; + if (!(HDMIInjection == other.HDMIInjection)) + return false; + if (!(NoDefaultProperties == other.NoDefaultProperties)) + return false; + if (!(UseIntelHDMI == other.UseIntelHDMI)) + return false; + if (!(ForceHPET == other.ForceHPET)) + return false; + if (!(DisableFunctions == other.DisableFunctions)) + return false; + if (!(AirportBridgeDeviceName == other.AirportBridgeDeviceName)) + return false; + if (!Audio.isEqual(other.Audio)) + return false; + if (!USB.isEqual(other.USB)) + return false; + if (!FakeID.isEqual(other.FakeID)) + return false; + if (!AddPropertyArray.isEqual(other.AddPropertyArray)) + return false; + if (!Properties.isEqual(other.Properties)) + return false; + if (!ArbitraryArray.isEqual(other.ArbitraryArray)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::DevicesClass& other) - { + void takeValueFrom(const ConfigPlistClass::DevicesClass &other) { StringInjector = other.dgetStringInjector(); IntelMaxBacklight = other.dgetIntelMaxBacklight(); IntelBacklight = other.dgetIntelBacklight(); @@ -1809,431 +2167,506 @@ class SETTINGS_DATA { ArbitraryArray.takeValueFrom(other.Arbitrary); } - // 2021-04 : Following is temporary to compare with old way of storing properties. - // Let's keep it few months until I am sure the refactoring isomorphic - private: - DEV_PROPERTY *ArbProperties = 0; // the old version. - public: - void FillDevicePropertiesOld(SETTINGS_DATA& gSettings, const TagDict* DevicesDict); - - XBool compareDevProperty(const XString8& label, const DEV_PROPERTY& oldProp, const DEV_PROPERTY& newProp) const - { - if ( newProp.Device != oldProp.Device ) - { - printf("%s.Device !=\n", label.c_str()); + // 2021-04 : Following is temporary to compare with old way of storing + // properties. Let's keep it few months until I am sure the refactoring + // isomorphic + private: + DEV_PROPERTY *ArbProperties = 0; // the old version. + public: + void FillDevicePropertiesOld(SETTINGS_DATA &gSettings, + const TagDict *DevicesDict); + + XBool compareDevProperty(const XString8 &label, const DEV_PROPERTY &oldProp, + const DEV_PROPERTY &newProp) const { + if (newProp.Device != oldProp.Device) { + printf("%s.Device !=\n", label.c_str()); + return false; + } + if (newProp.Key || oldProp.Key) { + if (!newProp.Key || !oldProp.Key) { + printf("%s.Key !=\n", label.c_str()); return false; } - if ( newProp.Key || oldProp.Key ) { - if ( !newProp.Key || !oldProp.Key ) { - printf("%s.Key !=\n", label.c_str()); - return false; - } #ifdef JIEF_DEBUG -if ( strcmp(oldProp.Key, "10") == 0 ) { -printf("%s", ""); -} -#endif - if ( strcmp(newProp.Key, oldProp.Key) != 0 ) - { - printf("%s.Key !=\n", label.c_str()); - return false; - } - } - if ( newProp.ValueLen != oldProp.ValueLen ) - { - printf("%s.Value.ValueLen %lld != %lld\n", label.c_str(), oldProp.ValueLen, newProp.ValueLen); - return false; - } else - { - if ( newProp.ValueLen > 0 ) { - if ( memcmp(newProp.Value, oldProp.Value, oldProp.ValueLen) != 0 ) - { - printf("%s.Value !=\n", label.c_str()); - return false; - } - } + if (strcmp(oldProp.Key, "10") == 0) { + printf("%s", ""); } - if ( newProp.ValueType != oldProp.ValueType ) - { - printf("%s.ValueType !=\n", label.c_str()); +#endif + if (strcmp(newProp.Key, oldProp.Key) != 0) { + printf("%s.Key !=\n", label.c_str()); return false; } - if ( newProp.Label || oldProp.Label ) { - if ( !newProp.Label || !oldProp.Label ) { - printf("%s.Label !=\n", label.c_str()); - return false; - } - if ( strcmp(newProp.Label, oldProp.Label) != 0 ) - { - printf("%s.Label != : old:%s new:%s\n", label.c_str(), oldProp.Label, newProp.Label); + } + if (newProp.ValueLen != oldProp.ValueLen) { + printf("%s.Value.ValueLen %lld != %lld\n", label.c_str(), + oldProp.ValueLen, newProp.ValueLen); + return false; + } else { + if (newProp.ValueLen > 0) { + if (memcmp(newProp.Value, oldProp.Value, oldProp.ValueLen) != 0) { + printf("%s.Value !=\n", label.c_str()); return false; } } - if ( newProp.MenuItem.BValue != oldProp.MenuItem.BValue ) - { - printf("%s.MenuItem.BValue !=\n", label.c_str()); + } + if (newProp.ValueType != oldProp.ValueType) { + printf("%s.ValueType !=\n", label.c_str()); + return false; + } + if (newProp.Label || oldProp.Label) { + if (!newProp.Label || !oldProp.Label) { + printf("%s.Label !=\n", label.c_str()); return false; } - DEV_PROPERTY *oldChild = oldProp.Child; - DEV_PROPERTY *newChild = newProp.Child; - size_t jdx = 0; - while ( oldChild && newChild ) - { - compareDevProperty(S8Printf("%s.child[%zu]", label.c_str(), jdx), *oldChild, *newChild); - oldChild = oldChild->Next; - newChild = newChild->Next; - jdx++; - } - if ( oldChild != newChild ) - { - printf("%s.Child count\n", label.c_str()); + if (strcmp(newProp.Label, oldProp.Label) != 0) { + printf("%s.Label != : old:%s new:%s\n", label.c_str(), oldProp.Label, + newProp.Label); return false; } - return true; } - - XBool compareOldAndCompatibleArb() - { -// { -// size_t oldArbIdx = 0; -// const DEV_PROPERTY* arb = ArbProperties; -// while ( arb ) { -// printf("ArbProperties[%zu].Key = %s\n", oldArbIdx++, arb->Key); -// arb = arb->Next; -// } -// } - const XObjArray compatibleArbProperties = getCompatibleArbProperty(); - // size_t oldArbIdx = 0; - for ( size_t idx = 0 ; idx < compatibleArbProperties.size() ; ++idx ) - { - if ( ArbProperties == NULL ) { - printf("ArbProperties.size < compatibleArbProperties.size()"); - return false; - } - if ( !compareDevProperty(S8Printf("ArbProperties[%zu]", idx), *ArbProperties, compatibleArbProperties[idx]) ) { - return false; - } - // ++oldArbIdx; - ArbProperties = ArbProperties->Next; + if (newProp.MenuItem.BValue != oldProp.MenuItem.BValue) { + printf("%s.MenuItem.BValue !=\n", label.c_str()); + return false; + } + DEV_PROPERTY *oldChild = oldProp.Child; + DEV_PROPERTY *newChild = newProp.Child; + size_t jdx = 0; + while (oldChild && newChild) { + compareDevProperty(S8Printf("%s.child[%zu]", label.c_str(), jdx), + *oldChild, *newChild); + oldChild = oldChild->Next; + newChild = newChild->Next; + jdx++; + } + if (oldChild != newChild) { + printf("%s.Child count\n", label.c_str()); + return false; + } + return true; + } + + XBool compareOldAndCompatibleArb() { + // { + // size_t oldArbIdx = 0; + // const DEV_PROPERTY* arb = ArbProperties; + // while ( arb ) { + // printf("ArbProperties[%zu].Key = %s\n", oldArbIdx++, + // arb->Key); arb = arb->Next; + // } + // } + const XObjArray compatibleArbProperties = + getCompatibleArbProperty(); + // size_t oldArbIdx = 0; + for (size_t idx = 0; idx < compatibleArbProperties.size(); ++idx) { + if (ArbProperties == NULL) { + printf("ArbProperties.size < compatibleArbProperties.size()"); + return false; } - if ( ArbProperties != NULL ) { - printf("ArbProperties.size > compatibleArbProperties.size()"); + if (!compareDevProperty(S8Printf("ArbProperties[%zu]", idx), + *ArbProperties, compatibleArbProperties[idx])) { return false; } - return true; + // ++oldArbIdx; + ArbProperties = ArbProperties->Next; } + if (ArbProperties != NULL) { + printf("ArbProperties.size > compatibleArbProperties.size()"); + return false; + } + return true; + } - public: - XObjArray getCompatibleArbProperty() const - { - XObjArray arb; - for ( size_t idx = ArbitraryArray.size() ; idx-- > 0 ; ) { - const ArbitraryPropertyClass& newArb = ArbitraryArray[idx]; - for ( size_t jdx = newArb.CustomPropertyArray.size() ; jdx-- > 0 ; ) { - const SimplePropertyClass& newArbProp = newArb.CustomPropertyArray[jdx]; - DEV_PROPERTY* newProp = new DEV_PROPERTY; - newProp->Device = newArb.Device; - newProp->Key = const_cast(newArbProp.Key.c_str()); // const_cast !!! So ugly. It is just because it's temporary. If ArbProperties is modified after this, a lot a memory problem will happen. I could have done some strdup, but that way I don't use memory and don't have to free it. - newProp->Value = const_cast(newArbProp.Value.data()); - newProp->ValueLen = newArbProp.Value.size(); - newProp->ValueType = newArbProp.ValueType; - newProp->MenuItem.BValue = newArbProp.MenuItem.BValue ; - newProp->Label = const_cast(newArb.Label.c_str()); - arb.AddReference(newProp, true); -// printf("Add prop key=%s label=%s at index %zu\n", newProp->Key.c_str(), newProp->Label.c_str(), arb.size()-1); - } + public: + XObjArray getCompatibleArbProperty() const { + XObjArray arb; + for (size_t idx = ArbitraryArray.size(); idx-- > 0;) { + const ArbitraryPropertyClass &newArb = ArbitraryArray[idx]; + for (size_t jdx = newArb.CustomPropertyArray.size(); jdx-- > 0;) { + const SimplePropertyClass &newArbProp = + newArb.CustomPropertyArray[jdx]; + DEV_PROPERTY *newProp = new DEV_PROPERTY; + newProp->Device = newArb.Device; + newProp->Key = const_cast( + newArbProp.Key + .c_str()); // const_cast !!! So ugly. It is just because it's + // temporary. If ArbProperties is modified after + // this, a lot a memory problem will happen. I + // could have done some strdup, but that way I + // don't use memory and don't have to free it. + newProp->Value = const_cast(newArbProp.Value.data()); + newProp->ValueLen = newArbProp.Value.size(); + newProp->ValueType = newArbProp.ValueType; + newProp->MenuItem.BValue = newArbProp.MenuItem.BValue; + newProp->Label = const_cast(newArb.Label.c_str()); + arb.AddReference(newProp, true); + // printf("Add prop key=%s label=%s at index %zu\n", + // newProp->Key.c_str(), newProp->Label.c_str(), + // arb.size()-1); } - // Non arb : device = 0 - for ( size_t idx = Properties.PropertyArray.size() ; idx-- > 0 ; ) { - const PropertiesClass::PropertyClass& Prop = Properties.PropertyArray[idx]; - DEV_PROPERTY* newProp = new DEV_PROPERTY; - newProp->Device = 0; - newProp->Key = 0; - if ( Prop.Enabled ) newProp->Label = XString8(Prop.DevicePathAsString).forgetDataWithoutFreeing(); - else newProp->Label = S8Printf("!%ls", Prop.DevicePathAsString.wc_str()).forgetDataWithoutFreeing(); - newProp->Child = NULL; - for ( size_t jdx = Properties.PropertyArray[idx].propertiesArray.size() ; jdx-- > 0 ; ) { - const SimplePropertyClass& SubProp = Prop.propertiesArray[jdx]; - DEV_PROPERTY* newSubProp = new DEV_PROPERTY; - newSubProp->Device = 0; - newSubProp->Key = const_cast(SubProp.Key.c_str()); -// newSubProp->Key = NULL; - newSubProp->Value = const_cast(SubProp.Value.data()); - newSubProp->ValueLen = SubProp.Value.size(); - newSubProp->ValueType = SubProp.ValueType; - newSubProp->MenuItem.BValue = true; - if ( newProp->Child ) { - DEV_PROPERTY* childs; - for ( childs = newProp->Child ; childs->Next ; childs = childs->Next ); - childs->Next = newSubProp; - }else{ - newProp->Child = newSubProp; - } + } + // Non arb : device = 0 + for (size_t idx = Properties.PropertyArray.size(); idx-- > 0;) { + const PropertiesClass::PropertyClass &Prop = + Properties.PropertyArray[idx]; + DEV_PROPERTY *newProp = new DEV_PROPERTY; + newProp->Device = 0; + newProp->Key = 0; + if (Prop.Enabled) + newProp->Label = + XString8(Prop.DevicePathAsString).forgetDataWithoutFreeing(); + else + newProp->Label = S8Printf("!%ls", Prop.DevicePathAsString.wc_str()) + .forgetDataWithoutFreeing(); + newProp->Child = NULL; + for (size_t jdx = Properties.PropertyArray[idx].propertiesArray.size(); + jdx-- > 0;) { + const SimplePropertyClass &SubProp = Prop.propertiesArray[jdx]; + DEV_PROPERTY *newSubProp = new DEV_PROPERTY; + newSubProp->Device = 0; + newSubProp->Key = const_cast(SubProp.Key.c_str()); + // newSubProp->Key = NULL; + newSubProp->Value = const_cast(SubProp.Value.data()); + newSubProp->ValueLen = SubProp.Value.size(); + newSubProp->ValueType = SubProp.ValueType; + newSubProp->MenuItem.BValue = true; + if (newProp->Child) { + DEV_PROPERTY *childs; + for (childs = newProp->Child; childs->Next; childs = childs->Next) + ; + childs->Next = newSubProp; + } else { + newProp->Child = newSubProp; } - arb.AddReference(newProp, true); -// MsgLog("Add prop %s at index %zu\n", newProp->Label, arb.size()-1); } - return arb; - }; + arb.AddReference(newProp, true); + // MsgLog("Add prop %s at index %zu\n", newProp->Label, + // arb.size()-1); + } + return arb; + }; }; class QuirksClass { + public: + class MMIOWhiteList { public: - class MMIOWhiteList - { - public : - UINTN address = 0; - XString8 comment = XString8(); - XBool enabled = false; - - #if __cplusplus > 201703L - XBool operator == (const MMIOWhiteList&) const = default; - #endif - XBool isEqual(const MMIOWhiteList& other) const - { - if ( !(address == other.address) ) return false; - if ( !(comment == other.comment) ) return false; - if ( !(enabled == other.enabled) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::Quirks_Class::Quirks_MmioWhitelist_Class& other) - { - address = other.dgetaddress(); - comment = other.dgetcomment(); - enabled = other.dgetenabled(); - } - }; - class OcKernelQuirksClass - { - public: - // XBool AppleCpuPmCfgLock = false; - // XBool AppleXcpmCfgLock = false; - XBool AppleXcpmExtraMsrs = false; - XBool AppleXcpmForceBoost = false; - // XBool CustomSmbiosGuid = false; - XBool DisableIoMapper = false; - XBool DisableLinkeditJettison = false; - // XBool DisableRtcChecksum = false; - XBool DummyPowerManagement = false; - XBool ExtendBTFeatureFlags = false; - XBool ExternalDiskIcons = false; - XBool IncreasePciBarSize = false; - XBool ForceAquantiaEthernet = false; - // XBool LapicKernelPanic = false; - // XBool PanicNoKextDump = false; - XBool PowerTimeoutKernelPanic = false; - XBool ThirdPartyDrives = false; - XBool XhciPortLimit = false; - XBool ProvideCurrentCpuInfo = false; - + UINTN address = 0; + XString8 comment = XString8(); + XBool enabled = false; + #if __cplusplus > 201703L - XBool operator == (const OcKernelQuirksClass&) const = default; + XBool operator==(const MMIOWhiteList &) const = default; #endif - XBool isEqual(const OcKernelQuirksClass& other) const - { - if ( !(AppleXcpmExtraMsrs == other.AppleXcpmExtraMsrs) ) return false; - if ( !(AppleXcpmForceBoost == other.AppleXcpmForceBoost) ) return false; - if ( !(DisableIoMapper == other.DisableIoMapper) ) return false; - if ( !(DisableLinkeditJettison == other.DisableLinkeditJettison) ) return false; - if ( !(DummyPowerManagement == other.DummyPowerManagement) ) return false; - if ( !(ExtendBTFeatureFlags == other.ExtendBTFeatureFlags) ) return false; - if ( !(ExternalDiskIcons == other.ExternalDiskIcons) ) return false; - if ( !(IncreasePciBarSize == other.IncreasePciBarSize) ) return false; - if ( !(ForceAquantiaEthernet == other.ForceAquantiaEthernet) ) return false; - if ( !(PowerTimeoutKernelPanic == other.PowerTimeoutKernelPanic) ) return false; - if ( !(ThirdPartyDrives == other.ThirdPartyDrives) ) return false; - if ( !(XhciPortLimit == other.XhciPortLimit) ) return false; - if ( !(ProvideCurrentCpuInfo == other.ProvideCurrentCpuInfo) ) return false; + XBool isEqual(const MMIOWhiteList &other) const { + if (!(address == other.address)) + return false; + if (!(comment == other.comment)) + return false; + if (!(enabled == other.enabled)) + return false; + return true; + } + void takeValueFrom( + const ConfigPlistClass::Quirks_Class::Quirks_MmioWhitelist_Class + &other) { + address = other.dgetaddress(); + comment = other.dgetcomment(); + enabled = other.dgetenabled(); + } + }; + class OcKernelQuirksClass { + public: + // XBool AppleCpuPmCfgLock = false; + // XBool AppleXcpmCfgLock = false; + XBool AppleXcpmExtraMsrs = false; + XBool AppleXcpmForceBoost = false; + // XBool CustomSmbiosGuid = false; + XBool DisableIoMapper = false; + XBool DisableIoMapperMapping = false; + XBool DisableLinkeditJettison = false; + // XBool DisableRtcChecksum = false; + XBool DummyPowerManagement = false; + XBool ExtendBTFeatureFlags = false; + XBool ExternalDiskIcons = false; + XBool IncreasePciBarSize = false; + XBool ForceAquantiaEthernet = false; + // XBool LapicKernelPanic = false; + // XBool PanicNoKextDump = false; + XBool PowerTimeoutKernelPanic = false; + XBool ThirdPartyDrives = false; + XBool XhciPortLimit = false; + XBool ProvideCurrentCpuInfo = false; - return true; - } - void takeValueFrom(const ConfigPlistClass::Quirks_Class::OcKernelQuirks_Class& other) - { - AppleXcpmExtraMsrs = other.dgetAppleXcpmExtraMsrs(); - AppleXcpmForceBoost = other.dgetAppleXcpmForceBoost(); - DisableIoMapper = other.dgetDisableIoMapper(); - DisableLinkeditJettison = other.dgetDisableLinkeditJettison(); - DummyPowerManagement = other.dgetDummyPowerManagement(); - ExtendBTFeatureFlags = other.dgetExtendBTFeatureFlags(); - ExternalDiskIcons = other.dgetExternalDiskIcons(); - IncreasePciBarSize = other.dgetIncreasePciBarSize(); - ForceAquantiaEthernet = other.dgetForceAquantiaEthernet(); - PowerTimeoutKernelPanic = other.dgetPowerTimeoutKernelPanic(); - ThirdPartyDrives = other.dgetThirdPartyDrives(); - XhciPortLimit = other.dgetXhciPortLimit(); - ProvideCurrentCpuInfo = other.dgetProvideCurrentCpuInfo(); - } - }; - - class OcBooterQuirksClass - { - public: - XBool AvoidRuntimeDefrag = false; - XBool DevirtualiseMmio = false; - XBool DisableSingleUser = false; - XBool DisableVariableWrite = false; - XBool DiscardHibernateMap = false; - XBool EnableSafeModeSlide = false; - XBool EnableWriteUnprotector = false; - XBool ForceExitBootServices = false; - XBool ProtectMemoryRegions = false; - XBool ProtectSecureBoot = false; - XBool ProtectUefiServices = false; - XBool ProvideCustomSlide = false; - uint8_t ProvideMaxSlide = 0; - XBool RebuildAppleMemoryMap = false; - XBool SetupVirtualMap = false; - XBool SignalAppleOS = false; - XBool SyncRuntimePermissions = false; - int8_t ResizeAppleGpuBars = 0; // 0 is NOT the default value if not set in config.plist. Default value if not set is returned by dgetResizeAppleGpuBars() - XBool ForceOcWriteFlash = false; - uint32_t TscSyncTimeout = 0; - #if __cplusplus > 201703L - XBool operator == (const OcBooterQuirksClass&) const = default; + XBool operator==(const OcKernelQuirksClass &) const = default; #endif - XBool isEqual(const OcBooterQuirksClass& other) const - { - if ( !(AvoidRuntimeDefrag == other.AvoidRuntimeDefrag) ) return false; - if ( !(DevirtualiseMmio == other.DevirtualiseMmio) ) return false; - if ( !(DisableSingleUser == other.DisableSingleUser) ) return false; - if ( !(DisableVariableWrite == other.DisableVariableWrite) ) return false; - if ( !(DiscardHibernateMap == other.DiscardHibernateMap) ) return false; - if ( !(EnableSafeModeSlide == other.EnableSafeModeSlide) ) return false; - if ( !(EnableWriteUnprotector == other.EnableWriteUnprotector) ) return false; - if ( !(ForceExitBootServices == other.ForceExitBootServices) ) return false; - if ( !(ProtectSecureBoot == other.ProtectSecureBoot) ) return false; - if ( !(ProtectUefiServices == other.ProtectUefiServices) ) return false; - if ( !(ProtectUefiServices == other.ProtectUefiServices) ) return false; - if ( !(ProvideCustomSlide == other.ProvideCustomSlide) ) return false; - if ( !(ProvideMaxSlide == other.ProvideMaxSlide) ) return false; - if ( !(RebuildAppleMemoryMap == other.RebuildAppleMemoryMap) ) return false; - if ( !(ResizeAppleGpuBars == other.ResizeAppleGpuBars) ) return false; - if ( !(SetupVirtualMap == other.SetupVirtualMap) ) return false; - if ( !(SignalAppleOS == other.SignalAppleOS) ) return false; - if ( !(SyncRuntimePermissions == other.SyncRuntimePermissions) ) return false; - if ( !(ForceOcWriteFlash == other.ForceOcWriteFlash) ) return false; - if ( !(TscSyncTimeout == other.TscSyncTimeout) ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::Quirks_Class::OcBooterQuirks_Class& other) - { - AvoidRuntimeDefrag = other.dgetAvoidRuntimeDefrag(); - DevirtualiseMmio = other.dgetDevirtualiseMmio(); - DisableSingleUser = other.dgetDisableSingleUser(); - DisableVariableWrite = other.dgetDisableVariableWrite(); - DiscardHibernateMap = other.dgetDiscardHibernateMap(); - EnableSafeModeSlide = other.dgetEnableSafeModeSlide(); - EnableWriteUnprotector = other.dgetEnableWriteUnprotector(); - ForceExitBootServices = other.dgetForceExitBootServices(); - ProtectSecureBoot = other.dgetProtectSecureBoot(); - ProtectUefiServices = other.dgetProtectUefiServices(); - ProtectUefiServices = other.dgetProtectUefiServices(); - ProvideCustomSlide = other.dgetProvideCustomSlide(); - ProvideMaxSlide = other.dgetProvideMaxSlide(); - RebuildAppleMemoryMap = other.dgetRebuildAppleMemoryMap(); - ResizeAppleGpuBars = other.dgetResizeAppleGpuBars(); - SetupVirtualMap = other.dgetSetupVirtualMap(); - SignalAppleOS = other.dgetSignalAppleOS(); - SyncRuntimePermissions = other.dgetSyncRuntimePermissions(); - ForceOcWriteFlash = other.dgetForceOcWriteFlash(); - TscSyncTimeout = other.dgetTscSyncTimeout(); - } + XBool isEqual(const OcKernelQuirksClass &other) const { + if (!(AppleXcpmExtraMsrs == other.AppleXcpmExtraMsrs)) + return false; + if (!(AppleXcpmForceBoost == other.AppleXcpmForceBoost)) + return false; + if (!(DisableIoMapper == other.DisableIoMapper)) + return false; + if (!(DisableIoMapperMapping == other.DisableIoMapperMapping)) + return false; + if (!(DisableLinkeditJettison == other.DisableLinkeditJettison)) + return false; + if (!(DummyPowerManagement == other.DummyPowerManagement)) + return false; + if (!(ExtendBTFeatureFlags == other.ExtendBTFeatureFlags)) + return false; + if (!(ExternalDiskIcons == other.ExternalDiskIcons)) + return false; + if (!(IncreasePciBarSize == other.IncreasePciBarSize)) + return false; + if (!(ForceAquantiaEthernet == other.ForceAquantiaEthernet)) + return false; + if (!(PowerTimeoutKernelPanic == other.PowerTimeoutKernelPanic)) + return false; + if (!(ThirdPartyDrives == other.ThirdPartyDrives)) + return false; + if (!(XhciPortLimit == other.XhciPortLimit)) + return false; + if (!(ProvideCurrentCpuInfo == other.ProvideCurrentCpuInfo)) + return false; + + return true; + } + void takeValueFrom( + const ConfigPlistClass::Quirks_Class::OcKernelQuirks_Class &other) { + AppleXcpmExtraMsrs = other.dgetAppleXcpmExtraMsrs(); + AppleXcpmForceBoost = other.dgetAppleXcpmForceBoost(); + DisableIoMapper = other.dgetDisableIoMapper(); + DisableIoMapperMapping = other.dgetDisableIoMapperMapping(); + DisableLinkeditJettison = other.dgetDisableLinkeditJettison(); + DummyPowerManagement = other.dgetDummyPowerManagement(); + ExtendBTFeatureFlags = other.dgetExtendBTFeatureFlags(); + ExternalDiskIcons = other.dgetExternalDiskIcons(); + IncreasePciBarSize = other.dgetIncreasePciBarSize(); + ForceAquantiaEthernet = other.dgetForceAquantiaEthernet(); + PowerTimeoutKernelPanic = other.dgetPowerTimeoutKernelPanic(); + ThirdPartyDrives = other.dgetThirdPartyDrives(); + XhciPortLimit = other.dgetXhciPortLimit(); + ProvideCurrentCpuInfo = other.dgetProvideCurrentCpuInfo(); + } + }; + + class OcBooterQuirksClass { + public: + XBool AvoidRuntimeDefrag = false; + XBool DevirtualiseMmio = false; + XBool DisableSingleUser = false; + XBool DisableVariableWrite = false; + XBool DiscardHibernateMap = false; + XBool EnableSafeModeSlide = false; + XBool EnableWriteUnprotector = false; + XBool ForceExitBootServices = false; + XBool ProtectMemoryRegions = false; + XBool ProtectSecureBoot = false; + XBool ProtectUefiServices = false; + XBool ProvideCustomSlide = false; + uint8_t ProvideMaxSlide = 0; + XBool RebuildAppleMemoryMap = false; + XBool SetupVirtualMap = false; + XBool SignalAppleOS = false; + XBool SyncRuntimePermissions = false; + int8_t ResizeAppleGpuBars = + 0; // 0 is NOT the default value if not set in config.plist. Default + // value if not set is returned by dgetResizeAppleGpuBars() + int8_t ResizeGpuBars = -1; + XBool ForceOcWriteFlash = false; + uint32_t TscSyncTimeout = 0; - }; - - XBool FuzzyMatch = XBool(); - XString8 OcKernelCache = XString8(); -// UINTN MaxSlide; - OcKernelQuirksClass OcKernelQuirks = OcKernelQuirksClass(); - OcBooterQuirksClass OcBooterQuirks = OcBooterQuirksClass(); - XObjArrayWithTakeValueFromXmlArray mmioWhiteListArray = XObjArrayWithTakeValueFromXmlArray(); - UINT32 QuirksMask = 0; - #if __cplusplus > 201703L - XBool operator == (const QuirksClass&) const = default; + XBool operator==(const OcBooterQuirksClass &) const = default; #endif - XBool isEqual(const QuirksClass& other) const - { - if ( !(FuzzyMatch == other.FuzzyMatch) ) return false; - if ( !(OcKernelCache == other.OcKernelCache) ) return false; - if ( !(OcKernelQuirks.isEqual(other.OcKernelQuirks)) ) return false; - if ( !(OcBooterQuirks.isEqual(other.OcBooterQuirks)) ) return false; - if ( !mmioWhiteListArray.isEqual(other.mmioWhiteListArray) ) return false; - if ( !(QuirksMask == other.QuirksMask) ) return false; + XBool isEqual(const OcBooterQuirksClass &other) const { + if (!(AvoidRuntimeDefrag == other.AvoidRuntimeDefrag)) + return false; + if (!(DevirtualiseMmio == other.DevirtualiseMmio)) + return false; + if (!(DisableSingleUser == other.DisableSingleUser)) + return false; + if (!(DisableVariableWrite == other.DisableVariableWrite)) + return false; + if (!(DiscardHibernateMap == other.DiscardHibernateMap)) + return false; + if (!(EnableSafeModeSlide == other.EnableSafeModeSlide)) + return false; + if (!(EnableWriteUnprotector == other.EnableWriteUnprotector)) + return false; + if (!(ForceExitBootServices == other.ForceExitBootServices)) + return false; + if (!(ProtectSecureBoot == other.ProtectSecureBoot)) + return false; + if (!(ProtectUefiServices == other.ProtectUefiServices)) + return false; + if (!(ProtectUefiServices == other.ProtectUefiServices)) + return false; + if (!(ProvideCustomSlide == other.ProvideCustomSlide)) + return false; + if (!(ProvideMaxSlide == other.ProvideMaxSlide)) + return false; + if (!(RebuildAppleMemoryMap == other.RebuildAppleMemoryMap)) + return false; + if (!(ResizeAppleGpuBars == other.ResizeAppleGpuBars)) + return false; + if (!(ResizeGpuBars == other.ResizeGpuBars)) + return false; + if (!(SetupVirtualMap == other.SetupVirtualMap)) + return false; + if (!(SignalAppleOS == other.SignalAppleOS)) + return false; + if (!(SyncRuntimePermissions == other.SyncRuntimePermissions)) + return false; + if (!(ForceOcWriteFlash == other.ForceOcWriteFlash)) + return false; + if (!(TscSyncTimeout == other.TscSyncTimeout)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::Quirks_Class& other) - { - FuzzyMatch = other.dgetFuzzyMatch(); - OcKernelCache = other.dgetOcKernelCache(); - OcKernelQuirks.takeValueFrom(other.OcKernelQuirks); - OcBooterQuirks.takeValueFrom(other.OcBooterQuirks); - mmioWhiteListArray.takeValueFrom(other.MmioWhitelist); - QuirksMask = other.dgetQuirksMask(); + void takeValueFrom( + const ConfigPlistClass::Quirks_Class::OcBooterQuirks_Class &other) { + AvoidRuntimeDefrag = other.dgetAvoidRuntimeDefrag(); + DevirtualiseMmio = other.dgetDevirtualiseMmio(); + DisableSingleUser = other.dgetDisableSingleUser(); + DisableVariableWrite = other.dgetDisableVariableWrite(); + DiscardHibernateMap = other.dgetDiscardHibernateMap(); + EnableSafeModeSlide = other.dgetEnableSafeModeSlide(); + EnableWriteUnprotector = other.dgetEnableWriteUnprotector(); + ForceExitBootServices = other.dgetForceExitBootServices(); + ProtectSecureBoot = other.dgetProtectSecureBoot(); + ProtectUefiServices = other.dgetProtectUefiServices(); + ProtectUefiServices = other.dgetProtectUefiServices(); + ProvideCustomSlide = other.dgetProvideCustomSlide(); + ProvideMaxSlide = other.dgetProvideMaxSlide(); + RebuildAppleMemoryMap = other.dgetRebuildAppleMemoryMap(); + ResizeAppleGpuBars = other.dgetResizeAppleGpuBars(); + ResizeGpuBars = other.dgetResizeGpuBars(); + SetupVirtualMap = other.dgetSetupVirtualMap(); + SignalAppleOS = other.dgetSignalAppleOS(); + SyncRuntimePermissions = other.dgetSyncRuntimePermissions(); + ForceOcWriteFlash = other.dgetForceOcWriteFlash(); + TscSyncTimeout = other.dgetTscSyncTimeout(); } -}; + }; + + XBool FuzzyMatch = XBool(); + XString8 OcKernelCache = XString8(); + // UINTN MaxSlide; + OcKernelQuirksClass OcKernelQuirks = OcKernelQuirksClass(); + OcBooterQuirksClass OcBooterQuirks = OcBooterQuirksClass(); + XObjArrayWithTakeValueFromXmlArray< + MMIOWhiteList, + ConfigPlistClass::Quirks_Class::Quirks_MmioWhitelist_Class> + mmioWhiteListArray = XObjArrayWithTakeValueFromXmlArray< + MMIOWhiteList, + ConfigPlistClass::Quirks_Class::Quirks_MmioWhitelist_Class>(); + UINT32 QuirksMask = 0; + +#if __cplusplus > 201703L + XBool operator==(const QuirksClass &) const = default; +#endif + XBool isEqual(const QuirksClass &other) const { + if (!(FuzzyMatch == other.FuzzyMatch)) + return false; + if (!(OcKernelCache == other.OcKernelCache)) + return false; + if (!(OcKernelQuirks.isEqual(other.OcKernelQuirks))) + return false; + if (!(OcBooterQuirks.isEqual(other.OcBooterQuirks))) + return false; + if (!mmioWhiteListArray.isEqual(other.mmioWhiteListArray)) + return false; + if (!(QuirksMask == other.QuirksMask)) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::Quirks_Class &other) { + FuzzyMatch = other.dgetFuzzyMatch(); + OcKernelCache = other.dgetOcKernelCache(); + OcKernelQuirks.takeValueFrom(other.OcKernelQuirks); + OcBooterQuirks.takeValueFrom(other.OcBooterQuirks); + mmioWhiteListArray.takeValueFrom(other.MmioWhitelist); + QuirksMask = other.dgetQuirksMask(); + } + }; class RtVariablesClass { + public: + class RT_VARIABLES { public: - class RT_VARIABLES - { - public: - XBool Disabled = XBool(); - XString8 Comment = XStringW(); - XStringW Name = XStringW(); - EFI_GUID Guid = EFI_GUID(); + XBool Disabled = XBool(); + XString8 Comment = XStringW(); + XStringW Name = XStringW(); + EFI_GUID Guid = EFI_GUID(); #if __cplusplus > 201703L - XBool operator == (const RT_VARIABLES&) const = default; + XBool operator==(const RT_VARIABLES &) const = default; #endif - XBool isEqual(const RT_VARIABLES& other) const - { - if ( !(Disabled == other.Disabled) ) return false; - if ( !(Comment == other.Comment) ) return false; - if ( !(Name == other.Name) ) return false; - if ( memcmp(&Guid, &other.Guid, sizeof(Guid)) != 0 ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::RtVariables_Class::Devices_RtVariables_Block& other) - { - Disabled = other.dgetDisabled(); - Comment = other.dgetComment(); - Name = other.dgetName(); - Guid = other.dgetGuid(); - } - }; - - XString8 RtROMAsString = XString8(); - XBuffer RtROMAsData = XBuffer(); - XString8 RtMLBSetting = XString8(); - UINT32 CsrActiveConfig = UINT32(); - UINT16 BooterConfig = UINT16(); - XString8 BooterCfgStr = XString8(); - XString8 HWTarget = XString8(); - XObjArrayWithTakeValueFromXmlArray BlockRtVariableArray = XObjArrayWithTakeValueFromXmlArray(); - - XBool GetLegacyLanAddress() const { - return RtROMAsString.isEqualIC("UseMacAddr0") || RtROMAsString.isEqualIC("UseMacAddr1"); + XBool isEqual(const RT_VARIABLES &other) const { + if (!(Disabled == other.Disabled)) + return false; + if (!(Comment == other.Comment)) + return false; + if (!(Name == other.Name)) + return false; + if (memcmp(&Guid, &other.Guid, sizeof(Guid)) != 0) + return false; + return true; } - + void takeValueFrom( + const ConfigPlistClass::RtVariables_Class::Devices_RtVariables_Block + &other) { + Disabled = other.dgetDisabled(); + Comment = other.dgetComment(); + Name = other.dgetName(); + Guid = other.dgetGuid(); + } + }; + + XString8 RtROMAsString = XString8(); + XBuffer RtROMAsData = XBuffer(); + XString8 RtMLBSetting = XString8(); + UINT32 CsrActiveConfig = UINT32(); + UINT16 BooterConfig = UINT16(); + XString8 BooterCfgStr = XString8(); + XString8 HWTarget = XString8(); + XObjArrayWithTakeValueFromXmlArray< + RT_VARIABLES, + ConfigPlistClass::RtVariables_Class::Devices_RtVariables_Block> + BlockRtVariableArray = XObjArrayWithTakeValueFromXmlArray< + RT_VARIABLES, + ConfigPlistClass::RtVariables_Class::Devices_RtVariables_Block>(); + + XBool GetLegacyLanAddress() const { + return RtROMAsString.isEqualIC("UseMacAddr0") || + RtROMAsString.isEqualIC("UseMacAddr1"); + } + #if __cplusplus > 201703L - XBool operator == (const RtVariablesClass&) const = default; + XBool operator==(const RtVariablesClass &) const = default; #endif - XBool isEqual(const RtVariablesClass& other) const - { - if ( !(RtROMAsString == other.RtROMAsString) ) return false; - if ( !(RtROMAsData == other.RtROMAsData) ) return false; - if ( !(RtMLBSetting == other.RtMLBSetting) ) return false; - if ( !(CsrActiveConfig == other.CsrActiveConfig) ) return false; - if ( !(BooterConfig == other.BooterConfig) ) return false; - if ( !(BooterCfgStr == other.BooterCfgStr) ) return false; - if ( !(HWTarget == other.HWTarget) ) return false; - if ( !BlockRtVariableArray.isEqual(other.BlockRtVariableArray) ) return false; + XBool isEqual(const RtVariablesClass &other) const { + if (!(RtROMAsString == other.RtROMAsString)) + return false; + if (!(RtROMAsData == other.RtROMAsData)) + return false; + if (!(RtMLBSetting == other.RtMLBSetting)) + return false; + if (!(CsrActiveConfig == other.CsrActiveConfig)) + return false; + if (!(BooterConfig == other.BooterConfig)) + return false; + if (!(BooterCfgStr == other.BooterCfgStr)) + return false; + if (!(HWTarget == other.HWTarget)) + return false; + if (!BlockRtVariableArray.isEqual(other.BlockRtVariableArray)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass::RtVariables_Class& other) - { + void takeValueFrom(const ConfigPlistClass::RtVariables_Class &other) { RtROMAsString = other.dgetRtROMAsString(); RtROMAsData = other.dgetRtROMAsData(); RtMLBSetting = other.dgetRtMLBSetting(); @@ -2243,245 +2676,292 @@ printf("%s", ""); BlockRtVariableArray.takeValueFrom(other.Block); HWTarget = other.dgetHWTarget(); } - }; - class SmbiosClass - { + class SmbiosClass { + public: + class SlotDeviceClass { public: + static const SlotDeviceClass NullSlotDevice; - class SlotDeviceClass - { - public: - static const SlotDeviceClass NullSlotDevice; - public: - uint8_t SmbiosIndex = 0xff; - UINT8 SlotID = UINT8(); - MISC_SLOT_TYPE SlotType = MISC_SLOT_TYPE(); - XString8 SlotName = XString8(); + public: + uint8_t SmbiosIndex = 0xff; + UINT8 SlotID = UINT8(); + MISC_SLOT_TYPE SlotType = MISC_SLOT_TYPE(); + XString8 SlotName = XString8(); - SlotDeviceClass() {} + SlotDeviceClass() {} #if __cplusplus > 201703L - XBool operator == (const SLOT_DEVICE&) const = default; + XBool operator==(const SLOT_DEVICE &) const = default; #endif - XBool isEqual(const SlotDeviceClass& other) const - { - if ( !(SmbiosIndex == other.SmbiosIndex) ) return false; - if ( !(SlotID == other.SlotID) ) return false; - if ( !(SlotType == other.SlotType) ) return false; - if ( !(SlotName == other.SlotName) ) return false; - return true; - } - void takeValueFrom(const SmbiosPlistClass::SmbiosDictClass::SlotDeviceDictClass& other) - { - SmbiosIndex = other.dgetDeviceN(); - SlotID = other.dgetSlotID(); - SlotType = other.dgetSlotType(); - SlotName = other.dgetSlotName(); - } - }; - - class SlotDeviceArrayClass : public XObjArrayWithTakeValueFromXmlArray - { - public: - XBool doesSlotForIndexExist(uint8_t idx2Look4) const { - for ( size_t idx = 0 ; idx < size() ; ++idx ) { - if ( ElementAt(idx).SmbiosIndex == idx2Look4 ) return true; - } - return false; - } - const SlotDeviceClass& getSlotForIndex(uint8_t idx2Look4) const { - for ( size_t idx = 0 ; idx < size() ; ++idx ) { - if ( ElementAt(idx).SmbiosIndex == idx2Look4 ) return ElementAt(idx); - } - log_technical_bug("%s : no idx==%hhd", __PRETTY_FUNCTION__, idx2Look4); - return SlotDeviceClass::NullSlotDevice; - } - const SlotDeviceClass& getSlotForIndexOrNull(uint8_t idx2Look4) const { - for ( size_t idx = 0 ; idx < size() ; ++idx ) { - if ( ElementAt(idx).SmbiosIndex == idx2Look4 ) return ElementAt(idx); - } - return SlotDeviceClass::NullSlotDevice; - } - }; - - class RamSlotInfo { - public: - UINT64 SlotIndex = UINT64(); - UINT32 ModuleSize = UINT32(); - UINT32 Frequency = UINT32(); - XString8 Vendor = XString8(); - XString8 PartNo = XString8(); - XString8 SerialNo = XString8(); - UINT8 Type = UINT8(); - - RamSlotInfo() {} - - #if __cplusplus > 201703L - XBool operator == (const RamSlotInfo&) const = default; - #endif - XBool isEqual(const RamSlotInfo& other) const - { - if ( !(SlotIndex == other.SlotIndex ) ) return false; - if ( !(ModuleSize == other.ModuleSize ) ) return false; - if ( !(Frequency == other.Frequency ) ) return false; - if ( !(Vendor == other.Vendor ) ) return false; - if ( !(PartNo == other.PartNo ) ) return false; - if ( !(SerialNo == other.SerialNo ) ) return false; - if ( !(Type == other.Type ) ) return false; - return true; - } - XBool takeValueFrom(const SmbiosPlistClass::SmbiosDictClass::MemoryDictClass::ModuleDictClass& other) - { - SlotIndex = other.dgetSlotIndex(); - ModuleSize = other.dgetModuleSize(); - Frequency = other.dgetFrequency(); - Vendor = other.dgetVendor(); - PartNo = other.dgetPartNo(); - SerialNo = other.dgetSerialNo(); - Type = other.dgetType(); + XBool isEqual(const SlotDeviceClass &other) const { + if (!(SmbiosIndex == other.SmbiosIndex)) + return false; + if (!(SlotID == other.SlotID)) + return false; + if (!(SlotType == other.SlotType)) + return false; + if (!(SlotName == other.SlotName)) + return false; + return true; + } + void takeValueFrom( + const SmbiosPlistClass::SmbiosDictClass::SlotDeviceDictClass &other) { + SmbiosIndex = other.dgetDeviceN(); + SlotID = other.dgetSlotID(); + SlotType = other.dgetSlotType(); + SlotName = other.dgetSlotName(); + } + }; + + class SlotDeviceArrayClass + : public XObjArrayWithTakeValueFromXmlArray< + SlotDeviceClass, + SmbiosPlistClass::SmbiosDictClass::SlotDeviceDictClass> { + public: + XBool doesSlotForIndexExist(uint8_t idx2Look4) const { + for (size_t idx = 0; idx < size(); ++idx) { + if (ElementAt(idx).SmbiosIndex == idx2Look4) return true; - } - }; + } + return false; + } + const SlotDeviceClass &getSlotForIndex(uint8_t idx2Look4) const { + for (size_t idx = 0; idx < size(); ++idx) { + if (ElementAt(idx).SmbiosIndex == idx2Look4) + return ElementAt(idx); + } + log_technical_bug("%s : no idx==%hhd", __PRETTY_FUNCTION__, idx2Look4); + return SlotDeviceClass::NullSlotDevice; + } + const SlotDeviceClass &getSlotForIndexOrNull(uint8_t idx2Look4) const { + for (size_t idx = 0; idx < size(); ++idx) { + if (ElementAt(idx).SmbiosIndex == idx2Look4) + return ElementAt(idx); + } + return SlotDeviceClass::NullSlotDevice; + } + }; - class RamSlotInfoArrayClass { - public: - UINT8 SlotCount = UINT8(); - UINT8 UserChannels = UINT8(); - XObjArrayWithTakeValueFromXmlArray User = XObjArrayWithTakeValueFromXmlArray(); + class RamSlotInfo { + public: + UINT64 SlotIndex = UINT64(); + UINT32 ModuleSize = UINT32(); + UINT32 Frequency = UINT32(); + XString8 Vendor = XString8(); + XString8 PartNo = XString8(); + XString8 SerialNo = XString8(); + UINT8 Type = UINT8(); - RamSlotInfoArrayClass() {} + RamSlotInfo() {} #if __cplusplus > 201703L - XBool operator == (const RamSlotInfoArrayClass&) const = default; + XBool operator==(const RamSlotInfo &) const = default; #endif - XBool isEqual(const RamSlotInfoArrayClass& other) const - { - if ( !(SlotCount == other.SlotCount) ) return false; - if ( !(UserChannels == other.UserChannels) ) return false; - if ( !(User.isEqual(other.User)) ) return false; - return true; - } - void takeValueFrom(const SmbiosPlistClass::SmbiosDictClass::MemoryDictClass& other) - { - SlotCount = other.dgetSlotCount(); - UserChannels = other.dgetUserChannels(); - User.takeValueFrom(other.Modules); - } - }; - + XBool isEqual(const RamSlotInfo &other) const { + if (!(SlotIndex == other.SlotIndex)) + return false; + if (!(ModuleSize == other.ModuleSize)) + return false; + if (!(Frequency == other.Frequency)) + return false; + if (!(Vendor == other.Vendor)) + return false; + if (!(PartNo == other.PartNo)) + return false; + if (!(SerialNo == other.SerialNo)) + return false; + if (!(Type == other.Type)) + return false; + return true; + } + XBool takeValueFrom(const SmbiosPlistClass::SmbiosDictClass:: + MemoryDictClass::ModuleDictClass &other) { + SlotIndex = other.dgetSlotIndex(); + ModuleSize = other.dgetModuleSize(); + Frequency = other.dgetFrequency(); + Vendor = other.dgetVendor(); + PartNo = other.dgetPartNo(); + SerialNo = other.dgetSerialNo(); + Type = other.dgetType(); + return true; + } + }; + class RamSlotInfoArrayClass { + public: + UINT8 SlotCount = UINT8(); + UINT8 UserChannels = UINT8(); + XObjArrayWithTakeValueFromXmlArray< + RamSlotInfo, + SmbiosPlistClass::SmbiosDictClass::MemoryDictClass::ModuleDictClass> + User = XObjArrayWithTakeValueFromXmlArray< + RamSlotInfo, SmbiosPlistClass::SmbiosDictClass::MemoryDictClass:: + ModuleDictClass>(); - // SMBIOS TYPE0 - XString8 BiosVendor = XString8(); - XString8 BiosVersion = XString8(); - XString8 EfiVersion = XString8(); - XString8 BiosReleaseDate = XString8(); - // SMBIOS TYPE1 - XString8 ManufactureName = XString8(); - XString8 ProductName = XString8(); - XString8 SystemVersion = XString8(); - XString8 SerialNr = XString8(); - EFI_GUID SmUUID = EFI_GUID(); - XString8 FamilyName = XString8(); - // SMBIOS TYPE2 - XString8 BoardManufactureName = XString8(); - XString8 BoardSerialNumber = XString8(); - XString8 BoardNumber = XString8(); //Board-ID - XString8 LocationInChassis = XString8(); - XString8 BoardVersion = XString8(); - UINT8 BoardType = UINT8(); - // SMBIOS TYPE3 - XBool Mobile = XBool(); - UINT8 ChassisType = UINT8(); - XString8 ChassisManufacturer = XString8(); - XString8 ChassisAssetTag = XString8(); - // SMBIOS TYPE4 - UINT32 SFakeCPU = UINT32(); - // SMBIOS TYPE17 - UINT16 SmbiosVersion = UINT16(); - INT8 Attribute = INT8(); -// These were set but never used. -// XString8 MemoryManufacturer; -// XString8 MemorySerialNumber; -// XString8 MemoryPartNumber; -// XString8 MemorySpeed; - // SMBIOS TYPE131 - // SMBIOS TYPE132 - XBool TrustSMBIOS = false; - XBool InjectMemoryTables = XBool(); // same as Memory.SlotCounts - // SMBIOS TYPE133 - UINT64 gPlatformFeature = UINT64(); - // PatchTableType11 - XBool NoRomInfo = XBool(); + RamSlotInfoArrayClass() {} - UINT32 FirmwareFeatures = UINT32(); - UINT32 FirmwareFeaturesMask = UINT32(); - UINT64 ExtendedFirmwareFeatures = UINT64(); - UINT64 ExtendedFirmwareFeaturesMask = UINT64(); - RamSlotInfoArrayClass RamSlotInfoArray = RamSlotInfoArrayClass(); - SlotDeviceArrayClass SlotDevices = SlotDeviceArrayClass(); +#if __cplusplus > 201703L + XBool operator==(const RamSlotInfoArrayClass &) const = default; +#endif + XBool isEqual(const RamSlotInfoArrayClass &other) const { + if (!(SlotCount == other.SlotCount)) + return false; + if (!(UserChannels == other.UserChannels)) + return false; + if (!(User.isEqual(other.User))) + return false; + return true; + } + void takeValueFrom( + const SmbiosPlistClass::SmbiosDictClass::MemoryDictClass &other) { + SlotCount = other.dgetSlotCount(); + UserChannels = other.dgetUserChannels(); + User.takeValueFrom(other.Modules); + } + }; + + // SMBIOS TYPE0 + XString8 BiosVendor = XString8(); + XString8 BiosVersion = XString8(); + XString8 EfiVersion = XString8(); + XString8 BiosReleaseDate = XString8(); + // SMBIOS TYPE1 + XString8 ManufactureName = XString8(); + XString8 ProductName = XString8(); + XString8 SystemVersion = XString8(); + XString8 SerialNr = XString8(); + EFI_GUID SmUUID = EFI_GUID(); + XString8 FamilyName = XString8(); + // SMBIOS TYPE2 + XString8 BoardManufactureName = XString8(); + XString8 BoardSerialNumber = XString8(); + XString8 BoardNumber = XString8(); // Board-ID + XString8 LocationInChassis = XString8(); + XString8 BoardVersion = XString8(); + UINT8 BoardType = UINT8(); + // SMBIOS TYPE3 + XBool Mobile = XBool(); + UINT8 ChassisType = UINT8(); + XString8 ChassisManufacturer = XString8(); + XString8 ChassisAssetTag = XString8(); + // SMBIOS TYPE4 + UINT32 SFakeCPU = UINT32(); + // SMBIOS TYPE17 + UINT16 SmbiosVersion = UINT16(); + INT8 Attribute = INT8(); + // These were set but never used. + // XString8 MemoryManufacturer; + // XString8 MemorySerialNumber; + // XString8 MemoryPartNumber; + // XString8 MemorySpeed; + // SMBIOS TYPE131 + // SMBIOS TYPE132 + XBool TrustSMBIOS = false; + XBool InjectMemoryTables = XBool(); // same as Memory.SlotCounts + // SMBIOS TYPE133 + UINT64 gPlatformFeature = UINT64(); + // PatchTableType11 + XBool NoRomInfo = XBool(); + + UINT32 FirmwareFeatures = UINT32(); + UINT32 FirmwareFeaturesMask = UINT32(); + UINT64 ExtendedFirmwareFeatures = UINT64(); + UINT64 ExtendedFirmwareFeaturesMask = UINT64(); + RamSlotInfoArrayClass RamSlotInfoArray = RamSlotInfoArrayClass(); + SlotDeviceArrayClass SlotDevices = SlotDeviceArrayClass(); SmbiosClass() {} - + #if __cplusplus > 201703L - XBool operator == (const SmbiosClass&) const = default; + XBool operator==(const SmbiosClass &) const = default; #endif - XBool isEqual(const SmbiosClass& other) const - { + XBool isEqual(const SmbiosClass &other) const { // SMBIOS TYPE0 - if ( !(BiosVendor == other.BiosVendor) ) return false; - if ( !(BiosVersion == other.BiosVersion) ) return false; - if ( !(EfiVersion == other.EfiVersion) ) return false; - if ( !(BiosReleaseDate == other.BiosReleaseDate) ) return false; + if (!(BiosVendor == other.BiosVendor)) + return false; + if (!(BiosVersion == other.BiosVersion)) + return false; + if (!(EfiVersion == other.EfiVersion)) + return false; + if (!(BiosReleaseDate == other.BiosReleaseDate)) + return false; // SMBIOS TYPE1 - if ( !(ManufactureName == other.ManufactureName) ) return false; - if ( !(ProductName == other.ProductName) ) return false; - if ( !(SystemVersion == other.SystemVersion) ) return false; - if ( !(SerialNr == other.SerialNr) ) return false; - if ( !(SmUUID == other.SmUUID) ) return false; - if ( !(FamilyName == other.FamilyName) ) return false; + if (!(ManufactureName == other.ManufactureName)) + return false; + if (!(ProductName == other.ProductName)) + return false; + if (!(SystemVersion == other.SystemVersion)) + return false; + if (!(SerialNr == other.SerialNr)) + return false; + if (!(SmUUID == other.SmUUID)) + return false; + if (!(FamilyName == other.FamilyName)) + return false; // SMBIOS TYPE2 - if ( !(BoardManufactureName == other.BoardManufactureName) ) return false; - if ( !(BoardSerialNumber == other.BoardSerialNumber) ) return false; - if ( !(BoardNumber == other.BoardNumber) ) return false; - if ( !(LocationInChassis == other.LocationInChassis) ) return false; - if ( !(BoardVersion == other.BoardVersion) ) return false; - if ( !(BoardType == other.BoardType) ) return false; + if (!(BoardManufactureName == other.BoardManufactureName)) + return false; + if (!(BoardSerialNumber == other.BoardSerialNumber)) + return false; + if (!(BoardNumber == other.BoardNumber)) + return false; + if (!(LocationInChassis == other.LocationInChassis)) + return false; + if (!(BoardVersion == other.BoardVersion)) + return false; + if (!(BoardType == other.BoardType)) + return false; // SMBIOS TYPE3 - if ( !(Mobile == other.Mobile) ) return false; - if ( !(ChassisType == other.ChassisType) ) return false; - if ( !(ChassisManufacturer == other.ChassisManufacturer) ) return false; - if ( !(ChassisAssetTag == other.ChassisAssetTag) ) return false; + if (!(Mobile == other.Mobile)) + return false; + 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; + if (!(SFakeCPU == other.SFakeCPU)) + return false; // SMBIOS TYPE17 - if ( !(SmbiosVersion == other.SmbiosVersion) ) return false; - if ( !(Attribute == other.Attribute) ) return false; + if (!(SmbiosVersion == other.SmbiosVersion)) + return false; + if (!(Attribute == other.Attribute)) + return false; // SMBIOS TYPE132 - if ( !(TrustSMBIOS == other.TrustSMBIOS) ) return false; - if ( !(InjectMemoryTables == other.InjectMemoryTables) ) return false; + if (!(TrustSMBIOS == other.TrustSMBIOS)) + return false; + if (!(InjectMemoryTables == other.InjectMemoryTables)) + return false; // SMBIOS TYPE133 - if ( !(gPlatformFeature == other.gPlatformFeature) ) return false; + if (!(gPlatformFeature == other.gPlatformFeature)) + return false; // PatchTableType11 - if ( !(NoRomInfo == other.NoRomInfo) ) return false; - - if ( !(FirmwareFeatures == other.FirmwareFeatures) ) return false; - if ( !(FirmwareFeaturesMask == other.FirmwareFeaturesMask) ) return false; - if ( !(ExtendedFirmwareFeatures == other.ExtendedFirmwareFeatures) ) return false; - if ( !(ExtendedFirmwareFeaturesMask == other.ExtendedFirmwareFeaturesMask) ) return false; - if ( !RamSlotInfoArray.isEqual(other.RamSlotInfoArray) ) return false; - if ( !SlotDevices.isEqual(other.SlotDevices) ) return false; - -// if ( memcmp(RPlt, other.RPlt, sizeof(RPlt)) != 0 ) return false; -// if ( memcmp(RBr, other.RBr, sizeof(RBr)) != 0 ) return false; -// if ( memcmp(EPCI, other.EPCI, sizeof(EPCI)) != 0 ) return false; -// if ( memcmp(REV, other.REV, sizeof(REV)) != 0 ) return false; + if (!(NoRomInfo == other.NoRomInfo)) + return false; + + if (!(FirmwareFeatures == other.FirmwareFeatures)) + return false; + if (!(FirmwareFeaturesMask == other.FirmwareFeaturesMask)) + return false; + if (!(ExtendedFirmwareFeatures == other.ExtendedFirmwareFeatures)) + return false; + if (!(ExtendedFirmwareFeaturesMask == other.ExtendedFirmwareFeaturesMask)) + return false; + if (!RamSlotInfoArray.isEqual(other.RamSlotInfoArray)) + return false; + if (!SlotDevices.isEqual(other.SlotDevices)) + return false; + + // if ( memcmp(RPlt, other.RPlt, sizeof(RPlt)) != 0 ) return false; + // if ( memcmp(RBr, other.RBr, sizeof(RBr)) != 0 ) return false; + // if ( memcmp(EPCI, other.EPCI, sizeof(EPCI)) != 0 ) return false; + // if ( memcmp(REV, other.REV, sizeof(REV)) != 0 ) return false; return true; } - void takeValueFrom(const SmbiosPlistClass::SmbiosDictClass& other) - { + void takeValueFrom(const SmbiosPlistClass::SmbiosDictClass &other) { // SMBIOS TYPE0 BiosVendor = other.dgetBiosVendor(); BiosVersion = other.dgetBiosVersion(); @@ -2518,47 +2998,47 @@ printf("%s", ""); gPlatformFeature = other.dgetgPlatformFeature(); // PatchTableType11 NoRomInfo = other.dgetNoRomInfo(); - //SMBIOS TYPE128 + // SMBIOS TYPE128 FirmwareFeatures = other.dgetFirmwareFeatures(); FirmwareFeaturesMask = other.dgetFirmwareFeaturesMask(); ExtendedFirmwareFeatures = other.dgetExtendedFirmwareFeatures(); ExtendedFirmwareFeaturesMask = other.dgetExtendedFirmwareFeaturesMask(); RamSlotInfoArray.takeValueFrom(other.Memory); SlotDevices.takeValueFrom(other.Slots); - } - }; class BootGraphicsClass { - public: - UINT32 DefaultBackgroundColor = 0; - UINT32 UIScale = 0; - UINT32 EFILoginHiDPI = 0; -// UINT8 flagstate[32] = {0}; - uint32_t _flagstate = uint32_t(); - - BootGraphicsClass() { -// flagstate.memset(0, 32); - } - + public: + UINT32 DefaultBackgroundColor = 0; + UINT32 UIScale = 0; + UINT32 EFILoginHiDPI = 0; + // UINT8 flagstate[32] = {0}; + uint32_t _flagstate = uint32_t(); + + BootGraphicsClass() { + // flagstate.memset(0, 32); + } + #if __cplusplus > 201703L - XBool operator == (const BootGraphicsClass&) const = default; + XBool operator==(const BootGraphicsClass &) const = default; #endif - XBool isEqual(const BootGraphicsClass& other) const - { - if ( !(DefaultBackgroundColor == other.DefaultBackgroundColor) ) return false; - if ( !(UIScale == other.UIScale) ) return false; - if ( !(EFILoginHiDPI == other.EFILoginHiDPI) ) return false; - if ( _flagstate != other._flagstate ) return false; - return true; - } - void takeValueFrom(const ConfigPlistClass::BootGraphics_Class& other) - { - DefaultBackgroundColor = other.dgetDefaultBackgroundColor(); - UIScale = other.dgetUIScale(); - EFILoginHiDPI = other.dgetEFILoginHiDPI(); - _flagstate = other.dget_flagstate(); - } + XBool isEqual(const BootGraphicsClass &other) const { + if (!(DefaultBackgroundColor == other.DefaultBackgroundColor)) + return false; + if (!(UIScale == other.UIScale)) + return false; + if (!(EFILoginHiDPI == other.EFILoginHiDPI)) + return false; + if (_flagstate != other._flagstate) + return false; + return true; + } + void takeValueFrom(const ConfigPlistClass::BootGraphics_Class &other) { + DefaultBackgroundColor = other.dgetDefaultBackgroundColor(); + UIScale = other.dgetUIScale(); + EFILoginHiDPI = other.dgetEFILoginHiDPI(); + _flagstate = other.dget_flagstate(); + } }; BootClass Boot = BootClass(); @@ -2568,41 +3048,52 @@ printf("%s", ""); SystemParametersClass SystemParameters = SystemParametersClass(); KERNEL_AND_KEXT_PATCHES KernelAndKextPatches = KERNEL_AND_KEXT_PATCHES(); GraphicsClass Graphics = GraphicsClass(); - XStringWArray DisabledDriverArray = XStringWArray(); + XStringWArray DisabledDriverArray = XStringWArray(); QuirksClass Quirks = QuirksClass(); RtVariablesClass RtVariables = RtVariablesClass(); DevicesClass Devices = DevicesClass(); SmbiosClass Smbios = SmbiosClass(); BootGraphicsClass BootGraphics = BootGraphicsClass(); - 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 + // 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 #if __cplusplus > 201703L - XBool operator == (const SETTINGS_DATA&) const = default; + XBool operator==(const SETTINGS_DATA &) const = default; #endif - XBool isEqual(const SETTINGS_DATA& other) const - { - if ( !Boot.isEqual(other.Boot) ) return false; - if ( !ACPI.isEqual(other.ACPI) ) return false; - if ( !GUI.isEqual(other.GUI) ) return false; - if ( !CPU.isEqual(other.CPU) ) return false; - if ( !SystemParameters.isEqual(other.SystemParameters) ) return false; - if ( !KernelAndKextPatches.isEqual(other.KernelAndKextPatches) ) return false; - if ( !Graphics.isEqual(other.Graphics) ) return false; - if ( !(DisabledDriverArray == other.DisabledDriverArray) ) return false; - if ( !Quirks.isEqual(other.Quirks) ) return false; - if ( !RtVariables.isEqual(other.RtVariables) ) return false; - if ( !Devices.isEqual(other.Devices) ) return false; - if ( !Smbios.isEqual(other.Smbios) ) return false; - if ( !BootGraphics.isEqual(other.BootGraphics) ) return false; + XBool isEqual(const SETTINGS_DATA &other) const { + if (!Boot.isEqual(other.Boot)) + return false; + if (!ACPI.isEqual(other.ACPI)) + return false; + if (!GUI.isEqual(other.GUI)) + return false; + if (!CPU.isEqual(other.CPU)) + return false; + if (!SystemParameters.isEqual(other.SystemParameters)) + return false; + if (!KernelAndKextPatches.isEqual(other.KernelAndKextPatches)) + return false; + if (!Graphics.isEqual(other.Graphics)) + return false; + if (!(DisabledDriverArray == other.DisabledDriverArray)) + return false; + if (!Quirks.isEqual(other.Quirks)) + return false; + if (!RtVariables.isEqual(other.RtVariables)) + return false; + if (!Devices.isEqual(other.Devices)) + return false; + if (!Smbios.isEqual(other.Smbios)) + return false; + if (!BootGraphics.isEqual(other.BootGraphics)) + return false; return true; } - void takeValueFrom(const ConfigPlistClass& other) - { + void takeValueFrom(const ConfigPlistClass &other) { Boot.takeValueFrom(other.Boot); ACPI.takeValueFrom(other.ACPI); GUI.takeValueFrom(other.GUI); @@ -2620,36 +3111,43 @@ printf("%s", ""); ~SETTINGS_DATA() {} - const EFI_GUID& getUUID(); -// const XString8& getUUID(EFI_GUID* efiGuid); + const EFI_GUID &getUUID(); + // const XString8& getUUID(EFI_GUID* efiGuid); // If CustomUuid is defined, return false by default // If SmUUID is defined, return true by default. XBool ShouldInjectSystemID() { - if ( SystemParameters.CustomUuid.notNull() /*&& SystemParameters.CustomUuid.notNull()*/ ) { - if ( SystemParameters._InjectSystemID == 2 ) return false; - else return SystemParameters._InjectSystemID != 0; + if (SystemParameters.CustomUuid + .notNull() /*&& SystemParameters.CustomUuid.notNull()*/) { + if (SystemParameters._InjectSystemID == 2) + return false; + else + return SystemParameters._InjectSystemID != 0; } - if ( Smbios.SmUUID.isNull() /* || Smbios.SmUUID.isNull() */) return false; - if ( SystemParameters._InjectSystemID == 2 ) return true; + if (Smbios.SmUUID.isNull() /* || Smbios.SmUUID.isNull() */) + return false; + if (SystemParameters._InjectSystemID == 2) + return true; return SystemParameters._InjectSystemID != 0; } - + XBool getEnableC6() const { - if ( CPU._EnableC6.isDefined() ) return CPU._EnableC6.value(); + if (CPU._EnableC6.isDefined()) + return CPU._EnableC6.value(); return ACPI.SSDT._EnableC6; } XBool getEnableC4() const { - if ( CPU._EnableC4.isDefined() ) return CPU._EnableC4.value(); + if (CPU._EnableC4.isDefined()) + return CPU._EnableC4.value(); return ACPI.SSDT._EnableC4; } XBool getEnableC2() const { - if ( CPU._EnableC2.isDefined() ) return CPU._EnableC2.value(); + if (CPU._EnableC2.isDefined()) + return CPU._EnableC2.value(); return ACPI.SSDT._EnableC2; } - }; -//#pragma GCC diagnostic ignored "-Wpadded" +// #pragma GCC diagnostic ignored "-Wpadded" typedef struct _DRIVERS_FLAGS { BOOLEAN EmuVariableLoaded; @@ -2665,35 +3163,36 @@ typedef struct _DRIVERS_FLAGS { } DRIVERS_FLAGS; // ACPI/PATCHED/AML -class ACPI_PATCHED_AML -{ +class ACPI_PATCHED_AML { public: - XString8 FileName = XString8(); - INPUT_ITEM MenuItem = INPUT_ITEM(); + XString8 FileName = XString8(); + INPUT_ITEM MenuItem = INPUT_ITEM(); ACPI_PATCHED_AML() {}; - ACPI_PATCHED_AML(const ACPI_PATCHED_AML& other) = delete; // Can be defined if needed - const ACPI_PATCHED_AML& operator = ( const ACPI_PATCHED_AML & ) = delete; // Can be defined if needed - ~ACPI_PATCHED_AML() { } + ACPI_PATCHED_AML(const ACPI_PATCHED_AML &other) = + delete; // Can be defined if needed + const ACPI_PATCHED_AML & + operator=(const ACPI_PATCHED_AML &) = delete; // Can be defined if needed + ~ACPI_PATCHED_AML() {} }; // syscl - Side load kext -class SIDELOAD_KEXT -{ +class SIDELOAD_KEXT { public: XObjArray PlugInList; - XStringW FileName = XStringW(); - XStringW KextDirNameUnderOEMPath = XStringW(); - XStringW Version = XStringW(); - INPUT_ITEM MenuItem = INPUT_ITEM(); - + XStringW FileName = XStringW(); + XStringW KextDirNameUnderOEMPath = XStringW(); + XStringW Version = XStringW(); + INPUT_ITEM MenuItem = INPUT_ITEM(); + SIDELOAD_KEXT() : PlugInList() {}; - SIDELOAD_KEXT(const SIDELOAD_KEXT& other) = delete; // Can be defined if needed - const SIDELOAD_KEXT& operator = ( const SIDELOAD_KEXT & ) = delete; // Can be defined if needed - ~SIDELOAD_KEXT() { } + SIDELOAD_KEXT(const SIDELOAD_KEXT &other) = + delete; // Can be defined if needed + const SIDELOAD_KEXT & + operator=(const SIDELOAD_KEXT &) = delete; // Can be defined if needed + ~SIDELOAD_KEXT() {} }; - extern XObjArray AudioList; extern XStringWArray ThemeNameArray; @@ -2701,145 +3200,135 @@ extern XStringWArray ConfigsList; extern XStringWArray DsdtsList; extern XStringWArray SmbiosList; -extern INTN OldChosenTheme; -extern INTN OldChosenConfig; -extern INTN OldChosenSmbios; -extern INTN OldChosenDsdt; -extern UINTN OldChosenAudio; -extern XBool SavePreBootLog; -extern UINT8 DefaultAudioVolume; - -extern SETTINGS_DATA gSettings; -extern XBool gFirmwareClover; -extern DRIVERS_FLAGS gDriversFlags; -extern EFI_EDID_DISCOVERED_PROTOCOL *EdidDiscovered; -extern UINTN gEvent; -extern UINT16 gBacklightLevel; - +extern INTN OldChosenTheme; +extern INTN OldChosenConfig; +extern INTN OldChosenSmbios; +extern INTN OldChosenDsdt; +extern UINTN OldChosenAudio; +extern XBool SavePreBootLog; +extern UINT8 DefaultAudioVolume; + +extern SETTINGS_DATA gSettings; +extern XBool gFirmwareClover; +extern DRIVERS_FLAGS gDriversFlags; +extern EFI_EDID_DISCOVERED_PROTOCOL *EdidDiscovered; +extern UINTN gEvent; +extern UINT16 gBacklightLevel; // ACPI/PATCHED/AML -extern XObjArray ACPIPatchedAML; +extern XObjArray ACPIPatchedAML; // Hold theme fixed IconFormat / extension -extern CHAR16 *IconFormat; -extern XBool ResumeFromCoreStorage; +extern CHAR16 *IconFormat; +extern XBool ResumeFromCoreStorage; extern EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl; - // // config module // -class REFIT_CONFIG -{ +class REFIT_CONFIG { public: - UINTN DisableFlags = 0; //to disable some volume types (optical, firewire etc) - XBool Quiet = true; - XBool SpecialBootMode = false; // content of nvram var "aptiofixflag" + UINTN DisableFlags = 0; // to disable some volume types (optical, firewire + // etc) + XBool Quiet = true; + XBool SpecialBootMode = false; // content of nvram var "aptiofixflag" - XBool gBootChanged = false; - XBool gThemeChanged = false; - XBool NeedPMfix = false; - XObjArray ACPIDropTables = XObjArray(); + XBool gBootChanged = false; + XBool gThemeChanged = false; + XBool NeedPMfix = false; + XObjArray ACPIDropTables = XObjArray(); - UINT8 CustomLogoType = 0; // this will be initialized with gSettings.Boot.CustomBoot and set back to CUSTOM_BOOT_DISABLED if CustomLogo could not be loaded or decoded (see afterGetUserSettings) - XImage *CustomLogo = 0; + UINT8 CustomLogoType = + 0; // this will be initialized with gSettings.Boot.CustomBoot and set back + // to CUSTOM_BOOT_DISABLED if CustomLogo could not be loaded or decoded + // (see afterGetUserSettings) + XImage *CustomLogo = 0; - XBool DropSSDT = false; // init with gSettings.Boot.DropSSDTSetting. Put back to false if one table is dropped (see afterGetUserSettings) + XBool DropSSDT = + false; // init with gSettings.Boot.DropSSDTSetting. Put back to false if + // one table is dropped (see afterGetUserSettings) - UINT8 SecureBoot = 0; - UINT8 SecureBootSetupMode = 0; + UINT8 SecureBoot = 0; + UINT8 SecureBootSetupMode = 0; - XBool SetTable132 = false; - XBool HWP = false; + XBool SetTable132 = false; + XBool HWP = false; - XBool EnableC6 = false; - XBool EnableC4 = false; - XBool EnableC2 = false; - uint16_t C3Latency = 0; + XBool EnableC6 = false; + XBool EnableC4 = false; + XBool EnableC2 = false; + uint16_t C3Latency = 0; - XObjArray CustomEntries = XObjArray(); - XObjArray CustomLegacyEntries = XObjArray(); - XObjArray CustomToolsEntries = XObjArray(); + XObjArray CustomEntries = + XObjArray(); + XObjArray CustomLegacyEntries = + XObjArray(); + XObjArray CustomToolsEntries = + XObjArray(); - INTN Codepage = 0xC0; - INTN CodepageSize = 0xC0; + INTN Codepage = 0xC0; + INTN CodepageSize = 0xC0; - XBool KPKernelPm = XBool(); - XBool KPAppleIntelCPUPM = XBool(); + XBool KPKernelPm = XBool(); + XBool KPAppleIntelCPUPM = XBool(); - XBuffer RtROM = XBuffer(); - XString8 RtMLB = XString8(); + XBuffer RtROM = XBuffer(); + XString8 RtMLB = XString8(); XBool Turbo = true; - XString8 OEMProductFromSmbios = XString8(); - XString8 OEMVendorFromSmbios = XString8(); - XString8 OEMBoardFromSmbios = XString8(); - UINT8 EnabledCores = 0; + XString8 OEMProductFromSmbios = XString8(); + XString8 OEMVendorFromSmbios = XString8(); + XString8 OEMBoardFromSmbios = XString8(); + UINT8 EnabledCores = 0; -// XStringW ConfigName; // Set but never used + // XStringW ConfigName; // Set but never used - UINT32 OptionsBits = 0; - UINT32 FlagsBits = 0; + UINT32 OptionsBits = 0; + UINT32 FlagsBits = 0; - XStringW BlockKexts = XStringW(); + XStringW BlockKexts = XStringW(); // KernelAndKextPatches - XBool KextPatchesAllowed = true; - XBool KernelPatchesAllowed = true; //From GUI: Only for user patches, not internal Clover - - UINT8 flagstate[32] = {0}; - MacModel CurrentModel = MaxMacModel; + XBool KextPatchesAllowed = true; + XBool KernelPatchesAllowed = + true; // From GUI: Only for user patches, not internal Clover - UINT32 IgPlatform = UINT32(); //could also be snb-platform-id + UINT8 flagstate[32] = {0}; + MacModel CurrentModel = MaxMacModel; + UINT32 IgPlatform = UINT32(); // could also be snb-platform-id REFIT_CONFIG() {}; - REFIT_CONFIG(const REFIT_CONFIG& other) = delete; // Can be defined if needed - const REFIT_CONFIG& operator = ( const REFIT_CONFIG & ) = delete; // Can be defined if needed - ~REFIT_CONFIG() { } + REFIT_CONFIG(const REFIT_CONFIG &other) = delete; // Can be defined if needed + const REFIT_CONFIG & + operator=(const REFIT_CONFIG &) = delete; // Can be defined if needed + ~REFIT_CONFIG() {} XBool isFastBoot() { return SpecialBootMode || gSettings.Boot.FastBoot; } - -} ; - +}; extern REFIT_CONFIG GlobalConfig; - EFI_STATUS -SetFSInjection ( - IN LOADER_ENTRY *Entry - ); - -void -SetDevices ( - LOADER_ENTRY *Entry - ); +SetFSInjection(IN LOADER_ENTRY *Entry); + +void SetDevices(LOADER_ENTRY *Entry); // // check if this entry corresponds to Boot# variable and then set BootCurrent // -void -SetBootCurrent(REFIT_MENU_ITEM_BOOTNUM *LoadedEntry); +void SetBootCurrent(REFIT_MENU_ITEM_BOOTNUM *LoadedEntry); +void afterGetUserSettings(SETTINGS_DATA &gSettings); +XStringW GetOtherKextsDir(XBool On); -void afterGetUserSettings(SETTINGS_DATA& gSettings); - -XStringW -GetOtherKextsDir (XBool On); - -XStringW GetOSVersionKextsDir(const MacOsVersion& OSVersion); +XStringW GetOSVersionKextsDir(const MacOsVersion &OSVersion); EFI_STATUS -InjectKextsFromDir ( - EFI_STATUS Status, - CHAR16 *SrcDir - ); - +InjectKextsFromDir(EFI_STATUS Status, CHAR16 *SrcDir); EFI_STATUS ApplySettings(void); - #endif diff --git a/rEFIt_UEFI/Platform/plist/TagDict.h b/rEFIt_UEFI/Platform/plist/TagDict.h index 93c318bcef..5f8b4de1cb 100644 --- a/rEFIt_UEFI/Platform/plist/TagDict.h +++ b/rEFIt_UEFI/Platform/plist/TagDict.h @@ -10,16 +10,12 @@ #include "plist.h" -class TagsDictFreeArray : public XObjArray -{ +class TagsDictFreeArray : public XObjArray { public: - ~TagsDictFreeArray () { - NOP; - } + ~TagsDictFreeArray() { (void)0; } }; -class TagDict : public TagStruct -{ +class TagDict : public TagStruct { XObjArray _dictContent; public: @@ -28,56 +24,50 @@ class TagDict : public TagStruct #endif TagDict() : _dictContent() {} - TagDict(const TagDict& other) = delete; // Can be defined if needed - const TagDict& operator = (const TagDict&); // Can be defined if needed - virtual ~TagDict() { } - - virtual XBool operator == (const TagStruct& other) const; - virtual XBool debugIsEqual(const TagStruct& other, const XString8& label) const; + TagDict(const TagDict &other) = delete; // Can be defined if needed + const TagDict &operator=(const TagDict &); // Can be defined if needed + virtual ~TagDict() {} + + virtual XBool operator==(const TagStruct &other) const; + virtual XBool debugIsEqual(const TagStruct &other, + const XString8 &label) const; - virtual TagDict* getDict() { return this; } - virtual const TagDict* getDict() const { return this; } + virtual TagDict *getDict() { return this; } + virtual const TagDict *getDict() const { return this; } virtual XBool isDict() const { return true; } virtual const XString8 getTypeAsXString8() const { return "Dict"_XS8; } - static TagDict* getEmptyTag(); + static TagDict *getEmptyTag(); virtual void ReleaseTag(); - - virtual void sprintf(unsigned int ident, XString8* s) const; + + virtual void sprintf(unsigned int ident, XString8 *s) const; /* * getters and setters */ - const XObjArray& dictContent() const - { + const XObjArray &dictContent() const { #ifdef JIEF_DEBUG - if ( !isDict() ) panic("TagDict::dictContent() : !isDict() "); + if (!isDict()) + panic("TagDict::dictContent() : !isDict() "); #endif return _dictContent; } - XObjArray& dictContent() - { + XObjArray &dictContent() { #ifdef JIEF_DEBUG - if ( !isDict() ) panic("TagDict::dictContent() : !isDict() "); + if (!isDict()) + panic("TagDict::dictContent() : !isDict() "); #endif return _dictContent; } INTN dictKeyCount() const; - EFI_STATUS getKeyAndValueAtIndex(INTN id, const TagKey** key, const TagStruct** value) const; - const TagStruct* propertyForKey(const CHAR8* key ) const; - const TagDict* dictPropertyForKey(const CHAR8* key) const; - const TagArray* arrayPropertyForKey(const CHAR8* key) const; - + EFI_STATUS getKeyAndValueAtIndex(INTN id, const TagKey **key, + const TagStruct **value) const; + const TagStruct *propertyForKey(const CHAR8 *key) const; + const TagDict *dictPropertyForKey(const CHAR8 *key) const; + const TagArray *arrayPropertyForKey(const CHAR8 *key) const; }; - EFI_STATUS -ParseXML( - CONST UINT8 *buffer, - TagDict** dict, - size_t bufSize - ); - - +ParseXML(CONST UINT8 *buffer, TagDict **dict, size_t bufSize); #endif /* __TagDict_h__ */ diff --git a/rEFIt_UEFI/Settings/ConfigPlist/Config_Quirks.h b/rEFIt_UEFI/Settings/ConfigPlist/Config_Quirks.h index 76aeab86b3..9b73677457 100644 --- a/rEFIt_UEFI/Settings/ConfigPlist/Config_Quirks.h +++ b/rEFIt_UEFI/Settings/ConfigPlist/Config_Quirks.h @@ -8,210 +8,363 @@ #ifndef _CONFIGPLISTCLASS_QUIRKS_H_ #define _CONFIGPLISTCLASS_QUIRKS_H_ - -class Quirks_Class : public XmlDict -{ +class Quirks_Class : public XmlDict { using super = XmlDict; -public: - - class Quirks_MmioWhitelist_Class : public XmlDict - { +public: + class Quirks_MmioWhitelist_Class : public XmlDict { using super = XmlDict; + public: XmlString8 Comment = XmlString8(); XmlUInt64 Address = XmlUInt64(); XmlBool Enabled = XmlBool(); XmlDictField m_fields[3] = { - {"Comment", Comment}, - {"Address", Address}, - {"Enabled", Enabled}, + {"Comment", Comment}, + {"Address", Address}, + {"Enabled", Enabled}, + }; + + 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 { *fields = m_fields; *nb = sizeof(m_fields)/sizeof(m_fields[0]); }; - - virtual XBool validate(XmlLiteParser* xmlLiteParser, const XString8& xmlPath, const XmlParserPosition& keyPos, XBool generateErrors) override { + virtual XBool validate(XmlLiteParser *xmlLiteParser, + const XString8 &xmlPath, + const XmlParserPosition &keyPos, + XBool generateErrors) override { bool b = super::validate(xmlLiteParser, xmlPath, keyPos, generateErrors); - if ( !Address.isDefined() || Address.value() == 0) { - if ( Enabled.isDefined() && Enabled.value() ) b = xmlLiteParser->addWarning(generateErrors, S8Printf("Enabled is ignored because Address is not defined or 0 in dict '%s:%d'", xmlPath.c_str(), keyPos.getLine())); + if (!Address.isDefined() || Address.value() == 0) { + if (Enabled.isDefined() && Enabled.value()) + b = xmlLiteParser->addWarning( + generateErrors, S8Printf("Enabled is ignored because Address is " + "not defined or 0 in dict '%s:%d'", + xmlPath.c_str(), keyPos.getLine())); } return b; } - static const decltype(Comment)::ValueType& defaultComment; - const decltype(Comment)::ValueType& dgetcomment() const { return Comment.isDefined() ? Comment.value() : defaultComment; }; - const decltype(Address)::ValueType& dgetaddress() const { return Address.isDefined() ? Address.value() : Address.nullValue; }; - const decltype(Enabled)::ValueType& dgetenabled() const { return Enabled.isDefined() ? Enabled.value() : Enabled.nullValue; }; - + static const decltype(Comment)::ValueType &defaultComment; + const decltype(Comment)::ValueType &dgetcomment() const { + return Comment.isDefined() ? Comment.value() : defaultComment; + }; + const decltype(Address)::ValueType &dgetaddress() const { + return Address.isDefined() ? Address.value() : Address.nullValue; + }; + const decltype(Enabled)::ValueType &dgetenabled() const { + return Enabled.isDefined() ? Enabled.value() : Enabled.nullValue; + }; }; + // This is to mimic what's in settings. This is NOT a plist dict section. It + // is just cosmetic. + class OcKernelQuirks_Class { + // const Quirks_Class& parent; + public: + XmlBool AppleXcpmExtraMsrs = XmlBool(); + XmlBool AppleXcpmForceBoost = XmlBool(); + XmlBool DisableIoMapper = XmlBool(); + XmlBool DisableIoMapperMapping = XmlBool(); + XmlBool DisableLinkeditJettison = XmlBool(); + XmlBool DummyPowerManagement = XmlBool(); + XmlBool ExtendBTFeatureFlags = XmlBool(); + XmlBool ExternalDiskIcons = XmlBool(); + XmlBool IncreasePciBarSize = XmlBool(); + XmlBool ForceAquantiaEthernet = XmlBool(); + XmlBool PowerTimeoutKernelPanic = XmlBool(); + XmlBool ThirdPartyDrives = XmlBool(); + XmlBool XhciPortLimit = XmlBool(); + XmlBool ProvideCurrentCpuInfo = XmlBool(); + XBool dgetAppleXcpmExtraMsrs() const { + return AppleXcpmExtraMsrs.isDefined() ? AppleXcpmExtraMsrs.value() + : AppleXcpmExtraMsrs.nullValue; + }; + XBool dgetAppleXcpmForceBoost() const { + return AppleXcpmForceBoost.isDefined() ? AppleXcpmForceBoost.value() + : AppleXcpmForceBoost.nullValue; + }; + XBool dgetDisableIoMapper() const { + return DisableIoMapper.isDefined() ? DisableIoMapper.value() + : DisableIoMapper.nullValue; + }; + XBool dgetDisableIoMapperMapping() const { + return DisableIoMapperMapping.isDefined() + ? DisableIoMapperMapping.value() + : DisableIoMapperMapping.nullValue; + }; + XBool dgetDisableLinkeditJettison() const { + return DisableLinkeditJettison.isDefined() + ? DisableLinkeditJettison.value() + : DisableLinkeditJettison.nullValue; + }; + XBool dgetDummyPowerManagement() const { + return DummyPowerManagement.isDefined() ? DummyPowerManagement.value() + : DummyPowerManagement.nullValue; + }; + XBool dgetExtendBTFeatureFlags() const { + return ExtendBTFeatureFlags.isDefined() ? ExtendBTFeatureFlags.value() + : ExtendBTFeatureFlags.nullValue; + }; + XBool dgetExternalDiskIcons() const { + return ExternalDiskIcons.isDefined() ? ExternalDiskIcons.value() + : ExternalDiskIcons.nullValue; + }; + XBool dgetIncreasePciBarSize() const { + return IncreasePciBarSize.isDefined() ? IncreasePciBarSize.value() + : IncreasePciBarSize.nullValue; + }; + XBool dgetForceAquantiaEthernet() const { + return ForceAquantiaEthernet.isDefined() + ? ForceAquantiaEthernet.value() + : ForceAquantiaEthernet.nullValue; + }; + XBool dgetPowerTimeoutKernelPanic() const { + return PowerTimeoutKernelPanic.isDefined() + ? PowerTimeoutKernelPanic.value() + : PowerTimeoutKernelPanic.nullValue; + }; + XBool dgetThirdPartyDrives() const { + return ThirdPartyDrives.isDefined() ? ThirdPartyDrives.value() + : ThirdPartyDrives.nullValue; + }; + XBool dgetXhciPortLimit() const { + return XhciPortLimit.isDefined() ? XhciPortLimit.value() + : XhciPortLimit.nullValue; + }; + XBool dgetProvideCurrentCpuInfo() const { + return ProvideCurrentCpuInfo.isDefined() + ? ProvideCurrentCpuInfo.value() + : ProvideCurrentCpuInfo.nullValue; + }; - - // This is to mimic what's in settings. This is NOT a plist dict section. It is just cosmetic. - class OcKernelQuirks_Class { - //const Quirks_Class& parent; - public: - XmlBool AppleXcpmExtraMsrs = XmlBool(); - XmlBool AppleXcpmForceBoost = XmlBool(); - XmlBool DisableIoMapper = XmlBool(); - XmlBool DisableLinkeditJettison = XmlBool(); - XmlBool DummyPowerManagement = XmlBool(); - XmlBool ExtendBTFeatureFlags = XmlBool(); - XmlBool ExternalDiskIcons = XmlBool(); - XmlBool IncreasePciBarSize = XmlBool(); - XmlBool ForceAquantiaEthernet = XmlBool(); - XmlBool PowerTimeoutKernelPanic = XmlBool(); - XmlBool ThirdPartyDrives = XmlBool(); - XmlBool XhciPortLimit = XmlBool(); - XmlBool ProvideCurrentCpuInfo = XmlBool(); - - XBool dgetAppleXcpmExtraMsrs() const { return AppleXcpmExtraMsrs.isDefined() ? AppleXcpmExtraMsrs.value() : AppleXcpmExtraMsrs.nullValue; }; - XBool dgetAppleXcpmForceBoost() const { return AppleXcpmForceBoost.isDefined() ? AppleXcpmForceBoost.value() : AppleXcpmForceBoost.nullValue; }; - XBool dgetDisableIoMapper() const { return DisableIoMapper.isDefined() ? DisableIoMapper.value() : DisableIoMapper.nullValue; }; - XBool dgetDisableLinkeditJettison() const { return DisableLinkeditJettison.isDefined() ? DisableLinkeditJettison.value() : DisableLinkeditJettison.nullValue; }; - XBool dgetDummyPowerManagement() const { return DummyPowerManagement.isDefined() ? DummyPowerManagement.value() : DummyPowerManagement.nullValue; }; - XBool dgetExtendBTFeatureFlags() const { return ExtendBTFeatureFlags.isDefined() ? ExtendBTFeatureFlags.value() : ExtendBTFeatureFlags.nullValue; }; - XBool dgetExternalDiskIcons() const { return ExternalDiskIcons.isDefined() ? ExternalDiskIcons.value() : ExternalDiskIcons.nullValue; }; - XBool dgetIncreasePciBarSize() const { return IncreasePciBarSize.isDefined() ? IncreasePciBarSize.value() : IncreasePciBarSize.nullValue; }; - XBool dgetForceAquantiaEthernet() const { return ForceAquantiaEthernet.isDefined() ? ForceAquantiaEthernet.value() : ForceAquantiaEthernet.nullValue; }; - XBool dgetPowerTimeoutKernelPanic() const { return PowerTimeoutKernelPanic.isDefined() ? PowerTimeoutKernelPanic.value() : PowerTimeoutKernelPanic.nullValue; }; - XBool dgetThirdPartyDrives() const { return ThirdPartyDrives.isDefined() ? ThirdPartyDrives.value() : ThirdPartyDrives.nullValue; }; - XBool dgetXhciPortLimit() const { return XhciPortLimit.isDefined() ? XhciPortLimit.value() : XhciPortLimit.nullValue; }; - XBool dgetProvideCurrentCpuInfo() const { return ProvideCurrentCpuInfo.isDefined() ? ProvideCurrentCpuInfo.value() : ProvideCurrentCpuInfo.nullValue; }; - - OcKernelQuirks_Class(const Quirks_Class& _parent) /*: parent(_parent)*/ {} + OcKernelQuirks_Class(const Quirks_Class &_parent) /*: parent(_parent)*/ {} }; - // This is to mimic what's in settings. This is NOT a plist dict section. It is just cosmetic. + // This is to mimic what's in settings. This is NOT a plist dict section. It + // is just cosmetic. class OcBooterQuirks_Class { - const Quirks_Class& parent; - public: - XmlBool AvoidRuntimeDefrag = XmlBool(); - XmlBool DevirtualiseMmio = XmlBool(); - XmlBool DisableSingleUser = XmlBool(); - XmlBool DisableVariableWrite = XmlBool(); - XmlBool DiscardHibernateMap = XmlBool(); - XmlBool EnableSafeModeSlide = XmlBool(); - XmlBool EnableWriteUnprotector = XmlBool(); - XmlBool ForceExitBootServices = XmlBool(); - XmlBool ProtectMemoryRegions = XmlBool(); - XmlBool ProtectSecureBoot = XmlBool(); - XmlBool ProtectUefiServices = XmlBool(); - XmlBool ProvideCustomSlide = XmlBool(); - XmlUInt8 ProvideMaxSlide = XmlUInt8(); - XmlBool RebuildAppleMemoryMap = XmlBool(); - XmlInt8 ResizeAppleGpuBars = XmlInt8(); - XmlBool SetupVirtualMap = XmlBool(); - XmlBool SignalAppleOS = XmlBool(); - XmlBool SyncRuntimePermissions = XmlBool(); - XmlBool ForceOcWriteFlash = XmlBool(); - XmlUInt32 TscSyncTimeout = XmlUInt32(); - - XBool dgetAvoidRuntimeDefrag() const { return parent.isDefined() ? AvoidRuntimeDefrag.isDefined() ? AvoidRuntimeDefrag.value() : XBool(true) : XBool(false); }; // TODO: different default value if section is not defined - XBool dgetDevirtualiseMmio() const { return DevirtualiseMmio.isDefined() ? DevirtualiseMmio.value() : DevirtualiseMmio.nullValue; }; - XBool dgetDisableSingleUser() const { return DisableSingleUser.isDefined() ? DisableSingleUser.value() : DisableSingleUser.nullValue; }; - XBool dgetDisableVariableWrite() const { return DisableVariableWrite.isDefined() ? DisableVariableWrite.value() : DisableVariableWrite.nullValue; }; - XBool dgetDiscardHibernateMap() const { return DiscardHibernateMap.isDefined() ? DiscardHibernateMap.value() : DiscardHibernateMap.nullValue; }; - XBool dgetEnableSafeModeSlide() const { return parent.isDefined() ? EnableSafeModeSlide.isDefined() ? EnableSafeModeSlide.value() : XBool(true) : XBool(false); }; // TODO: different default value if section is not defined - XBool dgetEnableWriteUnprotector() const { return parent.isDefined() ? EnableWriteUnprotector.isDefined() ? EnableWriteUnprotector.value() : XBool(true) : EnableWriteUnprotector.nullValue; }; // TODO: different default value if section is not defined - XBool dgetForceExitBootServices() const { return ForceExitBootServices.isDefined() ? ForceExitBootServices.value() : ForceExitBootServices.nullValue; }; - XBool dgetProtectMemoryRegions() const { return ProtectMemoryRegions.isDefined() ? ProtectMemoryRegions.value() : ProtectMemoryRegions.nullValue; }; - XBool dgetProtectSecureBoot() const { return ProtectSecureBoot.isDefined() ? ProtectSecureBoot.value() : ProtectSecureBoot.nullValue; }; - XBool dgetProtectUefiServices() const { return ProtectUefiServices.isDefined() ? ProtectUefiServices.value() : ProtectUefiServices.nullValue; }; - XBool dgetProvideCustomSlide() const { return ProvideCustomSlide.isDefined() ? ProvideCustomSlide.value() : ProvideCustomSlide.nullValue; }; - uint8_t dgetProvideMaxSlide() const { return ProvideMaxSlide.isDefined() ? ProvideMaxSlide.value() : ProvideMaxSlide.nullValue; }; - XBool dgetRebuildAppleMemoryMap() const { return RebuildAppleMemoryMap.isDefined() ? RebuildAppleMemoryMap.value() : RebuildAppleMemoryMap.nullValue; }; - XBool dgetSetupVirtualMap() const { return parent.isDefined() ? SetupVirtualMap.isDefined() ? SetupVirtualMap.value() : XBool(true) : SetupVirtualMap.nullValue; }; // TODO: different default value if section is not defined - XBool dgetSignalAppleOS() const { return SignalAppleOS.isDefined() ? SignalAppleOS.value() : SignalAppleOS.nullValue; }; - XBool dgetSyncRuntimePermissions() const { return parent.isDefined() ? SyncRuntimePermissions.isDefined() ? SyncRuntimePermissions.value() : XBool(true) : XBool(false); }; // TODO: different default value if section is not defined - int8_t dgetResizeAppleGpuBars() const { return parent.isDefined() && ResizeAppleGpuBars.isDefined() ? ResizeAppleGpuBars.value() : -1; }; - XBool dgetForceOcWriteFlash() const { return ForceOcWriteFlash.isDefined() ? ForceOcWriteFlash.value() : XBool(false); }; - uint32_t dgetTscSyncTimeout() const { return TscSyncTimeout.isDefined() ? TscSyncTimeout.value() : 0; }; - OcBooterQuirks_Class(const Quirks_Class& _parent) : parent(_parent) {} + const Quirks_Class &parent; + + public: + XmlBool AvoidRuntimeDefrag = XmlBool(); + XmlBool DevirtualiseMmio = XmlBool(); + XmlBool DisableSingleUser = XmlBool(); + XmlBool DisableVariableWrite = XmlBool(); + XmlBool DiscardHibernateMap = XmlBool(); + XmlBool EnableSafeModeSlide = XmlBool(); + XmlBool EnableWriteUnprotector = XmlBool(); + XmlBool ForceExitBootServices = XmlBool(); + XmlBool ProtectMemoryRegions = XmlBool(); + XmlBool ProtectSecureBoot = XmlBool(); + XmlBool ProtectUefiServices = XmlBool(); + XmlBool ProvideCustomSlide = XmlBool(); + XmlUInt8 ProvideMaxSlide = XmlUInt8(); + XmlBool RebuildAppleMemoryMap = XmlBool(); + XmlInt8 ResizeAppleGpuBars = XmlInt8(); + XmlInt8 ResizeGpuBars = XmlInt8(); + XmlBool SetupVirtualMap = XmlBool(); + XmlBool SignalAppleOS = XmlBool(); + XmlBool SyncRuntimePermissions = XmlBool(); + XmlBool ForceOcWriteFlash = XmlBool(); + XmlUInt32 TscSyncTimeout = XmlUInt32(); + + XBool dgetAvoidRuntimeDefrag() const { + return parent.isDefined() ? AvoidRuntimeDefrag.isDefined() + ? AvoidRuntimeDefrag.value() + : XBool(true) + : XBool(false); + }; // TODO: different default value if section is not defined + XBool dgetDevirtualiseMmio() const { + return DevirtualiseMmio.isDefined() ? DevirtualiseMmio.value() + : DevirtualiseMmio.nullValue; + }; + XBool dgetDisableSingleUser() const { + return DisableSingleUser.isDefined() ? DisableSingleUser.value() + : DisableSingleUser.nullValue; + }; + XBool dgetDisableVariableWrite() const { + return DisableVariableWrite.isDefined() ? DisableVariableWrite.value() + : DisableVariableWrite.nullValue; + }; + XBool dgetDiscardHibernateMap() const { + return DiscardHibernateMap.isDefined() ? DiscardHibernateMap.value() + : DiscardHibernateMap.nullValue; + }; + XBool dgetEnableSafeModeSlide() const { + return parent.isDefined() ? EnableSafeModeSlide.isDefined() + ? EnableSafeModeSlide.value() + : XBool(true) + : XBool(false); + }; // TODO: different default value if section is not defined + XBool dgetEnableWriteUnprotector() const { + return parent.isDefined() ? EnableWriteUnprotector.isDefined() + ? EnableWriteUnprotector.value() + : XBool(true) + : EnableWriteUnprotector.nullValue; + }; // TODO: different default value if section is not defined + XBool dgetForceExitBootServices() const { + return ForceExitBootServices.isDefined() + ? ForceExitBootServices.value() + : ForceExitBootServices.nullValue; + }; + XBool dgetProtectMemoryRegions() const { + return ProtectMemoryRegions.isDefined() ? ProtectMemoryRegions.value() + : ProtectMemoryRegions.nullValue; + }; + XBool dgetProtectSecureBoot() const { + return ProtectSecureBoot.isDefined() ? ProtectSecureBoot.value() + : ProtectSecureBoot.nullValue; + }; + XBool dgetProtectUefiServices() const { + return ProtectUefiServices.isDefined() ? ProtectUefiServices.value() + : ProtectUefiServices.nullValue; + }; + XBool dgetProvideCustomSlide() const { + return ProvideCustomSlide.isDefined() ? ProvideCustomSlide.value() + : ProvideCustomSlide.nullValue; + }; + uint8_t dgetProvideMaxSlide() const { + return ProvideMaxSlide.isDefined() ? ProvideMaxSlide.value() + : ProvideMaxSlide.nullValue; + }; + XBool dgetRebuildAppleMemoryMap() const { + return RebuildAppleMemoryMap.isDefined() + ? RebuildAppleMemoryMap.value() + : RebuildAppleMemoryMap.nullValue; + }; + XBool dgetSetupVirtualMap() const { + return parent.isDefined() ? SetupVirtualMap.isDefined() + ? SetupVirtualMap.value() + : XBool(true) + : SetupVirtualMap.nullValue; + }; // TODO: different default value if section is not defined + XBool dgetSignalAppleOS() const { + return SignalAppleOS.isDefined() ? SignalAppleOS.value() + : SignalAppleOS.nullValue; + }; + XBool dgetSyncRuntimePermissions() const { + return parent.isDefined() ? SyncRuntimePermissions.isDefined() + ? SyncRuntimePermissions.value() + : XBool(true) + : XBool(false); + }; // TODO: different default value if section is not defined + int8_t dgetResizeAppleGpuBars() const { + return parent.isDefined() && ResizeAppleGpuBars.isDefined() + ? ResizeAppleGpuBars.value() + : -1; + }; + int8_t dgetResizeGpuBars() const { + return parent.isDefined() && ResizeGpuBars.isDefined() + ? ResizeGpuBars.value() + : -1; + }; + XBool dgetForceOcWriteFlash() const { + return ForceOcWriteFlash.isDefined() ? ForceOcWriteFlash.value() + : XBool(false); + }; + uint32_t dgetTscSyncTimeout() const { + return TscSyncTimeout.isDefined() ? TscSyncTimeout.value() : 0; + }; + OcBooterQuirks_Class(const Quirks_Class &_parent) : parent(_parent) {} }; - XmlArray MmioWhitelist = XmlArray(); + XmlArray MmioWhitelist = + XmlArray(); + protected: XmlBool FuzzyMatch = XmlBool(); XmlString8AllowEmpty KernelCache = XmlString8AllowEmpty(); -// XmlBool ProvideConsoleGopEnable = XmlBool(); + // XmlBool ProvideConsoleGopEnable = XmlBool(); public: OcKernelQuirks_Class OcKernelQuirks; OcBooterQuirks_Class OcBooterQuirks; - XmlDictField m_fields[36] = { - {"AvoidRuntimeDefrag", OcBooterQuirks.AvoidRuntimeDefrag}, - {"DevirtualiseMmio", OcBooterQuirks.DevirtualiseMmio}, - {"DisableSingleUser", OcBooterQuirks.DisableSingleUser}, - {"DisableVariableWrite", OcBooterQuirks.DisableVariableWrite}, - {"DiscardHibernateMap", OcBooterQuirks.DiscardHibernateMap}, - {"EnableSafeModeSlide", OcBooterQuirks.EnableSafeModeSlide}, - {"EnableWriteUnprotector", OcBooterQuirks.EnableWriteUnprotector}, - {"ForceExitBootServices", OcBooterQuirks.ForceExitBootServices}, - {"ForceOcWriteFlash", OcBooterQuirks.ForceOcWriteFlash}, - {"ProtectMemoryRegions", OcBooterQuirks.ProtectMemoryRegions}, - {"ProtectSecureBoot", OcBooterQuirks.ProtectSecureBoot}, - {"ProtectUefiServices", OcBooterQuirks.ProtectUefiServices}, - {"ProvideCustomSlide", OcBooterQuirks.ProvideCustomSlide}, - {"ProvideMaxSlide", OcBooterQuirks.ProvideMaxSlide}, - {"RebuildAppleMemoryMap", OcBooterQuirks.RebuildAppleMemoryMap}, - {"ResizeAppleGpuBars", OcBooterQuirks.ResizeAppleGpuBars}, - {"SetupVirtualMap", OcBooterQuirks.SetupVirtualMap}, - {"SignalAppleOS", OcBooterQuirks.SignalAppleOS}, - {"SyncRuntimePermissions", OcBooterQuirks.SyncRuntimePermissions}, - {"TscSyncTimeout", OcBooterQuirks.TscSyncTimeout}, - {"MmioWhitelist", MmioWhitelist}, - {"FuzzyMatch", FuzzyMatch}, - {"KernelCache", KernelCache}, - {"AppleXcpmExtraMsrs", OcKernelQuirks.AppleXcpmExtraMsrs}, - {"AppleXcpmForceBoost", OcKernelQuirks.AppleXcpmForceBoost}, - {"DisableIoMapper", OcKernelQuirks.DisableIoMapper}, - {"DisableLinkeditJettison", OcKernelQuirks.DisableLinkeditJettison}, - {"DummyPowerManagement", OcKernelQuirks.DummyPowerManagement}, - {"ExtendBTFeatureFlags", OcKernelQuirks.ExtendBTFeatureFlags}, - {"ExternalDiskIcons", OcKernelQuirks.ExternalDiskIcons}, - {"IncreasePciBarSize", OcKernelQuirks.IncreasePciBarSize}, - {"ForceAquantiaEthernet", OcKernelQuirks.ForceAquantiaEthernet}, - {"PowerTimeoutKernelPanic", OcKernelQuirks.PowerTimeoutKernelPanic}, - {"ThirdPartyDrives", OcKernelQuirks.ThirdPartyDrives}, - {"XhciPortLimit", OcKernelQuirks.XhciPortLimit}, - {"ProvideCurrentCpuInfo", OcKernelQuirks.ProvideCurrentCpuInfo}, + XmlDictField m_fields[38] = { + {"AvoidRuntimeDefrag", OcBooterQuirks.AvoidRuntimeDefrag}, + {"DevirtualiseMmio", OcBooterQuirks.DevirtualiseMmio}, + {"DisableSingleUser", OcBooterQuirks.DisableSingleUser}, + {"DisableVariableWrite", OcBooterQuirks.DisableVariableWrite}, + {"DiscardHibernateMap", OcBooterQuirks.DiscardHibernateMap}, + {"EnableSafeModeSlide", OcBooterQuirks.EnableSafeModeSlide}, + {"EnableWriteUnprotector", OcBooterQuirks.EnableWriteUnprotector}, + {"ForceExitBootServices", OcBooterQuirks.ForceExitBootServices}, + {"ForceOcWriteFlash", OcBooterQuirks.ForceOcWriteFlash}, + {"ProtectMemoryRegions", OcBooterQuirks.ProtectMemoryRegions}, + {"ProtectSecureBoot", OcBooterQuirks.ProtectSecureBoot}, + {"ProtectUefiServices", OcBooterQuirks.ProtectUefiServices}, + {"ProvideCustomSlide", OcBooterQuirks.ProvideCustomSlide}, + {"ProvideMaxSlide", OcBooterQuirks.ProvideMaxSlide}, + {"RebuildAppleMemoryMap", OcBooterQuirks.RebuildAppleMemoryMap}, + {"ResizeAppleGpuBars", OcBooterQuirks.ResizeAppleGpuBars}, + {"ResizeGpuBars", OcBooterQuirks.ResizeGpuBars}, + {"SetupVirtualMap", OcBooterQuirks.SetupVirtualMap}, + {"SignalAppleOS", OcBooterQuirks.SignalAppleOS}, + {"SyncRuntimePermissions", OcBooterQuirks.SyncRuntimePermissions}, + {"TscSyncTimeout", OcBooterQuirks.TscSyncTimeout}, + {"MmioWhitelist", MmioWhitelist}, + {"FuzzyMatch", FuzzyMatch}, + {"KernelCache", KernelCache}, + {"AppleXcpmExtraMsrs", OcKernelQuirks.AppleXcpmExtraMsrs}, + {"AppleXcpmForceBoost", OcKernelQuirks.AppleXcpmForceBoost}, + {"DisableIoMapper", OcKernelQuirks.DisableIoMapper}, + {"DisableIoMapperMapping", OcKernelQuirks.DisableIoMapperMapping}, + {"DisableLinkeditJettison", OcKernelQuirks.DisableLinkeditJettison}, + {"DummyPowerManagement", OcKernelQuirks.DummyPowerManagement}, + {"ExtendBTFeatureFlags", OcKernelQuirks.ExtendBTFeatureFlags}, + {"ExternalDiskIcons", OcKernelQuirks.ExternalDiskIcons}, + {"IncreasePciBarSize", OcKernelQuirks.IncreasePciBarSize}, + {"ForceAquantiaEthernet", OcKernelQuirks.ForceAquantiaEthernet}, + {"PowerTimeoutKernelPanic", OcKernelQuirks.PowerTimeoutKernelPanic}, + {"ThirdPartyDrives", OcKernelQuirks.ThirdPartyDrives}, + {"XhciPortLimit", OcKernelQuirks.XhciPortLimit}, + {"ProvideCurrentCpuInfo", OcKernelQuirks.ProvideCurrentCpuInfo}, }; Quirks_Class() : OcKernelQuirks(*this), OcBooterQuirks(*this) {} - - virtual void getFields(XmlDictField** fields, size_t* nb) override { *fields = m_fields; *nb = sizeof(m_fields)/sizeof(m_fields[0]); }; - - virtual XBool validate(XmlLiteParser* xmlLiteParser, const XString8& xmlPath, const XmlParserPosition& keyPos, XBool generateErrors) override { + + virtual void getFields(XmlDictField **fields, size_t *nb) override { + *fields = m_fields; + *nb = sizeof(m_fields) / sizeof(m_fields[0]); + }; + + virtual XBool validate(XmlLiteParser *xmlLiteParser, const XString8 &xmlPath, + const XmlParserPosition &keyPos, + XBool generateErrors) override { bool b = super::validate(xmlLiteParser, xmlPath, keyPos, generateErrors); return b; } - const decltype(FuzzyMatch)::ValueType& dgetFuzzyMatch() const { return FuzzyMatch.isDefined() ? FuzzyMatch.value() : FuzzyMatch.nullValue; }; - const decltype(KernelCache)::ValueType& dgetOcKernelCache() const { return KernelCache.isDefined() ? KernelCache.value() : KernelCache.nullValue; }; -// XBool dgetProvideConsoleGop() const { return ProvideConsoleGopEnable.isDefined() ? ProvideConsoleGopEnable.value() : ProvideConsoleGopEnable.nullValue; }; + const decltype(FuzzyMatch)::ValueType &dgetFuzzyMatch() const { + return FuzzyMatch.isDefined() ? FuzzyMatch.value() : FuzzyMatch.nullValue; + }; + const decltype(KernelCache)::ValueType &dgetOcKernelCache() const { + return KernelCache.isDefined() ? KernelCache.value() + : KernelCache.nullValue; + }; + // XBool dgetProvideConsoleGop() const { return + // ProvideConsoleGopEnable.isDefined() ? ProvideConsoleGopEnable.value() : + // ProvideConsoleGopEnable.nullValue; }; UINT32 dgetQuirksMask() const { UINT32 mask = 0; - mask |= OcBooterQuirks.dgetAvoidRuntimeDefrag() ? QUIRK_DEFRAG:0; - mask |= OcBooterQuirks.dgetDevirtualiseMmio() ? QUIRK_MMIO:0; - mask |= OcBooterQuirks.dgetDisableSingleUser() ? QUIRK_SU:0; - mask |= OcBooterQuirks.dgetDisableVariableWrite() ? QUIRK_VAR:0; - mask |= OcBooterQuirks.dgetDiscardHibernateMap() ? QUIRK_HIBER:0; - mask |= OcBooterQuirks.dgetEnableSafeModeSlide() ? QUIRK_SAFE:0; - mask |= OcBooterQuirks.dgetEnableWriteUnprotector() ? QUIRK_UNPROT:0; - mask |= OcBooterQuirks.dgetForceExitBootServices() ? QUIRK_EXIT:0; - mask |= OcBooterQuirks.dgetProtectMemoryRegions() ? QUIRK_REGION:0; - mask |= OcBooterQuirks.dgetProtectSecureBoot() ? QUIRK_SECURE:0; - mask |= OcBooterQuirks.dgetProtectUefiServices() ? QUIRK_UEFI:0; - mask |= OcBooterQuirks.dgetProvideCustomSlide() ? QUIRK_CUSTOM:0; - mask |= OcBooterQuirks.dgetRebuildAppleMemoryMap() ? QUIRK_MAP:0; - mask |= OcBooterQuirks.dgetSetupVirtualMap() ? QUIRK_VIRT:0; - mask |= OcBooterQuirks.dgetSignalAppleOS() ? QUIRK_OS:0; - mask |= OcBooterQuirks.dgetSyncRuntimePermissions() ? QUIRK_PERM:0; + mask |= OcBooterQuirks.dgetAvoidRuntimeDefrag() ? QUIRK_DEFRAG : 0; + mask |= OcBooterQuirks.dgetDevirtualiseMmio() ? QUIRK_MMIO : 0; + mask |= OcBooterQuirks.dgetDisableSingleUser() ? QUIRK_SU : 0; + mask |= OcBooterQuirks.dgetDisableVariableWrite() ? QUIRK_VAR : 0; + mask |= OcBooterQuirks.dgetDiscardHibernateMap() ? QUIRK_HIBER : 0; + mask |= OcBooterQuirks.dgetEnableSafeModeSlide() ? QUIRK_SAFE : 0; + mask |= OcBooterQuirks.dgetEnableWriteUnprotector() ? QUIRK_UNPROT : 0; + mask |= OcBooterQuirks.dgetForceExitBootServices() ? QUIRK_EXIT : 0; + mask |= OcBooterQuirks.dgetProtectMemoryRegions() ? QUIRK_REGION : 0; + mask |= OcBooterQuirks.dgetProtectSecureBoot() ? QUIRK_SECURE : 0; + mask |= OcBooterQuirks.dgetProtectUefiServices() ? QUIRK_UEFI : 0; + mask |= OcBooterQuirks.dgetProvideCustomSlide() ? QUIRK_CUSTOM : 0; + mask |= OcBooterQuirks.dgetRebuildAppleMemoryMap() ? QUIRK_MAP : 0; + mask |= OcBooterQuirks.dgetSetupVirtualMap() ? QUIRK_VIRT : 0; + mask |= OcBooterQuirks.dgetSignalAppleOS() ? QUIRK_OS : 0; + mask |= OcBooterQuirks.dgetSyncRuntimePermissions() ? QUIRK_PERM : 0; return mask; }; - }; - #endif /* _CONFIGPLISTCLASS_QUIRKS_H_ */ diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 08ac5909ec..7c1e5437fe 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -42,62 +42,60 @@ #include "../cpp_lib/MemoryTracker.h" #include "../cpp_unit_test/all_tests.h" -#include "../entry_scan/entry_scan.h" -#include "../libeg/nanosvg.h" -#include "../gui/menu_items/menu_globals.h" -#include "menu.h" -#include "../Platform/Utils.h" -#include "../Platform/Settings.h" -#include "../Platform/DataHubCpu.h" -#include "../Platform/Events.h" -#include "screen.h" -#include "../entry_scan/bootscreen.h" -#include "../Platform/Nvram.h" -#include "../entry_scan/common.h" -#include "../gui/shared_with_menu.h" -#include "../Platform/platformdata.h" -#include "../Platform/guid.h" #include "../Platform/APFS.h" -#include "../Platform/cpu.h" -#include "../Platform/smbios.h" #include "../Platform/AcpiPatcher.h" +#include "../Platform/BasicIO.h" +#include "../Platform/BootOptions.h" +#include "../Platform/CloverVersion.h" +#include "../Platform/Console.h" +#include "../Platform/DataHubCpu.h" +#include "../Platform/Edid.h" +#include "../Platform/Events.h" #include "../Platform/Hibernate.h" +#include "../Platform/Injectors.h" +#include "../Platform/KextList.h" #include "../Platform/LegacyBoot.h" +#include "../Platform/Nvram.h" #include "../Platform/PlatformDriverOverride.h" -#include "../Platform/Edid.h" -#include "../Platform/Console.h" -#include "../Platform/spd.h" -#include "../Platform/Injectors.h" +#include "../Platform/Settings.h" +#include "../Platform/SmbiosFillPatchingValues.h" #include "../Platform/StartupSound.h" -#include "../Platform/BootOptions.h" +#include "../Platform/Utils.h" #include "../Platform/boot.h" -#include "../Platform/kext_inject.h" +#include "../Platform/cpu.h" #include "../Platform/device_inject.h" -#include "../Platform/KextList.h" -#include "../gui/REFIT_MENU_SCREEN.h" -#include "../gui/REFIT_MAINMENU_SCREEN.h" +#include "../Platform/guid.h" +#include "../Platform/kext_inject.h" +#include "../Platform/platformdata.h" +#include "../Platform/smbios.h" +#include "../Platform/spd.h" +#include "../Settings/ConfigManager.h" #include "../Settings/Self.h" #include "../Settings/SelfOem.h" -#include "../Platform/BasicIO.h" -#include "../include/OSTypes.h" +#include "../entry_scan/bootscreen.h" +#include "../entry_scan/common.h" +#include "../entry_scan/entry_scan.h" +#include "../gui/REFIT_MAINMENU_SCREEN.h" +#include "../gui/REFIT_MENU_SCREEN.h" +#include "../gui/menu_items/menu_globals.h" +#include "../gui/shared_with_menu.h" #include "../include/OSFlags.h" +#include "../include/OSTypes.h" #include "../libeg/XTheme.h" -#include "../Settings/ConfigManager.h" -#include "../Platform/CloverVersion.h" -#include "../Platform/SmbiosFillPatchingValues.h" +#include "../libeg/nanosvg.h" +#include "menu.h" +#include "screen.h" #include "../include/OC.h" - - #ifndef DEBUG_ALL -# ifdef DEBUG_ERALY_CRASH -# define DEBUG_MAIN 2 -# else -# define DEBUG_MAIN 1 -# endif +#ifdef DEBUG_ERALY_CRASH +#define DEBUG_MAIN 2 +#else +#define DEBUG_MAIN 1 +#endif #else -# define DEBUG_MAIN DEBUG_ALL +#define DEBUG_MAIN DEBUG_ALL #endif #if DEBUG_MAIN == 0 @@ -110,43 +108,40 @@ #define HIBERNATE 0 #endif - #ifndef CHECK_SMC #define CHECK_SMC 0 #endif - #define PCAT_RTC_ADDRESS_REGISTER 0x70 -#define PCAT_RTC_DATA_REGISTER 0x71 +#define PCAT_RTC_DATA_REGISTER 0x71 #ifdef JIEF_DEBUG - /* - * 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 +/* + * 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 #endif // variables - EFI_PHYSICAL_ADDRESS SomePages = EFI_SYSTEM_TABLE_MAX_ADDRESS; //0xFE000000;? - -XBool gGuiIsReady = false; -XBool gThemeNeedInit = true; -XBool DoHibernateWake = false; -UINT32 mCurrentColor; +EFI_PHYSICAL_ADDRESS SomePages = EFI_SYSTEM_TABLE_MAX_ADDRESS; // 0xFE000000;? -extern UINT32 gFakeCPUID; +XBool gGuiIsReady = false; +XBool gThemeNeedInit = true; +XBool DoHibernateWake = false; +UINT32 mCurrentColor; +extern UINT32 gFakeCPUID; EFI_HANDLE AudioDriverHandle; XStringW OpenRuntimeEfiName; @@ -154,45 +149,44 @@ XStringW OpenRuntimeEfiName; extern void HelpRefit(void); extern void AboutRefit(void); extern EFI_AUDIO_IO_PROTOCOL *AudioIo; -extern EFI_DXE_SERVICES *gDS; +extern EFI_DXE_SERVICES *gDS; EFI_PHYSICAL_ADDRESS ExtraSpace = EFI_SYSTEM_TABLE_MAX_ADDRESS; -void PrintMemoryMap() -{ - apd MemMap; - UINTN MemMapSize; - UINTN MapKey, DescriptorSize; - UINT32 DescriptorVersion; - EFI_STATUS Status; +void PrintMemoryMap() { + apd MemMap; + UINTN MemMapSize; + UINTN MapKey, DescriptorSize; + UINT32 DescriptorVersion; + EFI_STATUS Status; MemMapSize = 0; DescriptorSize = 0; - Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion); + Status = gBS->GetMemoryMap(&MemMapSize, MemMap, &MapKey, &DescriptorSize, + &DescriptorVersion); if (Status != EFI_BUFFER_TOO_SMALL) { - DBG("PrintMemoryMap: GetMemStatus=%s not EFI_BUFFER_TOO_SMALL\n", efiStrError(Status)); + DBG("PrintMemoryMap: GetMemStatus=%s not EFI_BUFFER_TOO_SMALL\n", + efiStrError(Status)); return; } MemMapSize += EFI_PAGE_SIZE; - MemMap = (EFI_MEMORY_DESCRIPTOR*)AllocatePool(MemMapSize); + MemMap = (EFI_MEMORY_DESCRIPTOR *)AllocatePool(MemMapSize); - Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion); - if ( EFI_ERROR(Status) ) { + Status = gBS->GetMemoryMap(&MemMapSize, MemMap, &MapKey, &DescriptorSize, + &DescriptorVersion); + if (EFI_ERROR(Status)) { DBG("PrintMemoryMap: GetMemoryMap failed=%s\n", efiStrError(Status)); return; } #ifndef JIEF_DEBUG - EFI_MEMORY_DESCRIPTOR* MemMapPtr = MemMap; - - for (UINTN Index = 0; Index < MemMapSize / DescriptorSize; Index ++) { - UINT64 Bytes = LShiftU64 (MemMapPtr->NumberOfPages, 12); - DEBUG ((EFI_D_ERROR, "%llX-%llX %llX %llX %X\n", - MemMapPtr->PhysicalStart, - MemMapPtr->PhysicalStart + Bytes - 1, - MemMapPtr->NumberOfPages, - MemMapPtr->Attribute, - MemMapPtr->Type)); + EFI_MEMORY_DESCRIPTOR *MemMapPtr = MemMap; + + for (UINTN Index = 0; Index < MemMapSize / DescriptorSize; Index++) { + UINT64 Bytes = LShiftU64(MemMapPtr->NumberOfPages, 12); + DEBUG((EFI_D_ERROR, "%llX-%llX %llX %llX %X\n", MemMapPtr->PhysicalStart, + MemMapPtr->PhysicalStart + Bytes - 1, MemMapPtr->NumberOfPages, + MemMapPtr->Attribute, MemMapPtr->Type)); MemMapPtr = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemMapPtr + DescriptorSize); } #else @@ -200,185 +194,173 @@ void PrintMemoryMap() #endif } -void AllocSmallBlocks(UINTN NumberOfPagesMax) -{ - EFI_MEMORY_DESCRIPTOR *MemMap; - UINTN MemMapSize; - UINTN MapKey, DescriptorSize; - UINT32 DescriptorVersion; - EFI_STATUS Status; - +void AllocSmallBlocks(UINTN NumberOfPagesMax) { + EFI_MEMORY_DESCRIPTOR *MemMap; + UINTN MemMapSize; + UINTN MapKey, DescriptorSize; + UINT32 DescriptorVersion; + EFI_STATUS Status; MemMapSize = 0; - MemMap = NULL; + MemMap = NULL; DescriptorSize = 0; - Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion); + Status = gBS->GetMemoryMap(&MemMapSize, MemMap, &MapKey, &DescriptorSize, + &DescriptorVersion); if (Status != EFI_BUFFER_TOO_SMALL) { - DBG("PrintMemoryMap: GetMemStatus=%s not EFI_BUFFER_TOO_SMALL\n", efiStrError(Status)); + DBG("PrintMemoryMap: GetMemStatus=%s not EFI_BUFFER_TOO_SMALL\n", + efiStrError(Status)); return; } MemMapSize += EFI_PAGE_SIZE; - MemMap = (EFI_MEMORY_DESCRIPTOR*)AllocatePool(MemMapSize); + MemMap = (EFI_MEMORY_DESCRIPTOR *)AllocatePool(MemMapSize); - Status = gBS->GetMemoryMap (&MemMapSize, MemMap, &MapKey, &DescriptorSize, &DescriptorVersion); - if ( EFI_ERROR(Status) ) { + Status = gBS->GetMemoryMap(&MemMapSize, MemMap, &MapKey, &DescriptorSize, + &DescriptorVersion); + if (EFI_ERROR(Status)) { DBG("PrintMemoryMap: GetMemoryMap failed=%s\n", efiStrError(Status)); return; } - for ( - EFI_MEMORY_DESCRIPTOR* EntryWalker = MemMap; + for (EFI_MEMORY_DESCRIPTOR *EntryWalker = MemMap; (UINT8 *)EntryWalker < ((UINT8 *)MemMap + MemMapSize); - EntryWalker = NEXT_MEMORY_DESCRIPTOR (EntryWalker, DescriptorSize)) - { + EntryWalker = NEXT_MEMORY_DESCRIPTOR(EntryWalker, DescriptorSize)) { if (EntryWalker->Type != EfiConventionalMemory) { continue; } - if ( (UINTN)EntryWalker->NumberOfPages < NumberOfPagesMax ) - { - gBS->AllocatePages(AllocateAddress, EfiBootServicesData, EntryWalker->NumberOfPages, &EntryWalker->PhysicalStart); + if ((UINTN)EntryWalker->NumberOfPages < NumberOfPagesMax) { + gBS->AllocatePages(AllocateAddress, EfiBootServicesData, + EntryWalker->NumberOfPages, + &EntryWalker->PhysicalStart); } } FreePool(MemMap); } -void AllocSmallBlocks() -{ - CONST EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable; +void AllocSmallBlocks() { + CONST EFI_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable; -//PrintMemoryMap(); + // PrintMemoryMap(); UINTN size = 64; UINTN nb = 0; AllocSmallBlocks(size); // 252KB - MemoryAttributesTable = OcGetMemoryAttributes (NULL); + MemoryAttributesTable = OcGetMemoryAttributes(NULL); nb = MemoryAttributesTable->NumberOfEntries; -//PrintMemoryMap(); - while ( size <= 2048 && nb > 100 ) { // XNU seems to handle max 128 entries. So let's shrink a little bit under 128 + // PrintMemoryMap(); + while (size <= 2048 && nb > 100) { // XNU seems to handle max 128 entries. So + // let's shrink a little bit under 128 size *= 2; AllocSmallBlocks(size); - MemoryAttributesTable = OcGetMemoryAttributes (NULL); + MemoryAttributesTable = OcGetMemoryAttributes(NULL); nb = MemoryAttributesTable->NumberOfEntries; -//PrintMemoryMap(); + // PrintMemoryMap(); } - if ( size > 2048 ) { + if (size > 2048) { DBG("Cannot shrink memory map enough. Nb entries = %lld\n", nb); } } OC_GLOBAL_CONFIG - mOpenCoreConfiguration; +mOpenCoreConfiguration; OC_STORAGE_CONTEXT - mOpenCoreStorage; +mOpenCoreStorage; OC_CPU_INFO - mOpenCoreCpuInfo; +mOpenCoreCpuInfo; UINT8 - mOpenCoreBooterHash[SHA1_DIGEST_SIZE]; +mOpenCoreBooterHash[SHA1_DIGEST_SIZE]; -OC_RSA_PUBLIC_KEY * - mOpenCoreVaultKey; +OC_RSA_PUBLIC_KEY *mOpenCoreVaultKey; OC_PRIVILEGE_CONTEXT - mOpenCorePrivilege; +mOpenCorePrivilege; EFI_HANDLE - mStorageHandle; +mStorageHandle; -EFI_DEVICE_PATH_PROTOCOL * - mStoragePath; +EFI_DEVICE_PATH_PROTOCOL *mStoragePath; -CHAR16 * - mStorageRoot; +CHAR16 *mStorageRoot; -VOID -OcMain ( - IN OC_STORAGE_CONTEXT *Storage, - IN EFI_DEVICE_PATH_PROTOCOL *LoadPath - ) -{ - EFI_STATUS Status; -// OC_PRIVILEGE_CONTEXT *Privilege; +VOID OcMain(IN OC_STORAGE_CONTEXT *Storage, + IN EFI_DEVICE_PATH_PROTOCOL *LoadPath) { + EFI_STATUS Status; + // OC_PRIVILEGE_CONTEXT *Privilege; DBG("OC: OcMiscEarlyInit...\n"); - Status = OcMiscEarlyInit ( - Storage, - &mOpenCoreConfiguration, - mOpenCoreVaultKey - ); + Status = OcMiscEarlyInit(Storage, &mOpenCoreConfiguration, mOpenCoreVaultKey); DBG("OC: OcMiscEarlyInit=%s\n", efiStrError(Status)); - if (EFI_ERROR (Status)) { + if (EFI_ERROR(Status)) { return; } -// OcCpuScanProcessor (&mOpenCoreCpuInfo); + // OcCpuScanProcessor (&mOpenCoreCpuInfo); -// DEBUG ((DEBUG_INFO, "OC: OcLoadNvramSupport...\n")); -// OcLoadNvramSupport (Storage, &mOpenCoreConfiguration); + // DEBUG ((DEBUG_INFO, "OC: OcLoadNvramSupport...\n")); + // OcLoadNvramSupport (Storage, &mOpenCoreConfiguration); DBG("OC: OcMiscMiddleInit...\n"); - OcMiscMiddleInit ( - Storage, - &mOpenCoreConfiguration, - mStorageRoot, - LoadPath, - mStorageHandle, - mOpenCoreConfiguration.Booter.Quirks.ForceBooterSignature ? mOpenCoreBooterHash : NULL - ); + OcMiscMiddleInit(Storage, &mOpenCoreConfiguration, mStorageRoot, LoadPath, + mStorageHandle, + mOpenCoreConfiguration.Booter.Quirks.ForceBooterSignature + ? mOpenCoreBooterHash + : NULL); DBG("OC: OcLoadUefiSupport...\n"); - OcLoadUefiSupport (Storage, &mOpenCoreConfiguration, &mOpenCoreCpuInfo, mOpenCoreBooterHash); + OcLoadUefiSupport(Storage, &mOpenCoreConfiguration, &mOpenCoreCpuInfo, + mOpenCoreBooterHash); #ifdef USE_OC_SECTION_Acpi DBG("OC: OcLoadAcpiSupport...\n"); - OcLoadAcpiSupport (&mOpenCoreStorage, &mOpenCoreConfiguration); + OcLoadAcpiSupport(&mOpenCoreStorage, &mOpenCoreConfiguration); #endif -// DBG("OC: OcLoadPlatformSupport...\n")); -// OcLoadPlatformSupport (&mOpenCoreConfiguration, &mOpenCoreCpuInfo); -// DBG("OC: OcLoadDevPropsSupport...\n")); -// OcLoadDevPropsSupport (&mOpenCoreConfiguration); + // DBG("OC: OcLoadPlatformSupport...\n")); + // OcLoadPlatformSupport (&mOpenCoreConfiguration, &mOpenCoreCpuInfo); + // DBG("OC: OcLoadDevPropsSupport...\n")); + // OcLoadDevPropsSupport (&mOpenCoreConfiguration); DBG("OC: OcMiscLateInit...\n"); - OcMiscLateInit (Storage, &mOpenCoreConfiguration); + OcMiscLateInit(Storage, &mOpenCoreConfiguration); DBG("OC: OcLoadKernelSupport...\n"); - OcLoadKernelSupport (&mOpenCoreStorage, &mOpenCoreConfiguration, &mOpenCoreCpuInfo); + OcLoadKernelSupport(&mOpenCoreStorage, &mOpenCoreConfiguration, + &mOpenCoreCpuInfo); if (mOpenCoreConfiguration.Misc.Security.EnablePassword) { mOpenCorePrivilege.CurrentLevel = OcPrivilegeUnauthorized; - mOpenCorePrivilege.Hash = mOpenCoreConfiguration.Misc.Security.PasswordHash; - mOpenCorePrivilege.Salt = OC_BLOB_GET (&mOpenCoreConfiguration.Misc.Security.PasswordSalt); - mOpenCorePrivilege.SaltSize = mOpenCoreConfiguration.Misc.Security.PasswordSalt.Size; + mOpenCorePrivilege.Hash = mOpenCoreConfiguration.Misc.Security.PasswordHash; + mOpenCorePrivilege.Salt = + OC_BLOB_GET(&mOpenCoreConfiguration.Misc.Security.PasswordSalt); + mOpenCorePrivilege.SaltSize = + mOpenCoreConfiguration.Misc.Security.PasswordSalt.Size; -// Privilege = &mOpenCorePrivilege; + // Privilege = &mOpenCorePrivilege; } else { -// Privilege = NULL; + // Privilege = NULL; } DBG("OC: All green, starting boot management...\n"); -// OcMiscBoot ( -// &mOpenCoreStorage, -// &mOpenCoreConfiguration, -// Privilege, -// OcStartImage, -// mOpenCoreConfiguration.Uefi.Quirks.RequestBootVarRouting, -// mStorageHandle -// ); + // OcMiscBoot ( + // &mOpenCoreStorage, + // &mOpenCoreConfiguration, + // Privilege, + // OcStartImage, + // mOpenCoreConfiguration.Uefi.Quirks.RequestBootVarRouting, + // mStorageHandle + // ); } - static EFI_STATUS LoadEFIImageList(IN EFI_DEVICE_PATH **DevicePaths, - IN CONST XStringW& ImageTitle, - OUT UINTN *ErrorInStep, - OUT EFI_HANDLE *NewImageHandle) -{ - EFI_STATUS Status, ReturnStatus; - EFI_HANDLE ChildImageHandle = 0; - UINTN DevicePathIndex; + IN CONST XStringW &ImageTitle, + OUT UINTN *ErrorInStep, + OUT EFI_HANDLE *NewImageHandle) { + EFI_STATUS Status, ReturnStatus; + EFI_HANDLE ChildImageHandle = 0; + UINTN DevicePathIndex; DBG("Loading %ls", ImageTitle.wc_str()); if (ErrorInStep != NULL) { @@ -389,35 +371,43 @@ static EFI_STATUS LoadEFIImageList(IN EFI_DEVICE_PATH **DevicePaths, } // load the image into memory - ReturnStatus = Status = EFI_NOT_FOUND; // in case the list is empty - for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; DevicePathIndex++) { - ReturnStatus = Status = gBS->LoadImage(false, self.getSelfImageHandle(), DevicePaths[DevicePathIndex], NULL, 0, &ChildImageHandle); + ReturnStatus = Status = EFI_NOT_FOUND; // in case the list is empty + for (DevicePathIndex = 0; DevicePaths[DevicePathIndex] != NULL; + DevicePathIndex++) { + ReturnStatus = Status = gBS->LoadImage(false, self.getSelfImageHandle(), + DevicePaths[DevicePathIndex], NULL, + 0, &ChildImageHandle); DBG(" status=%s", efiStrError(Status)); if (ReturnStatus != EFI_NOT_FOUND) break; } - XStringW ErrorInfo = SWPrintf(" while loading %ls", ImageTitle.wc_str()); + XStringW ErrorInfo = SWPrintf(" while loading %ls", ImageTitle.wc_str()); if (CheckError(Status, ErrorInfo.wc_str())) { if (ErrorInStep != NULL) *ErrorInStep = 1; PauseForKey(NullXString8); goto bailout; - }else{ + } else { DBG("\n"); #ifdef JIEF_DEBUG DBG("ChildImaheHandle=%llx\n", uintptr_t(ChildImageHandle)); #endif } - if (!EFI_ERROR(ReturnStatus)) { //why unload driver?! + if (!EFI_ERROR(ReturnStatus)) { // why unload driver?! if (NewImageHandle != NULL) { *NewImageHandle = ChildImageHandle; } #ifdef JIEF_DEBUG - EFI_LOADED_IMAGE_PROTOCOL* loadedBootImage = NULL; - if (!EFI_ERROR(Status = gBS->HandleProtocol(ChildImageHandle, &gEfiLoadedImageProtocolGuid, (void**)(&loadedBootImage)))) { - DBG("%ls : Image base = 0x%llx\n", ImageTitle.wc_str(), (uintptr_t)loadedBootImage->ImageBase); // Jief : Do not change this, it's used by grep to feed the debugger - }else{ + EFI_LOADED_IMAGE_PROTOCOL *loadedBootImage = NULL; + if (!EFI_ERROR(Status = gBS->HandleProtocol(ChildImageHandle, + &gEfiLoadedImageProtocolGuid, + (void **)(&loadedBootImage)))) { + DBG("%ls : Image base = 0x%llx\n", ImageTitle.wc_str(), + (uintptr_t) + loadedBootImage->ImageBase); // Jief : Do not change this, it's + // used by grep to feed the debugger + } else { DBG("Can't get loaded image protocol\n"); } #endif @@ -430,69 +420,82 @@ static EFI_STATUS LoadEFIImageList(IN EFI_DEVICE_PATH **DevicePaths, return ReturnStatus; } - static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle, - IN CONST XString8Array& LoadOptions, IN CONST XStringW& LoadOptionsPrefix, - IN CONST XStringW& ImageTitle, - OUT UINTN *ErrorInStep) -{ - EFI_STATUS Status, ReturnStatus; - EFI_LOADED_IMAGE_PROTOCOL *ChildLoadedImage; - CHAR16 ErrorInfo[256]; - - XStringW loadOptionsW; // This has to be declared here, so it's not be freed before calling StartImage - -// DBG("Starting %ls\n", ImageTitle); + IN CONST XString8Array &LoadOptions, + IN CONST XStringW &LoadOptionsPrefix, + IN CONST XStringW &ImageTitle, + OUT UINTN *ErrorInStep) { + EFI_STATUS Status, ReturnStatus; + EFI_LOADED_IMAGE_PROTOCOL *ChildLoadedImage; + CHAR16 ErrorInfo[256]; + + XStringW loadOptionsW; // This has to be declared here, so it's not be freed + // before calling StartImage + + // DBG("Starting %ls\n", ImageTitle); if (ErrorInStep != NULL) { *ErrorInStep = 0; } - ReturnStatus = Status = EFI_NOT_FOUND; // in case no image handle was specified + ReturnStatus = Status = + EFI_NOT_FOUND; // in case no image handle was specified if (ChildImageHandle == NULL) { - if (ErrorInStep != NULL) *ErrorInStep = 1; + if (ErrorInStep != NULL) + *ErrorInStep = 1; goto bailout; } // set load options if (!LoadOptions.isEmpty()) { - ReturnStatus = Status = gBS->HandleProtocol(ChildImageHandle, &gEfiLoadedImageProtocolGuid, (void **) &ChildLoadedImage); + ReturnStatus = Status = + gBS->HandleProtocol(ChildImageHandle, &gEfiLoadedImageProtocolGuid, + (void **)&ChildLoadedImage); if (CheckError(Status, L"while getting a LoadedImageProtocol handle")) { if (ErrorInStep != NULL) *ErrorInStep = 2; goto bailout_unload; } - if ( LoadOptionsPrefix.notEmpty() ) { - // NOTE: That last space is also added by the EFI shell and seems to be significant + if (LoadOptionsPrefix.notEmpty()) { + // NOTE: That last space is also added by the EFI shell and seems to be + // significant // when passing options to Apple's boot.efi... - loadOptionsW = SWPrintf("%ls %s ", LoadOptionsPrefix.wc_str(), LoadOptions.ConcatAll(" "_XS8).c_str()); - }else{ - loadOptionsW = SWPrintf("%s ", LoadOptions.ConcatAll(" "_XS8).c_str()); // Jief : should we add a space ? Wasn't the case before big refactoring. Yes, a space required. + loadOptionsW = SWPrintf("%ls %s ", LoadOptionsPrefix.wc_str(), + LoadOptions.ConcatAll(" "_XS8).c_str()); + } else { + loadOptionsW = SWPrintf( + "%s ", + LoadOptions.ConcatAll(" "_XS8) + .c_str()); // Jief : should we add a space ? Wasn't the case + // before big refactoring. Yes, a space required. } // NOTE: We also include the terminating null in the length for safety. - ChildLoadedImage->LoadOptionsSize = (UINT32)loadOptionsW.sizeInBytes() + sizeof(wchar_t); - ChildLoadedImage->LoadOptions = loadOptionsW.wc_str(); //will it be deleted after the procedure exit? Yes, if we don't copy loadOptionsW, so it'll be freed at the end of method + ChildLoadedImage->LoadOptionsSize = + (UINT32)loadOptionsW.sizeInBytes() + sizeof(wchar_t); + ChildLoadedImage->LoadOptions = + loadOptionsW.wc_str(); // will it be deleted after the procedure exit? + // Yes, if we don't copy loadOptionsW, so it'll + // be freed at the end of method DBG("start image '%ls'\n", ImageTitle.s()); - DBG("Using load options '%ls'\n", (CHAR16*)ChildLoadedImage->LoadOptions); - + DBG("Using load options '%ls'\n", (CHAR16 *)ChildLoadedImage->LoadOptions); } - + // close open file handles UninitRefitLib(); // turn control over to the image // // Before calling the image, enable the Watchdog Timer for - // the 5 Minute period - Slice - NO! For slow driver and slow disk we need more + // the 5 Minute period - Slice - NO! For slow driver and slow disk we need + // more // - gBS->SetWatchdogTimer (600, 0x0000, 0x00, NULL); + gBS->SetWatchdogTimer(600, 0x0000, 0x00, NULL); ReturnStatus = Status = gBS->StartImage(ChildImageHandle, NULL, NULL); // // Clear the Watchdog Timer after the image returns // - gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL); - + gBS->SetWatchdogTimer(0x0000, 0x0000, 0x0000, NULL); ReinitRefitLib(); // control returns here when the child image calls Exit() @@ -504,7 +507,7 @@ static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle, if (ErrorInStep != NULL) *ErrorInStep = 3; } - if (!EFI_ERROR(ReturnStatus)) { //why unload driver?! + if (!EFI_ERROR(ReturnStatus)) { // why unload driver?! goto bailout; } @@ -515,12 +518,10 @@ static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle, return ReturnStatus; } - static EFI_STATUS LoadEFIImage(IN EFI_DEVICE_PATH *DevicePath, - IN CONST XStringW& ImageTitle, - OUT UINTN *ErrorInStep, - OUT EFI_HANDLE *NewImageHandle) -{ + IN CONST XStringW &ImageTitle, + OUT UINTN *ErrorInStep, + OUT EFI_HANDLE *NewImageHandle) { EFI_DEVICE_PATH *DevicePaths[2]; #ifdef ENABLE_SECURE_BOOT @@ -540,31 +541,29 @@ static EFI_STATUS LoadEFIImage(IN EFI_DEVICE_PATH *DevicePath, return LoadEFIImageList(DevicePaths, ImageTitle, ErrorInStep, NewImageHandle); } - static EFI_STATUS StartEFIImage(IN EFI_DEVICE_PATH *DevicePath, - IN CONST XString8Array& LoadOptions, IN CONST XStringW& LoadOptionsPrefix, - IN CONST XStringW& ImageTitle, + IN CONST XString8Array &LoadOptions, + IN CONST XStringW &LoadOptionsPrefix, + IN CONST XStringW &ImageTitle, OUT UINTN *ErrorInStep, - OUT EFI_HANDLE *NewImageHandle) -{ + OUT EFI_HANDLE *NewImageHandle) { EFI_STATUS Status; EFI_HANDLE ChildImageHandle = NULL; Status = LoadEFIImage(DevicePath, ImageTitle, ErrorInStep, &ChildImageHandle); if (!EFI_ERROR(Status)) { - Status = StartEFILoadedImage(ChildImageHandle, LoadOptions, LoadOptionsPrefix, ImageTitle, ErrorInStep); + Status = StartEFILoadedImage(ChildImageHandle, LoadOptions, + LoadOptionsPrefix, ImageTitle, ErrorInStep); } if (NewImageHandle != NULL) { - *NewImageHandle = ChildImageHandle; + *NewImageHandle = ChildImageHandle; } return Status; } - #ifdef DUMP_KERNEL_KEXT_PATCHES -void DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches) -{ +void DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches) { if (!Patches) { DBG("Kernel and Kext Patches null pointer\n"); return; @@ -572,7 +571,7 @@ void DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches) DBG("Kernel and Kext Patches at %llx:\n", (uintptr_t)Patches); DBG("\tAllowed: %c\n", GlobalConfig.KextPatchesAllowed ? 'y' : 'n'); DBG("\tDebug: %c\n", Patches->KPDebug ? 'y' : 'n'); -// DBG("\tKernelCpu: %c\n", Patches->KPKernelCpu ? 'y' : 'n'); + // DBG("\tKernelCpu: %c\n", Patches->KPKernelCpu ? 'y' : 'n'); DBG("\tKernelLapic: %c\n", Patches->KPKernelLapic ? 'y' : 'n'); DBG("\tKernelXCPM: %c\n", Patches->KPKernelXCPM ? 'y' : 'n'); DBG("\tKernelPm: %c\n", Patches->KPKernelPm ? 'y' : 'n'); @@ -581,115 +580,155 @@ void DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches) // Dell smbios truncate fix DBG("\tDellSMBIOSPatch: %c\n", Patches->KPDELLSMBIOS ? 'y' : 'n'); DBG("\tFakeCPUID: 0x%X\n", Patches->FakeCPUID); - DBG("\tATIController: %s\n", Patches->KPATIConnectorsController.isEmpty() ? "(null)": Patches->KPATIConnectorsController.c_str()); + DBG("\tATIController: %s\n", + Patches->KPATIConnectorsController.isEmpty() + ? "(null)" + : Patches->KPATIConnectorsController.c_str()); DBG("\tATIDataLength: %zu\n", Patches->KPATIConnectorsData.size()); DBG("\t%zu Kexts to load\n", Patches->ForceKextsToLoad.size()); if (Patches->ForceKextsToLoad.size()) { size_t i = 0; for (; i < Patches->ForceKextsToLoad.size(); ++i) { - DBG("\t KextToLoad[%zu]: %ls\n", i, Patches->ForceKextsToLoad[i].wc_str()); + DBG("\t KextToLoad[%zu]: %ls\n", i, + Patches->ForceKextsToLoad[i].wc_str()); } } DBG("\t%zu Kexts to patch\n", Patches->KextPatches.size()); if (Patches->KextPatches.size()) { size_t i = 0; for (; i < Patches->KextPatches.size(); ++i) { - if (Patches->KextPatches[i].IsPlistPatch) { - DBG("\t KextPatchPlist[%zu]: %zu bytes, %s\n", i, Patches->KextPatches[i].Data.size(), Patches->KextPatches[i].Name.c_str()); - } else { - DBG("\t KextPatch[%zu]: %zu bytes, %s\n", i, Patches->KextPatches[i].Data.size(), Patches->KextPatches[i].Name.c_str()); - } + if (Patches->KextPatches[i].IsPlistPatch) { + DBG("\t KextPatchPlist[%zu]: %zu bytes, %s\n", i, + Patches->KextPatches[i].Data.size(), + Patches->KextPatches[i].Name.c_str()); + } else { + DBG("\t KextPatch[%zu]: %zu bytes, %s\n", i, + Patches->KextPatches[i].Data.size(), + Patches->KextPatches[i].Name.c_str()); + } } } } #endif -void LOADER_ENTRY::FilterKextPatches() -{ - if ( GlobalConfig.KextPatchesAllowed && KernelAndKextPatches.KextPatches.size() > 0 ) { +void LOADER_ENTRY::FilterKextPatches() { + if (GlobalConfig.KextPatchesAllowed && + KernelAndKextPatches.KextPatches.size() > 0) { DBG("Filtering KextPatches:\n"); for (size_t i = 0; i < KernelAndKextPatches.KextPatches.size(); i++) { - DBG(" - [%02zu]: %s :: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]", - i, - KernelAndKextPatches.KextPatches[i].Label.c_str(), - KernelAndKextPatches.KextPatches[i].IsPlistPatch ? "PlistPatch" : "BinPatch", - macOSVersion.asString().c_str(), - KernelAndKextPatches.KextPatches[i].MatchOS.notEmpty() ? KernelAndKextPatches.KextPatches[i].MatchOS.c_str() : "All", - KernelAndKextPatches.KextPatches[i].MatchBuild.notEmpty() ? KernelAndKextPatches.KextPatches[i].MatchBuild.c_str() : "All" - ); + DBG(" - [%02zu]: %s :: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]", i, + KernelAndKextPatches.KextPatches[i].Label.c_str(), + KernelAndKextPatches.KextPatches[i].IsPlistPatch ? "PlistPatch" + : "BinPatch", + macOSVersion.asString().c_str(), + KernelAndKextPatches.KextPatches[i].MatchOS.notEmpty() + ? KernelAndKextPatches.KextPatches[i].MatchOS.c_str() + : "All", + KernelAndKextPatches.KextPatches[i].MatchBuild.notEmpty() + ? KernelAndKextPatches.KextPatches[i].MatchBuild.c_str() + : "All"); if (!gSettings.KernelAndKextPatches.KextPatches[i].MenuItem.BValue) { KernelAndKextPatches.KextPatches[i].MenuItem.BValue = false; DBG(" ==> disabled by user\n"); continue; } KernelAndKextPatches.KextPatches[i].MenuItem.BValue = true; - if ((BuildVersion.notEmpty()) && (KernelAndKextPatches.KextPatches[i].MatchBuild.notEmpty())) { - KernelAndKextPatches.KextPatches[i].MenuItem.BValue = KernelAndKextPatches.KextPatches[i].IsPatchEnabledByBuildNumber(BuildVersion); - DBG(" ==> %s\n", KernelAndKextPatches.KextPatches[i].MenuItem.BValue ? "allowed" : "not allowed"); - continue; + if ((BuildVersion.notEmpty()) && + (KernelAndKextPatches.KextPatches[i].MatchBuild.notEmpty())) { + KernelAndKextPatches.KextPatches[i].MenuItem.BValue = + KernelAndKextPatches.KextPatches[i].IsPatchEnabledByBuildNumber( + BuildVersion); + DBG(" ==> %s\n", KernelAndKextPatches.KextPatches[i].MenuItem.BValue + ? "allowed" + : "not allowed"); + continue; } - KernelAndKextPatches.KextPatches[i].MenuItem.BValue = KernelAndKextPatches.KextPatches[i].IsPatchEnabled(macOSVersion); - DBG(" ==> %s\n", KernelAndKextPatches.KextPatches[i].MenuItem.BValue ? "allowed" : "not allowed"); + KernelAndKextPatches.KextPatches[i].MenuItem.BValue = + KernelAndKextPatches.KextPatches[i].IsPatchEnabled(macOSVersion); + DBG(" ==> %s\n", KernelAndKextPatches.KextPatches[i].MenuItem.BValue + ? "allowed" + : "not allowed"); } } } -void LOADER_ENTRY::FilterKernelPatches() -{ - if ( GlobalConfig.KernelPatchesAllowed && KernelAndKextPatches.KernelPatches.notEmpty() ) { +void LOADER_ENTRY::FilterKernelPatches() { + if (GlobalConfig.KernelPatchesAllowed && + KernelAndKextPatches.KernelPatches.notEmpty()) { DBG("Filtering KernelPatches:\n"); for (size_t i = 0; i < KernelAndKextPatches.KernelPatches.size(); ++i) { - DBG(" - [%02zu]: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]", - i, - KernelAndKextPatches.KernelPatches[i].Label.c_str(), - macOSVersion.asString().c_str(), - KernelAndKextPatches.KernelPatches[i].MatchOS.notEmpty() ? KernelAndKextPatches.KernelPatches[i].MatchOS.c_str() : "All", - KernelAndKextPatches.KernelPatches[i].MatchBuild.notEmpty() ? KernelAndKextPatches.KernelPatches[i].MatchBuild.c_str() : "All" - ); + DBG(" - [%02zu]: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]", i, + KernelAndKextPatches.KernelPatches[i].Label.c_str(), + macOSVersion.asString().c_str(), + KernelAndKextPatches.KernelPatches[i].MatchOS.notEmpty() + ? KernelAndKextPatches.KernelPatches[i].MatchOS.c_str() + : "All", + KernelAndKextPatches.KernelPatches[i].MatchBuild.notEmpty() + ? KernelAndKextPatches.KernelPatches[i].MatchBuild.c_str() + : "All"); if (!gSettings.KernelAndKextPatches.KernelPatches[i].MenuItem.BValue) { KernelAndKextPatches.KernelPatches[i].MenuItem.BValue = false; DBG(" ==> disabled by user\n"); continue; } KernelAndKextPatches.KernelPatches[i].MenuItem.BValue = true; - if ((BuildVersion.notEmpty()) && (KernelAndKextPatches.KernelPatches[i].MatchBuild.notEmpty())) { - KernelAndKextPatches.KernelPatches[i].MenuItem.BValue = KernelAndKextPatches.KernelPatches[i].IsPatchEnabledByBuildNumber(BuildVersion); - DBG(" ==> %s by build\n", KernelAndKextPatches.KernelPatches[i].MenuItem.BValue ? "allowed" : "not allowed"); - continue; + if ((BuildVersion.notEmpty()) && + (KernelAndKextPatches.KernelPatches[i].MatchBuild.notEmpty())) { + KernelAndKextPatches.KernelPatches[i].MenuItem.BValue = + KernelAndKextPatches.KernelPatches[i].IsPatchEnabledByBuildNumber( + BuildVersion); + DBG(" ==> %s by build\n", + KernelAndKextPatches.KernelPatches[i].MenuItem.BValue + ? "allowed" + : "not allowed"); + continue; } - KernelAndKextPatches.KernelPatches[i].MenuItem.BValue = KernelAndKextPatches.KernelPatches[i].IsPatchEnabled(macOSVersion); - DBG(" ==> %s by OS\n", KernelAndKextPatches.KernelPatches[i].MenuItem.BValue ? "allowed" : "not allowed"); + KernelAndKextPatches.KernelPatches[i].MenuItem.BValue = + KernelAndKextPatches.KernelPatches[i].IsPatchEnabled(macOSVersion); + DBG(" ==> %s by OS\n", + KernelAndKextPatches.KernelPatches[i].MenuItem.BValue + ? "allowed" + : "not allowed"); } } } -void LOADER_ENTRY::FilterBootPatches() -{ - if ( KernelAndKextPatches.BootPatches.notEmpty() ) { +void LOADER_ENTRY::FilterBootPatches() { + if (KernelAndKextPatches.BootPatches.notEmpty()) { DBG("Filtering BootPatches:\n"); for (size_t i = 0; i < KernelAndKextPatches.BootPatches.size(); ++i) { - DBG(" - [%02zu]: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]", - i, + DBG(" - [%02zu]: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]", i, KernelAndKextPatches.BootPatches[i].Label.c_str(), macOSVersion.asString().c_str(), - KernelAndKextPatches.BootPatches[i].MatchOS.notEmpty() ? KernelAndKextPatches.BootPatches[i].MatchOS.c_str() : "All", - KernelAndKextPatches.BootPatches[i].MatchBuild.notEmpty() ? KernelAndKextPatches.BootPatches[i].MatchBuild.c_str() : "All" - ); + KernelAndKextPatches.BootPatches[i].MatchOS.notEmpty() + ? KernelAndKextPatches.BootPatches[i].MatchOS.c_str() + : "All", + KernelAndKextPatches.BootPatches[i].MatchBuild.notEmpty() + ? KernelAndKextPatches.BootPatches[i].MatchBuild.c_str() + : "All"); if (!gSettings.KernelAndKextPatches.BootPatches[i].MenuItem.BValue) { DBG(" ==> disabled by user\n"); continue; } KernelAndKextPatches.BootPatches[i].MenuItem.BValue = true; - if ((BuildVersion.notEmpty()) && (KernelAndKextPatches.BootPatches[i].MatchBuild.notEmpty())) { - KernelAndKextPatches.BootPatches[i].MenuItem.BValue = KernelAndKextPatches.BootPatches[i].IsPatchEnabledByBuildNumber(BuildVersion); - DBG(" ==> %s by build\n", KernelAndKextPatches.BootPatches[i].MenuItem.BValue ? "allowed" : "not allowed"); + if ((BuildVersion.notEmpty()) && + (KernelAndKextPatches.BootPatches[i].MatchBuild.notEmpty())) { + KernelAndKextPatches.BootPatches[i].MenuItem.BValue = + KernelAndKextPatches.BootPatches[i].IsPatchEnabledByBuildNumber( + BuildVersion); + DBG(" ==> %s by build\n", + KernelAndKextPatches.BootPatches[i].MenuItem.BValue + ? "allowed" + : "not allowed"); continue; } - - KernelAndKextPatches.BootPatches[i].MenuItem.BValue = KernelAndKextPatches.BootPatches[i].IsPatchEnabled(macOSVersion); - DBG(" ==> %s by OS\n", KernelAndKextPatches.BootPatches[i].MenuItem.BValue ? "allowed" : "not allowed"); - + + KernelAndKextPatches.BootPatches[i].MenuItem.BValue = + KernelAndKextPatches.BootPatches[i].IsPatchEnabled(macOSVersion); + DBG(" ==> %s by OS\n", KernelAndKextPatches.BootPatches[i].MenuItem.BValue + ? "allowed" + : "not allowed"); } } } @@ -698,21 +737,19 @@ void LOADER_ENTRY::FilterBootPatches() // Null ConOut OutputString() implementation - for blocking // text output from boot.efi when booting in graphics mode // -EFI_STATUS EFIAPI -NullConOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *, IN CONST CHAR16 *) { +EFI_STATUS EFIAPI NullConOutOutputString(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *, + IN CONST CHAR16 *) { return EFI_SUCCESS; } - -void CheckEmptyFB() -{ +void CheckEmptyFB() { XBool EmptyFB = (GlobalConfig.IgPlatform == 0x00050000) || - (GlobalConfig.IgPlatform == 0x01620007) || - (GlobalConfig.IgPlatform == 0x04120004) || - (GlobalConfig.IgPlatform == 0x19120001) || - (GlobalConfig.IgPlatform == 0x59120003) || - (GlobalConfig.IgPlatform == 0x9BC80003) || - (GlobalConfig.IgPlatform == 0x3E910003); + (GlobalConfig.IgPlatform == 0x01620007) || + (GlobalConfig.IgPlatform == 0x04120004) || + (GlobalConfig.IgPlatform == 0x19120001) || + (GlobalConfig.IgPlatform == 0x59120003) || + (GlobalConfig.IgPlatform == 0x9BC80003) || + (GlobalConfig.IgPlatform == 0x3E910003); if (EmptyFB) { gSettings.Smbios.gPlatformFeature |= PT_FEATURE_HAS_HEADLESS_GPU; } else { @@ -720,42 +757,45 @@ void CheckEmptyFB() } } -size_t setKextAtPos(XObjArray* kextArrayPtr, const XString8& kextName, size_t pos) -{ - XObjArray& kextArray = *kextArrayPtr; +size_t setKextAtPos(XObjArray *kextArrayPtr, + const XString8 &kextName, size_t pos) { + XObjArray &kextArray = *kextArrayPtr; - for (size_t kextIdx = 0 ; kextIdx < kextArray.size() ; kextIdx++ ) { - if ( kextArray[kextIdx].FileName.contains(kextName) ) { - if ( pos >= kextArray.size() ) { + for (size_t kextIdx = 0; kextIdx < kextArray.size(); kextIdx++) { + if (kextArray[kextIdx].FileName.contains(kextName)) { + if (pos >= kextArray.size()) { log_technical_bug("pos >= kextArray.size()"); - return kextArray.size() - 1 ; // If we're here, kextArray.size() is at least 1 + return kextArray.size() - + 1; // If we're here, kextArray.size() is at least 1 } - if ( pos == kextIdx ) return pos+1; - if ( pos > kextIdx ) pos -= 1; - SIDELOAD_KEXT* kextToMove = &kextArray[kextIdx]; + if (pos == kextIdx) + return pos + 1; + if (pos > kextIdx) + pos -= 1; + SIDELOAD_KEXT *kextToMove = &kextArray[kextIdx]; kextArray.RemoveWithoutFreeingAtIndex(kextIdx); kextArray.InsertRef(kextToMove, pos, false); - return pos+1; + return pos + 1; } } return pos; } -static XStringW getDriversPath() -{ +static XStringW getDriversPath() { #if defined(MDE_CPU_X64) if (gFirmwareClover) { if (FileExists(&self.getCloverDir(), L"drivers\\BIOS")) { return L"drivers\\BIOS"_XSW; } else { - return L"drivers64"_XSW; //backward compatibility + return L"drivers64"_XSW; // backward compatibility } - } else if (FileExists(&self.getCloverDir(), L"drivers\\5142")) { // can be excluded as obsolete - return L"drivers\\5142"_XSW; + } else if (FileExists(&self.getCloverDir(), + L"drivers\\5142")) { // can be excluded as obsolete + return L"drivers\\5142"_XSW; } else if (FileExists(&self.getCloverDir(), L"drivers\\UEFI")) { - return L"drivers\\UEFI"_XSW; + return L"drivers\\UEFI"_XSW; } else { - return L"drivers64UEFI"_XSW; + return L"drivers64UEFI"_XSW; } #else return L"drivers32"_XSW; @@ -763,19 +803,23 @@ static XStringW getDriversPath() } #ifdef JIEF_DEBUG -void debugStartImageWithOC() -{ +void debugStartImageWithOC() { MsgLog("debugStartImageWithOC\n"); UINT64 CPUFrequencyFromART; InternalCalculateARTFrequencyIntel(&CPUFrequencyFromART, NULL, 1); - EFI_LOADED_IMAGE* OcLoadedImage; - EFI_STATUS Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (void **) &OcLoadedImage); - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem = OcLocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath); - Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, NULL, NULL, self.getCloverDirFullPath().wc_str(), NULL); + EFI_LOADED_IMAGE *OcLoadedImage; + EFI_STATUS Status = gBS->HandleProtocol( + gImageHandle, &gEfiLoadedImageProtocolGuid, (void **)&OcLoadedImage); + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem = + OcLocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath); + Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, NULL, NULL, + self.getCloverDirFullPath().wc_str(), NULL); - Status = ClOcReadConfigurationFile(&mOpenCoreStorage, L"config-oc.plist", &mOpenCoreConfiguration); - if ( EFI_ERROR(Status) ) panic("ClOcReadConfigurationFile"); + Status = ClOcReadConfigurationFile(&mOpenCoreStorage, L"config-oc.plist", + &mOpenCoreConfiguration); + if (EFI_ERROR(Status)) + panic("ClOcReadConfigurationFile"); mOpenCoreConfiguration.Misc.Debug.Target = 0; OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Boot.PickerMode, "Builtin"); @@ -787,117 +831,165 @@ void debugStartImageWithOC() OcMain(&mOpenCoreStorage, NULL); XStringW devicePathToLookFor; -// devicePathToLookFor.takeValueFrom("PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0x0,0x0)/HD(4,GPT,CA224585-830E-4274-5826-1ACB6DA08A4E,0x299F000,0x4AE6310)/VenMedia(BE74FCF7-0B7C-49F3-9147-01F4042E6842,1ABE434C8D0357398516CFDF0A9DD7EF)"); // Jief High Sierra DevicePath - devicePathToLookFor.takeValueFrom("PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0x0,0x0)/HD(2,GPT,D8C7DA82-1E4C-4579-BA7C-6737A5D43464,0x64028,0x1BF08E8)"); // Jief Big Sur Install device path - UINTN HandleCount = 0; - EFI_HANDLE *Handles = NULL; - Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &HandleCount, &Handles); + // devicePathToLookFor.takeValueFrom("PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0x0,0x0)/HD(4,GPT,CA224585-830E-4274-5826-1ACB6DA08A4E,0x299F000,0x4AE6310)/VenMedia(BE74FCF7-0B7C-49F3-9147-01F4042E6842,1ABE434C8D0357398516CFDF0A9DD7EF)"); + // // Jief High Sierra DevicePath + devicePathToLookFor + .takeValueFrom("PciRoot(0x0)/Pci(0x1F,0x2)/Sata(0x0,0x0,0x0)/" + "HD(2,GPT,D8C7DA82-1E4C-4579-BA7C-6737A5D43464,0x64028," + "0x1BF08E8)"); // Jief Big Sur Install device path + UINTN HandleCount = 0; + EFI_HANDLE *Handles = NULL; + Status = + gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid, + NULL, &HandleCount, &Handles); UINTN HandleIndex = 0; for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) { - EFI_DEVICE_PATH_PROTOCOL* DevicePath = DevicePathFromHandle(Handles[HandleIndex]); - CHAR16* UnicodeDevicePath = ConvertDevicePathToText(DevicePath, false, false); + EFI_DEVICE_PATH_PROTOCOL *DevicePath = + DevicePathFromHandle(Handles[HandleIndex]); + CHAR16 *UnicodeDevicePath = + ConvertDevicePathToText(DevicePath, false, false); MsgLog("debugStartImageWithOC : path %ls\n", UnicodeDevicePath); - if ( StrCmp(devicePathToLookFor.wc_str(), UnicodeDevicePath) == 0 ) break; + if (StrCmp(devicePathToLookFor.wc_str(), UnicodeDevicePath) == 0) + break; } - if ( HandleIndex < HandleCount ) - { - EFI_DEVICE_PATH_PROTOCOL* jfkImagePath = FileDevicePath(Handles[HandleIndex], L"\\System\\Library\\CoreServices\\boot.efi"); - CHAR16* UnicodeDevicePath = ConvertDevicePathToText (jfkImagePath, false, false); (void)UnicodeDevicePath; + if (HandleIndex < HandleCount) { + EFI_DEVICE_PATH_PROTOCOL *jfkImagePath = FileDevicePath( + Handles[HandleIndex], L"\\System\\Library\\CoreServices\\boot.efi"); + CHAR16 *UnicodeDevicePath = + ConvertDevicePathToText(jfkImagePath, false, false); + (void)UnicodeDevicePath; EFI_HANDLE EntryHandle = NULL; // point to InternalEfiLoadImage from OC - Status = gBS->LoadImage ( - false, - gImageHandle, - jfkImagePath, - NULL, - 0, - &EntryHandle - ); - if ( EFI_ERROR(Status) ) return; // TODO message ? + Status = gBS->LoadImage(false, gImageHandle, jfkImagePath, NULL, 0, + &EntryHandle); + if (EFI_ERROR(Status)) + return; // TODO message ? EFI_LOADED_IMAGE *LoadedImage = NULL; - EFI_STATUS OptionalStatus = gBS->HandleProtocol ( - EntryHandle, - &gEfiLoadedImageProtocolGuid, - (void **) &LoadedImage - ); - if ( EFI_ERROR(OptionalStatus) ) return; // TODO message ? - - // XStringW LoadOptionsAsXStringW = SWPrintf("%s ", LoadOptions.ConcatAll(" "_XS8).c_str()); - XStringW LoadOptionsAsXStringW = SWPrintf("boot.efi -v -no_compat_check slide=0 kext-dev-mode=1 keepsyms=1 -wegdbg igfxgl=1 bpr_probedelay=200 bpr_initialdelay=400 bpr_postresetdelay=400 "); - LoadedImage->LoadOptions = (void*)LoadOptionsAsXStringW.wc_str(); - LoadedImage->LoadOptionsSize = (UINT32)LoadOptionsAsXStringW.sizeInBytesIncludingTerminator(); + EFI_STATUS OptionalStatus = gBS->HandleProtocol( + EntryHandle, &gEfiLoadedImageProtocolGuid, (void **)&LoadedImage); + if (EFI_ERROR(OptionalStatus)) + return; // TODO message ? + + // XStringW LoadOptionsAsXStringW = SWPrintf("%s ", LoadOptions.ConcatAll(" + // "_XS8).c_str()); + XStringW LoadOptionsAsXStringW = + SWPrintf("boot.efi -v -no_compat_check slide=0 kext-dev-mode=1 " + "keepsyms=1 -wegdbg igfxgl=1 bpr_probedelay=200 " + "bpr_initialdelay=400 bpr_postresetdelay=400 "); + LoadedImage->LoadOptions = (void *)LoadOptionsAsXStringW.wc_str(); + LoadedImage->LoadOptionsSize = + (UINT32)LoadOptionsAsXStringW.sizeInBytesIncludingTerminator(); // point to OcStartImage from OC - Status = gBS->StartImage (EntryHandle, 0, NULL); - if ( EFI_ERROR(Status) ) return; // TODO message ? - }else{ + Status = gBS->StartImage(EntryHandle, 0, NULL); + if (EFI_ERROR(Status)) + return; // TODO message ? + } else { MsgLog("debugStartImageWithOC : not found\n"); } } #endif - -void LOADER_ENTRY::DelegateKernelPatches() -{ +void LOADER_ENTRY::DelegateKernelPatches() { XObjArray selectedPathArray; - for (size_t kernelPatchIdx = 0 ; kernelPatchIdx < KernelAndKextPatches.KernelPatches.size() ; kernelPatchIdx++ ) - { - if ( KernelAndKextPatches.KernelPatches[kernelPatchIdx].MenuItem.BValue ) - selectedPathArray.AddReference(&KernelAndKextPatches.KernelPatches[kernelPatchIdx], false); + for (size_t kernelPatchIdx = 0; + kernelPatchIdx < KernelAndKextPatches.KernelPatches.size(); + kernelPatchIdx++) { + if (KernelAndKextPatches.KernelPatches[kernelPatchIdx].MenuItem.BValue) + selectedPathArray.AddReference( + &KernelAndKextPatches.KernelPatches[kernelPatchIdx], false); } - for (size_t kextPatchIdx = 0 ; kextPatchIdx < KernelAndKextPatches.KextPatches.size() ; kextPatchIdx++ ) - { - if ( KernelAndKextPatches.KextPatches[kextPatchIdx].MenuItem.BValue ) - selectedPathArray.AddReference(&KernelAndKextPatches.KextPatches[kextPatchIdx], false); + for (size_t kextPatchIdx = 0; + kextPatchIdx < KernelAndKextPatches.KextPatches.size(); kextPatchIdx++) { + if (KernelAndKextPatches.KextPatches[kextPatchIdx].MenuItem.BValue) + selectedPathArray.AddReference( + &KernelAndKextPatches.KextPatches[kextPatchIdx], false); } 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)*)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)); - + 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) *)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)); + UINT32 FakeCPUID = gSettings.Smbios.SFakeCPU; - if (FakeCPUID != 0) gFakeCPUID = FakeCPUID; + if (FakeCPUID != 0) + gFakeCPUID = FakeCPUID; DBG("Set FakeCPUID: 0x%X\n", gFakeCPUID); - memset(mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Data, 0, sizeof(mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Data)); - memset(mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Mask, 0, sizeof(mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Mask)); + memset(mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Data, 0, + sizeof(mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Data)); + memset(mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Mask, 0, + sizeof(mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Mask)); mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Data[0] = gFakeCPUID; mOpenCoreConfiguration.Kernel.Emulate.Cpuid1Mask[0] = 0xFFFFFFFF; - for (size_t kextPatchIdx = 0 ; kextPatchIdx < selectedPathArray.size() ; kextPatchIdx++ ) - { - const ABSTRACT_KEXT_OR_KERNEL_PATCH& kextPatch = selectedPathArray[kextPatchIdx]; //as well as kernel patches - DBG("Bridge %s patch to OC : %s\n", kextPatch.getName().c_str(), 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, OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch)); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Base, kextPatch.ProcedureName.c_str()); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Comment, kextPatch.Label.c_str()); - mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Count = (UINT32)kextPatch.Count; + for (size_t kextPatchIdx = 0; kextPatchIdx < selectedPathArray.size(); + kextPatchIdx++) { + const ABSTRACT_KEXT_OR_KERNEL_PATCH &kextPatch = + selectedPathArray[kextPatchIdx]; // as well as kernel patches + DBG("Bridge %s patch to OC : %s\n", kextPatch.getName().c_str(), + 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, + OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch)); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Base, + kextPatch.ProcedureName.c_str()); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Comment, + kextPatch.Label.c_str()); + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Count = + (UINT32)kextPatch.Count; mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Enabled = 1; - - OC_DATA_ASSIGN_N(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Find, kextPatch.Find.data(), kextPatch.Find.size()); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Identifier, kextPatch.getName().c_str()); - mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Limit = (UINT32)kextPatch.SearchLen; - OC_DATA_ASSIGN_N(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Mask, kextPatch.MaskFind.data(), kextPatch.MaskFind.size()); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->MaxKernel, ""); // it has been filtered, so we don't need to set Min and MaxKernel - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->MinKernel, ""); - OC_DATA_ASSIGN_N(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Replace, kextPatch.Replace.data(), kextPatch.Replace.size()); - OC_DATA_ASSIGN_N(mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->ReplaceMask, kextPatch.MaskReplace.data(), kextPatch.MaskReplace.size()); - mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Skip = (UINT32)kextPatch.Skip; + + OC_DATA_ASSIGN_N( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Find, + kextPatch.Find.data(), kextPatch.Find.size()); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Identifier, + kextPatch.getName().c_str()); + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Limit = + (UINT32)kextPatch.SearchLen; + OC_DATA_ASSIGN_N( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Mask, + kextPatch.MaskFind.data(), kextPatch.MaskFind.size()); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->MaxKernel, + ""); // it has been filtered, so we don't need to set Min and MaxKernel + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->MinKernel, + ""); + OC_DATA_ASSIGN_N( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Replace, + kextPatch.Replace.data(), kextPatch.Replace.size()); + OC_DATA_ASSIGN_N( + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->ReplaceMask, + kextPatch.MaskReplace.data(), kextPatch.MaskReplace.size()); + mOpenCoreConfiguration.Kernel.Patch.Values[kextPatchIdx]->Skip = + (UINT32)kextPatch.Skip; } } -void LOADER_ENTRY::StartLoader() -{ - EFI_STATUS Status; - EFI_TEXT_STRING ConOutOutputString = 0; - EFI_HANDLE ImageHandle = NULL; - EFI_LOADED_IMAGE *LoadedImage = NULL; - CONST CHAR8 *InstallerVersion; +void LOADER_ENTRY::StartLoader() { + EFI_STATUS Status; + EFI_TEXT_STRING ConOutOutputString = 0; + EFI_HANDLE ImageHandle = NULL; + EFI_LOADED_IMAGE *LoadedImage = NULL; + CONST CHAR8 *InstallerVersion; DbgHeader("StartLoader"); @@ -905,8 +997,9 @@ void LOADER_ENTRY::StartLoader() #ifdef JIEF_DEBUG displayFreeMemory("LOADER_ENTRY::StartLoader()"_XS8); #endif -// while ( OcCountFreePages(NULL) > 300000 && AllocatePages(100) ) /*DBG("Free memory : %lld\n", OcCountFreePages(NULL))*/; -// displayFreeMemory(); + // while ( OcCountFreePages(NULL) > 300000 && AllocatePages(100) ) + // /*DBG("Free memory : %lld\n", OcCountFreePages(NULL))*/; + // displayFreeMemory(); if (Settings.notEmpty()) { DBG(" Settings: %ls\n", Settings.wc_str()); @@ -918,214 +1011,270 @@ void LOADER_ENTRY::StartLoader() /* we are not sure of the state of gSettings here... try to boot anyway */ } } - + DBG("Finally: ExternalClock=%lluMHz BusSpeed=%llukHz CPUFreq=%uMHz", - DivU64x32(gCPUStructure.ExternalClock + Kilo - 1, Kilo), - DivU64x32(gCPUStructure.FSBFrequency + Kilo - 1, Kilo), - gCPUStructure.MaxSpeed); + DivU64x32(gCPUStructure.ExternalClock + Kilo - 1, Kilo), + DivU64x32(gCPUStructure.FSBFrequency + Kilo - 1, Kilo), + gCPUStructure.MaxSpeed); if (gSettings.CPU.QPI) { DBG(" QPI: hw.busfrequency=%lluHz\n", MultU64x32(gSettings.CPU.QPI, Mega)); } else { // to match the value of hw.busfrequency in the terminal - DBG(" PIS: hw.busfrequency=%lluHz\n", MultU64x32(LShiftU64(DivU64x32(gCPUStructure.ExternalClock + Kilo - 1, Kilo), 2), Mega)); + DBG(" PIS: hw.busfrequency=%lluHz\n", + MultU64x32( + LShiftU64(DivU64x32(gCPUStructure.ExternalClock + Kilo - 1, Kilo), + 2), + Mega)); } - - //Free memory + + // Free memory ConfigsList.setEmpty(); DsdtsList.setEmpty(); OptionMenu.FreeMenu(); - //there is a place to free memory - // GuiAnime - // mainParser - // BuiltinIcons - // OSIcons - - delete ThemeX; - ThemeX = NULL; + // there is a place to free memory + // GuiAnime + // mainParser + // BuiltinIcons + // OSIcons - devprop_free_string(); + delete ThemeX; + ThemeX = NULL; + devprop_free_string(); #ifdef NANOSVG_MEMORY_ALLOCATION_TRACE - if ( nsvg__nbDanglingPtr() > 0 ) { - DBG("There is %zu dangling ptr from SVG subsytem\n", nsvg__nbDanglingPtr()); - nsvg__outputDanglingPtr(); - } + if (nsvg__nbDanglingPtr() > 0) { + DBG("There is %zu dangling ptr from SVG subsytem\n", nsvg__nbDanglingPtr()); + nsvg__outputDanglingPtr(); + } #endif #ifdef JIEF_DEBUG - displayFreeMemory("LOADER_ENTRY::StartLoader() atfer ThemeX deleted"_XS8); + displayFreeMemory("LOADER_ENTRY::StartLoader() atfer ThemeX deleted"_XS8); #endif + if (OSTYPE_IS_OSX(LoaderType) || OSTYPE_IS_OSX_RECOVERY(LoaderType) || + OSTYPE_IS_OSX_INSTALLER(LoaderType)) { - if ( OSTYPE_IS_OSX(LoaderType) || OSTYPE_IS_OSX_RECOVERY(LoaderType) || OSTYPE_IS_OSX_INSTALLER(LoaderType) ) { - - // if OC is NOT initialized with OcMain, we need the following - // OcConfigureLogProtocol ( - // 9, - // 0, - // 2151678018, - // 2147483648, - // OPEN_CORE_LOG_PREFIX_PATH, - // mOpenCoreStorage.FileSystem - // ); - // DEBUG ((DEBUG_INFO, "OC: Log initialized...\n")); - // OcAppleDebugLogInstallProtocol(0); + // if OC is NOT initialized with OcMain, we need the following + // OcConfigureLogProtocol ( + // 9, + // 0, + // 2151678018, + // 2147483648, + // OPEN_CORE_LOG_PREFIX_PATH, + // mOpenCoreStorage.FileSystem + // ); + // DEBUG ((DEBUG_INFO, "OC: Log initialized...\n")); + // OcAppleDebugLogInstallProtocol(0); DBG("Beginning OC\n"); - EFI_LOADED_IMAGE* OcLoadedImage; - Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &OcLoadedImage); - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem = OcLocateFileSystem(OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath); - Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, NULL, NULL, self.getCloverDirFullPath().wc_str(), NULL); - + EFI_LOADED_IMAGE *OcLoadedImage; + Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, + (VOID **)&OcLoadedImage); + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem = OcLocateFileSystem( + OcLoadedImage->DeviceHandle, OcLoadedImage->FilePath); + Status = OcStorageInitFromFs(&mOpenCoreStorage, FileSystem, NULL, NULL, + self.getCloverDirFullPath().wc_str(), NULL); - #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) +#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 used 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 ( gSettings.Boot.DebugLog ) { + // DBG("config-oc.plist isn't used 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 (gSettings.Boot.DebugLog) { mOpenCoreConfiguration.Misc.Debug.AppleDebug = true; mOpenCoreConfiguration.Misc.Debug.ApplePanic = true; - #ifdef JIEF_DEBUG - mOpenCoreConfiguration.Misc.Debug.SysReport = true; - #endif +#ifdef JIEF_DEBUG + mOpenCoreConfiguration.Misc.Debug.SysReport = true; +#endif - #ifndef LESS_DEBUG +#ifndef LESS_DEBUG mOpenCoreConfiguration.Misc.Debug.DisplayLevel = 0x80400042; - #else +#else mOpenCoreConfiguration.Misc.Debug.DisplayLevel = 0x80000042; - #endif +#endif mOpenCoreConfiguration.Misc.Debug.Target = 0x41; } else { - #ifdef JIEF_DEBUG +#ifdef JIEF_DEBUG egSetGraphicsModeEnabled(false); mOpenCoreConfiguration.Misc.Debug.ApplePanic = true; mOpenCoreConfiguration.Misc.Debug.DisplayLevel = 0x80000042; mOpenCoreConfiguration.Misc.Debug.Target = 0x41; - #endif +#endif } - #ifndef USE_OC_SECTION_Misc - OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Security.SecureBootModel, "Disabled"); +#ifndef USE_OC_SECTION_Misc + OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Security.SecureBootModel, + "Disabled"); OC_STRING_ASSIGN(mOpenCoreConfiguration.Misc.Security.Vault, "Optional"); - #endif - #ifdef USE_OC_SECTION_Nvram +#endif +#ifdef USE_OC_SECTION_Nvram mOpenCoreConfiguration.Nvram.WriteFlash = true; - #endif +#endif #ifndef USE_OC_SECTION_Uefi - mOpenCoreConfiguration.Uefi.Quirks.ForceOcWriteFlash = gSettings.Quirks.OcBooterQuirks.ForceOcWriteFlash; + mOpenCoreConfiguration.Uefi.Quirks.ForceOcWriteFlash = + gSettings.Quirks.OcBooterQuirks.ForceOcWriteFlash; #endif - #ifndef USE_OC_SECTION_Booter - - mOpenCoreConfiguration.Booter.MmioWhitelist.Count = (UINT32)gSettings.Quirks.mmioWhiteListArray.size(); - 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 - if ( mOpenCoreConfiguration.Booter.MmioWhitelist.Count > 0 ) { - mOpenCoreConfiguration.Booter.MmioWhitelist.Values = (OC_BOOTER_WL_ENTRY**)AllocatePool(mOpenCoreConfiguration.Booter.MmioWhitelist.AllocCount * sizeof(*mOpenCoreConfiguration.Booter.MmioWhitelist.Values)); // sizeof(OC_KERNEL_ADD_ENTRY) == 680 +#ifndef USE_OC_SECTION_Booter + + mOpenCoreConfiguration.Booter.MmioWhitelist.Count = + (UINT32)gSettings.Quirks.mmioWhiteListArray.size(); + 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 + if (mOpenCoreConfiguration.Booter.MmioWhitelist.Count > 0) { + mOpenCoreConfiguration.Booter.MmioWhitelist.Values = + (OC_BOOTER_WL_ENTRY **)AllocatePool( + mOpenCoreConfiguration.Booter.MmioWhitelist.AllocCount * + sizeof(*mOpenCoreConfiguration.Booter.MmioWhitelist + .Values)); // sizeof(OC_KERNEL_ADD_ENTRY) == 680 } else { mOpenCoreConfiguration.Booter.MmioWhitelist.Values = NULL; } - for ( size_t idx = 0 ; idx < gSettings.Quirks.mmioWhiteListArray.size() ; 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()); - mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx] = (__typeof_am__(*mOpenCoreConfiguration.Booter.MmioWhitelist.Values))AllocatePool(mOpenCoreConfiguration.Booter.MmioWhitelist.ValueSize); - mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Address = entry.address; - OC_STRING_ASSIGN(mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Comment, entry.comment.c_str()); - mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Enabled = entry.enabled; - } - - // It's possible to memcpy the whole struct instead of assigning individual member. But that would be relying on internel C++ binary structure, - // and worse, if a field is added by OC, everything could be shifted. - memset(&mOpenCoreConfiguration.Booter.Quirks, 0, sizeof(mOpenCoreConfiguration.Booter.Quirks)); - mOpenCoreConfiguration.Booter.Quirks.AvoidRuntimeDefrag = gSettings.Quirks.OcBooterQuirks.AvoidRuntimeDefrag; - mOpenCoreConfiguration.Booter.Quirks.DevirtualiseMmio = gSettings.Quirks.OcBooterQuirks.DevirtualiseMmio; - mOpenCoreConfiguration.Booter.Quirks.DisableSingleUser = gSettings.Quirks.OcBooterQuirks.DisableSingleUser; - mOpenCoreConfiguration.Booter.Quirks.DisableVariableWrite = gSettings.Quirks.OcBooterQuirks.DisableVariableWrite; - mOpenCoreConfiguration.Booter.Quirks.DiscardHibernateMap = gSettings.Quirks.OcBooterQuirks.DiscardHibernateMap; - mOpenCoreConfiguration.Booter.Quirks.EnableSafeModeSlide = gSettings.Quirks.OcBooterQuirks.EnableSafeModeSlide; - mOpenCoreConfiguration.Booter.Quirks.EnableWriteUnprotector = gSettings.Quirks.OcBooterQuirks.EnableWriteUnprotector; - mOpenCoreConfiguration.Booter.Quirks.ForceExitBootServices = gSettings.Quirks.OcBooterQuirks.ForceExitBootServices; - mOpenCoreConfiguration.Booter.Quirks.ProtectMemoryRegions = gSettings.Quirks.OcBooterQuirks.ProtectMemoryRegions; - mOpenCoreConfiguration.Booter.Quirks.ProtectSecureBoot = gSettings.Quirks.OcBooterQuirks.ProtectSecureBoot; - mOpenCoreConfiguration.Booter.Quirks.ProtectUefiServices = gSettings.Quirks.OcBooterQuirks.ProtectUefiServices; - mOpenCoreConfiguration.Booter.Quirks.ProvideCustomSlide = gSettings.Quirks.OcBooterQuirks.ProvideCustomSlide; - mOpenCoreConfiguration.Booter.Quirks.ProvideMaxSlide = gSettings.Quirks.OcBooterQuirks.ProvideMaxSlide; - mOpenCoreConfiguration.Booter.Quirks.RebuildAppleMemoryMap = gSettings.Quirks.OcBooterQuirks.RebuildAppleMemoryMap; - mOpenCoreConfiguration.Booter.Quirks.ResizeAppleGpuBars = gSettings.Quirks.OcBooterQuirks.ResizeAppleGpuBars; - mOpenCoreConfiguration.Booter.Quirks.SetupVirtualMap = gSettings.Quirks.OcBooterQuirks.SetupVirtualMap; - mOpenCoreConfiguration.Booter.Quirks.SignalAppleOS = false; //gSettings.Quirks.OcBooterQuirks.SignalAppleOS; - mOpenCoreConfiguration.Booter.Quirks.SyncRuntimePermissions = gSettings.Quirks.OcBooterQuirks.SyncRuntimePermissions; - - - #endif + for (size_t idx = 0; idx < gSettings.Quirks.mmioWhiteListArray.size(); + 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()); + mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx] = (__typeof_am__( + *mOpenCoreConfiguration.Booter.MmioWhitelist.Values)) + AllocatePool(mOpenCoreConfiguration.Booter.MmioWhitelist.ValueSize); + mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Address = + entry.address; + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Comment, + entry.comment.c_str()); + mOpenCoreConfiguration.Booter.MmioWhitelist.Values[idx]->Enabled = + entry.enabled; + } + + // It's possible to memcpy the whole struct instead of assigning individual + // member. But that would be relying on internel C++ binary structure, and + // worse, if a field is added by OC, everything could be shifted. + memset(&mOpenCoreConfiguration.Booter.Quirks, 0, + sizeof(mOpenCoreConfiguration.Booter.Quirks)); + mOpenCoreConfiguration.Booter.Quirks.AvoidRuntimeDefrag = + gSettings.Quirks.OcBooterQuirks.AvoidRuntimeDefrag; + mOpenCoreConfiguration.Booter.Quirks.DevirtualiseMmio = + gSettings.Quirks.OcBooterQuirks.DevirtualiseMmio; + mOpenCoreConfiguration.Booter.Quirks.DisableSingleUser = + gSettings.Quirks.OcBooterQuirks.DisableSingleUser; + mOpenCoreConfiguration.Booter.Quirks.DisableVariableWrite = + gSettings.Quirks.OcBooterQuirks.DisableVariableWrite; + mOpenCoreConfiguration.Booter.Quirks.DiscardHibernateMap = + gSettings.Quirks.OcBooterQuirks.DiscardHibernateMap; + mOpenCoreConfiguration.Booter.Quirks.EnableSafeModeSlide = + gSettings.Quirks.OcBooterQuirks.EnableSafeModeSlide; + mOpenCoreConfiguration.Booter.Quirks.EnableWriteUnprotector = + gSettings.Quirks.OcBooterQuirks.EnableWriteUnprotector; + mOpenCoreConfiguration.Booter.Quirks.ForceExitBootServices = + gSettings.Quirks.OcBooterQuirks.ForceExitBootServices; + mOpenCoreConfiguration.Booter.Quirks.ProtectMemoryRegions = + gSettings.Quirks.OcBooterQuirks.ProtectMemoryRegions; + mOpenCoreConfiguration.Booter.Quirks.ProtectSecureBoot = + gSettings.Quirks.OcBooterQuirks.ProtectSecureBoot; + mOpenCoreConfiguration.Booter.Quirks.ProtectUefiServices = + gSettings.Quirks.OcBooterQuirks.ProtectUefiServices; + mOpenCoreConfiguration.Booter.Quirks.ProvideCustomSlide = + gSettings.Quirks.OcBooterQuirks.ProvideCustomSlide; + mOpenCoreConfiguration.Booter.Quirks.ProvideMaxSlide = + gSettings.Quirks.OcBooterQuirks.ProvideMaxSlide; + mOpenCoreConfiguration.Booter.Quirks.RebuildAppleMemoryMap = + gSettings.Quirks.OcBooterQuirks.RebuildAppleMemoryMap; + mOpenCoreConfiguration.Booter.Quirks.ResizeAppleGpuBars = + gSettings.Quirks.OcBooterQuirks.ResizeAppleGpuBars; + mOpenCoreConfiguration.Booter.Quirks.SetupVirtualMap = + gSettings.Quirks.OcBooterQuirks.SetupVirtualMap; + mOpenCoreConfiguration.Booter.Quirks.SignalAppleOS = + false; // gSettings.Quirks.OcBooterQuirks.SignalAppleOS; + mOpenCoreConfiguration.Booter.Quirks.SyncRuntimePermissions = + gSettings.Quirks.OcBooterQuirks.SyncRuntimePermissions; +#endif FillOCCpuInfo(&mOpenCoreCpuInfo); - mOpenCoreConfiguration.Uefi.Quirks.TscSyncTimeout = gSettings.Quirks.OcBooterQuirks.TscSyncTimeout; + mOpenCoreConfiguration.Uefi.Quirks.TscSyncTimeout = + gSettings.Quirks.OcBooterQuirks.TscSyncTimeout; + mOpenCoreConfiguration.Uefi.Quirks.ResizeGpuBars = + gSettings.Quirks.OcBooterQuirks.ResizeGpuBars; - #ifndef USE_OC_SECTION_Kernel +#ifndef USE_OC_SECTION_Kernel XObjArray kextArray; if (!DoHibernateWake) { @@ -1133,60 +1282,98 @@ void LOADER_ENTRY::StartLoader() } OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Scheme.KernelArch, "x86_64"); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Scheme.KernelCache, gSettings.Quirks.OcKernelCache.c_str()); - mOpenCoreConfiguration.Kernel.Scheme.FuzzyMatch = gSettings.Quirks.FuzzyMatch; - - memset(&mOpenCoreConfiguration.Kernel.Quirks, 0, sizeof(mOpenCoreConfiguration.Kernel.Quirks)); - - mOpenCoreConfiguration.Kernel.Quirks.SetApfsTrimTimeout = -1; // Jief: Slice modified OcConfigurationLib.h to set -1 by default instead of 999. I prefer the modification here to minimize commits in OC submodule. Makes it easier to upgrade submodule. - mOpenCoreConfiguration.Kernel.Quirks.AppleCpuPmCfgLock = GlobalConfig.KPAppleIntelCPUPM || GlobalConfig.NeedPMfix ; - mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmCfgLock = GlobalConfig.KPKernelPm || GlobalConfig.NeedPMfix ; - - mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmExtraMsrs = gSettings.Quirks.OcKernelQuirks.AppleXcpmExtraMsrs; - mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmForceBoost = gSettings.Quirks.OcKernelQuirks.AppleXcpmForceBoost; - #ifndef USE_OC_SECTION_PlatformInfo - mOpenCoreConfiguration.Kernel.Quirks.CustomSmbiosGuid = gSettings.KernelAndKextPatches.KPDELLSMBIOS; - #endif - mOpenCoreConfiguration.Kernel.Quirks.DisableIoMapper = gSettings.Quirks.OcKernelQuirks.DisableIoMapper; - mOpenCoreConfiguration.Kernel.Quirks.DisableLinkeditJettison = gSettings.Quirks.OcKernelQuirks.DisableLinkeditJettison; - mOpenCoreConfiguration.Kernel.Quirks.DisableRtcChecksum = gSettings.KernelAndKextPatches.KPAppleRTC; - mOpenCoreConfiguration.Kernel.Emulate.DummyPowerManagement = gSettings.Quirks.OcKernelQuirks.DummyPowerManagement; - mOpenCoreConfiguration.Kernel.Quirks.ExtendBTFeatureFlags = gSettings.Quirks.OcKernelQuirks.ExtendBTFeatureFlags; - mOpenCoreConfiguration.Kernel.Quirks.ExternalDiskIcons = gSettings.Quirks.OcKernelQuirks.ExternalDiskIcons; - mOpenCoreConfiguration.Kernel.Quirks.IncreasePciBarSize = gSettings.Quirks.OcKernelQuirks.IncreasePciBarSize; - mOpenCoreConfiguration.Kernel.Quirks.ForceAquantiaEthernet = gSettings.Quirks.OcKernelQuirks.ForceAquantiaEthernet; - mOpenCoreConfiguration.Kernel.Quirks.LapicKernelPanic = gSettings.KernelAndKextPatches.KPKernelLapic; - mOpenCoreConfiguration.Kernel.Quirks.PanicNoKextDump = gSettings.KernelAndKextPatches.KPPanicNoKextDump; - mOpenCoreConfiguration.Kernel.Quirks.PowerTimeoutKernelPanic = gSettings.Quirks.OcKernelQuirks.PowerTimeoutKernelPanic; - mOpenCoreConfiguration.Kernel.Quirks.ThirdPartyDrives = gSettings.Quirks.OcKernelQuirks.ThirdPartyDrives; - mOpenCoreConfiguration.Kernel.Quirks.XhciPortLimit = gSettings.Quirks.OcKernelQuirks.XhciPortLimit; - mOpenCoreConfiguration.Kernel.Quirks.ProvideCurrentCpuInfo = gSettings.Quirks.OcKernelQuirks.ProvideCurrentCpuInfo; + OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Scheme.KernelCache, + gSettings.Quirks.OcKernelCache.c_str()); + mOpenCoreConfiguration.Kernel.Scheme.FuzzyMatch = + gSettings.Quirks.FuzzyMatch; + + memset(&mOpenCoreConfiguration.Kernel.Quirks, 0, + sizeof(mOpenCoreConfiguration.Kernel.Quirks)); + + mOpenCoreConfiguration.Kernel.Quirks.SetApfsTrimTimeout = + -1; // Jief: Slice modified OcConfigurationLib.h to set -1 by default + // instead of 999. I prefer the modification here to minimize + // commits in OC submodule. Makes it easier to upgrade submodule. + mOpenCoreConfiguration.Kernel.Quirks.AppleCpuPmCfgLock = + GlobalConfig.KPAppleIntelCPUPM || GlobalConfig.NeedPMfix; + mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmCfgLock = + GlobalConfig.KPKernelPm || GlobalConfig.NeedPMfix; + + mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmExtraMsrs = + gSettings.Quirks.OcKernelQuirks.AppleXcpmExtraMsrs; + mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmForceBoost = + gSettings.Quirks.OcKernelQuirks.AppleXcpmForceBoost; +#ifndef USE_OC_SECTION_PlatformInfo + mOpenCoreConfiguration.Kernel.Quirks.CustomSmbiosGuid = + gSettings.KernelAndKextPatches.KPDELLSMBIOS; +#endif + mOpenCoreConfiguration.Kernel.Quirks.DisableIoMapper = + gSettings.Quirks.OcKernelQuirks.DisableIoMapper; + mOpenCoreConfiguration.Kernel.Quirks.DisableIoMapperMapping = + gSettings.Quirks.OcKernelQuirks.DisableIoMapperMapping; + mOpenCoreConfiguration.Kernel.Quirks.DisableLinkeditJettison = + gSettings.Quirks.OcKernelQuirks.DisableLinkeditJettison; + mOpenCoreConfiguration.Kernel.Quirks.DisableRtcChecksum = + gSettings.KernelAndKextPatches.KPAppleRTC; + mOpenCoreConfiguration.Kernel.Emulate.DummyPowerManagement = + gSettings.Quirks.OcKernelQuirks.DummyPowerManagement; + mOpenCoreConfiguration.Kernel.Quirks.ExtendBTFeatureFlags = + gSettings.Quirks.OcKernelQuirks.ExtendBTFeatureFlags; + mOpenCoreConfiguration.Kernel.Quirks.ExternalDiskIcons = + gSettings.Quirks.OcKernelQuirks.ExternalDiskIcons; + mOpenCoreConfiguration.Kernel.Quirks.IncreasePciBarSize = + gSettings.Quirks.OcKernelQuirks.IncreasePciBarSize; + mOpenCoreConfiguration.Kernel.Quirks.ForceAquantiaEthernet = + gSettings.Quirks.OcKernelQuirks.ForceAquantiaEthernet; + mOpenCoreConfiguration.Kernel.Quirks.LapicKernelPanic = + gSettings.KernelAndKextPatches.KPKernelLapic; + mOpenCoreConfiguration.Kernel.Quirks.PanicNoKextDump = + gSettings.KernelAndKextPatches.KPPanicNoKextDump; + mOpenCoreConfiguration.Kernel.Quirks.PowerTimeoutKernelPanic = + gSettings.Quirks.OcKernelQuirks.PowerTimeoutKernelPanic; + mOpenCoreConfiguration.Kernel.Quirks.ThirdPartyDrives = + gSettings.Quirks.OcKernelQuirks.ThirdPartyDrives; + mOpenCoreConfiguration.Kernel.Quirks.XhciPortLimit = + gSettings.Quirks.OcKernelQuirks.XhciPortLimit; + mOpenCoreConfiguration.Kernel.Quirks.ProvideCurrentCpuInfo = + gSettings.Quirks.OcKernelQuirks.ProvideCurrentCpuInfo; 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**)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)); + 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 **)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); pos = setKextAtPos(&kextArray, "VirtualSMC.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "FakeSMC.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "WhateverGreen.kext"_XS8, pos); -// pos = setKextAtPos(&kextArray, "AppleMCEReporterDisabler.kext"_XS8, pos); -// pos = setKextAtPos(&kextArray, "AppleIntelI210Ethernet.kext"_XS8, pos); -// pos = setKextAtPos(&kextArray, "USBWakeFixup.kext"_XS8, pos); - pos = setKextAtPos(&kextArray, "USBInjectAll.kext"_XS8, pos); -// pos = setKextAtPos(&kextArray, "FeatureUnlock.kext"_XS8, pos); -// pos = setKextAtPos(&kextArray, "vecLib.kext"_XS8, pos); -// pos = setKextAtPos(&kextArray, "IOAudioFamily.kext"_XS8, pos); + // pos = setKextAtPos(&kextArray, "AppleMCEReporterDisabler.kext"_XS8, + // pos); pos = setKextAtPos(&kextArray, + // "AppleIntelI210Ethernet.kext"_XS8, pos); pos = + // setKextAtPos(&kextArray, "USBWakeFixup.kext"_XS8, pos); + pos = setKextAtPos(&kextArray, "USBInjectAll.kext"_XS8, pos); + // pos = setKextAtPos(&kextArray, "FeatureUnlock.kext"_XS8, pos); + // pos = setKextAtPos(&kextArray, "vecLib.kext"_XS8, pos); + // pos = setKextAtPos(&kextArray, "IOAudioFamily.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "IOSkywalkFamily.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "FakePCIID.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "FakePCIID_XHCIMux.kext"_XS8, pos); - pos = setKextAtPos(&kextArray, "AMDRyzenCPUPowerManagement.kext"_XS8, pos); + pos = setKextAtPos(&kextArray, "AMDRyzenCPUPowerManagement.kext"_XS8, + pos); pos = setKextAtPos(&kextArray, "SMCAMDProcessor.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "AppleALC.kext"_XS8, pos); -// pos = setKextAtPos(&kextArray, "IntelMausi.kext"_XS8, pos); // not needed special order? + // pos = setKextAtPos(&kextArray, "IntelMausi.kext"_XS8, pos); // not + // needed special order? pos = setKextAtPos(&kextArray, "SMCProcessor.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "USBPorts.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "VoodooGPIO.kext"_XS8, pos); @@ -1207,69 +1394,122 @@ void LOADER_ENTRY::StartLoader() pos = setKextAtPos(&kextArray, "SMCProcessorAMD.kext"_XS8, pos); pos = setKextAtPos(&kextArray, "SMCSuperIO.kext"_XS8, pos); - for (size_t kextIdx = 0 ; kextIdx < kextArray.size() ; kextIdx++ ) { - const SIDELOAD_KEXT& KextEntry = kextArray[kextIdx]; - DBG("Bridge kext to OC : Path=%ls\\%ls\n", KextEntry.KextDirNameUnderOEMPath.wc_str(), KextEntry.FileName.wc_str()); - 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); + for (size_t kextIdx = 0; kextIdx < kextArray.size(); kextIdx++) { + const SIDELOAD_KEXT &KextEntry = kextArray[kextIdx]; + DBG("Bridge kext to OC : Path=%ls\\%ls\n", + KextEntry.KextDirNameUnderOEMPath.wc_str(), + KextEntry.FileName.wc_str()); + 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, 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, ""); - - assert( selfOem.isKextsDirFound() ); // be sure before calling getKextsPathRelToSelfDir() - XStringW dirPath = SWPrintf("%ls\\%ls", selfOem.getKextsDirPathRelToSelfDir().wc_str(), KextEntry.KextDirNameUnderOEMPath.wc_str()); - - XString8 bundleFullPath = S8Printf("%ls\\%ls", dirPath.wc_str(), KextEntry.FileName.wc_str()); - if ( FileExists(&self.getCloverDir(), bundleFullPath) ) { - XString8 bundlePathUnderKextsDir = S8Printf("%ls\\%ls", KextEntry.KextDirNameUnderOEMPath.wc_str(), KextEntry.FileName.wc_str()); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath, bundlePathUnderKextsDir.c_str()); - // DBG("OC BundlePath = '%s'\n", OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath)); + 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, ""); + + assert(selfOem.isKextsDirFound()); // be sure before calling + // getKextsPathRelToSelfDir() + XStringW dirPath = + SWPrintf("%ls\\%ls", selfOem.getKextsDirPathRelToSelfDir().wc_str(), + KextEntry.KextDirNameUnderOEMPath.wc_str()); + + XString8 bundleFullPath = + S8Printf("%ls\\%ls", dirPath.wc_str(), KextEntry.FileName.wc_str()); + if (FileExists(&self.getCloverDir(), bundleFullPath)) { + XString8 bundlePathUnderKextsDir = + S8Printf("%ls\\%ls", KextEntry.KextDirNameUnderOEMPath.wc_str(), + KextEntry.FileName.wc_str()); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath, + bundlePathUnderKextsDir.c_str()); + // DBG("OC BundlePath = '%s'\n", + // OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath)); } else { DBG("Cannot find kext bundlePath at '%s'\n", bundleFullPath.c_str()); } - #if 1 - //CFBundleExecutable +#if 1 + // CFBundleExecutable XBool NoContents = false; - XStringW infoPlistPathRelToSelf = getKextPlist(&self.getCloverDir(), dirPath, KextEntry.FileName, &NoContents); //it will be fullPath, including dir + XStringW infoPlistPathRelToSelf = + getKextPlist(&self.getCloverDir(), dirPath, KextEntry.FileName, + &NoContents); // it will be fullPath, including dir - // XBool inject = checkOSBundleRequired(dict); + // XBool inject = checkOSBundleRequired(dict); XBool inject = true; if (inject) { - if ( infoPlistPathRelToSelf.notEmpty()) { + if (infoPlistPathRelToSelf.notEmpty()) { if (NoContents) { - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Info.plist"); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, + "Info.plist"); } else { - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Contents\\Info.plist"); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, + "Contents\\Info.plist"); } - // DBG("OC PlistPath = '%s'\n", OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath)); + // DBG("OC PlistPath = '%s'\n", + // OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath)); } else { - DBG("Cannot find kext info.plist at '%ls'\n", KextEntry.FileName.wc_str()); + DBG("Cannot find kext info.plist at '%ls'\n", + KextEntry.FileName.wc_str()); } - TagDict* dict = getInfoPlist(&self.getCloverDir(), infoPlistPathRelToSelf); - XString8 execpath = getKextExecPath(&self.getCloverDir(), KextEntry.KextDirNameUnderOEMPath, KextEntry.FileName, dict, NoContents); + TagDict *dict = + getInfoPlist(&self.getCloverDir(), infoPlistPathRelToSelf); + XString8 execpath = getKextExecPath( + &self.getCloverDir(), KextEntry.KextDirNameUnderOEMPath, + KextEntry.FileName, dict, NoContents); if (execpath.notEmpty()) { - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, execpath.c_str()); - // DBG("OC ExecutablePath = '%s'\n", execpath.c_str()); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ExecutablePath, + execpath.c_str()); + // DBG("OC ExecutablePath = '%s'\n", execpath.c_str()); } - if ( dict ) dict->ReleaseTag(); + if (dict) + dict->ReleaseTag(); } - #else - XStringW execpath = S8Printf("Contents\\MacOS\\%ls", KextEntry.FileName.subString(0, KextEntry.FileName.rindexOf(".")).wc_str()); - XStringW fullPath = SWPrintf("%s\\%ls", OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath), execpath.wc_str()); - if ( FileExists(&self.getCloverDir(), 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()); +#else + XStringW execpath = S8Printf( + "Contents\\MacOS\\%ls", + KextEntry.FileName.subString(0, KextEntry.FileName.rindexOf(".")) + .wc_str()); + XStringW fullPath = SWPrintf( + "%s\\%ls", + OC_BLOB_GET( + &mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath), + execpath.wc_str()); + if (FileExists(&self.getCloverDir(), 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()); } - XStringW infoPlistPathRelToSelf = SWPrintf("%s\\Contents\\Info.plist", OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath)); + XStringW infoPlistPathRelToSelf = SWPrintf( + "%s\\Contents\\Info.plist", + OC_BLOB_GET( + &mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->BundlePath)); if (FileExists(&self.getCloverDir(), infoPlistPathRelToSelf)) { - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, "Contents/Info.plist"); // TODO : is always Contents/Info.plist ? + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistPath, + "Contents/Info.plist"); // TODO : is always Contents/Info.plist ? } else { - DBG("Cannot find kext info.plist at '%ls'\n", infoPlistPathRelToSelf.wc_str()); + DBG("Cannot find kext info.plist at '%ls'\n", + infoPlistPathRelToSelf.wc_str()); } - #endif +#endif mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ImageData = NULL; mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->ImageDataSize = 0; mOpenCoreConfiguration.Kernel.Add.Values[kextIdx]->PlistData = NULL; @@ -1277,55 +1517,73 @@ void LOADER_ENTRY::StartLoader() } // for (size_t kextIdx - - mOpenCoreConfiguration.Kernel.Force.Count = (UINT32)KernelAndKextPatches.ForceKextsToLoad.size(); - mOpenCoreConfiguration.Kernel.Force.AllocCount = mOpenCoreConfiguration.Kernel.Force.Count; - mOpenCoreConfiguration.Kernel.Force.ValueSize = sizeof(__typeof_am__(**mOpenCoreConfiguration.Kernel.Force.Values)); // sizeof(OC_KERNEL_FORCE_ENTRY) - int valuesSize = mOpenCoreConfiguration.Kernel.Force.AllocCount*sizeof(*mOpenCoreConfiguration.Kernel.Force.Values); - mOpenCoreConfiguration.Kernel.Force.Values = (OC_KERNEL_ADD_ENTRY**)malloc(valuesSize); // sizeof(OC_KERNEL_FORCE_ENTRY*) == sizeof(ptr) + mOpenCoreConfiguration.Kernel.Force.Count = + (UINT32)KernelAndKextPatches.ForceKextsToLoad.size(); + mOpenCoreConfiguration.Kernel.Force.AllocCount = + mOpenCoreConfiguration.Kernel.Force.Count; + mOpenCoreConfiguration.Kernel.Force.ValueSize = + sizeof(__typeof_am__(**mOpenCoreConfiguration.Kernel.Force + .Values)); // sizeof(OC_KERNEL_FORCE_ENTRY) + int valuesSize = mOpenCoreConfiguration.Kernel.Force.AllocCount * + sizeof(*mOpenCoreConfiguration.Kernel.Force.Values); + mOpenCoreConfiguration.Kernel.Force.Values = (OC_KERNEL_ADD_ENTRY **)malloc( + valuesSize); // sizeof(OC_KERNEL_FORCE_ENTRY*) == sizeof(ptr) memset(mOpenCoreConfiguration.Kernel.Force.Values, 0, valuesSize); - - - for (size_t kextIdx = 0; kextIdx < KernelAndKextPatches.ForceKextsToLoad.size(); kextIdx++) { - const XStringW& forceKext = KernelAndKextPatches.ForceKextsToLoad[kextIdx]; + for (size_t kextIdx = 0; + kextIdx < KernelAndKextPatches.ForceKextsToLoad.size(); kextIdx++) { + const XStringW &forceKext = + KernelAndKextPatches.ForceKextsToLoad[kextIdx]; DBG("Force kext to OC : Path=%ls\n", forceKext.wc_str()); - mOpenCoreConfiguration.Kernel.Force.Values[kextIdx] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Force.Values))malloc(mOpenCoreConfiguration.Kernel.Force.ValueSize); - memset(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx], 0, mOpenCoreConfiguration.Kernel.Force.ValueSize); + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx] = + (__typeof_am__(*mOpenCoreConfiguration.Kernel.Force.Values))malloc( + mOpenCoreConfiguration.Kernel.Force.ValueSize); + memset(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx], 0, + mOpenCoreConfiguration.Kernel.Force.ValueSize); mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Enabled = 1; - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Arch, OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch)); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Comment, ""); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->MaxKernel, ""); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->MinKernel, ""); - // OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Identifier, ""); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Arch, + OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch)); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Comment, ""); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->MaxKernel, ""); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->MinKernel, ""); + // OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Identifier, + // ""); mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->ImageData = NULL; mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->ImageDataSize = 0; mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->PlistData = NULL; mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->PlistDataSize = 0; - REFIT_VOLUME * SystemVolume = Volume; - EFI_FILE* SysRoot = Volume->RootDir; - + REFIT_VOLUME *SystemVolume = Volume; + EFI_FILE *SysRoot = Volume->RootDir; if (Volume->ApfsRole == APPLE_APFS_VOLUME_ROLE_PREBOOT) { - //search for other partition + // search for other partition DBG("boot from Preboot, index=%llu\n", Volume->Index); size_t numbers = Volumes.size(); size_t sysIndex = 0; - for (sysIndex=Volume->Index+1; sysIndex < numbers; sysIndex++) { + for (sysIndex = Volume->Index + 1; sysIndex < numbers; sysIndex++) { SystemVolume = &Volumes[sysIndex]; SysRoot = SystemVolume->RootDir; - DBG("test volume %zd, name %ls:\n", sysIndex, SystemVolume->VolName.wc_str()); + DBG("test volume %zd, name %ls:\n", sysIndex, + SystemVolume->VolName.wc_str()); - if (FileExists(SysRoot, L"\\System\\Library\\CoreServices\\boot.efi")) { + if (FileExists(SysRoot, + L"\\System\\Library\\CoreServices\\boot.efi")) { DBG("boot.efi found on %zd\n", sysIndex); } - REFIT_DIR_ITER DirIter; - EFI_FILE_INFO *DirEntry = NULL; - DirIterOpen(SysRoot, L"\\System\\Library\\Extensions\\AMDSupport.kext\\Contents\\MacOS\\", &DirIter); + REFIT_DIR_ITER DirIter; + EFI_FILE_INFO *DirEntry = NULL; + DirIterOpen(SysRoot, + L"\\System\\Library\\Extensions\\AMDSupport." + L"kext\\Contents\\MacOS\\", + &DirIter); while (DirIterNext(&DirIter, 1, L"*", &DirEntry)) { if (DirEntry->FileName[0] == '.') { DBG("Skip dot entries: %ls\n", DirEntry->FileName); @@ -1334,142 +1592,177 @@ void LOADER_ENTRY::StartLoader() DBG("%ls attr=%llu\n", DirEntry->FileName, DirEntry->Attribute); } DirIterClose(&DirIter); - if (FileExists(SysRoot, L"\\System\\Library\\Extensions\\AMDSupport.kext\\Contents\\MacOS\\AMDSupport")) { - DBG("AMDSupport found on %zd\n", sysIndex); //never found - break; + if (FileExists(SysRoot, L"\\System\\Library\\Extensions\\AMDSupport." + L"kext\\Contents\\MacOS\\AMDSupport")) { + DBG("AMDSupport found on %zd\n", sysIndex); // never found + break; } } } - mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->ImageData = (UINT8*)SysRoot; + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->ImageData = + (UINT8 *)SysRoot; size_t i1 = forceKext.rindexOf("\\") + 1; size_t i2 = forceKext.rindexOf("."); XStringW identifier = forceKext.subString(i1, i2 - i1); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Identifier, S8Printf("%ls", identifier.wc_str()).c_str()); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->Identifier, + S8Printf("%ls", identifier.wc_str()).c_str()); XString8 execpath = S8Printf("Contents\\MacOS\\%ls", identifier.wc_str()); DBG("calculated execpath=%s\n", execpath.c_str()); - - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->BundlePath, S8Printf("%ls",forceKext.wc_str()).c_str()); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->PlistPath, "Contents\\Info.plist"); - - //then we have to find executablePath and plistPath - DBG("bundle path=%s\n", mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->BundlePath.Value); - - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->ExecutablePath, execpath.c_str()); - DBG("assign executable as '%s'\n", mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->ExecutablePath.Value); - + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->BundlePath, + S8Printf("%ls", forceKext.wc_str()).c_str()); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->PlistPath, + "Contents\\Info.plist"); + + // then we have to find executablePath and plistPath + DBG("bundle path=%s\n", + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx] + ->BundlePath.Value); + + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx]->ExecutablePath, + execpath.c_str()); + DBG("assign executable as '%s'\n", + mOpenCoreConfiguration.Kernel.Force.Values[kextIdx] + ->ExecutablePath.Value); } if (gSettings.KernelAndKextPatches.BlockSkywalk) { - mOpenCoreConfiguration.Kernel.Block.Count = 1; - mOpenCoreConfiguration.Kernel.Block.AllocCount = 1; - mOpenCoreConfiguration.Kernel.Block.ValueSize = sizeof(__typeof_am__(**mOpenCoreConfiguration.Kernel.Block.Values)); - valuesSize = mOpenCoreConfiguration.Kernel.Block.AllocCount*sizeof(*mOpenCoreConfiguration.Kernel.Block.Values); - mOpenCoreConfiguration.Kernel.Block.Values = (OC_KERNEL_BLOCK_ENTRY**)malloc(valuesSize); - - memset(mOpenCoreConfiguration.Kernel.Block.Values, 0, valuesSize); - - mOpenCoreConfiguration.Kernel.Block.Values[0] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Block.Values))malloc(mOpenCoreConfiguration.Kernel.Block.ValueSize); - memset(mOpenCoreConfiguration.Kernel.Block.Values[0], 0, mOpenCoreConfiguration.Kernel.Block.ValueSize); - mOpenCoreConfiguration.Kernel.Block.Values[0]->Enabled = 1; - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Arch, OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch)); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Comment, "Allow IOSkywalk Downgrade"); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->MaxKernel, ""); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->MinKernel, "23"); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Identifier, "com.apple.iokit.IOSkywalkFamily"); - OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Strategy, "Exclude"); - -// mOpenCoreConfiguration.Kernel.Block.Values[1] = (__typeof_am__(*mOpenCoreConfiguration.Kernel.Block.Values))malloc(mOpenCoreConfiguration.Kernel.Block.ValueSize); -// memset(mOpenCoreConfiguration.Kernel.Block.Values[1], 0, mOpenCoreConfiguration.Kernel.Block.ValueSize); -// mOpenCoreConfiguration.Kernel.Block.Values[1]->Enabled = 1; -// OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->Arch, OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch)); -// OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->Comment, ""); -// OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->MaxKernel, ""); -// OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->MinKernel, "23"); -// OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->Identifier, "com.apple.driver.mDNSOffloadUserClient"); -// OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->Strategy, "Exclude"); - - } - #endif - - #ifdef USE_OC_SECTION_Uefi + mOpenCoreConfiguration.Kernel.Block.Count = 1; + mOpenCoreConfiguration.Kernel.Block.AllocCount = 1; + mOpenCoreConfiguration.Kernel.Block.ValueSize = + sizeof(__typeof_am__(**mOpenCoreConfiguration.Kernel.Block.Values)); + valuesSize = mOpenCoreConfiguration.Kernel.Block.AllocCount * + sizeof(*mOpenCoreConfiguration.Kernel.Block.Values); + mOpenCoreConfiguration.Kernel.Block.Values = + (OC_KERNEL_BLOCK_ENTRY **)malloc(valuesSize); + + memset(mOpenCoreConfiguration.Kernel.Block.Values, 0, valuesSize); + + mOpenCoreConfiguration.Kernel.Block.Values[0] = + (__typeof_am__(*mOpenCoreConfiguration.Kernel.Block.Values))malloc( + mOpenCoreConfiguration.Kernel.Block.ValueSize); + memset(mOpenCoreConfiguration.Kernel.Block.Values[0], 0, + mOpenCoreConfiguration.Kernel.Block.ValueSize); + mOpenCoreConfiguration.Kernel.Block.Values[0]->Enabled = 1; + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Block.Values[0]->Arch, + OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch)); + OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Comment, + "Allow IOSkywalk Downgrade"); + OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->MaxKernel, + ""); + OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->MinKernel, + "23"); + OC_STRING_ASSIGN( + mOpenCoreConfiguration.Kernel.Block.Values[0]->Identifier, + "com.apple.iokit.IOSkywalkFamily"); + OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[0]->Strategy, + "Exclude"); + + // mOpenCoreConfiguration.Kernel.Block.Values[1] = + // (__typeof_am__(*mOpenCoreConfiguration.Kernel.Block.Values))malloc(mOpenCoreConfiguration.Kernel.Block.ValueSize); + // memset(mOpenCoreConfiguration.Kernel.Block.Values[1], 0, + // mOpenCoreConfiguration.Kernel.Block.ValueSize); + // mOpenCoreConfiguration.Kernel.Block.Values[1]->Enabled = 1; + // OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->Arch, + // OC_BLOB_GET(&mOpenCoreConfiguration.Kernel.Scheme.KernelArch)); + // OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->Comment, + // ""); + // OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->MaxKernel, + // ""); + // OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->MinKernel, + // "23"); + // OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->Identifier, + // "com.apple.driver.mDNSOffloadUserClient"); + // OC_STRING_ASSIGN(mOpenCoreConfiguration.Kernel.Block.Values[1]->Strategy, + // "Exclude"); + } +#endif + +#ifdef USE_OC_SECTION_Uefi gSettings.Devices.USB.USBFixOwnership = false; // Use OC FixUsbOwnership - mOpenCoreConfiguration.Uefi.Quirks.ReleaseUsbOwnership = false; // Clover has it's own FixUsbOwnership - #else - mOpenCoreConfiguration.Uefi.Output.ProvideConsoleGop = gSettings.GUI.ProvideConsoleGop; - OC_STRING_ASSIGN(mOpenCoreConfiguration.Uefi.Output.Resolution, XString8(gSettings.GUI.ScreenResolution).c_str()); - #endif - - if ( OpenRuntimeEfiName.notEmpty() ) { - XStringW FileName = SWPrintf("%ls\\%ls\\%ls", self.getCloverDirFullPath().wc_str(), getDriversPath().wc_str(), OpenRuntimeEfiName.wc_str()); + mOpenCoreConfiguration.Uefi.Quirks.ReleaseUsbOwnership = + false; // Clover has it's own FixUsbOwnership +#else + mOpenCoreConfiguration.Uefi.Output.ProvideConsoleGop = + gSettings.GUI.ProvideConsoleGop; + OC_STRING_ASSIGN(mOpenCoreConfiguration.Uefi.Output.Resolution, + XString8(gSettings.GUI.ScreenResolution).c_str()); +#endif + + if (OpenRuntimeEfiName.notEmpty()) { + XStringW FileName = + SWPrintf("%ls\\%ls\\%ls", self.getCloverDirFullPath().wc_str(), + getDriversPath().wc_str(), OpenRuntimeEfiName.wc_str()); EFI_HANDLE DriverHandle; - Status = gBS->LoadImage(false, gImageHandle, FileDevicePath(self.getSelfLoadedImage().DeviceHandle, FileName), NULL, 0, &DriverHandle); - if ( !EFI_ERROR(Status) ) { + Status = gBS->LoadImage( + false, gImageHandle, + FileDevicePath(self.getSelfLoadedImage().DeviceHandle, FileName), + NULL, 0, &DriverHandle); + if (!EFI_ERROR(Status)) { Status = gBS->StartImage(DriverHandle, 0, 0); - DBG("Start '%ls' : Status %s\n", OpenRuntimeEfiName.wc_str(), efiStrError(Status)); - - if ( !EFI_ERROR(Status) ) - { - OC_FIRMWARE_RUNTIME_PROTOCOL *FwRuntime; - Status = gBS->LocateProtocol ( - gOcFirmwareRuntimeProtocolGuid, - NULL, - (VOID **) &FwRuntime - ); - - if (!EFI_ERROR (Status)) { + DBG("Start '%ls' : Status %s\n", OpenRuntimeEfiName.wc_str(), + efiStrError(Status)); + + if (!EFI_ERROR(Status)) { + OC_FIRMWARE_RUNTIME_PROTOCOL *FwRuntime; + Status = gBS->LocateProtocol(gOcFirmwareRuntimeProtocolGuid, NULL, + (VOID **)&FwRuntime); + + if (!EFI_ERROR(Status)) { if (FwRuntime->Revision == OC_FIRMWARE_RUNTIME_REVISION) { } else { - DEBUG (( - DEBUG_ERROR, - "OCABC: Incompatible OpenRuntime r%u, require r%u\n", - (UINT32) FwRuntime->Revision, - (UINT32) OC_FIRMWARE_RUNTIME_REVISION - )); - DBG("Incompatible OpenRuntime r%llu, require r%u\n", FwRuntime->Revision, OC_FIRMWARE_RUNTIME_REVISION); + DEBUG((DEBUG_ERROR, + "OCABC: Incompatible OpenRuntime r%u, require r%u\n", + (UINT32)FwRuntime->Revision, + (UINT32)OC_FIRMWARE_RUNTIME_REVISION)); + DBG("Incompatible OpenRuntime r%llu, require r%u\n", + FwRuntime->Revision, OC_FIRMWARE_RUNTIME_REVISION); } } } - }else{ - DBG("Error when loading '%ls' : Status %s.\n", OpenRuntimeEfiName.wc_str(), efiStrError(Status)); + } else { + DBG("Error when loading '%ls' : Status %s.\n", + OpenRuntimeEfiName.wc_str(), efiStrError(Status)); } - }else{ + } else { DBG("No OpenRuntime driver. This is wrong, OpenRuntime is mandatory.\n"); } OcMain(&mOpenCoreStorage, NULL); XStringW DevicePathAsString = DevicePathToXStringW(DevicePath); - if ( DevicePathAsString.rindexOf(".dmg") == MAX_XSIZE ) - { + if (DevicePathAsString.rindexOf(".dmg") == MAX_XSIZE) { // point to InternalEfiLoadImage from OC - Status = gBS->LoadImage ( - false, - gImageHandle, - DevicePath, - NULL, - 0, - &ImageHandle - ); - if ( EFI_ERROR(Status) ) { - DBG("LoadImage at '%ls' failed. Status = %s\n", DevicePathAsString.wc_str(), efiStrError(Status)); + Status = gBS->LoadImage(false, gImageHandle, DevicePath, NULL, 0, + &ImageHandle); + if (EFI_ERROR(Status)) { + DBG("LoadImage at '%ls' failed. Status = %s\n", + DevicePathAsString.wc_str(), efiStrError(Status)); return; } DBG("ImageHandle = %llx\n", uintptr_t(ImageHandle)); } else { // NOTE : OpenCore ignore the name of the dmg. - // InternalLoadDmg calls InternalFindFirstDmgFileName to find the dmg file name. - // So be careful that, if an other dmg exists in the dir, that might boot on the wrong one. + // InternalLoadDmg calls InternalFindFirstDmgFileName to find the + // dmg file name. So be careful that, if an other dmg exists in the + // dir, that might boot on the wrong one. - EFI_DEVICE_PATH_PROTOCOL* DevicePathCopy = DuplicateDevicePath(DevicePath); + EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy = + DuplicateDevicePath(DevicePath); - EFI_DEVICE_PATH_PROTOCOL* PreviousNode = NULL; - EFI_DEVICE_PATH_PROTOCOL* Node = DevicePathCopy; + EFI_DEVICE_PATH_PROTOCOL *PreviousNode = NULL; + EFI_DEVICE_PATH_PROTOCOL *Node = DevicePathCopy; while (!IsDevicePathEnd(Node)) { - if ( Node->Type == MEDIA_DEVICE_PATH && Node->SubType == MEDIA_FILEPATH_DP ) { - PreviousNode = Node; - break; + if (Node->Type == MEDIA_DEVICE_PATH && + Node->SubType == MEDIA_FILEPATH_DP) { + PreviousNode = Node; + break; } PreviousNode = Node; @@ -1477,75 +1770,78 @@ void LOADER_ENTRY::StartLoader() } SetDevicePathEndNode(PreviousNode); - EFI_DEVICE_PATH_PROTOCOL* LoaderPathBasenameNode = ConvertTextToDeviceNode(LoaderPath.dirname().wc_str()); - EFI_DEVICE_PATH_PROTOCOL* DevicePathToDmgDir = AppendDevicePathNode(DevicePathCopy, LoaderPathBasenameNode); - DBG("DevicePathToDmgDir = %ls\n", DevicePathToXStringW(DevicePathToDmgDir).wc_str()); + EFI_DEVICE_PATH_PROTOCOL *LoaderPathBasenameNode = + ConvertTextToDeviceNode(LoaderPath.dirname().wc_str()); + EFI_DEVICE_PATH_PROTOCOL *DevicePathToDmgDir = + AppendDevicePathNode(DevicePathCopy, LoaderPathBasenameNode); + DBG("DevicePathToDmgDir = %ls\n", + DevicePathToXStringW(DevicePathToDmgDir).wc_str()); - INTERNAL_DMG_LOAD_CONTEXT DmgLoadContext = {0,0,0}; + INTERNAL_DMG_LOAD_CONTEXT DmgLoadContext = {0, 0, 0}; DmgLoadContext.DevicePath = DevicePathToDmgDir; - EFI_DEVICE_PATH_PROTOCOL* BootEfiFromDmgDevicePath = InternalLoadDmg(&DmgLoadContext, OcDmgLoadingAnyImage); - DBG("DevicePath of dmg = %ls\n", DevicePathToXStringW(BootEfiFromDmgDevicePath).wc_str()); + EFI_DEVICE_PATH_PROTOCOL *BootEfiFromDmgDevicePath = + InternalLoadDmg(&DmgLoadContext, OcDmgLoadingAnyImage); + DBG("DevicePath of dmg = %ls\n", + DevicePathToXStringW(BootEfiFromDmgDevicePath).wc_str()); // point to InternalEfiLoadImage from OC - Status = gBS->LoadImage ( - false, - gImageHandle, - BootEfiFromDmgDevicePath, - NULL, - 0, - &ImageHandle - ); - if ( EFI_ERROR(Status) ) { - DBG("LoadImage at '%ls' failed. Status = %s\n", DevicePathToXStringW(BootEfiFromDmgDevicePath).wc_str(), efiStrError(Status)); + Status = gBS->LoadImage(false, gImageHandle, BootEfiFromDmgDevicePath, + NULL, 0, &ImageHandle); + if (EFI_ERROR(Status)) { + DBG("LoadImage at '%ls' failed. Status = %s\n", + DevicePathToXStringW(BootEfiFromDmgDevicePath).wc_str(), + efiStrError(Status)); return; } } - EFI_STATUS OptionalStatus = gBS->HandleProtocol ( - ImageHandle, - &gEfiLoadedImageProtocolGuid, - (void **) &LoadedImage - ); - if ( EFI_ERROR(OptionalStatus) ) return; // TODO message ? + EFI_STATUS OptionalStatus = gBS->HandleProtocol( + ImageHandle, &gEfiLoadedImageProtocolGuid, (void **)&LoadedImage); + if (EFI_ERROR(OptionalStatus)) + return; // TODO message ? } else { // Load image into memory (will be started later) - Status = LoadEFIImage(DevicePath, LoaderPath.basename(), NULL, &ImageHandle); + Status = + LoadEFIImage(DevicePath, LoaderPath.basename(), NULL, &ImageHandle); if (EFI_ERROR(Status)) { DBG("Image is not loaded, status=%s\n", efiStrError(Status)); return; // no reason to continue if loading image failed } } - egClearScreen(&BootBgColor); //if not set then it is already MenuBackgroundPixel + egClearScreen( + &BootBgColor); // if not set then it is already MenuBackgroundPixel -// KillMouse(); + // KillMouse(); -// if (LoaderType == OSTYPE_OSX) { - if (OSTYPE_IS_OSX(LoaderType) || - OSTYPE_IS_OSX_RECOVERY(LoaderType) || + // if (LoaderType == OSTYPE_OSX) { + if (OSTYPE_IS_OSX(LoaderType) || OSTYPE_IS_OSX_RECOVERY(LoaderType) || OSTYPE_IS_OSX_INSTALLER(LoaderType)) { - // To display progress bar properly (especially in FV2 mode) boot.efi needs to be in graphics mode. - // Unfortunately many UEFI implementations change the resolution when SetMode happens. - // This is not what boot.efi expects, and it freely calls SetMode at its will. - // As a result we see progress bar at improper resolution and the background is also missing (10.12.x+). + // To display progress bar properly (especially in FV2 mode) boot.efi needs + // to be in graphics mode. Unfortunately many UEFI implementations change + // the resolution when SetMode happens. This is not what boot.efi expects, + // and it freely calls SetMode at its will. As a result we see progress bar + // at improper resolution and the background is also missing (10.12.x+). // - // libeg already has a workaround for SetMode behaviour, so we extend it for boot.efi support. - // The approach tries to be follows: + // libeg already has a workaround for SetMode behaviour, so we extend it for + // boot.efi support. The approach tries to be follows: // 1. Ensure we have graphics mode set (since it is a must in the future). - // 2. Request text mode for boot.efi, which it expects by default (here a SetMode libeg hack will trigger + // 2. Request text mode for boot.efi, which it expects by default (here a + // SetMode libeg hack will trigger // on problematic UEFI implementations like AMI). egSetGraphicsModeEnabled(true); egSetGraphicsModeEnabled(false); DBG("GetOSVersion:"); - //needed for boot.efi patcher - Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, (void **) &LoadedImage); + // needed for boot.efi patcher + Status = gBS->HandleProtocol(ImageHandle, &gEfiLoadedImageProtocolGuid, + (void **)&LoadedImage); // Correct OSVersion if it was not found // This should happen only for 10.7-10.9 OSTYPE_OSX_INSTALLER // For these cases, take OSVersion from loaded boot.efi image in memory - if ( macOSVersion.isEmpty()) { + if (macOSVersion.isEmpty()) { if (!EFI_ERROR(Status)) { // version in boot.efi appears as "Mac OS X 10.?" @@ -1553,10 +1849,12 @@ void LOADER_ENTRY::StartLoader() Start OSName Mac OS X 10.12 End OSName Start OSVendor Apple Inc. End */ - InstallerVersion = AsciiStrStr((CHAR8*)LoadedImage->ImageBase, "Mac OS X "); + InstallerVersion = + AsciiStrStr((CHAR8 *)LoadedImage->ImageBase, "Mac OS X "); int location = 9; if (InstallerVersion == NULL) { - InstallerVersion = AsciiStrStr((CHAR8*)LoadedImage->ImageBase, "macOS "); + InstallerVersion = + AsciiStrStr((CHAR8 *)LoadedImage->ImageBase, "macOS "); location = 7; } if (InstallerVersion != NULL) { // string was found @@ -1576,10 +1874,9 @@ void LOADER_ENTRY::StartLoader() strncmp(InstallerVersion, "12.", 3) && strncmp(InstallerVersion, "13.", 3) && strncmp(InstallerVersion, "14.", 3) && - strncmp(InstallerVersion, "15.", 3) && - strncmp(InstallerVersion, "16.", 3) && - strncmp(InstallerVersion, "26.", 3) - ) { + strncmp(InstallerVersion, "15.", 3) && + strncmp(InstallerVersion, "16.", 3) && + strncmp(InstallerVersion, "26.", 3)) { InstallerVersion = NULL; // flag known version was not found } if (InstallerVersion != NULL) { // known version was found in image @@ -1597,7 +1894,7 @@ void LOADER_ENTRY::StartLoader() DBG(" %s\n", macOSVersion.asString().c_str()); } - if ( macOSVersion >= MacOsVersion("10.11"_XS8) ) { + if (macOSVersion >= MacOsVersion("10.11"_XS8)) { if (OSFLAG_ISSET(Flags, OSFLAG_NOSIP)) { gSettings.RtVariables.CsrActiveConfig = (UINT32)0xBEF; gSettings.RtVariables.BooterConfig = 0x28; @@ -1607,20 +1904,24 @@ void LOADER_ENTRY::StartLoader() FilterKextPatches(); FilterKernelPatches(); FilterBootPatches(); - if (LoadedImage && !BooterPatch((UINT8*)LoadedImage->ImageBase, LoadedImage->ImageSize)) { + if (LoadedImage && + !BooterPatch((UINT8 *)LoadedImage->ImageBase, LoadedImage->ImageSize)) { DBG("Will not patch boot.efi\n"); } gConf.ReloadSmbios(OSName); DelegateKernelPatches(); - // Set boot argument for kernel if no caches, this should force kernel loading - if ( OSFLAG_ISSET(Flags, OSFLAG_NOCACHES) && !LoadOptions.containsStartWithIC("Kernel=") ) { + // Set boot argument for kernel if no caches, this should force kernel + // loading + if (OSFLAG_ISSET(Flags, OSFLAG_NOCACHES) && + !LoadOptions.containsStartWithIC("Kernel=")) { XString8 KernelLocation; - if ( macOSVersion.notEmpty() && macOSVersion <= MacOsVersion("10.9"_XS8) ) { + if (macOSVersion.notEmpty() && macOSVersion <= MacOsVersion("10.9"_XS8)) { KernelLocation.S8Printf("\"Kernel=/mach_kernel\""); } else { - // used for 10.10, 10.11, and new version. Jief : also for unknown version. + // used for 10.10, 10.11, and new version. Jief : also for unknown + // version. KernelLocation.S8Printf("\"Kernel=/System/Library/Kernels/kernel\""); } LoadOptions.AddID(KernelLocation); @@ -1630,64 +1931,72 @@ void LOADER_ENTRY::StartLoader() // but before ACPI patch we need smbios patch CheckEmptyFB(); - - SmbiosFillPatchingValues(GlobalConfig.SetTable132, GlobalConfig.EnabledCores, g_SmbiosDiscoveredSettings.RamSlotCount, gConf.SlotDeviceArray, gSettings, gCPUStructure, &g_SmbiosInjectedSettings); + SmbiosFillPatchingValues( + GlobalConfig.SetTable132, GlobalConfig.EnabledCores, + g_SmbiosDiscoveredSettings.RamSlotCount, gConf.SlotDeviceArray, + gSettings, gCPUStructure, &g_SmbiosInjectedSettings); PatchSmbios(g_SmbiosInjectedSettings); #ifdef USE_OC_SECTION_Acpi - // If we use the ACPI section form config-oc.plist, let's also delegate the acpi patching to OC + // If we use the ACPI section form config-oc.plist, let's also delegate the + // acpi patching to OC #else PatchACPI(Volume, macOSVersion); #endif #ifdef JIEF_DEBUG - //SaveOemTables(); - if ( mOpenCoreConfiguration.Misc.Debug.SysReport ) { + // SaveOemTables(); + if (mOpenCoreConfiguration.Misc.Debug.SysReport) { DBG("OC: OcMiscLoadSystemReport\n"); - OcMiscLoadSystemReport (&mOpenCoreConfiguration, self.getSelfDeviceHandle()); + OcMiscLoadSystemReport(&mOpenCoreConfiguration, + self.getSelfDeviceHandle()); } #endif -// + // DbgHeader("RestSetup macOS"); SetDevices(this); SetVariablesForOSX(this); -// Jief : if we want to use our FixUSBOwnership, we need our OnExitBootServices + // Jief : if we want to use our FixUSBOwnership, we need our + // OnExitBootServices EventsInitialize(this); FinalizeSmbios(g_SmbiosInjectedSettings); - SetCPUProperties(); //very special procedure + SetCPUProperties(); // very special procedure if (OSFLAG_ISSET(Flags, OSFLAG_HIBERNATED)) { DoHibernateWake = PrepareHibernation(Volume); } SetupDataForOSX(DoHibernateWake); - - if ( gDriversFlags.AptioFixLoaded && - !DoHibernateWake && - !LoadOptions.containsStartWithIC("slide=") ) { + if (gDriversFlags.AptioFixLoaded && !DoHibernateWake && + !LoadOptions.containsStartWithIC("slide=")) { // Add slide=0 argument for ML+ if not present LoadOptions.AddID("slide=0"_XS8); } - - + /** - * syscl - append "-xcpm" argument conditionally if set KernelXCPM on Intel Haswell+ low-end CPUs + * syscl - append "-xcpm" argument conditionally if set KernelXCPM on Intel + * Haswell+ low-end CPUs */ if (KernelAndKextPatches.KPKernelXCPM && - gCPUStructure.Vendor == CPU_VENDOR_INTEL && gCPUStructure.Model >= CPU_MODEL_HASWELL && - (gCPUStructure.BrandString.contains("Celeron") || gCPUStructure.BrandString.contains("Pentium")) && - macOSVersion >= MacOsVersion("10.8.5"_XS8) && macOSVersion < MacOsVersion("10.12"_XS8) && - (!LoadOptions.containsIC("-xcpm"))) { - // add "-xcpm" argv if not present on Haswell+ Celeron/Pentium - LoadOptions.AddID("-xcpm"_XS8); - } - - // add -xcpm on Ivy Bridge if set KernelXCPM and system version is 10.8.5 - 10.11.x + gCPUStructure.Vendor == CPU_VENDOR_INTEL && + gCPUStructure.Model >= CPU_MODEL_HASWELL && + (gCPUStructure.BrandString.contains("Celeron") || + gCPUStructure.BrandString.contains("Pentium")) && + macOSVersion >= MacOsVersion("10.8.5"_XS8) && + macOSVersion < MacOsVersion("10.12"_XS8) && + (!LoadOptions.containsIC("-xcpm"))) { + // add "-xcpm" argv if not present on Haswell+ Celeron/Pentium + LoadOptions.AddID("-xcpm"_XS8); + } + + // add -xcpm on Ivy Bridge if set KernelXCPM and system version is 10.8.5 + // - 10.11.x if (KernelAndKextPatches.KPKernelXCPM && gCPUStructure.Model == CPU_MODEL_IVY_BRIDGE && - macOSVersion >= MacOsVersion("10.8.5"_XS8) && macOSVersion < MacOsVersion("10.12"_XS8) && + macOSVersion >= MacOsVersion("10.8.5"_XS8) && + macOSVersion < MacOsVersion("10.12"_XS8) && (!LoadOptions.containsIC("-xcpm"))) { // add "-xcpm" argv if not present on Ivy Bridge LoadOptions.AddID("-xcpm"_XS8); @@ -1695,15 +2004,16 @@ void LOADER_ENTRY::StartLoader() if (AudioIo) { AudioIo->StopPlayback(AudioIo); -// CheckSyncSound(true); - EFI_DRIVER_BINDING_PROTOCOL *DriverBinding = NULL; - Status = gBS->HandleProtocol(AudioDriverHandle, &gEfiDriverBindingProtocolGuid, (void **)&DriverBinding); + // CheckSyncSound(true); + EFI_DRIVER_BINDING_PROTOCOL *DriverBinding = NULL; + Status = + gBS->HandleProtocol(AudioDriverHandle, &gEfiDriverBindingProtocolGuid, + (void **)&DriverBinding); if (DriverBinding) { DriverBinding->Stop(DriverBinding, AudioDriverHandle, 0, NULL); } } - // blocking boot.efi output if -v is not specified // note: this blocks output even if -v is specified in // /Library/Preferences/SystemConfiguration/com.apple.Boot.plist @@ -1713,18 +2023,16 @@ void LOADER_ENTRY::StartLoader() if (LoadOptions.containsIC("-v")) { Flags = OSFLAG_UNSET(Flags, OSFLAG_USEGRAPHICS); } - } - else if (OSTYPE_IS_WINDOWS(LoaderType)) { + } else if (OSTYPE_IS_WINDOWS(LoaderType)) { if (AudioIo) { AudioIo->StopPlayback(AudioIo); } DBG("Closing events for Windows\n"); - gBS->CloseEvent (OnReadyToBootEvent); - gBS->CloseEvent (ExitBootServiceEvent); - gBS->CloseEvent (mSimpleFileSystemChangeEvent); - + gBS->CloseEvent(OnReadyToBootEvent); + gBS->CloseEvent(ExitBootServiceEvent); + gBS->CloseEvent(mSimpleFileSystemChangeEvent); if (gEmuVariableControl != NULL) { gEmuVariableControl->UninstallEmulation(gEmuVariableControl); @@ -1732,13 +2040,12 @@ void LOADER_ENTRY::StartLoader() PatchACPI_OtherOS(L"Windows", false); - } - else if (OSTYPE_IS_LINUX(LoaderType) || (LoaderType == OSTYPE_LINEFI)) { + } else if (OSTYPE_IS_LINUX(LoaderType) || (LoaderType == OSTYPE_LINEFI)) { DBG("Closing events for Linux\n"); - gBS->CloseEvent (OnReadyToBootEvent); - gBS->CloseEvent (ExitBootServiceEvent); - gBS->CloseEvent (mSimpleFileSystemChangeEvent); + gBS->CloseEvent(OnReadyToBootEvent); + gBS->CloseEvent(ExitBootServiceEvent); + gBS->CloseEvent(mSimpleFileSystemChangeEvent); if (gEmuVariableControl != NULL) { gEmuVariableControl->UninstallEmulation(gEmuVariableControl); @@ -1748,13 +2055,17 @@ void LOADER_ENTRY::StartLoader() } if (gSettings.Boot.LastBootedVolume) { - if ( APFSTargetUUID.notNull() ) { - // Jief : we need to LoaderPath. If not, GUI can't know which target was selected. + if (APFSTargetUUID.notNull()) { + // Jief : we need to LoaderPath. If not, GUI can't know which target was + // selected. SetStartupDiskVolume(Volume, LoaderPath); - }else{ - // Jief : I'm not sure why NullXStringW was given if LoaderType == OSTYPE_OSX. - // Let's do it like it was before when not in case of APFSTargetUUID - SetStartupDiskVolume(Volume, LoaderType == OSTYPE_OSX ? NullXStringW : LoaderPath); + } else { + // Jief : I'm not sure why NullXStringW was given if LoaderType == + // OSTYPE_OSX. + // Let's do it like it was before when not in case of + // APFSTargetUUID + SetStartupDiskVolume(Volume, LoaderType == OSTYPE_OSX ? NullXStringW + : LoaderPath); } } else if (gSettings.Boot.DefaultVolume.notEmpty()) { // DefaultVolume specified in Config.plist or in Boot Option @@ -1762,29 +2073,32 @@ void LOADER_ENTRY::StartLoader() // to reboot into another volume RemoveStartupDiskVolume(); } -/* - { - // UINT32 machineSignature = 0; - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtPointer = NULL; - EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs = NULL; - - // DBG("---dump hibernations data---\n"); - FadtPointer = GetFadt(); - if (FadtPointer != NULL) { - Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE*)(UINTN)(FadtPointer->FirmwareCtrl); - - DBG(" Firmware wake address=%08lx\n", Facs->FirmwareWakingVector); - DBG(" Firmware wake 64 addr=%16llx\n", Facs->XFirmwareWakingVector); - DBG(" Hardware signature =%08lx\n", Facs->HardwareSignature); - DBG(" GlobalLock =%08lx\n", Facs->GlobalLock); - DBG(" Flags =%08lx\n", Facs->Flags); - DBG(" HS at offset 0x%08X\n", OFFSET_OF(EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE, HardwareSignature)); - // machineSignature = Facs->HardwareSignature; + /* + { + // UINT32 machineSignature = 0; + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtPointer = NULL; + EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs = NULL; + + // DBG("---dump hibernations data---\n"); + FadtPointer = GetFadt(); + if (FadtPointer != NULL) { + Facs = + (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE*)(UINTN)(FadtPointer->FirmwareCtrl); + + DBG(" Firmware wake address=%08lx\n", Facs->FirmwareWakingVector); + DBG(" Firmware wake 64 addr=%16llx\n", Facs->XFirmwareWakingVector); + DBG(" Hardware signature =%08lx\n", Facs->HardwareSignature); + DBG(" GlobalLock =%08lx\n", Facs->GlobalLock); + DBG(" Flags =%08lx\n", Facs->Flags); + DBG(" HS at offset 0x%08X\n", + OFFSET_OF(EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE, HardwareSignature)); + // machineSignature = Facs->HardwareSignature; + } } - } -*/ + */ - BeginExternalScreen(OSFLAG_ISSET(Flags, OSFLAG_USEGRAPHICS)/*, L"Booting OS"*/); + BeginExternalScreen( + OSFLAG_ISSET(Flags, OSFLAG_USEGRAPHICS) /*, L"Booting OS"*/); if (!OSTYPE_IS_WINDOWS(LoaderType) && !OSTYPE_IS_LINUX(LoaderType)) { if (OSFLAG_ISSET(Flags, OSFLAG_USEGRAPHICS)) { @@ -1793,84 +2107,92 @@ void LOADER_ENTRY::StartLoader() ConOutOutputString = gST->ConOut->OutputString; gST->ConOut->OutputString = NullConOutOutputString; } - + // Initialize the boot screen if (EFI_ERROR(Status = InitBootScreen(this))) { - if (Status != EFI_ABORTED) DBG("Failed to initialize custom boot screen: %s!\n", efiStrError(Status)); - } - else if (EFI_ERROR(Status = LockBootScreen())) { + if (Status != EFI_ABORTED) + DBG("Failed to initialize custom boot screen: %s!\n", + efiStrError(Status)); + } else if (EFI_ERROR(Status = LockBootScreen())) { DBG("Failed to lock custom boot screen: %s!\n", efiStrError(Status)); } } // !OSTYPE_IS_WINDOWS - if (OSTYPE_IS_OSX(LoaderType) || - OSTYPE_IS_OSX_RECOVERY(LoaderType) || + if (OSTYPE_IS_OSX(LoaderType) || OSTYPE_IS_OSX_RECOVERY(LoaderType) || OSTYPE_IS_OSX_INSTALLER(LoaderType)) { if (DoHibernateWake) { DBG("Closing events for wake\n"); - gBS->CloseEvent (OnReadyToBootEvent); -// gBS->CloseEvent (ExitBootServiceEvent); // Jief : we don't need that anymore, if we continue to use OC onExtBootService event - gBS->CloseEvent (mSimpleFileSystemChangeEvent); + gBS->CloseEvent(OnReadyToBootEvent); + // gBS->CloseEvent (ExitBootServiceEvent); // Jief : we don't need + // that anymore, if we continue to use OC onExtBootService event + gBS->CloseEvent(mSimpleFileSystemChangeEvent); - // When doing hibernate wake, save to DataHub only up to initial size of log + // When doing hibernate wake, save to DataHub only up to initial size of + // log SavePreBootLog = false; } else { // delete boot-switch-vars if exists Status = gRT->SetVariable(L"boot-switch-vars", gEfiAppleBootGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, 0, NULL); DeleteNvramVariable(L"IOHibernateRTCVariables", gEfiAppleBootGuid); - DeleteNvramVariable(L"boot-image", gEfiAppleBootGuid); - + DeleteNvramVariable(L"boot-image", gEfiAppleBootGuid); } SetupBooterLog(!DoHibernateWake); - XStringW LoadOptionsAsXStringW = SWPrintf("%ls %s ", Basename(LoaderPath.wc_str()), LoadOptions.ConcatAll(" "_XS8).c_str()); - LoadedImage->LoadOptions = (void*)LoadOptionsAsXStringW.wc_str(); - LoadedImage->LoadOptionsSize = (UINT32)LoadOptionsAsXStringW.sizeInBytesIncludingTerminator(); - - DBG("UEFI Quirks\n"); - DBG("EBSD %d TST %d AHS %d DSP %d EVA %d EV %d FUS %d IIFR %d RGB %d RUPR %d RUO %d ROR %d RBVR %d SRP %d UFC %d FOWF %d", - mOpenCoreConfiguration.Uefi.Quirks.ExitBootServicesDelay, - mOpenCoreConfiguration.Uefi.Quirks.TscSyncTimeout, - mOpenCoreConfiguration.Uefi.Quirks.ActivateHpetSupport, - mOpenCoreConfiguration.Uefi.Quirks.DisableSecurityPolicy, - mOpenCoreConfiguration.Uefi.Quirks.EnableVectorAcceleration, - mOpenCoreConfiguration.Uefi.Quirks.EnableVmx, - mOpenCoreConfiguration.Uefi.Quirks.ForgeUefiSupport, - mOpenCoreConfiguration.Uefi.Quirks.IgnoreInvalidFlexRatio, - mOpenCoreConfiguration.Uefi.Quirks.ResizeGpuBars, - mOpenCoreConfiguration.Uefi.Quirks.ResizeUsePciRbIo, - mOpenCoreConfiguration.Uefi.Quirks.ReleaseUsbOwnership, - mOpenCoreConfiguration.Uefi.Quirks.ReloadOptionRoms, - mOpenCoreConfiguration.Uefi.Quirks.RequestBootVarRouting, - mOpenCoreConfiguration.Uefi.Quirks.ShimRetainProtocol, - mOpenCoreConfiguration.Uefi.Quirks.UnblockFsConnect, - mOpenCoreConfiguration.Uefi.Quirks.ForceOcWriteFlash); - - DBG("Kernel quirks\n"); - DBG("ACPCL %d AXCL %d AXEM %d AXFB %d CSG %d DIM %d DLJ %d DRC %d DPM %d EBTFF %d EDI %d FAI %d IPBS %d LKP %d PNKD %d PTKP %d TPD %d XPL %d PCC %d\n", - mOpenCoreConfiguration.Kernel.Quirks.AppleCpuPmCfgLock, - mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmCfgLock, - mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmExtraMsrs, - mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmForceBoost, - mOpenCoreConfiguration.Kernel.Quirks.CustomSmbiosGuid, - mOpenCoreConfiguration.Kernel.Quirks.DisableIoMapper, - mOpenCoreConfiguration.Kernel.Quirks.DisableLinkeditJettison, - mOpenCoreConfiguration.Kernel.Quirks.DisableRtcChecksum, - mOpenCoreConfiguration.Kernel.Emulate.DummyPowerManagement, - mOpenCoreConfiguration.Kernel.Quirks.ExtendBTFeatureFlags, - mOpenCoreConfiguration.Kernel.Quirks.ExternalDiskIcons, - mOpenCoreConfiguration.Kernel.Quirks.IncreasePciBarSize, - mOpenCoreConfiguration.Kernel.Quirks.ForceAquantiaEthernet, - mOpenCoreConfiguration.Kernel.Quirks.LapicKernelPanic, - mOpenCoreConfiguration.Kernel.Quirks.PanicNoKextDump, - mOpenCoreConfiguration.Kernel.Quirks.PowerTimeoutKernelPanic, - mOpenCoreConfiguration.Kernel.Quirks.ThirdPartyDrives, - mOpenCoreConfiguration.Kernel.Quirks.XhciPortLimit, - mOpenCoreConfiguration.Kernel.Quirks.ProvideCurrentCpuInfo); - + XStringW LoadOptionsAsXStringW = + SWPrintf("%ls %s ", Basename(LoaderPath.wc_str()), + LoadOptions.ConcatAll(" "_XS8).c_str()); + LoadedImage->LoadOptions = (void *)LoadOptionsAsXStringW.wc_str(); + LoadedImage->LoadOptionsSize = + (UINT32)LoadOptionsAsXStringW.sizeInBytesIncludingTerminator(); + + DBG("UEFI Quirks\n"); + DBG("EBSD %d TST %d AHS %d DSP %d EVA %d EV %d FUS %d IIFR %d RGB " + "%d RUPR %d RUO %d ROR %d RBVR %d SRP %d UFC %d FOWF %d", + mOpenCoreConfiguration.Uefi.Quirks.ExitBootServicesDelay, + mOpenCoreConfiguration.Uefi.Quirks.TscSyncTimeout, + mOpenCoreConfiguration.Uefi.Quirks.ActivateHpetSupport, + mOpenCoreConfiguration.Uefi.Quirks.DisableSecurityPolicy, + mOpenCoreConfiguration.Uefi.Quirks.EnableVectorAcceleration, + mOpenCoreConfiguration.Uefi.Quirks.EnableVmx, + mOpenCoreConfiguration.Uefi.Quirks.ForgeUefiSupport, + mOpenCoreConfiguration.Uefi.Quirks.IgnoreInvalidFlexRatio, + mOpenCoreConfiguration.Uefi.Quirks.ResizeGpuBars, + mOpenCoreConfiguration.Uefi.Quirks.ResizeUsePciRbIo, + mOpenCoreConfiguration.Uefi.Quirks.ReleaseUsbOwnership, + mOpenCoreConfiguration.Uefi.Quirks.ReloadOptionRoms, + mOpenCoreConfiguration.Uefi.Quirks.RequestBootVarRouting, + mOpenCoreConfiguration.Uefi.Quirks.ShimRetainProtocol, + mOpenCoreConfiguration.Uefi.Quirks.UnblockFsConnect, + mOpenCoreConfiguration.Uefi.Quirks.ForceOcWriteFlash); + + DBG("Kernel quirks\n"); + DBG("ACPCL %d AXCL %d AXEM %d AXFB %d CSG %d DIM %d DLJ %d DRC %d DPM %d " + "EBTFF %d EDI %d FAI %d IPBS %d LKP %d PNKD %d PTKP %d TPD %d XPL %d " + "PCC %d\n", + mOpenCoreConfiguration.Kernel.Quirks.AppleCpuPmCfgLock, + mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmCfgLock, + mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmExtraMsrs, + mOpenCoreConfiguration.Kernel.Quirks.AppleXcpmForceBoost, + mOpenCoreConfiguration.Kernel.Quirks.CustomSmbiosGuid, + mOpenCoreConfiguration.Kernel.Quirks.DisableIoMapper, + mOpenCoreConfiguration.Kernel.Quirks.DisableLinkeditJettison, + mOpenCoreConfiguration.Kernel.Quirks.DisableRtcChecksum, + mOpenCoreConfiguration.Kernel.Emulate.DummyPowerManagement, + mOpenCoreConfiguration.Kernel.Quirks.ExtendBTFeatureFlags, + mOpenCoreConfiguration.Kernel.Quirks.ExternalDiskIcons, + mOpenCoreConfiguration.Kernel.Quirks.IncreasePciBarSize, + mOpenCoreConfiguration.Kernel.Quirks.ForceAquantiaEthernet, + mOpenCoreConfiguration.Kernel.Quirks.LapicKernelPanic, + mOpenCoreConfiguration.Kernel.Quirks.PanicNoKextDump, + mOpenCoreConfiguration.Kernel.Quirks.PowerTimeoutKernelPanic, + mOpenCoreConfiguration.Kernel.Quirks.ThirdPartyDrives, + mOpenCoreConfiguration.Kernel.Quirks.XhciPortLimit, + mOpenCoreConfiguration.Kernel.Quirks.ProvideCurrentCpuInfo); DBG("Closing log\n"); if (SavePreBootLog) { @@ -1882,16 +2204,18 @@ void LOADER_ENTRY::StartLoader() PrintMemoryMap(); displayFreeMemory("Just before launching image"_XS8); #endif - Status = gBS->StartImage (ImageHandle, 0, NULL); // point to OcStartImage from OC + Status = + gBS->StartImage(ImageHandle, 0, NULL); // point to OcStartImage from OC - if ( EFI_ERROR(Status) ) { + if (EFI_ERROR(Status)) { // Ideally, we would return to the menu, displaying an error message // Truth is that we get a black screen before seeing the menu again. // If I remember well, we get a freeze in BdsLibConnectAllEfi() // I'm guessing there is a lot of patching done for booting. // To be able to go back to the menu and boot another thing, // we must undo all the patching... - // Here is a quick, not as bad as a black screen solution : a text message and a reboot ! + // Here is a quick, not as bad as a black screen solution : a text message + // and a reboot ! DBG("StartImage failed : %s\n", efiStrError(Status)); SaveBooterLog(&self.getCloverDir(), PREBOOT_LOG); egSetGraphicsModeEnabled(false); @@ -1906,10 +2230,11 @@ void LOADER_ENTRY::StartLoader() return; } -}else{ + } else { - StartEFILoadedImage(ImageHandle, LoadOptions, NullXStringW, LoaderPath.basename(), NULL); -} + StartEFILoadedImage(ImageHandle, LoadOptions, NullXStringW, + LoaderPath.basename(), NULL); + } // Unlock boot screen if (EFI_ERROR(Status = UnlockBootScreen())) { DBG("Failed to unlock custom boot screen: %s!\n", efiStrError(Status)); @@ -1919,64 +2244,59 @@ void LOADER_ENTRY::StartLoader() gST->ConOut->OutputString = ConOutOutputString; } - FinishExternalScreen(); - } +void LEGACY_ENTRY::StartLegacy() { + EFI_STATUS Status = EFI_UNSUPPORTED; -void LEGACY_ENTRY::StartLegacy() -{ - EFI_STATUS Status = EFI_UNSUPPORTED; - - // Unload EmuVariable before booting legacy. - // This is not needed in most cases, but it seems to interfere with legacy OS - // booted on some UEFI bioses, such as Phoenix UEFI 2.0 - if (gEmuVariableControl != NULL) { - gEmuVariableControl->UninstallEmulation(gEmuVariableControl); - } - - if (gSettings.Boot.LastBootedVolume) { - SetStartupDiskVolume(Volume, NullXStringW); - } else if (gSettings.Boot.DefaultVolume.notEmpty()) { - // DefaultVolume specified in Config.plist: - // we'll remove macOS Startup Disk vars which may be present if it is used - // to reboot into another volume - RemoveStartupDiskVolume(); - } + // Unload EmuVariable before booting legacy. + // This is not needed in most cases, but it seems to interfere with legacy OS + // booted on some UEFI bioses, such as Phoenix UEFI 2.0 + if (gEmuVariableControl != NULL) { + gEmuVariableControl->UninstallEmulation(gEmuVariableControl); + } + if (gSettings.Boot.LastBootedVolume) { + SetStartupDiskVolume(Volume, NullXStringW); + } else if (gSettings.Boot.DefaultVolume.notEmpty()) { + // DefaultVolume specified in Config.plist: + // we'll remove macOS Startup Disk vars which may be present if it is used + // to reboot into another volume + RemoveStartupDiskVolume(); + } egClearScreen(&MenuBackgroundPixel); - BeginExternalScreen(true/*, L"Booting Legacy OS"*/); + BeginExternalScreen(true /*, L"Booting Legacy OS"*/); XImage BootLogoX; BootLogoX.LoadXImage(&ThemeX->getThemeDir(), Volume->LegacyOS.IconName); - BootLogoX.Draw((UGAWidth - BootLogoX.GetWidth()) >> 1, + BootLogoX.Draw((UGAWidth - BootLogoX.GetWidth()) >> 1, (UGAHeight - BootLogoX.GetHeight()) >> 1); - //try my LegacyBoot - switch (Volume->BootType) { - case BOOTING_BY_CD: - Status = bootElTorito(Volume); - break; - case BOOTING_BY_MBR: - Status = bootMBR(Volume); - break; - case BOOTING_BY_PBR: - if (gSettings.Boot.LegacyBoot == "LegacyBiosDefault"_XS8) { - Status = bootLegacyBiosDefault(gSettings.Boot.LegacyBiosDefaultEntry); - } else if (gSettings.Boot.LegacyBoot == "PBRtest"_XS8) { - Status = bootPBRtest(Volume); - } else if (gSettings.Boot.LegacyBoot == "PBRsata"_XS8) { - Status = bootPBR(Volume, true); - } else { - // default - Status = bootPBR(Volume, false); - } - break; - default: - break; - } - CheckError(Status, L"while LegacyBoot"); + // try my LegacyBoot + switch (Volume->BootType) { + case BOOTING_BY_CD: + Status = bootElTorito(Volume); + break; + case BOOTING_BY_MBR: + Status = bootMBR(Volume); + break; + case BOOTING_BY_PBR: + if (gSettings.Boot.LegacyBoot == "LegacyBiosDefault"_XS8) { + Status = bootLegacyBiosDefault(gSettings.Boot.LegacyBiosDefaultEntry); + } else if (gSettings.Boot.LegacyBoot == "PBRtest"_XS8) { + Status = bootPBRtest(Volume); + } else if (gSettings.Boot.LegacyBoot == "PBRsata"_XS8) { + Status = bootPBR(Volume, true); + } else { + // default + Status = bootPBR(Volume, false); + } + break; + default: + break; + } + CheckError(Status, L"while LegacyBoot"); FinishExternalScreen(); } @@ -1985,13 +2305,17 @@ void LEGACY_ENTRY::StartLegacy() // pre-boot tool functions // -void REFIT_MENU_ENTRY_LOADER_TOOL::StartTool() -{ +void REFIT_MENU_ENTRY_LOADER_TOOL::StartTool() { DBG("Start Tool: %ls\n", LoaderPath.wc_str()); egClearScreen(&MenuBackgroundPixel); // assumes "Start " as assigned below - BeginExternalScreen(OSFLAG_ISSET(Flags, OSFLAG_USEGRAPHICS)/*, &Entry->Title[6]*/); // Shouldn't we check that length of Title is at least 6 ? - StartEFIImage(DevicePath, LoadOptions, NullXStringW, LoaderPath.basename(), NULL, NULL); + BeginExternalScreen(OSFLAG_ISSET( + Flags, + OSFLAG_USEGRAPHICS) /*, &Entry->Title[6]*/); // Shouldn't we check that + // length of Title is at + // least 6 ? + StartEFIImage(DevicePath, LoadOptions, NullXStringW, LoaderPath.basename(), + NULL, NULL); FinishExternalScreen(); } @@ -1999,52 +2323,49 @@ void REFIT_MENU_ENTRY_LOADER_TOOL::StartTool() // pre-boot driver functions // -static void ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConnect, OUT UINTN *DriversToConnectNum) -{ - EFI_STATUS Status; - REFIT_DIR_ITER DirIter; - EFI_FILE_INFO *DirEntry; - EFI_HANDLE DriverHandle; - EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; - UINTN DriversArrSize; - UINTN DriversArrNum; - EFI_HANDLE *DriversArr; - XBool Skip; - UINT8 AptioBlessed; - STATIC CHAR16 CONST * CONST AptioNames[] = { - L"AptioMemoryFix", - L"AptioFix3Drv", - L"AptioFix2Drv", - L"AptioFixDrv", - L"LowMemFix" - }; +static void ScanDriverDir(IN CONST CHAR16 *Path, + OUT EFI_HANDLE **DriversToConnect, + OUT UINTN *DriversToConnectNum) { + EFI_STATUS Status; + REFIT_DIR_ITER DirIter; + EFI_FILE_INFO *DirEntry; + EFI_HANDLE DriverHandle; + EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; + UINTN DriversArrSize; + UINTN DriversArrNum; + EFI_HANDLE *DriversArr; + XBool Skip; + UINT8 AptioBlessed; + STATIC CHAR16 CONST *CONST AptioNames[] = {L"AptioMemoryFix", L"AptioFix3Drv", + L"AptioFix2Drv", L"AptioFixDrv", + L"LowMemFix"}; STATIC UINT8 CONST AptioIndices[] = { - OFFSET_OF(DRIVERS_FLAGS, AptioMemFixLoaded), - OFFSET_OF(DRIVERS_FLAGS, AptioFix3Loaded), - OFFSET_OF(DRIVERS_FLAGS, AptioFix2Loaded), - OFFSET_OF(DRIVERS_FLAGS, AptioFixLoaded), - OFFSET_OF(DRIVERS_FLAGS, MemFixLoaded) - }; + OFFSET_OF(DRIVERS_FLAGS, AptioMemFixLoaded), + OFFSET_OF(DRIVERS_FLAGS, AptioFix3Loaded), + OFFSET_OF(DRIVERS_FLAGS, AptioFix2Loaded), + OFFSET_OF(DRIVERS_FLAGS, AptioFixLoaded), + OFFSET_OF(DRIVERS_FLAGS, MemFixLoaded)}; DriversArrSize = 0; DriversArrNum = 0; DriversArr = NULL; - // OpenRuntimeEfiName.setEmpty(); + // OpenRuntimeEfiName.setEmpty(); -//only one driver with highest priority will obtain status "Loaded" + // only one driver with highest priority will obtain status "Loaded" DirIterOpen(&self.getCloverDir(), Path, &DirIter); -#define BOOLEAN_AT_INDEX(k) (*(XBool*)((UINTN)&gDriversFlags + AptioIndices[(k)])) +#define BOOLEAN_AT_INDEX(k) \ + (*(XBool *)((UINTN) & gDriversFlags + AptioIndices[(k)])) for (size_t i = 0; i != ARRAY_SIZE(AptioIndices); ++i) BOOLEAN_AT_INDEX(i) = false; - AptioBlessed = (UINT8) ARRAY_SIZE(AptioNames); + AptioBlessed = (UINT8)ARRAY_SIZE(AptioNames); while (DirIterNext(&DirIter, 2, L"*.efi", &DirEntry)) { size_t i; for (i = 0; i != ARRAY_SIZE(AptioNames); ++i) if (StrStr(DirEntry->FileName, AptioNames[i]) != NULL) break; - if (((UINT8) i) >= AptioBlessed) + if (((UINT8)i) >= AptioBlessed) continue; - AptioBlessed = (UINT8) i; + AptioBlessed = (UINT8)i; if (!i) break; } @@ -2054,47 +2375,55 @@ static void ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne DirIterOpen(&self.getCloverDir(), Path, &DirIter); while (DirIterNext(&DirIter, 2, L"*.efi", &DirEntry)) { Skip = (DirEntry->FileName[0] == L'.'); - for (size_t i=0; i<gSettings.DisabledDriverArray.size(); i++) { - if (StrStr(DirEntry->FileName, gSettings.DisabledDriverArray[i].wc_str()) != NULL) { - Skip = true; // skip this + for (size_t i = 0; i < gSettings.DisabledDriverArray.size(); i++) { + if (StrStr(DirEntry->FileName, + gSettings.DisabledDriverArray[i].wc_str()) != NULL) { + Skip = true; // skip this break; } } if (Skip) { continue; } - if ( LStringW(DirEntry->FileName).startWith("._") ) { + if (LStringW(DirEntry->FileName).startWith("._")) { continue; } - if ( LStringW(DirEntry->FileName).containsIC("OcQuirks") ) { + if (LStringW(DirEntry->FileName).containsIC("OcQuirks")) { continue; } - if ( LStringW(DirEntry->FileName).containsIC("AptioMemoryFix") ) { + if (LStringW(DirEntry->FileName).containsIC("AptioMemoryFix")) { continue; } - if ( LStringW(DirEntry->FileName).containsIC("OpenRuntime") ) { + if (LStringW(DirEntry->FileName).containsIC("OpenRuntime")) { if (!OpenRuntimeEfiName.isEmpty()) { DBG(" - OpenRuntime already detected\n"); continue; } - if ( LStringW(DirEntry->FileName).isEqualIC("OpenRuntime-v12.efi") && LString8(OPEN_CORE_VERSION).isEqual("0.7.5") ) { + if (LStringW(DirEntry->FileName).isEqualIC("OpenRuntime-v12.efi") && + LString8(OPEN_CORE_VERSION).isEqual("0.7.5")) { OpenRuntimeEfiName.takeValueFrom(DirEntry->FileName); - DBG(" - OpenRuntime-v12 for 075 taken from %ls\n", getDriversPath().wc_str()); - }else - if ( LStringW(DirEntry->FileName).isEqualIC("OpenRuntime-v12.efi") && LString8(OPEN_CORE_VERSION).isEqual("0.7.3") ) { + DBG(" - OpenRuntime-v12 for 075 taken from %ls\n", + getDriversPath().wc_str()); + } else if (LStringW(DirEntry->FileName) + .isEqualIC("OpenRuntime-v12.efi") && + LString8(OPEN_CORE_VERSION).isEqual("0.7.3")) { OpenRuntimeEfiName.takeValueFrom(DirEntry->FileName); - DBG(" - OpenRuntime-v12 for 073 taken from %ls\n", getDriversPath().wc_str()); - }else - if ( LStringW(DirEntry->FileName).isEqualIC("OpenRuntime-v11.efi") && LString8(OPEN_CORE_VERSION).isEqual("0.6.5") ) { + DBG(" - OpenRuntime-v12 for 073 taken from %ls\n", + getDriversPath().wc_str()); + } else if (LStringW(DirEntry->FileName) + .isEqualIC("OpenRuntime-v11.efi") && + LString8(OPEN_CORE_VERSION).isEqual("0.6.5")) { OpenRuntimeEfiName.takeValueFrom(DirEntry->FileName); - DBG(" - OpenRuntime-v11 for 065 taken from %ls\n", getDriversPath().wc_str()); - }else - if ( LStringW(DirEntry->FileName).isEqualIC("OpenRuntime-v11.efi") && LString8(OPEN_CORE_VERSION).isEqual("0.6.1") ) { + DBG(" - OpenRuntime-v11 for 065 taken from %ls\n", + getDriversPath().wc_str()); + } else if (LStringW(DirEntry->FileName) + .isEqualIC("OpenRuntime-v11.efi") && + LString8(OPEN_CORE_VERSION).isEqual("0.6.1")) { OpenRuntimeEfiName.takeValueFrom(DirEntry->FileName); - DBG(" - OpenRuntime-v11 for 061 taken from %ls\n", getDriversPath().wc_str()); - }else - if ( OpenRuntimeEfiName.isEmpty() ) { + DBG(" - OpenRuntime-v11 for 061 taken from %ls\n", + getDriversPath().wc_str()); + } else if (OpenRuntimeEfiName.isEmpty()) { OpenRuntimeEfiName.takeValueFrom(DirEntry->FileName); } continue; @@ -2106,52 +2435,66 @@ static void ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne if (StrStr(DirEntry->FileName, AptioNames[i]) != NULL) break; if (i != ARRAY_SIZE(AptioNames)) { - if (((UINT8) i) != AptioBlessed) + if (((UINT8)i) != AptioBlessed) continue; - if (AptioBlessed < (UINT8) ARRAY_SIZE(AptioIndices)) + if (AptioBlessed < (UINT8)ARRAY_SIZE(AptioIndices)) BOOLEAN_AT_INDEX(AptioBlessed) = true; - AptioBlessed = (UINT8) ARRAY_SIZE(AptioNames); + AptioBlessed = (UINT8)ARRAY_SIZE(AptioNames); } } #undef BOOLEAN_AT_INDEX - XStringW FileName = SWPrintf("%ls\\%ls\\%ls", self.getCloverDirFullPath().wc_str(), Path, DirEntry->FileName); - Status = StartEFIImage(apd<EFI_DEVICE_PATH_PROTOCOL*>(FileDevicePath(self.getSelfLoadedImage().DeviceHandle, FileName)), NullXString8Array, LStringW(DirEntry->FileName), XStringW().takeValueFrom(DirEntry->FileName), NULL, &DriverHandle); + XStringW FileName = + SWPrintf("%ls\\%ls\\%ls", self.getCloverDirFullPath().wc_str(), Path, + DirEntry->FileName); + Status = StartEFIImage( + apd<EFI_DEVICE_PATH_PROTOCOL *>( + FileDevicePath(self.getSelfLoadedImage().DeviceHandle, FileName)), + NullXString8Array, LStringW(DirEntry->FileName), + XStringW().takeValueFrom(DirEntry->FileName), NULL, &DriverHandle); if (EFI_ERROR(Status)) { continue; } - if ( FileName.containsIC("AudioDxe") ) { + if (FileName.containsIC("AudioDxe")) { AudioDriverHandle = DriverHandle; } - if ( FileName.containsIC("EmuVariable") ) { + if (FileName.containsIC("EmuVariable")) { gDriversFlags.EmuVariableLoaded = true; - } else if ( FileName.containsIC("Video") ) { + } else if (FileName.containsIC("Video")) { gDriversFlags.VideoLoaded = true; - } else if ( FileName.containsIC("Partition") ) { + } else if (FileName.containsIC("Partition")) { gDriversFlags.PartitionLoaded = true; - } else if ( FileName.containsIC("HFS") ) { + } else if (FileName.containsIC("HFS")) { gDriversFlags.HFSLoaded = true; - } else if ( FileName.containsIC("apfs") ) { + } else if (FileName.containsIC("apfs")) { gDriversFlags.APFSLoaded = true; } - if (DriverHandle != NULL && DriversToConnectNum != NULL && DriversToConnect != NULL) { + if (DriverHandle != NULL && DriversToConnectNum != NULL && + DriversToConnect != NULL) { // driver loaded - check for EFI_DRIVER_BINDING_PROTOCOL - Status = gBS->HandleProtocol(DriverHandle, &gEfiDriverBindingProtocolGuid, (void **) &DriverBinding); + Status = gBS->HandleProtocol(DriverHandle, &gEfiDriverBindingProtocolGuid, + (void **)&DriverBinding); if (!EFI_ERROR(Status) && DriverBinding != NULL) { DBG(" - driver needs connecting\n"); - // standard UEFI driver - we would reconnect after loading - add to array - MemoryStopRecord msr; // DriversArr won't be deallocated because it's passed to RegisterDriversToHighestPriority that keeps it global. + // standard UEFI driver - we would reconnect after loading - add to + // array + MemoryStopRecord + msr; // DriversArr won't be deallocated because it's passed to + // RegisterDriversToHighestPriority that keeps it global. if (DriversArrSize == 0) { // new array DriversArrSize = 16; - DriversArr = (__typeof__(DriversArr))AllocateZeroPool(sizeof(EFI_HANDLE) * DriversArrSize); + DriversArr = (__typeof__(DriversArr))AllocateZeroPool( + sizeof(EFI_HANDLE) * DriversArrSize); } else if (DriversArrNum + 1 == DriversArrSize) { // extend array - DriversArr = (__typeof__(DriversArr))ReallocatePool(DriversArrSize, DriversArrSize + 16, DriversArr); + DriversArr = (__typeof__(DriversArr))ReallocatePool( + DriversArrSize, DriversArrSize + 16, DriversArr); DriversArrSize += 16; } DriversArr[DriversArrNum] = DriverHandle; - // DBG(" driver %ls included with Binding=%X\n", FileName, DriverBinding); + // DBG(" driver %ls included with Binding=%X\n", FileName, + // DriverBinding); DriversArrNum++; // we'll make array terminated DriversArr[DriversArrNum] = NULL; @@ -2160,7 +2503,8 @@ static void ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne } Status = DirIterClose(&DirIter); if (Status != EFI_NOT_FOUND) { - CheckError(Status, SWPrintf( "while scanning the %ls directory", Path).wc_str()); + CheckError(Status, + SWPrintf("while scanning the %ls directory", Path).wc_str()); } if (DriversToConnectNum != NULL && DriversToConnect != NULL) { @@ -2169,7 +2513,6 @@ static void ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne } } - /** * Some UEFI's (like HPQ EFI from HP notebooks) have DiskIo protocols * opened BY_DRIVER (by Partition driver in HP case) even when no file system @@ -2178,25 +2521,25 @@ static void ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne * To fix it: we will disconnect drivers that connected to DiskIo BY_DRIVER * if this is partition volume and if those drivers did not produce file system. */ -void DisconnectInvalidDiskIoChildDrivers(void) -{ - EFI_STATUS Status; - UINTN HandleCount = 0; - UINTN Index; - UINTN OpenInfoIndex; - EFI_HANDLE *Handles = NULL; - EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs; - EFI_BLOCK_IO_PROTOCOL *BlockIo; - EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo; - UINTN OpenInfoCount; - XBool Found; +void DisconnectInvalidDiskIoChildDrivers(void) { + EFI_STATUS Status; + UINTN HandleCount = 0; + UINTN Index; + UINTN OpenInfoIndex; + EFI_HANDLE *Handles = NULL; + EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs; + EFI_BLOCK_IO_PROTOCOL *BlockIo; + EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo; + UINTN OpenInfoCount; + XBool Found; DBG("Searching for invalid DiskIo BY_DRIVER connects:"); // // Get all DiskIo handles // - Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDiskIoProtocolGuid, NULL, &HandleCount, &Handles); + Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiDiskIoProtocolGuid, NULL, + &HandleCount, &Handles); if (EFI_ERROR(Status) || HandleCount == 0) { DBG(" no DiskIo handles\n"); return; @@ -2207,100 +2550,96 @@ void DisconnectInvalidDiskIoChildDrivers(void) // Found = false; for (Index = 0; Index < HandleCount; Index++) { - //DBG("\n"); - //DBG(" - Handle %p:", Handles[Index]); + // DBG("\n"); + // DBG(" - Handle %p:", Handles[Index]); // - // If this is not partition - skip it. - // This is then whole disk and DiskIo - // should be opened here BY_DRIVER by Partition driver - // to produce partition volumes. + // If this is not partition - skip it. + // This is then whole disk and DiskIo + // should be opened here BY_DRIVER by Partition driver + // to produce partition volumes. // - Status = gBS->HandleProtocol ( - Handles[Index], - &gEfiBlockIoProtocolGuid, - (void **) &BlockIo - ); + Status = gBS->HandleProtocol(Handles[Index], &gEfiBlockIoProtocolGuid, + (void **)&BlockIo); if (EFI_ERROR(Status)) { - //DBG(" BlockIo: %s - skipping\n", efiStrError(Status)); + // DBG(" BlockIo: %s - skipping\n", efiStrError(Status)); continue; } if (BlockIo->Media == NULL) { - //DBG(" BlockIo: no media - skipping\n"); + // DBG(" BlockIo: no media - skipping\n"); continue; - } if (!BlockIo->Media->LogicalPartition) { - //DBG(" BlockIo: whole disk - skipping\n"); + // DBG(" BlockIo: whole disk - skipping\n"); continue; - } - //DBG(" BlockIo: partition"); + // DBG(" BlockIo: partition"); // // If SimpleFileSystem is already produced - skip it, this is ok // - Status = gBS->HandleProtocol ( - Handles[Index], - &gEfiSimpleFileSystemProtocolGuid, - (void **) &Fs - ); + Status = gBS->HandleProtocol( + Handles[Index], &gEfiSimpleFileSystemProtocolGuid, (void **)&Fs); if (Status == EFI_SUCCESS) { - //DBG(" FS: ok - skipping\n"); + // DBG(" FS: ok - skipping\n"); continue; } - //DBG(" FS: no"); + // DBG(" FS: no"); // // If no SimpleFileSystem on this handle but DiskIo is opened BY_DRIVER // then disconnect this connection // - Status = gBS->OpenProtocolInformation ( - Handles[Index], - &gEfiDiskIoProtocolGuid, - &OpenInfo, - &OpenInfoCount - ); + Status = gBS->OpenProtocolInformation( + Handles[Index], &gEfiDiskIoProtocolGuid, &OpenInfo, &OpenInfoCount); if (EFI_ERROR(Status)) { - //DBG(" OpenInfo: no - skipping\n"); + // DBG(" OpenInfo: no - skipping\n"); continue; } - //DBG(" OpenInfo: %d", OpenInfoCount); + // DBG(" OpenInfo: %d", OpenInfoCount); for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) { - if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == EFI_OPEN_PROTOCOL_BY_DRIVER) { + if ((OpenInfo[OpenInfoIndex].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) == + EFI_OPEN_PROTOCOL_BY_DRIVER) { if (!Found) { DBG("\n"); } Found = true; - Status = gBS->DisconnectController (Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, NULL); - //DBG(" BY_DRIVER Agent: %p, Disconnect: %s", OpenInfo[OpenInfoIndex].AgentHandle, efiStrError(Status)); - DBG(" - Handle %llx with DiskIo, is Partition, no Fs, BY_DRIVER Agent: %llx, Disconnect: %s\n", (uintptr_t)Handles[Index], (uintptr_t)(OpenInfo[OpenInfoIndex].AgentHandle), efiStrError(Status)); + Status = gBS->DisconnectController( + Handles[Index], OpenInfo[OpenInfoIndex].AgentHandle, NULL); + // DBG(" BY_DRIVER Agent: %p, Disconnect: %s", + // OpenInfo[OpenInfoIndex].AgentHandle, efiStrError(Status)); + DBG(" - Handle %llx with DiskIo, is Partition, no Fs, BY_DRIVER Agent: " + "%llx, Disconnect: %s\n", + (uintptr_t)Handles[Index], + (uintptr_t)(OpenInfo[OpenInfoIndex].AgentHandle), + efiStrError(Status)); } } - gBS->FreePool(OpenInfo); // use gBS->FreePool instead of FreePool to avoid message from MemoryTracker + gBS->FreePool(OpenInfo); // use gBS->FreePool instead of FreePool to avoid + // message from MemoryTracker } - gBS->FreePool(Handles); // use gBS->FreePool instead of FreePool to avoid message from MemoryTracker + gBS->FreePool(Handles); // use gBS->FreePool instead of FreePool to avoid + // message from MemoryTracker if (!Found) { DBG(" not found, all ok\n"); } } -void DisconnectSomeDevices(void) -{ - EFI_STATUS Status; - UINTN HandleCount; - UINTN Index, Index2; - EFI_HANDLE *Handles ; - EFI_HANDLE *ControllerHandles; - UINTN ControllerHandleCount; - EFI_BLOCK_IO_PROTOCOL *BlockIo = NULL; -// EFI_DISK_IO_PROTOCOL *DiskIo = NULL; - EFI_PCI_IO_PROTOCOL *PciIo = NULL; -// EFI_FILE_PROTOCOL *RootFP = NULL; -// EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *VolumeFS = NULL; - PCI_TYPE00 Pci; - CHAR16 *DriverName = NULL; - EFI_COMPONENT_NAME_PROTOCOL *CompName = NULL; +void DisconnectSomeDevices(void) { + EFI_STATUS Status; + UINTN HandleCount; + UINTN Index, Index2; + EFI_HANDLE *Handles; + EFI_HANDLE *ControllerHandles; + UINTN ControllerHandleCount; + EFI_BLOCK_IO_PROTOCOL *BlockIo = NULL; + // EFI_DISK_IO_PROTOCOL *DiskIo = NULL; + EFI_PCI_IO_PROTOCOL *PciIo = NULL; + // EFI_FILE_PROTOCOL *RootFP = NULL; + // EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *VolumeFS = NULL; + PCI_TYPE00 Pci; + CHAR16 *DriverName = NULL; + EFI_COMPONENT_NAME_PROTOCOL *CompName = NULL; if (gDriversFlags.PartitionLoaded) { DBG("Partition driver loaded: "); @@ -2308,10 +2647,12 @@ void DisconnectSomeDevices(void) HandleCount = 0; Handles = NULL; - Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiBlockIoProtocolGuid, NULL, &HandleCount, &Handles); + Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiBlockIoProtocolGuid, NULL, + &HandleCount, &Handles); if (Status == EFI_SUCCESS) { for (Index = 0; Index < HandleCount; Index++) { - Status = gBS->HandleProtocol(Handles[Index], &gEfiBlockIoProtocolGuid, (void **) &BlockIo); + Status = gBS->HandleProtocol(Handles[Index], &gEfiBlockIoProtocolGuid, + (void **)&BlockIo); if (EFI_ERROR(Status)) { continue; } @@ -2321,9 +2662,9 @@ void DisconnectSomeDevices(void) DBG("CD disconnect %s", efiStrError(Status)); } } -/* for (Index = 0; Index < HandleCount; Index++) { - Status = gBS->DisconnectController(Handles[Index], NULL, NULL); - } */ + /* for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->DisconnectController(Handles[Index], NULL, NULL); + } */ FreePool(Handles); } DBG("\n"); @@ -2341,36 +2682,38 @@ void DisconnectSomeDevices(void) ControllerHandleCount = 0; ControllerHandles = NULL; - Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, &ControllerHandleCount, &ControllerHandles); - /* if (!EFI_ERROR(Status)) { - for (Index2 = 0; Index2 < ControllerHandleCount; Index2++) { - Status = gBS->DisconnectController(ControllerHandles[Index2], - NULL, NULL); - DBG("Driver [%d] disconnect %s\n", Index2, efiStrError(Status)); - } - } */ + Status = gBS->LocateHandleBuffer( + ByProtocol, &gEfiSimpleFileSystemProtocolGuid, NULL, + &ControllerHandleCount, &ControllerHandles); + /* if (!EFI_ERROR(Status)) { + for (Index2 = 0; Index2 < ControllerHandleCount; Index2++) { + Status = gBS->DisconnectController(ControllerHandles[Index2], + NULL, NULL); + DBG("Driver [%d] disconnect %s\n", Index2, efiStrError(Status)); + } + } */ HandleCount = 0; Handles = NULL; - Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid, NULL, &HandleCount, &Handles); + Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiComponentNameProtocolGuid, + NULL, &HandleCount, &Handles); if (!EFI_ERROR(Status)) { for (Index = 0; Index < HandleCount; Index++) { Status = gBS->OpenProtocol( - Handles[Index], - gEfiComponentNameProtocolGuid, - (void**)&CompName, - gImageHandle, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL); + Handles[Index], gEfiComponentNameProtocolGuid, (void **)&CompName, + gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (EFI_ERROR(Status)) { -// DBG("CompName %s\n", efiStrError(Status)); + // DBG("CompName %s\n", efiStrError(Status)); continue; } - // 2021-05, Jief : PG7 had a crash. In some cases, CompName->GetDriverName == NULL. - if ( CompName->GetDriverName == NULL ) { - DBG("DisconnectSomeDevices: GetDriverName CompName=%lld, CompName->GetDriverName=NULL\n", uintptr_t(CompName)); + // 2021-05, Jief : PG7 had a crash. In some cases, + // CompName->GetDriverName == NULL. + if (CompName->GetDriverName == NULL) { + DBG("DisconnectSomeDevices: GetDriverName CompName=%lld, " + "CompName->GetDriverName=NULL\n", + uintptr_t(CompName)); continue; } Status = CompName->GetDriverName(CompName, "eng", &DriverName); @@ -2381,32 +2724,37 @@ void DisconnectSomeDevices(void) for (Index2 = 0; Index2 < ControllerHandleCount; Index2++) { Status = gBS->DisconnectController(ControllerHandles[Index2], Handles[Index], NULL); - //DBG("Disconnect [%ls] from %llX: %s\n", DriverName, uintptr_t(ControllerHandles[Index2]), efiStrError(Status)); + // DBG("Disconnect [%ls] from %llX: %s\n", DriverName, + // uintptr_t(ControllerHandles[Index2]), efiStrError(Status)); } } } - gBS->FreePool(Handles); // use gBS->FreePool instead of FreePool to avoid message from MemoryTracker + gBS->FreePool(Handles); // use gBS->FreePool instead of FreePool to avoid + // message from MemoryTracker } -// DBG("\n"); - gBS->FreePool(ControllerHandles); // use gBS->FreePool instead of FreePool to avoid message from MemoryTracker + // DBG("\n"); + gBS->FreePool(ControllerHandles); // use gBS->FreePool instead of FreePool + // to avoid message from MemoryTracker } - if (gDriversFlags.VideoLoaded) { DBG("Video driver loaded: "); // get all PciIo handles HandleCount = 0; Handles = NULL; - Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiPciIoProtocolGuid, NULL, &HandleCount, &Handles); + Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiPciIoProtocolGuid, NULL, + &HandleCount, &Handles); if (Status == EFI_SUCCESS) { for (Index = 0; Index < HandleCount; Index++) { - Status = gBS->HandleProtocol(Handles[Index], &gEfiPciIoProtocolGuid, (void **) &PciIo); + Status = gBS->HandleProtocol(Handles[Index], &gEfiPciIoProtocolGuid, + (void **)&PciIo); if (EFI_ERROR(Status)) { continue; } - Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, sizeof (Pci) / sizeof (UINT32), &Pci); + Status = PciIo->Pci.Read(PciIo, EfiPciIoWidthUint32, 0, + sizeof(Pci) / sizeof(UINT32), &Pci); if (!EFI_ERROR(Status)) { - if(IS_PCI_VGA(&Pci) == true) { + if (IS_PCI_VGA(&Pci) == true) { // disconnect VGA Status = gBS->DisconnectController(Handles[Index], NULL, NULL); DBG("disconnect %s", efiStrError(Status)); @@ -2423,12 +2771,12 @@ void DisconnectSomeDevices(void) } } +void PatchVideoBios(UINT8 *Edid) { -void PatchVideoBios(UINT8 *Edid) -{ - - if ( gSettings.Graphics.PatchVBiosBytes.notEmpty() ) { - VideoBiosPatchBytes(gSettings.Graphics.PatchVBiosBytes.getVBIOS_PATCH_BYTES(), gSettings.Graphics.PatchVBiosBytes.getVBIOS_PATCH_BYTES_count()); + if (gSettings.Graphics.PatchVBiosBytes.notEmpty()) { + VideoBiosPatchBytes( + gSettings.Graphics.PatchVBiosBytes.getVBIOS_PATCH_BYTES(), + gSettings.Graphics.PatchVBiosBytes.getVBIOS_PATCH_BYTES_count()); } if (gSettings.Graphics.PatchVBios) { @@ -2436,19 +2784,17 @@ void PatchVideoBios(UINT8 *Edid) } } - -static void LoadDrivers(void) -{ - EFI_STATUS Status; - EFI_HANDLE *DriversToConnect = NULL; - UINTN DriversToConnectNum = 0; - UINT8 *Edid; - UINTN VarSize = 0; - XBool VBiosPatchNeeded; +static void LoadDrivers(void) { + EFI_STATUS Status; + EFI_HANDLE *DriversToConnect = NULL; + UINTN DriversToConnectNum = 0; + UINT8 *Edid; + UINTN VarSize = 0; + XBool VBiosPatchNeeded; DbgHeader("LoadDrivers"); - // load drivers from /efi/drivers + // load drivers from /efi/drivers #if defined(MDE_CPU_X64) if (gFirmwareClover) { if (FileExists(&self.getCloverDir(), L"drivers\\BIOS")) { @@ -2470,25 +2816,25 @@ static void LoadDrivers(void) #else ScanDriverDir(L"drivers32", &DriversToConnect, &DriversToConnectNum); #endif - // DriversToConnect is allocated by ScanDriverDir, but DO NOT free it. RegisterDriversToHighestPriority will store it in the global var mPriorityDrivers. + // DriversToConnect is allocated by ScanDriverDir, but DO NOT free it. + // RegisterDriversToHighestPriority will store it in the global var + // mPriorityDrivers. - VBiosPatchNeeded = gSettings.Graphics.PatchVBios || gSettings.Graphics.PatchVBiosBytes.getVBIOS_PATCH_BYTES_count() > 0; + VBiosPatchNeeded = + gSettings.Graphics.PatchVBios || + gSettings.Graphics.PatchVBiosBytes.getVBIOS_PATCH_BYTES_count() > 0; if (VBiosPatchNeeded) { // check if it is already done in CloverEFI BiosVideo - Status = gRT->GetVariable ( - L"CloverVBiosPatchDone", - gEfiGlobalVariableGuid, - NULL, - &VarSize, - NULL - ); + Status = gRT->GetVariable(L"CloverVBiosPatchDone", gEfiGlobalVariableGuid, + NULL, &VarSize, NULL); if (Status == EFI_BUFFER_TOO_SMALL) { // var exists - it's done - let's not do it again VBiosPatchNeeded = false; } } - if ( (gSettings.Graphics.EDID.CustomEDID.notEmpty() && gFirmwareClover) || (VBiosPatchNeeded && !gDriversFlags.VideoLoaded)) { + if ((gSettings.Graphics.EDID.CustomEDID.notEmpty() && gFirmwareClover) || + (VBiosPatchNeeded && !gDriversFlags.VideoLoaded)) { // we have video bios patch - force video driver reconnect DBG("Video bios patch requested or CustomEDID - forcing video reconnect\n"); gDriversFlags.VideoLoaded = true; @@ -2519,24 +2865,25 @@ static void LoadDrivers(void) // Boot speedup: remove temporary "BiosVideoBlockSwitchMode" RT var // to unlock mode switching in CsmVideo - gRT->SetVariable(L"BiosVideoBlockSwitchMode", gEfiGlobalVariableGuid, EFI_VARIABLE_BOOTSERVICE_ACCESS, 0, NULL); - }else{ - BdsLibConnectAllEfi(); // jief : without any driver loaded, i couldn't see my CD, unless I call BdsLibConnectAllEfi + gRT->SetVariable(L"BiosVideoBlockSwitchMode", gEfiGlobalVariableGuid, + EFI_VARIABLE_BOOTSERVICE_ACCESS, 0, NULL); + } else { + BdsLibConnectAllEfi(); // jief : without any driver loaded, i couldn't see + // my CD, unless I call BdsLibConnectAllEfi } ReinitRefitLib(); } +INTN FindDefaultEntry(void) { + INTN Index = -1; + REFIT_VOLUME *Volume; + XBool SearchForLoader; -INTN FindDefaultEntry(void) -{ - INTN Index = -1; - REFIT_VOLUME *Volume; - XBool SearchForLoader; + // DBG("FindDefaultEntry ...\n"); + // DbgHeader("FindDefaultEntry"); -// DBG("FindDefaultEntry ...\n"); - //DbgHeader("FindDefaultEntry"); - - if ( gSettings.Boot.BootFirstAvailable ) return 0; + if (gSettings.Boot.BootFirstAvailable) + return 0; // // try to detect volume set by Startup Disk or previous Clover selection @@ -2549,106 +2896,122 @@ INTN FindDefaultEntry(void) Index = FindStartupDiskVolume(&MainMenu); if (Index >= 0) { - DBG("Boot redirected to Entry %lld. '%ls'\n", Index, MainMenu.Entries[Index].Title.s()); + DBG("Boot redirected to Entry %lld. '%ls'\n", Index, + MainMenu.Entries[Index].Title.s()); // we got boot-device-data, no need to keep emulating anymore if (gEmuVariableControl != NULL) { - gEmuVariableControl->UninstallEmulation(gEmuVariableControl); + gEmuVariableControl->UninstallEmulation(gEmuVariableControl); } return Index; } // // if not found, then try DefaultVolume from config.plist - // if not null or empty, search volume that matches gSettings.Boot.DefaultVolume + // if not null or empty, search volume that matches + // gSettings.Boot.DefaultVolume // if (gSettings.Boot.DefaultVolume.notEmpty()) { - // if not null or empty, also search for loader that matches gSettings.Boot.DefaultLoader + // if not null or empty, also search for loader that matches + // gSettings.Boot.DefaultLoader SearchForLoader = gSettings.Boot.DefaultLoader.notEmpty(); -/* - if (SearchForLoader) { - DBG("Searching for DefaultVolume '%ls', DefaultLoader '%ls' ...\n", gSettings.Boot.DefaultVolume, gSettings.Boot.DefaultLoader); - } else { - DBG("Searching for DefaultVolume '%ls' ...\n", gSettings.Boot.DefaultVolume); - } -*/ - for (Index = 0; Index < (INTN)MainMenu.Entries.size() && MainMenu.Entries[Index].getLOADER_ENTRY() && MainMenu.Entries[Index].getLOADER_ENTRY()->Row == 0 ; Index++) { + /* + if (SearchForLoader) { + DBG("Searching for DefaultVolume '%ls', DefaultLoader '%ls' ...\n", + gSettings.Boot.DefaultVolume, gSettings.Boot.DefaultLoader); } else { + DBG("Searching for DefaultVolume '%ls' ...\n", + gSettings.Boot.DefaultVolume); + } + */ + for (Index = 0; Index < (INTN)MainMenu.Entries.size() && + MainMenu.Entries[Index].getLOADER_ENTRY() && + MainMenu.Entries[Index].getLOADER_ENTRY()->Row == 0; + Index++) { - LOADER_ENTRY& Entry = *MainMenu.Entries[Index].getLOADER_ENTRY(); + LOADER_ENTRY &Entry = *MainMenu.Entries[Index].getLOADER_ENTRY(); if (!Entry.Volume) { continue; } Volume = Entry.Volume; - if ( (Volume->VolName.isEmpty() || Volume->VolName != gSettings.Boot.DefaultVolume) && - !Volume->DevicePathString.contains(gSettings.Boot.DefaultVolume) ) { + if ((Volume->VolName.isEmpty() || + Volume->VolName != gSettings.Boot.DefaultVolume) && + !Volume->DevicePathString.contains(gSettings.Boot.DefaultVolume)) { continue; } // we alreday know that Entry.isLoader - if (SearchForLoader && (/*Entry.Tag != TAG_LOADER ||*/ !Entry.LoaderPath.containsIC(gSettings.Boot.DefaultLoader))) { + if (SearchForLoader && + (/*Entry.Tag != TAG_LOADER ||*/ !Entry.LoaderPath.containsIC( + gSettings.Boot.DefaultLoader))) { continue; } - DBG(" - found entry %lld. '%ls', Volume '%ls', DevicePath '%ls'\n", Index, Entry.Title.s(), Volume->VolName.wc_str(), Entry.DevicePathString.wc_str()); + DBG(" - found entry %lld. '%ls', Volume '%ls', DevicePath '%ls'\n", Index, + Entry.Title.s(), Volume->VolName.wc_str(), + Entry.DevicePathString.wc_str()); // if first method failed and second succeeded - uninstall emulation if (gEmuVariableControl != NULL) { gEmuVariableControl->UninstallEmulation(gEmuVariableControl); } return Index; } - } DBG("Default boot entry not found\n"); - // if both methods to determine default boot entry have failed - uninstall emulation before GUI - if (gEmuVariableControl != NULL) { + // if both methods to determine default boot entry have failed - uninstall + // emulation before GUI + if (gEmuVariableControl != NULL) { gEmuVariableControl->UninstallEmulation(gEmuVariableControl); - } + } return -1; } -void SetVariablesFromNvram() -{ - CHAR8 *tmpString; - UINTN Size = 0; - UINTN index = 0, index2, i; - CHAR8 *arg = NULL; +void SetVariablesFromNvram() { + CHAR8 *tmpString; + UINTN Size = 0; + UINTN index = 0, index2, i; + CHAR8 *arg = NULL; -// DbgHeader("SetVariablesFromNvram"); + // DbgHeader("SetVariablesFromNvram"); - tmpString = (__typeof__(tmpString))GetNvramVariable(L"boot-args", gEfiAppleBootGuid, NULL, &Size); + tmpString = (__typeof__(tmpString))GetNvramVariable( + L"boot-args", gEfiAppleBootGuid, NULL, &Size); if (tmpString && (Size <= 0x1000) && (Size > 0)) { DBG("found boot-args in NVRAM:%s, size=%llu\n", tmpString, Size); // use and forget old one -// DeleteNvramVariable(L"boot-args", &gEfiAppleBootGuid); - Size = AsciiStrLen(tmpString); // some EFI implementations include '\0' in Size, and others don't, so update Size to string length - arg = (__typeof__(arg))AllocatePool(Size+1); - -/* if (AsciiStrStr(tmpString, "nvda_drv=1")) { //found substring - gSettings.NvidiaWeb = true; - } */ - //first we will find new args that is not present in main args + // DeleteNvramVariable(L"boot-args", &gEfiAppleBootGuid); + Size = AsciiStrLen( + tmpString); // some EFI implementations include '\0' in Size, and others + // don't, so update Size to string length + arg = (__typeof__(arg))AllocatePool(Size + 1); + + /* if (AsciiStrStr(tmpString, "nvda_drv=1")) { //found substring + gSettings.NvidiaWeb = true; + } */ + // first we will find new args that is not present in main args index = 0; while ((index < Size) && (tmpString[index] != 0x0)) { - ZeroMem(arg, Size+1); + ZeroMem(arg, Size + 1); index2 = 0; if (tmpString[index] != '\"') { - // DBG("search space index=%d\n", index); - while ((index < Size) && (tmpString[index] != 0x20) && (tmpString[index] != 0x0)) { + // DBG("search space index=%d\n", index); + while ((index < Size) && (tmpString[index] != 0x20) && + (tmpString[index] != 0x0)) { arg[index2++] = tmpString[index++]; } DBG("...found arg:%s\n", arg); } else { index++; -// DBG("search quote index=%d\n", index); - while ((index < Size) && (tmpString[index] != '\"') && (tmpString[index] != 0x0)) { + // DBG("search quote index=%d\n", index); + while ((index < Size) && (tmpString[index] != '\"') && + (tmpString[index] != 0x0)) { arg[index2++] = tmpString[index++]; } if (tmpString[index] == '\"') { index++; } - DBG("...found quoted arg:\n"/*, arg*/); + DBG("...found quoted arg:\n" /*, arg*/); } while (tmpString[index] == 0x20) { index++; @@ -2659,7 +3022,7 @@ void SetVariablesFromNvram() continue; } if (!gSettings.Boot.BootArgs.contains(arg)) { - //this arg is not present will add + // this arg is not present will add DBG("...adding arg:%s\n", arg); gSettings.Boot.BootArgs.trim(); gSettings.Boot.BootArgs += ' '; @@ -2674,22 +3037,20 @@ void SetVariablesFromNvram() if (tmpString) { FreePool(tmpString); } - - tmpString = (__typeof__(tmpString))GetNvramVariable(L"nvda_drv", gEfiAppleBootGuid, NULL, NULL); + + tmpString = (__typeof__(tmpString))GetNvramVariable( + L"nvda_drv", gEfiAppleBootGuid, NULL, NULL); if (tmpString && AsciiStrCmp(tmpString, "1") == 0) { gSettings.SystemParameters.NvidiaWeb = true; } if (tmpString) { FreePool(tmpString); } - } -void -GetListOfConfigs() -{ - REFIT_DIR_ITER DirIter; - EFI_FILE_INFO *DirEntry; +void GetListOfConfigs() { + REFIT_DIR_ITER DirIter; + EFI_FILE_INFO *DirEntry; ConfigsList.setEmpty(); OldChosenConfig = 0; @@ -2701,24 +3062,28 @@ GetListOfConfigs() continue; } if (StriCmp(DirEntry->FileName, L"config.plist") == 0) { - OldChosenConfig = ConfigsList.size(); // DirEntry->FileName is not yet inserted into ConfigsList. So its index will be ConfigsList.size() + OldChosenConfig = + ConfigsList + .size(); // DirEntry->FileName is not yet inserted into + // ConfigsList. So its index will be ConfigsList.size() } - size_t NameLen = wcslen(DirEntry->FileName) - 6; //without ".plist" - if ( NameLen <= MAX_INTN ) { - ConfigsList.AddReference(SWPrintf("%.*ls", (int)NameLen, DirEntry->FileName).forgetDataWithoutFreeing(), true); // this avoid to reallocate and copy memory + size_t NameLen = wcslen(DirEntry->FileName) - 6; // without ".plist" + if (NameLen <= MAX_INTN) { + ConfigsList.AddReference( + SWPrintf("%.*ls", (int)NameLen, DirEntry->FileName) + .forgetDataWithoutFreeing(), + true); // this avoid to reallocate and copy memory DBG("- %ls\n", DirEntry->FileName); - }else{ + } else { DBG("- bug!, NameLen > MAX_INTN"); } } DirIterClose(&DirIter); } -void -GetListOfDsdts() -{ - REFIT_DIR_ITER DirIter; - EFI_FILE_INFO *DirEntry; +void GetListOfDsdts() { + REFIT_DIR_ITER DirIter; + EFI_FILE_INFO *DirEntry; DsdtsList.setEmpty(); OldChosenDsdt = 0xFFFF; @@ -2729,95 +3094,101 @@ GetListOfDsdts() if (DirEntry->FileName[0] == L'.') { continue; } - if ( gSettings.ACPI.DSDT.DsdtName.isEqualIC(DirEntry->FileName) ) { - OldChosenDsdt = DsdtsList.size(); // DirEntry->FileName is not yet inserted into DsdtsList. So its index will be DsdtsList.size() - } - size_t NameLen = wcslen(DirEntry->FileName); //with ".aml" - DsdtsList.AddReference(SWPrintf("%.*ls", (int)NameLen, DirEntry->FileName).forgetDataWithoutFreeing(), true); // this avoid to reallocate and copy memory - DBG("- %ls\n", DirEntry->FileName); + if (gSettings.ACPI.DSDT.DsdtName.isEqualIC(DirEntry->FileName)) { + OldChosenDsdt = + DsdtsList.size(); // DirEntry->FileName is not yet inserted into + // DsdtsList. So its index will be DsdtsList.size() } + size_t NameLen = wcslen(DirEntry->FileName); // with ".aml" + DsdtsList.AddReference(SWPrintf("%.*ls", (int)NameLen, DirEntry->FileName) + .forgetDataWithoutFreeing(), + true); // this avoid to reallocate and copy memory + DBG("- %ls\n", DirEntry->FileName); + } DirIterClose(&DirIter); } -void -GetListOfACPI() -{ - REFIT_DIR_ITER DirIter; - EFI_FILE_INFO *DirEntry = NULL; +void GetListOfACPI() { + REFIT_DIR_ITER DirIter; + EFI_FILE_INFO *DirEntry = NULL; -// XStringW AcpiPath = SWPrintf("%ls\\ACPI\\patched", OEMPath.wc_str()); -// DBG("Get list of ACPI at path %ls\n", AcpiPath.wc_str()); + // XStringW AcpiPath = SWPrintf("%ls\\ACPI\\patched", + // OEMPath.wc_str()); DBG("Get list of ACPI at path %ls\n", + // AcpiPath.wc_str()); ACPIPatchedAML.setEmpty(); DirIterOpen(&selfOem.getConfigDir(), L"ACPI\\patched", &DirIter); while (DirIterNext(&DirIter, 2, L"*.aml", &DirEntry)) { -// DBG("next entry is %ls\n", DirEntry->FileName); + // DBG("next entry is %ls\n", DirEntry->FileName); if (DirEntry->FileName[0] == L'.') { continue; } if (StriStr(DirEntry->FileName, L"DSDT")) { continue; } -// DBG("Found name %ls\n", DirEntry->FileName); - XBool ACPIDisabled = false; - ACPI_PATCHED_AML* ACPIPatchedAMLTmp = new ACPI_PATCHED_AML; - ACPIPatchedAMLTmp->FileName.takeValueFrom(DirEntry->FileName); - - INTN Count = gSettings.ACPI.DisabledAML.size(); - for (INTN i = 0; i < Count; i++) { - if ( gSettings.ACPI.DisabledAML[i].isEqualIC(ACPIPatchedAMLTmp->FileName) ) { -// if ((gSettings.ACPI.DisabledAML[i] != NULL) && -// (StriCmp(ACPIPatchedAMLTmp->FileName, gSettings.ACPI.DisabledAML[i]) == 0) -// ) { - ACPIDisabled = true; - break; - } + // DBG("Found name %ls\n", DirEntry->FileName); + XBool ACPIDisabled = false; + ACPI_PATCHED_AML *ACPIPatchedAMLTmp = new ACPI_PATCHED_AML; + ACPIPatchedAMLTmp->FileName.takeValueFrom(DirEntry->FileName); + + INTN Count = gSettings.ACPI.DisabledAML.size(); + for (INTN i = 0; i < Count; i++) { + if (gSettings.ACPI.DisabledAML[i].isEqualIC( + ACPIPatchedAMLTmp->FileName)) { + // if ((gSettings.ACPI.DisabledAML[i] != NULL) && + // (StriCmp(ACPIPatchedAMLTmp->FileName, + // gSettings.ACPI.DisabledAML[i]) == 0) ) { + ACPIDisabled = true; + break; } - ACPIPatchedAMLTmp->MenuItem.BValue = ACPIDisabled; - ACPIPatchedAML.AddReference(ACPIPatchedAMLTmp, true); } + ACPIPatchedAMLTmp->MenuItem.BValue = ACPIDisabled; + ACPIPatchedAML.AddReference(ACPIPatchedAMLTmp, true); + } DirIterClose(&DirIter); } -void -GetListOfThemes () -{ - EFI_STATUS Status = EFI_NOT_FOUND; +void GetListOfThemes() { + EFI_STATUS Status = EFI_NOT_FOUND; REFIT_DIR_ITER DirIter; - EFI_FILE_INFO *DirEntry; - XStringW ThemeTestPath; - EFI_FILE *ThemeTestDir = NULL; - UINT8 *ThemePtr = NULL; - UINTN Size = 0; + EFI_FILE_INFO *DirEntry; + XStringW ThemeTestPath; + EFI_FILE *ThemeTestDir = NULL; + UINT8 *ThemePtr = NULL; + UINTN Size = 0; DbgHeader("GetListOfThemes"); ThemeNameArray.setEmpty(); - if ( !self.themesDirExists() ) { + if (!self.themesDirExists()) { DBG("No theme dir was discovered\n"); return; } DirIterOpen(&self.getThemesDir(), NULL, &DirIter); while (DirIterNext(&DirIter, 1, L"*", &DirEntry)) { if (DirEntry->FileName[0] == '.') { - //DBG("Skip theme: %ls\n", DirEntry->FileName); + // DBG("Skip theme: %ls\n", DirEntry->FileName); continue; } - //DBG("Found theme directory: %ls", DirEntry->FileName); + // DBG("Found theme directory: %ls", DirEntry->FileName); DBG("- [%02zu]: %ls", ThemeNameArray.size(), DirEntry->FileName); - Status = self.getThemesDir().Open(&self.getThemesDir(), &ThemeTestDir, DirEntry->FileName, EFI_FILE_MODE_READ, 0); + Status = + self.getThemesDir().Open(&self.getThemesDir(), &ThemeTestDir, + DirEntry->FileName, EFI_FILE_MODE_READ, 0); if (!EFI_ERROR(Status)) { - Status = egLoadFile(ThemeTestDir, CONFIG_THEME_FILENAME, &ThemePtr, &Size); + Status = + egLoadFile(ThemeTestDir, CONFIG_THEME_FILENAME, &ThemePtr, &Size); if (EFI_ERROR(Status) || (ThemePtr == NULL) || (Size == 0)) { Status = egLoadFile(ThemeTestDir, CONFIG_THEME_SVG, &ThemePtr, &Size); if (EFI_ERROR(Status)) { Status = EFI_NOT_FOUND; - DBG(" - bad theme because %ls nor %ls can't be load", CONFIG_THEME_FILENAME, CONFIG_THEME_SVG); + DBG(" - bad theme because %ls nor %ls can't be load", + CONFIG_THEME_FILENAME, CONFIG_THEME_SVG); } } if (!EFI_ERROR(Status)) { - //we found a theme + // we found a theme if ((StriCmp(DirEntry->FileName, L"embedded") == 0) || (StriCmp(DirEntry->FileName, L"random") == 0)) { ThemePtr = NULL; @@ -2839,39 +3210,37 @@ GetListOfThemes () // EFI_STATUS EFIAPI -RefitMainMain (IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable) -{ +RefitMainMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) { EFI_STATUS Status; - XBool MainLoopRunning = true; - XBool ReinitDesktop = true; - XBool AfterTool = false; - REFIT_ABSTRACT_MENU_ENTRY *ChosenEntry = NULL; - REFIT_ABSTRACT_MENU_ENTRY *DefaultEntry = NULL; - REFIT_ABSTRACT_MENU_ENTRY *OptionEntry = NULL; - INTN DefaultIndex; - UINTN MenuExit; - UINTN i; - EFI_TIME Now; - XBool HaveDefaultVolume; + XBool MainLoopRunning = true; + XBool ReinitDesktop = true; + XBool AfterTool = false; + REFIT_ABSTRACT_MENU_ENTRY *ChosenEntry = NULL; + REFIT_ABSTRACT_MENU_ENTRY *DefaultEntry = NULL; + REFIT_ABSTRACT_MENU_ENTRY *OptionEntry = NULL; + INTN DefaultIndex; + UINTN MenuExit; + UINTN i; + EFI_TIME Now; + XBool HaveDefaultVolume; REFIT_MENU_SCREEN BootScreen; - BootScreen.isBootScreen = true; //other screens will be constructed as false + BootScreen.isBootScreen = true; // other screens will be constructed as false MemLogInit(); // bootstrap - gST = SystemTable; - gImageHandle = ImageHandle; - gBS = SystemTable->BootServices; - gRT = SystemTable->RuntimeServices; - /*Status = */EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (void **) &gDS); - + gST = SystemTable; + gImageHandle = ImageHandle; + gBS = SystemTable->BootServices; + gRT = SystemTable->RuntimeServices; + /*Status = */ EfiGetSystemConfigurationTable(&gEfiDxeServicesTableGuid, + (void **)&gDS); InitBooterLog(); // ConsoleInHandle = SystemTable->ConsoleInHandle; -//#define DEBUG_ERALY_CRASH +// #define DEBUG_ERALY_CRASH #ifdef DEBUG_ERALY_CRASH SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Step1"); // PauseForKey(); @@ -2882,23 +3251,28 @@ RefitMainMain (IN EFI_HANDLE ImageHandle, #endif { - EFI_LOADED_IMAGE* LoadedImage; - Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, (void **) &LoadedImage); + EFI_LOADED_IMAGE *LoadedImage; + Status = gBS->HandleProtocol(gImageHandle, &gEfiLoadedImageProtocolGuid, + (void **)&LoadedImage); #ifdef DEBUG_ERALY_CRASH - SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Step2"); + SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Step2"); // PauseForKey(); #endif -// if ( !EFI_ERROR(Status) ) { -// XString8 msg = S8Printf("CloverX64 : Image base = 0x%llX\n", (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by grep to feed the debugger -// SerialPortWrite((UINT8*)msg.c_str(), msg.length()); -// } - if ( !EFI_ERROR(Status) ) { - DBG("CloverX64 : Image base = 0x%llX\n", (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by grep to feed the debugger + // if ( !EFI_ERROR(Status) ) { + // XString8 msg = S8Printf("CloverX64 : Image base = 0x%llX\n", + // (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by + // grep to feed the debugger SerialPortWrite((UINT8*)msg.c_str(), + // msg.length()); + // } + if (!EFI_ERROR(Status)) { + DBG("CloverX64 : Image base = 0x%llX\n", + (uintptr_t)LoadedImage->ImageBase); // do not change, it's used by + // grep to feed the debugger DBG("Clover ImageHandle = %llx\n", (uintptr_t)ImageHandle); #ifdef DEBUG_ERALY_CRASH - SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Step3"); + SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Step3"); // PauseForKey(); #endif } @@ -2914,14 +3288,16 @@ RefitMainMain (IN EFI_HANDLE ImageHandle, #endif #ifdef CLOVER_BUILD - // BE CAREFUL. construct_globals_objects will call ctor on every static struct and classes. - // For example, if you do "gCPUStructure.TSCCalibr = GetMemLogTscTicksPerSecond();" before this point, it will be erased by construct_globals_objects() + // BE CAREFUL. construct_globals_objects will call ctor on every static struct + // and classes. For example, if you do "gCPUStructure.TSCCalibr = + // GetMemLogTscTicksPerSecond();" before this point, it will be erased by + // construct_globals_objects() construct_globals_objects(gImageHandle); #endif MemoryTrackerInstallHook(); - gCPUStructure.TSCCalibr = GetMemLogTscTicksPerSecond(); //ticks for 1second + gCPUStructure.TSCCalibr = GetMemLogTscTicksPerSecond(); // ticks for 1second #ifdef DEBUG_ERALY_CRASH SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Step5"); @@ -2935,7 +3311,9 @@ RefitMainMain (IN EFI_HANDLE ImageHandle, gRT->GetTime(&Now, NULL); - Status = InitRefitLib(gImageHandle); // From here, debug.log starts to be saved because InitRefitLib call self.initialize() + Status = + InitRefitLib(gImageHandle); // From here, debug.log starts to be saved + // because InitRefitLib call self.initialize() if (EFI_ERROR(Status)) return Status; @@ -2944,33 +3322,36 @@ RefitMainMain (IN EFI_HANDLE ImageHandle, PauseForKey(); #endif -// firmware detection + // firmware detection gFirmwareClover = StrCmp(gST->FirmwareVendor, L"CLOVER") == 0; if (!gFirmwareRevision) { -// gFirmwareRevision = P__oolPrint(L"%d", gST->FirmwareRevision); + // gFirmwareRevision = P__oolPrint(L"%d", gST->FirmwareRevision); } - DataHubInstall (ImageHandle, SystemTable); + DataHubInstall(ImageHandle, SystemTable); InitializeConsoleSim(); DbgHeader("Starting Clover"); if (Now.TimeZone < -1440 || Now.TimeZone > 1440) { - MsgLog("Now is %02d.%02d.%d, %02d:%02d:%02d (GMT)\n", - Now.Day, Now.Month, Now.Year, Now.Hour, Now.Minute, Now.Second); + MsgLog("Now is %02d.%02d.%d, %02d:%02d:%02d (GMT)\n", Now.Day, Now.Month, + Now.Year, Now.Hour, Now.Minute, Now.Second); } else { - MsgLog("Now is %02d.%02d.%d, %02d:%02d:%02d (GMT+%d)\n", - Now.Day, Now.Month, Now.Year, Now.Hour, Now.Minute, Now.Second, gSettings.GUI.Timezone); + MsgLog("Now is %02d.%02d.%d, %02d:%02d:%02d (GMT+%d)\n", Now.Day, + Now.Month, Now.Year, Now.Hour, Now.Minute, Now.Second, + gSettings.GUI.Timezone); } - //MsgLog("Starting Clover rev %ls on %ls EFI\n", gFirmwareRevision, gST->FirmwareVendor); + // MsgLog("Starting Clover rev %ls on %ls EFI\n", gFirmwareRevision, + // gST->FirmwareVendor); MsgLog("Starting %s on %ls EFI\n", gRevisionStr, gST->FirmwareVendor); MsgLog("Build id: %s\n", gBuildId.c_str()); - if ( gBuildInfo ) DBG("Build with: [%s]\n", gBuildInfo); + if (gBuildInfo) + DBG("Build with: [%s]\n", gBuildInfo); #ifdef JIEF_DEBUG displayFreeMemory(""_XS8); #endif - //dumping SETTING structure - // if you change something in Platform.h, please uncomment and test that all offsets - // are natural aligned i.e. pointers are 8 bytes aligned + // dumping SETTING structure + // if you change something in Platform.h, please uncomment and test that all + // offsets are natural aligned i.e. pointers are 8 bytes aligned /* DBG("Settings offsets:\n"); DBG(" OEMProduct: %X\n", OFFSET_OF(SETTINGS_DATA, OEMProduct)); @@ -2981,57 +3362,59 @@ RefitMainMain (IN EFI_HANDLE ImageHandle, DBG(" FakeATI: %X\n", OFFSET_OF(SETTINGS_DATA, FakeATI)); DBG(" PatchVBiosBytes:%X\n", OFFSET_OF(SETTINGS_DATA, PatchVBiosBytes)); DBG(" VRAM: %X\n", OFFSET_OF(SETTINGS_DATA, VRAM)); - DBG(" SecureBootWhiteListCount: %X\n", OFFSET_OF(SETTINGS_DATA, SecureBootWhiteListCount)); - DBG(" LegacyBoot: %X\n", OFFSET_OF(SETTINGS_DATA, LegacyBoot)); - DBG(" HVHideStrings: %X\n", OFFSET_OF(SETTINGS_DATA, HVHideStrings)); - DBG(" PointerSpeed: %X\n", OFFSET_OF(SETTINGS_DATA, PointerSpeed)); - DBG(" RtMLB: %X\n", OFFSET_OF(SETTINGS_DATA, RtMLB)); - DBG(" ConfigName: %X\n", OFFSET_OF(SETTINGS_DATA, ConfigName)); - DBG(" PointerSpeed: %X\n", OFFSET_OF(SETTINGS_DATA, PointerSpeed)); - DBG(" PatchDsdtNum: %X\n", OFFSET_OF(SETTINGS_DATA, PatchDsdtNum)); - DBG(" LenToReplace: %X\n", OFFSET_OF(SETTINGS_DATA, LenToReplace)); - DBG(" ACPIDropTables: %X\n", OFFSET_OF(SETTINGS_DATA, ACPIDropTables)); - DBG(" CustomEntries: %X\n", OFFSET_OF(SETTINGS_DATA, CustomEntries)); - DBG(" CustomTool: %X\n", OFFSET_OF(SETTINGS_DATA, CustomTool)); - DBG(" AddProperties: %X\n", OFFSET_OF(SETTINGS_DATA, AddProperties)); - DBG(" BlockKexts: %X\n", OFFSET_OF(SETTINGS_DATA, BlockKexts)); + DBG(" SecureBootWhiteListCount: %X\n", OFFSET_OF(SETTINGS_DATA, + SecureBootWhiteListCount)); DBG(" LegacyBoot: %X\n", + OFFSET_OF(SETTINGS_DATA, LegacyBoot)); DBG(" HVHideStrings: %X\n", + OFFSET_OF(SETTINGS_DATA, HVHideStrings)); DBG(" PointerSpeed: %X\n", + OFFSET_OF(SETTINGS_DATA, PointerSpeed)); DBG(" RtMLB: %X\n", + OFFSET_OF(SETTINGS_DATA, RtMLB)); DBG(" ConfigName: %X\n", + OFFSET_OF(SETTINGS_DATA, ConfigName)); DBG(" PointerSpeed: %X\n", + OFFSET_OF(SETTINGS_DATA, PointerSpeed)); DBG(" PatchDsdtNum: %X\n", + OFFSET_OF(SETTINGS_DATA, PatchDsdtNum)); DBG(" LenToReplace: %X\n", + OFFSET_OF(SETTINGS_DATA, LenToReplace)); DBG(" ACPIDropTables: %X\n", + OFFSET_OF(SETTINGS_DATA, ACPIDropTables)); DBG(" CustomEntries: %X\n", + OFFSET_OF(SETTINGS_DATA, CustomEntries)); DBG(" CustomTool: %X\n", + OFFSET_OF(SETTINGS_DATA, CustomTool)); DBG(" AddProperties: %X\n", + OFFSET_OF(SETTINGS_DATA, AddProperties)); DBG(" BlockKexts: %X\n", + OFFSET_OF(SETTINGS_DATA, BlockKexts)); */ // disable EFI watchdog timer gBS->SetWatchdogTimer(0x0000, 0x0000, 0x0000, NULL); -// ZeroMem((void*)&gSettings, sizeof(SETTINGS_DATA)); + // ZeroMem((void*)&gSettings, sizeof(SETTINGS_DATA)); Status = InitializeUnicodeCollationProtocol(); if (EFI_ERROR(Status)) { DBG("UnicodeCollation Status=%s\n", efiStrError(Status)); } - -// Status = gBS->HandleProtocol(ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (void **)&SimpleTextEx); -// if ( EFI_ERROR(Status) ) { -// SimpleTextEx = NULL; -// } -// DBG("SimpleTextEx Status=%s\n", efiStrError(Status)); + + // Status = gBS->HandleProtocol(ConsoleInHandle, + // &gEfiSimpleTextInputExProtocolGuid, (void **)&SimpleTextEx); if ( + // EFI_ERROR(Status) ) { + // SimpleTextEx = NULL; + // } + // DBG("SimpleTextEx Status=%s\n", efiStrError(Status)); gConf.InitialisePlatform(); #ifdef JIEF_DEBUG - //DumpNvram(); + // DumpNvram(); #endif /* * saving debug.log works from here */ - { -// UINT32 machineSignature = 0; - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtPointer = NULL; - EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs = NULL; + // UINT32 machineSignature = 0; + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *FadtPointer = NULL; + EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs = NULL; -// DBG("---dump hibernations data---\n"); + // DBG("---dump hibernations data---\n"); FadtPointer = GetFadt(); if (FadtPointer != NULL) { - Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE*)(UINTN)(FadtPointer->FirmwareCtrl); + Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE + *)(UINTN)(FadtPointer->FirmwareCtrl); /* DBG(" Firmware wake address=%08lx\n", Facs->FirmwareWakingVector); DBG(" Firmware wake 64 addr=%16llx\n", Facs->XFirmwareWakingVector); @@ -3042,14 +3425,14 @@ RefitMainMain (IN EFI_HANDLE ImageHandle, machineSignature = Facs->HardwareSignature; } #if HIBERNATE_DUMP_DATA -//------------------------------------------------------ + //------------------------------------------------------ DumpVariable(L"Boot0082", gEfiGlobalVariableGuid, 8); DumpVariable(L"boot-switch-vars", gEfiAppleBootGuid, -1); - DumpVariable(L"boot-signature", gEfiAppleBootGuid, -1); - DumpVariable(L"boot-image-key", gEfiAppleBootGuid, -1); - DumpVariable(L"boot-image", gEfiAppleBootGuid, 0); -//----------------------------------------------------------- - + DumpVariable(L"boot-signature", gEfiAppleBootGuid, -1); + DumpVariable(L"boot-image-key", gEfiAppleBootGuid, -1); + DumpVariable(L"boot-image", gEfiAppleBootGuid, 0); + //----------------------------------------------------------- + #endif // } @@ -3057,7 +3440,7 @@ RefitMainMain (IN EFI_HANDLE ImageHandle, //testing place { //#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0])) - #define L_STR_LEN(String) (ARRAY_SIZE (String) - 1) +#define L_STR_LEN(String) (ARRAY_SIZE(String) - 1) DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); DBG(" size CHAR8=%ld\n", sizeof(CHAR8)); DBG(" size CHAR16=%ld\n", sizeof(CHAR16)); @@ -3105,14 +3488,14 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); if (!GlobalConfig.isFastBoot()) { GetListOfThemes(); GetListOfConfigs(); -// SmbiosList.setEmpty(); -// SmbiosList.AddReference(new XStringW(L"auto"_XSW), true); + // SmbiosList.setEmpty(); + // SmbiosList.AddReference(new XStringW(L"auto"_XSW), true); } -// ThemeX->FillByEmbedded(); //init XTheme before EarlyUserSettings + // ThemeX->FillByEmbedded(); //init XTheme before EarlyUserSettings { - void *Value = NULL; - UINTN Size = 0; - //read aptiofixflag from nvram for special boot + void *Value = NULL; + UINTN Size = 0; + // read aptiofixflag from nvram for special boot Status = GetVariable2(L"aptiofixflag", gEfiAppleBootGuid, &Value, &Size); if (!EFI_ERROR(Status)) { GlobalConfig.SpecialBootMode = true; @@ -3121,11 +3504,11 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); } } -// for (i=0; i<2; i++) { -// if (gConfigDict[i]) { -// GetEarlyUserSettings(gConfigDict[i], gSettings); -// } -// } + // for (i=0; i<2; i++) { + // if (gConfigDict[i]) { + // GetEarlyUserSettings(gConfigDict[i], gSettings); + // } + // } #ifdef ENABLE_SECURE_BOOT // Install secure boot shim @@ -3135,11 +3518,13 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); } #endif // ENABLE_SECURE_BOOT - MainMenu.TimeoutSeconds = gSettings.Boot.Timeout >= 0 ? gSettings.Boot.Timeout : 0; - //DBG("LoadDrivers() start\n"); + MainMenu.TimeoutSeconds = + gSettings.Boot.Timeout >= 0 ? gSettings.Boot.Timeout : 0; + // DBG("LoadDrivers() start\n"); LoadDrivers(); - - Status = gBS->LocateProtocol(gEmuVariableControlProtocolGuid, NULL, (void**)&gEmuVariableControl); + + Status = gBS->LocateProtocol(gEmuVariableControlProtocolGuid, NULL, + (void **)&gEmuVariableControl); if (EFI_ERROR(Status)) { gEmuVariableControl = NULL; } @@ -3156,17 +3541,17 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); } else { InitScreen(!gFirmwareClover); // ? false : true); } - //DBG("DBG: setup screen\n"); + // DBG("DBG: setup screen\n"); SetupScreen(); } else { InitScreen(false); } - //DBG("ReinitRefitLib\n"); - //Now we have to reinit handles + // DBG("ReinitRefitLib\n"); + // Now we have to reinit handles Status = ReinitRefitLib(); - if (EFI_ERROR(Status)){ - // DebugLog(2, " %s", efiStrError(Status)); + if (EFI_ERROR(Status)) { + // DebugLog(2, " %s", efiStrError(Status)); PauseForKey("Error reinit refit."_XS8); #ifdef ENABLE_SECURE_BOOT UninstallSecureBoot(); @@ -3177,53 +3562,59 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); ThemeX = new XTheme(); // DBG("DBG: messages\n"); - if (!gSettings.Boot.NoEarlyProgress && !GlobalConfig.isFastBoot() && gSettings.Boot.Timeout>0) { - XStringW Message = SWPrintf(" Welcome to Clover %ls ", gFirmwareRevision); - BootScreen.DrawTextXY(Message, (UGAWidth >> 1), UGAHeight >> 1, X_IS_CENTER); - BootScreen.DrawTextXY(L"... testing hardware ..."_XSW, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); + if (!gSettings.Boot.NoEarlyProgress && !GlobalConfig.isFastBoot() && + gSettings.Boot.Timeout > 0) { + XStringW Message = + SWPrintf(" Welcome to Clover %ls ", gFirmwareRevision); + BootScreen.DrawTextXY(Message, (UGAWidth >> 1), UGAHeight >> 1, + X_IS_CENTER); + BootScreen.DrawTextXY(L"... testing hardware ..."_XSW, (UGAWidth >> 1), + (UGAHeight >> 1) + 20, X_IS_CENTER); } -// DumpBiosMemoryMap(); + // DumpBiosMemoryMap(); -// PrintMemoryMap(); + // PrintMemoryMap(); GuiEventsInitialize(); - //DBG("ScanSPD() start\n"); + // DBG("ScanSPD() start\n"); ScanSPD(); - //DBG("ScanSPD() end\n"); + // DBG("ScanSPD() end\n"); SetPrivateVarProto(); -// GetDefaultSettings(); + // GetDefaultSettings(); GetAcpiTablesList(); - - if (!gSettings.Boot.NoEarlyProgress && !GlobalConfig.isFastBoot() && gSettings.Boot.Timeout>0) { + if (!gSettings.Boot.NoEarlyProgress && !GlobalConfig.isFastBoot() && + gSettings.Boot.Timeout > 0) { XStringW Message = SWPrintf("... user settings ..."); BootScreen.EraseTextXY(); - BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); + BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, + X_IS_CENTER); } - + afterGetUserSettings(gSettings); gFakeCPUID = gSettings.KernelAndKextPatches.FakeCPUID; DBG("Set FakeCPUID: 0x%X\n", gFakeCPUID); HaveDefaultVolume = gSettings.Boot.DefaultVolume.notEmpty(); - if (!gFirmwareClover && - !gDriversFlags.EmuVariableLoaded && - !HaveDefaultVolume && - gSettings.Boot.Timeout == 0 && !ReadAllKeyStrokes()) { -// UEFI boot: get gEfiBootDeviceGuid from NVRAM. -// if present, ScanVolumes() will skip scanning other volumes -// in the first run. -// this speeds up loading of default macOS volume. - GetEfiBootDeviceFromNvram(); - } - - if (!gSettings.Boot.NoEarlyProgress && !GlobalConfig.isFastBoot() && gSettings.Boot.Timeout>0) { + if (!gFirmwareClover && !gDriversFlags.EmuVariableLoaded && + !HaveDefaultVolume && gSettings.Boot.Timeout == 0 && + !ReadAllKeyStrokes()) { + // UEFI boot: get gEfiBootDeviceGuid from NVRAM. + // if present, ScanVolumes() will skip scanning other volumes + // in the first run. + // this speeds up loading of default macOS volume. + GetEfiBootDeviceFromNvram(); + } + + if (!gSettings.Boot.NoEarlyProgress && !GlobalConfig.isFastBoot() && + gSettings.Boot.Timeout > 0) { XStringW Message = SWPrintf("... scan entries ..."); BootScreen.EraseTextXY(); - BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, X_IS_CENTER); + BootScreen.DrawTextXY(Message, (UGAWidth >> 1), (UGAHeight >> 1) + 20, + X_IS_CENTER); } AfterTool = false; @@ -3232,9 +3623,10 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); GlobalConfig.gThemeChanged = true; do { - if (GlobalConfig.gBootChanged && GlobalConfig.gThemeChanged) { // config changed - GetListOfDsdts(); //only after GetUserSettings - GetListOfACPI(); //ssdt and other tables + if (GlobalConfig.gBootChanged && + GlobalConfig.gThemeChanged) { // config changed + GetListOfDsdts(); // only after GetUserSettings + GetListOfACPI(); // ssdt and other tables } GlobalConfig.gBootChanged = false; MainMenu.Entries.setEmpty(); @@ -3242,26 +3634,31 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); InitKextList(); ScanVolumes(); - // as soon as we have Volumes, find latest nvram.plist and copy it to RT vars + // as soon as we have Volumes, find latest nvram.plist and copy it to RT + // vars if (!AfterTool) { if (gFirmwareClover || gDriversFlags.EmuVariableLoaded) { PutNvramPlistToRtVars(); } } - + // log Audio devices in boot-log. This is for clients like Clover.app GetOutputs(); for (i = 0; i < AudioList.size(); i++) { if (AudioList[i].Name.notEmpty()) { - // Never change this log, otherwise clients will stop interpret the output. - MsgLog("Found Audio Device %ls (%s) at index %llu\n", AudioList[i].Name.wc_str(), AudioOutputNames[AudioList[i].Device], i); + // Never change this log, otherwise clients will stop interpret the + // output. + MsgLog("Found Audio Device %ls (%s) at index %llu\n", + AudioList[i].Name.wc_str(), + AudioOutputNames[AudioList[i].Device], i); } } - + if (!GlobalConfig.isFastBoot()) { if (gThemeNeedInit) { - UINTN Size = 0; - CHAR8* ChoosenTheme = (CHAR8*)GetNvramVariable(L"Clover.Theme", gEfiAppleBootGuid, NULL, &Size); + UINTN Size = 0; + CHAR8 *ChoosenTheme = (CHAR8 *)GetNvramVariable( + L"Clover.Theme", gEfiAppleBootGuid, NULL, &Size); InitTheme(ChoosenTheme); FreePool(ChoosenTheme); gThemeNeedInit = false; @@ -3278,17 +3675,18 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); DBG("Chosen theme %ls\n", ThemeX->Theme.wc_str()); } - //now it is a time to set RtVariables + // now it is a time to set RtVariables SetVariablesFromNvram(); - - XString8Array TmpArgs = Split<XString8Array>(gSettings.Boot.BootArgs, " "); + + XString8Array TmpArgs = + Split<XString8Array>(gSettings.Boot.BootArgs, " "); DBG("after NVRAM boot-args=%s\n", gSettings.Boot.BootArgs.c_str()); GlobalConfig.OptionsBits = EncodeOptions(TmpArgs); -// DBG("initial OptionsBits %X\n", GlobalConfig.OptionsBits); + // DBG("initial OptionsBits %X\n", GlobalConfig.OptionsBits); FillInputs(true); // scan for loaders and tools, add then to the menu - if (gSettings.GUI.Scan.LegacyFirst){ + if (gSettings.GUI.Scan.LegacyFirst) { AddCustomLegacy(); if (!gSettings.GUI.Scan.NoLegacy) { ScanLegacy(); @@ -3296,7 +3694,7 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); } } GetSmcKeys(true); - + // Add custom entries AddCustomEntries(); if (gSettings.GUI.Scan.DisableEntryScan) { @@ -3326,19 +3724,22 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); } MenuEntryOptions.Image = ThemeX->GetIcon(BUILTIN_ICON_FUNC_OPTIONS); -// DBG("Options: IconID=%lld name=%s empty=%s\n", MenuEntryOptions.Image.Id, MenuEntryOptions.Image.Name.c_str(), + // DBG("Options: IconID=%lld name=%s empty=%s\n", + // MenuEntryOptions.Image.Id, MenuEntryOptions.Image.Name.c_str(), if (gSettings.Boot.DisableCloverHotkeys) MenuEntryOptions.ShortcutLetter = 0x00; MainMenu.AddMenuEntry(&MenuEntryOptions, false); - + MenuEntryAbout.Image = ThemeX->GetIcon((INTN)BUILTIN_ICON_FUNC_ABOUT); -// DBG("About: IconID=%lld name=%s empty=%s\n", MenuEntryAbout.Image.Id, MenuEntryAbout.Image.Name.c_str(), + // DBG("About: IconID=%lld name=%s empty=%s\n", + // MenuEntryAbout.Image.Id, MenuEntryAbout.Image.Name.c_str(), if (gSettings.Boot.DisableCloverHotkeys) MenuEntryAbout.ShortcutLetter = 0x00; MainMenu.AddMenuEntry(&MenuEntryAbout, false); - if (!(ThemeX->HideUIFlags & HIDEUI_FLAG_FUNCS) || MainMenu.Entries.size() == 0) { + if (!(ThemeX->HideUIFlags & HIDEUI_FLAG_FUNCS) || + MainMenu.Entries.size() == 0) { if (gSettings.Boot.DisableCloverHotkeys) MenuEntryReset.ShortcutLetter = 0x00; MenuEntryReset.Image = ThemeX->GetIcon(BUILTIN_ICON_FUNC_RESET); @@ -3348,7 +3749,6 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); MenuEntryShutdown.Image = ThemeX->GetIcon(BUILTIN_ICON_FUNC_EXIT); MainMenu.AddMenuEntry(&MenuEntryShutdown, false); } - } // wait for user ACK when there were errors FinishTextScreen(false); @@ -3357,7 +3757,8 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); #endif DefaultIndex = FindDefaultEntry(); -// DBG("DefaultIndex=%lld and MainMenu.Entries.size()=%llu\n", DefaultIndex, MainMenu.Entries.size()); + // DBG("DefaultIndex=%lld and MainMenu.Entries.size()=%llu\n", + // DefaultIndex, MainMenu.Entries.size()); if ((DefaultIndex >= 0) && (DefaultIndex < (INTN)MainMenu.Entries.size())) { DefaultEntry = &MainMenu.Entries[DefaultIndex]; } else { @@ -3367,24 +3768,26 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); MainLoopRunning = true; if (DefaultEntry && (GlobalConfig.isFastBoot() || (gSettings.Boot.SkipHibernateTimeout && - DefaultEntry->getLOADER_ENTRY() - && OSFLAG_ISSET(DefaultEntry->getLOADER_ENTRY()->Flags, OSFLAG_HIBERNATED)))) { + DefaultEntry->getLOADER_ENTRY() && + OSFLAG_ISSET(DefaultEntry->getLOADER_ENTRY()->Flags, + OSFLAG_HIBERNATED)))) { if (DefaultEntry->getLOADER_ENTRY()) { DefaultEntry->StartLoader(); - } else if (DefaultEntry->getLEGACY_ENTRY()){ + } else if (DefaultEntry->getLEGACY_ENTRY()) { DefaultEntry->StartLegacy(); } - gSettings.Boot.FastBoot = false; //Hmm... will never be here + gSettings.Boot.FastBoot = false; // Hmm... will never be here } #ifdef JIEF_DEBUG -//MainMenu.TimeoutSeconds=1; -//DefaultEntry = NULL; -//DefaultIndex = MainMenu.Entries.length()-1; // this should be "Exit Clover" +// MainMenu.TimeoutSeconds=1; +// DefaultEntry = NULL; +// DefaultIndex = MainMenu.Entries.length()-1; // this should be "Exit Clover" #endif AfterTool = false; - gEvent = 0; //clear to cancel loop + gEvent = 0; // clear to cancel loop while (MainLoopRunning) { - if (gSettings.Boot.Timeout == 0 && DefaultEntry != NULL && !ReadAllKeyStrokes()) { + if (gSettings.Boot.Timeout == 0 && DefaultEntry != NULL && + !ReadAllKeyStrokes()) { // go strait to DefaultVolume loading MenuExit = MENU_EXIT_TIMEOUT; } else { @@ -3394,24 +3797,26 @@ DBG("strlen '<' =%ld or %lld\n", L_STR_LEN("<"), AsciiStrLen("<")); ThemeX->ClearScreen(); } #ifdef JIEF_DEBUG -displayFreeMemory("Before RunMainMenu"_XS8); + displayFreeMemory("Before RunMainMenu"_XS8); #endif MenuExit = MainMenu.RunMainMenu(DefaultIndex, &ChosenEntry); } -// DBG("exit from MainMenu %llu ChosenEntry=%zu\n", MenuExit, MainMenu.Entries.indexOf(*ChosenEntry)); //MENU_EXIT_ENTER=(1) MENU_EXIT_DETAILS=3 + // DBG("exit from MainMenu %llu ChosenEntry=%zu\n", MenuExit, + // MainMenu.Entries.indexOf(*ChosenEntry)); //MENU_EXIT_ENTER=(1) + // MENU_EXIT_DETAILS=3 // disable default boot - have sense only in the first run gSettings.Boot.Timeout = -1; if ((DefaultEntry != NULL) && (MenuExit == MENU_EXIT_TIMEOUT)) { if (DefaultEntry->getLOADER_ENTRY()) { DefaultEntry->StartLoader(); - } else if (DefaultEntry->getLEGACY_ENTRY()){ + } else if (DefaultEntry->getLEGACY_ENTRY()) { DefaultEntry->StartLegacy(); } // if something goes wrong - break main loop to reinit volumes break; } - if (MenuExit == MENU_EXIT_OPTIONS){ + if (MenuExit == MENU_EXIT_OPTIONS) { GlobalConfig.gBootChanged = false; OptionsMenu(&OptionEntry); if (GlobalConfig.gBootChanged) { @@ -3422,52 +3827,52 @@ displayFreeMemory("Before RunMainMenu"_XS8); continue; } - if (MenuExit == MENU_EXIT_HELP){ + if (MenuExit == MENU_EXIT_HELP) { HelpRefit(); continue; } // EjectVolume - if (MenuExit == MENU_EXIT_EJECT){ + if (MenuExit == MENU_EXIT_EJECT) { Status = EFI_SUCCESS; - if (ChosenEntry->getLOADER_ENTRY() ) { + if (ChosenEntry->getLOADER_ENTRY()) { Status = EjectVolume(ChosenEntry->getLOADER_ENTRY()->Volume); } - if ( ChosenEntry->getLEGACY_ENTRY() ) { + if (ChosenEntry->getLEGACY_ENTRY()) { Status = EjectVolume(ChosenEntry->getLEGACY_ENTRY()->Volume); } if (!EFI_ERROR(Status)) { - break; //main loop is broken so Reinit all + break; // main loop is broken so Reinit all } continue; } // Hide toggle if (MenuExit == MENU_EXIT_HIDE_TOGGLE) { - MainMenu.Entries.includeHidden = !MainMenu.Entries.includeHidden; - continue; + MainMenu.Entries.includeHidden = !MainMenu.Entries.includeHidden; + continue; } // We don't allow exiting the main menu with the Escape key. - if (MenuExit == MENU_EXIT_ESCAPE){ - break; //refresh main menu + if (MenuExit == MENU_EXIT_ESCAPE) { + break; // refresh main menu // continue; } - if ( ChosenEntry->getREFIT_MENU_ITEM_RESET() ) { // Restart + if (ChosenEntry->getREFIT_MENU_ITEM_RESET()) { // Restart if (MenuExit == MENU_EXIT_DETAILS) { - //do clear cmos as for AMI BIOS - // not sure for more robust method - IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, 0x10); - IoWrite8 (PCAT_RTC_DATA_REGISTER, 0x0); - IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, 0x11); - IoWrite8 (PCAT_RTC_DATA_REGISTER, 0x0); -// or may be -// IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, 0x17); -// IoWrite8 (PCAT_RTC_DATA_REGISTER, 0x17); - -// } + // do clear cmos as for AMI BIOS + // not sure for more robust method + IoWrite8(PCAT_RTC_ADDRESS_REGISTER, 0x10); + IoWrite8(PCAT_RTC_DATA_REGISTER, 0x0); + IoWrite8(PCAT_RTC_ADDRESS_REGISTER, 0x11); + IoWrite8(PCAT_RTC_DATA_REGISTER, 0x0); + // or may be + // IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, 0x17); + // IoWrite8 (PCAT_RTC_DATA_REGISTER, 0x17); + + // } } // Attempt warm reboot gRT->ResetSystem(EfiResetWarm, EFI_SUCCESS, 0, NULL); @@ -3480,45 +3885,53 @@ displayFreeMemory("Before RunMainMenu"_XS8); AfterTool = true; } - if ( ChosenEntry->getREFIT_MENU_ITEM_SHUTDOWN() ) { // It is not Shut Down, it is Exit from Clover + if (ChosenEntry + ->getREFIT_MENU_ITEM_SHUTDOWN()) { // It is not Shut Down, it is + // Exit from Clover TerminateScreen(); // gRT->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL); - MainLoopRunning = false; // just in case we get this far + MainLoopRunning = false; // just in case we get this far ReinitDesktop = false; AfterTool = true; } - if ( ChosenEntry->getREFIT_MENU_ITEM_OPTIONS() ) { // Options like KernelFlags, DSDTname etc. + if (ChosenEntry + ->getREFIT_MENU_ITEM_OPTIONS()) { // Options like KernelFlags, + // DSDTname etc. GlobalConfig.gBootChanged = false; OptionsMenu(&OptionEntry); if (GlobalConfig.gBootChanged) AfterTool = true; - if (GlobalConfig.gBootChanged || GlobalConfig.gThemeChanged) // If theme has changed reinit the desktop + if (GlobalConfig.gBootChanged || + GlobalConfig + .gThemeChanged) // If theme has changed reinit the desktop MainLoopRunning = false; } - if ( ChosenEntry->getREFIT_MENU_ITEM_ABOUT() ) { // About rEFIt + if (ChosenEntry->getREFIT_MENU_ITEM_ABOUT()) { // About rEFIt AboutRefit(); } - /* -- not passed here -// case TAG_HELP: - HelpRefit(); - break; - */ - if ( ChosenEntry->getLOADER_ENTRY() ) { // Boot OS via .EFI loader + /* -- not passed here + // case TAG_HELP: + HelpRefit(); + break; + */ + if (ChosenEntry->getLOADER_ENTRY()) { // Boot OS via .EFI loader SetBootCurrent(ChosenEntry->getLOADER_ENTRY()); ChosenEntry->StartLoader(); - //if boot.efi failed we should somehow exit from the loop + // if boot.efi failed we should somehow exit from the loop TerminateScreen(); MainLoopRunning = false; ReinitDesktop = false; AfterTool = true; } - if ( ChosenEntry->getLEGACY_ENTRY() ) { // Boot legacy OS + if (ChosenEntry->getLEGACY_ENTRY()) { // Boot legacy OS if (StrCmp(gST->FirmwareVendor, L"Phoenix Technologies Ltd.") == 0 && - gST->Hdr.Revision >> 16 == 2 && (gST->Hdr.Revision & ((1 << 16) - 1)) == 0){ - // Phoenix SecureCore Tiano 2.0 can't properly initiate LegacyBios protocol when called externally - // which results in "Operating System not found" message coming from BIOS - // in this case just quit Clover to enter BIOS again + gST->Hdr.Revision >> 16 == 2 && + (gST->Hdr.Revision & ((1 << 16) - 1)) == 0) { + // Phoenix SecureCore Tiano 2.0 can't properly initiate LegacyBios + // protocol when called externally which results in "Operating System + // not found" message coming from BIOS in this case just quit Clover + // to enter BIOS again TerminateScreen(); MainLoopRunning = false; ReinitDesktop = false; @@ -3528,45 +3941,51 @@ displayFreeMemory("Before RunMainMenu"_XS8); ChosenEntry->StartLegacy(); } } - if ( ChosenEntry->getREFIT_MENU_ENTRY_LOADER_TOOL() ) { // Start a EFI tool + if (ChosenEntry->getREFIT_MENU_ENTRY_LOADER_TOOL()) { // Start a EFI tool ChosenEntry->StartTool(); - TerminateScreen(); //does not happen + TerminateScreen(); // does not happen // return EFI_SUCCESS; // BdsLibConnectAllDriversToAllControllers(); // PauseForKey(L"Returned from StartTool\n"); MainLoopRunning = false; AfterTool = true; } - #ifdef ENABLE_SECURE_BOOT -//log_technical_bug("not done yet"); -// if ( ChosenEntry->getREFIT_MENU_ENTRY_SECURE_BOOT() ) { // Try to enable secure boot -// EnableSecureBoot(); -// MainLoopRunning = false; -// AfterTool = true; -// } -// -// if ( ChosenEntry->getREFIT_MENU_ENTRY_SECURE_BOOT_CONFIG() ) { // Configure secure boot -// MainLoopRunning = !ConfigureSecureBoot(); -// AfterTool = true; -// } - #endif // ENABLE_SECURE_BOOT -// DBG("come to Clover entry with letter %c\n", ChosenEntry->ShortcutLetter); - REFIT_MENU_ENTRY_CLOVER* LoaderEntry = ChosenEntry->getREFIT_MENU_ENTRY_CLOVER(); - if ((ChosenEntry->ShortcutLetter == L'C') || LoaderEntry != NULL ) { // Clover options -// DBG("enter Clover entry\n"); +#ifdef ENABLE_SECURE_BOOT + // log_technical_bug("not done yet"); + // if ( ChosenEntry->getREFIT_MENU_ENTRY_SECURE_BOOT() ) { // Try to + // enable secure boot + // EnableSecureBoot(); + // MainLoopRunning = false; + // AfterTool = true; + // } + // + // if ( ChosenEntry->getREFIT_MENU_ENTRY_SECURE_BOOT_CONFIG() ) { // + // Configure secure boot + // MainLoopRunning = !ConfigureSecureBoot(); + // AfterTool = true; + // } +#endif // ENABLE_SECURE_BOOT + // DBG("come to Clover entry with letter %c\n", + // ChosenEntry->ShortcutLetter); + REFIT_MENU_ENTRY_CLOVER *LoaderEntry = + ChosenEntry->getREFIT_MENU_ENTRY_CLOVER(); + if ((ChosenEntry->ShortcutLetter == L'C') || + LoaderEntry != NULL) { // Clover options + // DBG("enter Clover entry\n"); if (LoaderEntry->LoadOptions.notEmpty()) { - // we are uninstalling in case user selected Clover Options and EmuVar is installed - // because adding bios boot option requires access to real nvram - //Slice: sure? - /* if (gEmuVariableControl != NULL) { - gEmuVariableControl->UninstallEmulation(gEmuVariableControl); - } - */ - // DBG(" Clover entry not empty\n"); - if ( LoaderEntry->LoadOptions.contains(L"BO-ADD") ) { - // DBG(" BO-ADD"); + // we are uninstalling in case user selected Clover Options and EmuVar + // is installed because adding bios boot option requires access to + // real nvram + // Slice: sure? + /* if (gEmuVariableControl != NULL) { + gEmuVariableControl->UninstallEmulation(gEmuVariableControl); + } + */ + // DBG(" Clover entry not empty\n"); + if (LoaderEntry->LoadOptions.contains(L"BO-ADD")) { + // DBG(" BO-ADD"); XStringW Description; CONST CHAR16 *LoaderName; INTN EntryIndex, NameSize, Name2Size; @@ -3574,11 +3993,12 @@ displayFreeMemory("Before RunMainMenu"_XS8); UINT8 *OptionalData; UINTN OptionalDataSize; UINTN BootNum; - // EFI_HANDLE UsedHandle = 0; + // EFI_HANDLE UsedHandle = 0; PrintBootOptions(false); - for (EntryIndex = 0; EntryIndex < (INTN)MainMenu.Entries.size(); EntryIndex++) { + for (EntryIndex = 0; EntryIndex < (INTN)MainMenu.Entries.size(); + EntryIndex++) { if (MainMenu.Entries[EntryIndex].Row != 0) { continue; } @@ -3586,8 +4006,9 @@ displayFreeMemory("Before RunMainMenu"_XS8); continue; } - Entry = (LOADER_ENTRY *)MainMenu.Entries[EntryIndex].getLOADER_ENTRY(); - XStringW& VolName = Entry->Volume->VolName; + Entry = (LOADER_ENTRY *)MainMenu.Entries[EntryIndex] + .getLOADER_ENTRY(); + XStringW &VolName = Entry->Volume->VolName; DBG("add entry for volume %ls\n", VolName.wc_str()); if (VolName.isEmpty()) { VolName = NullXStringW; @@ -3597,68 +4018,62 @@ displayFreeMemory("Before RunMainMenu"_XS8); if (Entry->LoaderPath.notEmpty()) { LoaderName = Basename(Entry->LoaderPath.wc_str()); } else { - LoaderName = NULL; //legacy boot + LoaderName = NULL; // legacy boot } if (LoaderName != NULL) { Name2Size = StrSize(LoaderName); } Description = SWPrintf("Clover UEFI"); - OptionalDataSize = NameSize + Name2Size + 4 + 2; //signature + VolNameSize - OptionalData = (__typeof__(OptionalData))AllocateZeroPool(OptionalDataSize); + OptionalDataSize = + NameSize + Name2Size + 4 + 2; // signature + VolNameSize + OptionalData = + (__typeof__(OptionalData))AllocateZeroPool(OptionalDataSize); if (OptionalData == NULL) { break; } - CopyMem(OptionalData, "Clvr", 4); //signature = 0x72766c43 + CopyMem(OptionalData, "Clvr", 4); // signature = 0x72766c43 CopyMem(OptionalData + 4, &NameSize, 2); - CopyMem(OptionalData + 6, (void*)VolName.wc_str(), VolName.sizeInBytes()); + CopyMem(OptionalData + 6, (void *)VolName.wc_str(), + VolName.sizeInBytes()); if (Name2Size != 0) { CopyMem(OptionalData + 6 + NameSize, LoaderName, Name2Size); } -// UsedHandle = LoaderEntry->Volume->DeviceHandle; - Status = AddBootOptionForFile ( - LoaderEntry->Volume->DeviceHandle, - LoaderEntry->LoaderPath, - true, - Description.wc_str(), - OptionalData, - OptionalDataSize, - 0, //EntryIndex, - (UINT16*)&BootNum - ); + // UsedHandle = LoaderEntry->Volume->DeviceHandle; + Status = AddBootOptionForFile( + LoaderEntry->Volume->DeviceHandle, LoaderEntry->LoaderPath, + true, Description.wc_str(), OptionalData, OptionalDataSize, + 0, // EntryIndex, + (UINT16 *)&BootNum); if (!EFI_ERROR(Status)) { DBG("Entry %lld assigned option %04llX\n", EntryIndex, BootNum); Entry->BootNum = BootNum; } FreePool(OptionalData); break; - } //for (EntryIndex - + } // for (EntryIndex PrintBootOptions(false); - } else if ( LoaderEntry->LoadOptions.contains(L"BO-REMOVE") ) { + } else if (LoaderEntry->LoadOptions.contains(L"BO-REMOVE")) { PrintBootOptions(false); - Status = DeleteBootOptionForFile (LoaderEntry->Volume->DeviceHandle, - LoaderEntry->LoaderPath - ); + Status = DeleteBootOptionForFile(LoaderEntry->Volume->DeviceHandle, + LoaderEntry->LoaderPath); PrintBootOptions(false); - } else if ( LoaderEntry->LoadOptions.contains(L"BO-PRINT") ) { + } else if (LoaderEntry->LoadOptions.contains(L"BO-PRINT")) { PrintBootOptions(true); } - } MainLoopRunning = false; AfterTool = true; } - } //MainLoopRunning + } // MainLoopRunning UninitRefitLib(); if (!AfterTool) { // PauseForKey(L"After uninit"); - //reconnectAll + // reconnectAll if (!gFirmwareClover) { BdsLibConnectAllEfi(); - } - else { + } else { DBG("ConnectAll after refresh menu\n"); BdsLibConnectAllDriversToAllControllers(); } @@ -3674,7 +4089,7 @@ displayFreeMemory("Before RunMainMenu"_XS8); // If we end up here, things have gone wrong. Try to reboot, and if that // fails, go into an endless loop. - //Slice - NO!!! Return to EFI GUI + // Slice - NO!!! Return to EFI GUI // gRT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); // EndlessIdleLoop(); @@ -3682,15 +4097,16 @@ displayFreeMemory("Before RunMainMenu"_XS8); UninstallSecureBoot(); #endif // ENABLE_SECURE_BOOT - // Unload EmuVariable before returning to EFI GUI, as it should not be present when booting other Operating Systems. - // This seems critical in some UEFI implementations, such as Phoenix UEFI 2.0 + // Unload EmuVariable before returning to EFI GUI, as it should not be present + // when booting other Operating Systems. This seems critical in some UEFI + // implementations, such as Phoenix UEFI 2.0 if (gEmuVariableControl != NULL) { gEmuVariableControl->UninstallEmulation(gEmuVariableControl); } - UninitializeConsoleSim (); + UninitializeConsoleSim(); - delete ThemeX; // do this before destruct_globals_objects() + delete ThemeX; // do this before destruct_globals_objects() FreePool(BlankLine); // Convert BlankLine to XStringW instead. TagStruct::EmptyCache(); @@ -3706,11 +4122,10 @@ displayFreeMemory("Before RunMainMenu"_XS8); // EFI_STATUS EFIAPI -RefitMain (IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable) -{ +RefitMain(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) { MemoryTrackerInit(); - //MemoryTrackerInstallHook(); can't install hook before construct_globals_objects()... yet + // MemoryTrackerInstallHook(); can't install hook before + // construct_globals_objects()... yet EFI_STATUS Status = RefitMainMain(ImageHandle, SystemTable); @@ -3724,4 +4139,3 @@ RefitMain (IN EFI_HANDLE ImageHandle, return Status; } -