2020-04-04 14:27:02 +02:00
# ifndef __SETTINGS_H__
# define __SETTINGS_H__
2021-02-06 18:16:46 +01:00
# include <Efi.h>
2020-04-16 11:09:22 +02:00
# include "../gui/menu_items/menu_items.h"
2021-03-22 13:40:01 +01:00
# include "../include/OSFlags.h"
# include "../include/OSTypes.h"
2021-03-23 20:59:30 +01:00
# include "../include/Languages.h"
2020-08-25 17:35:19 +02:00
# include "../Platform/plist/plist.h"
2020-11-18 22:49:02 +01:00
# include "../Platform/guid.h"
2020-11-12 22:25:56 +01:00
# include "MacOsVersion.h"
2021-02-06 18:16:46 +01:00
# include "KERNEL_AND_KEXT_PATCHES.h"
# include "../libeg/XIcon.h"
2021-03-19 16:35:01 +01:00
# include "../cpp_lib/undefinable.h"
2021-03-20 15:29:34 +01:00
# include "../entry_scan/loader.h" // for KERNEL_SCAN_xxx constants
2021-03-27 19:53:30 +01:00
2021-02-06 18:16:46 +01:00
# define CLOVER_SIGN SIGNATURE_32('C','l','v','r')
2020-04-16 09:48:13 +02:00
//// SysVariables
//typedef struct SYSVARIABLES SYSVARIABLES;
//struct SYSVARIABLES
//{
// SYSVARIABLES *Next;
// CHAR16 *Key;
// INPUT_ITEM MenuItem;
//};
2021-02-06 18:16:46 +01:00
extern CONST CHAR8 * AudioOutputNames [ ] ;
2020-08-31 09:07:36 +02:00
class HDA_OUTPUTS
{
public :
XStringW Name ;
2020-04-16 09:15:26 +02:00
// CHAR8 *LineName;
2020-08-31 09:07:36 +02:00
UINT8 Index ;
2021-02-06 18:16:46 +01:00
EFI_HANDLE Handle = NULL ;
EFI_AUDIO_IO_PROTOCOL_DEVICE Device = EfiAudioIoDeviceOther ;
2020-08-31 09:07:36 +02:00
2021-02-06 18:16:46 +01:00
HDA_OUTPUTS ( ) : Name ( ) , Index ( 0 ) { }
2020-08-31 09:07:36 +02:00
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 ( ) { }
} ;
2020-04-16 09:15:26 +02:00
typedef enum {
Unknown ,
Ati , /* 0x1002 */
Intel , /* 0x8086 */
Nvidia , /* 0x10de */
RDC , /* 0x17f3 */
VIA , /* 0x1106 */
SiS , /* 0x1039 */
ULI /* 0x10b9 */
} HRDW_MANUFACTERER ;
typedef struct {
HRDW_MANUFACTERER Vendor ;
UINT8 Ports ;
UINT16 DeviceID ;
UINT16 Family ;
//UINT16 Width;
//UINT16 Height;
CHAR8 Model [ 64 ] ;
CHAR8 Config [ 64 ] ;
BOOLEAN LoadVBios ;
//BOOLEAN PatchVBios;
UINTN Segment ;
UINTN Bus ;
UINTN Device ;
UINTN Function ;
EFI_HANDLE Handle ;
UINT8 * Mmio ;
UINT32 Connectors ;
BOOLEAN 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 ;
} HDA_PROPERTIES ;
typedef struct ACPI_NAME_LIST ACPI_NAME_LIST ;
struct ACPI_NAME_LIST {
ACPI_NAME_LIST * Next ;
CHAR8 * Name ;
} ;
2020-08-09 17:55:30 +02:00
class ACPI_DROP_TABLE
2020-04-16 09:15:26 +02:00
{
2020-08-09 17:55:30 +02:00
public :
2020-04-16 09:15:26 +02:00
ACPI_DROP_TABLE * Next ;
UINT32 Signature ;
UINT32 Length ;
UINT64 TableId ;
2021-02-06 18:16:46 +01:00
INPUT_ITEM MenuItem = INPUT_ITEM ( ) ;
2020-04-20 18:33:42 +02:00
BOOLEAN OtherOS ;
2020-08-09 17:55:30 +02:00
2021-02-06 18:16:46 +01:00
ACPI_DROP_TABLE ( ) : Next ( 0 ) , Signature ( 0 ) , Length ( 0 ) , TableId ( 0 ) , OtherOS ( 0 ) { }
2020-08-09 17:55:30 +02:00
ACPI_DROP_TABLE ( const ACPI_DROP_TABLE & other ) = delete ; // Can be defined if needed
const ACPI_DROP_TABLE & operator = ( const ACPI_DROP_TABLE & ) = delete ; // Can be defined if needed
~ ACPI_DROP_TABLE ( ) { }
2020-04-16 09:15:26 +02:00
} ;
2021-03-23 09:32:57 +01:00
class CUSTOM_LOADER_SUBENTRY_SETTINGS ;
class CUSTOM_LOADER_SUBENTRY ;
2021-03-27 19:53:30 +01:00
//class ConfigPlistClass;
//class ConfigPlistClass::GUI_Custom_Entry_Class;
//template<class C> class XmlArray;
2021-03-22 13:40:01 +01:00
2021-03-27 19:53:30 +01:00
//void CompareCustomSubEntries(const XString8& label, const XObjArray<CUSTOM_LOADER_SUBENTRY_SETTINGS>& olDCustomEntries, const XmlArray<GUI_Custom_SubEntry_Class>& newCustomEntries);
//BOOLEAN FillinCustomSubEntry(UINT8 parentType, IN OUT CUSTOM_LOADER_SUBENTRY_SETTINGS *Entry, const TagDict* DictPointer, IN BOOLEAN SubEntry);
2021-03-22 13:40:01 +01:00
class CUSTOM_LOADER_SUBENTRY_SETTINGS
2020-08-15 22:39:25 +02:00
{
public :
2021-03-20 15:29:34 +01:00
bool Disabled = 0 ;
2021-03-27 19:53:30 +01:00
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 ( ) ;
2021-03-22 13:40:01 +01:00
2021-03-27 19:53:30 +01:00
undefinable_XString8 _FullTitle = undefinable_XString8 ( ) ;
undefinable_XString8 _Title = undefinable_XString8 ( ) ;
2021-03-22 13:40:01 +01:00
2021-03-27 19:53:30 +01:00
undefinable_bool _NoCaches = undefinable_bool ( ) ;
2021-03-23 09:32:57 +01:00
2021-03-22 13:40:01 +01:00
public :
2021-03-27 19:53:30 +01:00
// friend void ::CompareCustomSubEntries(const XString8& label, const XObjArray<CUSTOM_LOADER_SUBENTRY_SETTINGS>& olDCustomEntries, const XmlArray<GUI_Custom_SubEntry_Class>& newCustomEntries);
// friend BOOLEAN FillinCustomSubEntry(UINT8 parentType, IN OUT CUSTOM_LOADER_SUBENTRY_SETTINGS *Entry, const TagDict* DictPointer, IN BOOLEAN SubEntry);
// friend class ::CUSTOM_LOADER_SUBENTRY;
2021-03-22 13:40:01 +01:00
} ;
class CUSTOM_LOADER_ENTRY ;
class CUSTOM_LOADER_SUBENTRY
{
public :
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 ) { }
XString8Array getLoadOptions ( ) const ;
UINT8 getFlags ( bool NoCachesDefault ) const ;
const XString8 & getTitle ( ) const ;
const XString8 & getFullTitle ( ) const ;
} ;
2021-03-27 19:53:30 +01:00
//class GUI_Custom_Entry_Class;
2021-03-23 09:32:57 +01:00
class CUSTOM_LOADER_ENTRY_SETTINGS ;
2021-03-27 19:53:30 +01:00
//
//void CompareCustomEntries(const XString8& label, const XObjArray<CUSTOM_LOADER_ENTRY_SETTINGS>& olDCustomEntries, const XmlArray<GUI_Custom_Entry_Class>& newCustomEntries);
//BOOLEAN FillinCustomEntry(IN OUT CUSTOM_LOADER_ENTRY_SETTINGS *Entry, const TagDict* DictPointer, IN BOOLEAN SubEntry);
2021-03-23 09:32:57 +01:00
extern const XString8 defaultInstallTitle ;
extern const XString8 defaultRecoveryTitle ;
extern const XStringW defaultRecoveryImagePath ;
extern const XStringW defaultRecoveryDriveImagePath ;
2021-03-22 13:40:01 +01:00
class CUSTOM_LOADER_ENTRY_SETTINGS
{
public :
bool Disabled = 0 ;
XBuffer < UINT8 > ImageData = XBuffer < UINT8 > ( ) ;
XBuffer < UINT8 > DriveImageData = XBuffer < UINT8 > ( ) ;
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
2021-03-19 21:32:42 +01:00
CHAR16 Hotkey = 0 ;
BOOLEAN CommonSettings = 0 ;
2021-03-22 13:40:01 +01:00
// UINT8 Flags = 0;
2021-03-19 21:32:42 +01:00
bool Hidden = 0 ;
2021-03-22 13:40:01 +01:00
bool AlwaysHidden = 0 ;
2021-03-19 21:32:42 +01:00
UINT8 Type = 0 ;
UINT8 VolumeType = 0 ;
2021-03-20 15:29:34 +01:00
UINT8 KernelScan = KERNEL_SCAN_ALL ;
XString8 CustomLogoAsXString8 = XString8 ( ) ;
XBuffer < UINT8 > CustomLogoAsData = XBuffer < UINT8 > ( ) ;
2021-02-06 18:16:46 +01:00
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor = EFI_GRAPHICS_OUTPUT_BLT_PIXEL ( { 0 , 0 , 0 , 0 } ) ;
2021-03-20 15:29:34 +01:00
INT8 InjectKexts = - 1 ;
2021-03-22 13:40:01 +01:00
undefinable_bool NoCaches = undefinable_bool ( ) ;
2021-03-27 19:53:30 +01:00
XObjArray < CUSTOM_LOADER_SUBENTRY_SETTINGS > SubEntriesSettings = XObjArray < CUSTOM_LOADER_SUBENTRY_SETTINGS > ( ) ;
public : // temporary, must be protected:
XStringW m_DriveImagePath = XStringW ( ) ;
XString8 m_Title = XStringW ( ) ;
UINT8 CustomLogoTypeSettings = 0 ;
XStringW m_ImagePath = XStringW ( ) ;
2021-03-22 13:40:01 +01:00
2021-03-27 19:53:30 +01:00
public :
2021-03-23 09:32:57 +01:00
friend class : : CUSTOM_LOADER_ENTRY ;
2021-03-27 19:53:30 +01:00
// friend void ::CompareCustomEntries(const XString8& label, const XObjArray<CUSTOM_LOADER_ENTRY_SETTINGS>& olDCustomEntries, const XmlArray<GUI_Custom_Entry_Class>& newCustomEntries);
2021-03-23 09:32:57 +01:00
friend BOOLEAN FillinCustomEntry ( IN OUT CUSTOM_LOADER_ENTRY_SETTINGS * Entry , const TagDict * DictPointer , IN BOOLEAN SubEntry ) ;
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 ) ) {
return defaultInstallTitle ;
}
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 ;
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 ;
return NullXStringW ;
}
2020-04-16 09:15:26 +02:00
} ;
2021-03-22 13:40:01 +01:00
class CUSTOM_LOADER_ENTRY
{
public :
const CUSTOM_LOADER_ENTRY_SETTINGS & settings = CUSTOM_LOADER_ENTRY_SETTINGS ( ) ;
XObjArray < CUSTOM_LOADER_SUBENTRY > SubEntries = XObjArray < CUSTOM_LOADER_SUBENTRY > ( ) ;
2021-03-23 09:32:57 +01:00
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 ) ;
2021-03-22 13:40:01 +01:00
XString8Array getLoadOptions ( ) const ;
2021-03-23 09:32:57 +01:00
2021-03-22 13:40:01 +01:00
UINT8 getFlags ( bool 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 ) ) {
Flags = OSFLAG_UNSET ( Flags , OSFLAG_NOCACHES ) ;
}
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 ) ;
return Flags ;
}
} ;
2021-03-23 20:59:30 +01:00
class CUSTOM_LEGACY_ENTRY_SETTINGS
2020-08-09 17:55:30 +02:00
{
public :
2021-03-23 20:59:30 +01:00
bool Disabled = 0 ;
2021-03-19 21:32:42 +01:00
XStringW ImagePath = XStringW ( ) ;
2021-03-23 20:59:30 +01:00
XBuffer < UINT8 > ImageData = XBuffer < UINT8 > ( ) ;
2021-03-19 21:32:42 +01:00
XStringW DriveImagePath = XStringW ( ) ;
2021-03-23 20:59:30 +01:00
XBuffer < UINT8 > DriveImageData = XBuffer < UINT8 > ( ) ;
2021-03-19 21:32:42 +01:00
XStringW Volume = XStringW ( ) ;
XStringW FullTitle = XStringW ( ) ;
XStringW Title = XStringW ( ) ;
CHAR16 Hotkey = 0 ;
2021-03-23 20:59:30 +01:00
// UINT8 Flags = 0;
2021-03-19 21:32:42 +01:00
bool Hidden = 0 ;
2021-03-23 20:59:30 +01:00
bool AlwaysHidden = 0 ;
2021-03-19 21:32:42 +01:00
UINT8 Type = 0 ;
UINT8 VolumeType = 0 ;
2021-03-23 20:59:30 +01:00
} ;
2021-03-19 21:32:42 +01:00
2021-03-23 20:59:30 +01:00
class CUSTOM_LEGACY_ENTRY
{
public :
const CUSTOM_LEGACY_ENTRY_SETTINGS & settings = CUSTOM_LEGACY_ENTRY_SETTINGS ( ) ;
XIcon Image = XIcon ( ) ;
XIcon DriveImage = XIcon ( ) ;
2021-03-23 22:23:44 +01:00
CUSTOM_LEGACY_ENTRY ( const CUSTOM_LEGACY_ENTRY_SETTINGS & _settings , const EFI_FILE & ThemeDir ) : settings ( _settings )
2021-03-23 20:59:30 +01:00
{
if ( settings . ImagePath . notEmpty ( ) ) {
Image . LoadXImage ( & ThemeDir , settings . ImagePath ) ;
} else if ( settings . ImageData . notEmpty ( ) ) {
if ( ! EFI_ERROR ( Image . Image . FromPNG ( settings . ImageData . data ( ) , settings . ImageData . size ( ) ) ) ) {
Image . setFilled ( ) ;
}
}
if ( settings . DriveImagePath . notEmpty ( ) ) {
DriveImage . LoadXImage ( & ThemeDir , settings . DriveImagePath ) ;
} else if ( settings . DriveImageData . notEmpty ( ) ) {
if ( ! EFI_ERROR ( DriveImage . Image . FromPNG ( settings . DriveImageData . data ( ) , settings . DriveImageData . size ( ) ) ) ) {
DriveImage . setFilled ( ) ;
}
}
}
UINT8 getFlags ( ) const {
UINT8 Flags = 0 ;
if ( settings . Disabled | | settings . AlwaysHidden ) Flags = OSFLAG_SET ( Flags , OSFLAG_DISABLED ) ;
return Flags ;
}
2020-04-16 09:15:26 +02:00
} ;
2021-03-23 20:59:30 +01:00
class CUSTOM_TOOL_ENTRY_SETTINGS
2020-08-09 17:55:30 +02:00
{
public :
2021-03-23 20:59:30 +01:00
bool Disabled = 0 ;
2021-03-19 21:32:42 +01:00
XStringW ImagePath = XStringW ( ) ;
2021-03-23 20:59:30 +01:00
XBuffer < UINT8 > ImageData = XBuffer < UINT8 > ( ) ;
2021-03-19 21:32:42 +01:00
XStringW Volume = XStringW ( ) ;
XStringW Path = XStringW ( ) ;
2021-03-23 20:59:30 +01:00
// XString8Array LoadOptions = XString8Array();
XString8 Arguments = XString8 ( ) ;
2021-03-19 21:32:42 +01:00
XStringW FullTitle = XStringW ( ) ;
XStringW Title = XStringW ( ) ;
CHAR16 Hotkey = 0 ;
2021-03-23 20:59:30 +01:00
// UINT8 Flags = 0;
2021-03-19 21:32:42 +01:00
bool Hidden = 0 ;
2021-03-23 20:59:30 +01:00
bool AlwaysHidden = 0 ;
2021-03-19 21:32:42 +01:00
UINT8 VolumeType = 0 ;
2021-03-23 20:59:30 +01:00
} ;
class CUSTOM_TOOL_ENTRY
{
public :
XIcon Image = XIcon ( ) ;
const CUSTOM_TOOL_ENTRY_SETTINGS & settings = CUSTOM_TOOL_ENTRY_SETTINGS ( ) ;
2021-03-23 22:23:44 +01:00
CUSTOM_TOOL_ENTRY ( const CUSTOM_TOOL_ENTRY_SETTINGS & _settings , const EFI_FILE & ThemeDir ) : settings ( _settings )
2021-03-23 20:59:30 +01:00
{
if ( settings . ImagePath . notEmpty ( ) ) {
Image . LoadXImage ( & ThemeDir , settings . ImagePath ) ;
} else if ( settings . ImageData . notEmpty ( ) ) {
if ( ! EFI_ERROR ( Image . Image . FromPNG ( settings . ImageData . data ( ) , settings . ImageData . size ( ) ) ) ) {
Image . setFilled ( ) ;
}
}
}
UINT8 getFlags ( ) const {
UINT8 Flags = 0 ;
if ( settings . Disabled | | settings . AlwaysHidden ) Flags = OSFLAG_SET ( Flags , OSFLAG_DISABLED ) ;
return Flags ;
}
XString8Array getLoadOptions ( ) const {
return Split < XString8Array > ( settings . Arguments , " " ) ;
}
2020-04-16 09:15:26 +02:00
} ;
2020-08-09 17:55:30 +02:00
class DEV_PROPERTY
{
public :
2021-03-29 10:50:02 +02:00
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 ( ) { } ;
2020-08-09 17:55:30 +02:00
// Not sure if default are valid. Delete them. If needed, proper ones can be created
2021-03-29 10:50:02 +02:00
DEV_PROPERTY ( const DEV_PROPERTY & ) { panic ( " nope " ) ; } ;
DEV_PROPERTY & operator = ( const DEV_PROPERTY & ) { panic ( " nope " ) ; } ;
} ;
class DEV_ADDPROPERTY
{
public :
UINT32 Device = 0 ;
XString8 Key = XString8 ( ) ;
XBuffer < uint8_t > Value = XBuffer < uint8_t > ( ) ;
INPUT_ITEM MenuItem = INPUT_ITEM ( ) ;
2020-04-16 09:15:26 +02:00
} ;
2021-03-26 10:43:15 +01:00
/**
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
* */
class VBIOS_PATCH {
public :
XBuffer < uint8_t > Find = XBuffer < uint8_t > ( ) ;
XBuffer < uint8_t > Replace = XBuffer < uint8_t > ( ) ;
} ;
class PatchVBiosBytesNewClass : public XObjArray < VBIOS_PATCH >
{
mutable XArray < VBIOS_PATCH_BYTES > VBIOS_PATCH_BYTES_array = XArray < VBIOS_PATCH_BYTES > ( ) ;
public :
// Temporary bridge to old struct.
const VBIOS_PATCH_BYTES * getVBIOS_PATCH_BYTES ( ) {
VBIOS_PATCH_BYTES_array . setSize ( size ( ) ) ;
for ( size_t idx = 0 ; idx < size ( ) ; + + idx ) {
VBIOS_PATCH_BYTES_array [ idx ] . Find = ElementAt ( idx ) . Find . data ( ) ;
VBIOS_PATCH_BYTES_array [ idx ] . Replace = ElementAt ( idx ) . Replace . data ( ) ;
VBIOS_PATCH_BYTES_array [ idx ] . NumberOfBytes = ElementAt ( idx ) . Replace . size ( ) ;
}
return VBIOS_PATCH_BYTES_array ;
}
size_t getVBIOS_PATCH_BYTES_count ( ) const {
return size ( ) ;
}
} ;
2021-03-25 15:32:56 +01:00
class SETTINGS_DATA ;
2021-03-27 19:53:30 +01:00
class ConfigPlistClass ;
2021-03-25 15:32:56 +01:00
class TagDict ;
2021-03-27 19:53:30 +01:00
//bool CompareOldNewSettings(const SETTINGS_DATA& , const ConfigPlistClass& );
2021-03-25 15:32:56 +01:00
EFI_STATUS GetUserSettings ( const TagDict * CfgDict , SETTINGS_DATA & gSettings ) ;
2020-08-11 14:43:53 +02:00
class SETTINGS_DATA {
public :
2021-02-02 10:02:21 +01:00
class BootClass {
public :
INTN Timeout = - 1 ;
bool SkipHibernateTimeout = false ;
bool DisableCloverHotkeys = false ;
XString8 BootArgs = XString8 ( ) ;
2021-03-15 10:02:34 +01:00
bool NeverDoRecovery = 0 ;
2021-02-02 10:02:21 +01:00
bool LastBootedVolume = false ;
XStringW DefaultVolume = XStringW ( ) ;
XStringW DefaultLoader = XStringW ( ) ;
bool DebugLog = false ;
bool FastBoot = false ;
bool NoEarlyProgress = false ;
bool NeverHibernate = false ;
bool StrictHibernate = false ;
bool RtcHibernateAware = false ;
bool HibernationFixup = false ;
bool SignatureFixup = false ;
2021-03-15 10:02:34 +01:00
INT8 SecureSetting = 0 ; // 0 == false, 1 == true, -1 == undefined
2021-03-27 19:53:30 +01:00
//UINT8 SecureBoot = 0;
//UINT8 SecureBootSetupMode = 0;
2021-02-02 10:02:21 +01:00
UINT8 SecureBootPolicy = 0 ;
// Secure boot white/black list
2021-02-11 12:41:59 +01:00
XStringWArray SecureBootWhiteList = XStringWArray ( ) ;
XStringWArray SecureBootBlackList = XStringWArray ( ) ;
2021-02-02 10:02:21 +01:00
INT8 XMPDetection = 0 ;
// LegacyBoot
XStringW LegacyBoot = XStringW ( ) ;
UINT16 LegacyBiosDefaultEntry = 0 ;
2021-03-20 15:29:34 +01:00
UINT8 CustomLogoType = 0 ;
2021-03-15 10:02:34 +01:00
XString8 CustomLogoAsXString8 = XString8 ( ) ;
XBuffer < UINT8 > CustomLogoAsData = XBuffer < UINT8 > ( ) ;
2021-03-27 19:53:30 +01:00
} ;
2021-02-11 12:41:59 +01:00
class ACPIClass
{
public :
class ACPIDropTablesClass
{
public :
UINT32 Signature = 0 ;
UINT64 TableId = 0 ;
UINT32 TabLength = 0 ;
bool OtherOS = 0 ;
} ;
class DSDTClass
{
public :
2021-03-27 19:53:30 +01:00
class DSDT_Patch
{
public :
bool Disabled = bool ( ) ;
XString8 PatchDsdtLabel = XString8 ( ) ;
XBuffer < UINT8 > PatchDsdtFind = XBuffer < UINT8 > ( ) ;
XBuffer < UINT8 > PatchDsdtReplace = XBuffer < UINT8 > ( ) ;
XBuffer < UINT8 > PatchDsdtTgt = XBuffer < UINT8 > ( ) ;
INPUT_ITEM PatchDsdtMenuItem = INPUT_ITEM ( ) ;
} ;
2021-02-11 12:41:59 +01:00
XStringW DsdtName = XStringW ( ) ;
2021-03-25 21:21:41 +01:00
bool DebugDSDT = 0 ;
bool Rtc8Allowed = 0 ;
2021-02-11 12:41:59 +01:00
UINT8 PNLF_UID = 0 ;
UINT32 FixDsdt = 0 ;
2021-03-25 21:21:41 +01:00
bool ReuseFFFF = 0 ;
bool SuspendOverride = 0 ;
2021-02-11 12:41:59 +01:00
XObjArray < DSDT_Patch > DSDTPatchArray = XObjArray < DSDT_Patch > ( ) ;
2021-03-27 19:53:30 +01:00
} ;
2021-02-11 12:41:59 +01:00
class SSDTClass
{
public :
class GenerateClass
{
public :
2021-03-23 20:59:30 +01:00
bool GeneratePStates = 0 ;
bool GenerateCStates = 0 ;
bool GenerateAPSN = 0 ;
bool GenerateAPLF = 0 ;
bool GeneratePluginType = 0 ;
2021-03-27 19:53:30 +01:00
} ;
bool DropSSDTSetting = 0 ;
bool NoOemTableId = 0 ;
bool NoDynamicExtract = 0 ;
bool EnableISS = 0 ;
bool EnableC7 = 0 ;
bool _EnableC6 = 0 ;
bool _EnableC4 = 0 ;
bool _EnableC2 = 0 ;
2021-03-19 16:35:01 +01:00
UINT16 _C3Latency = 0 ;
2021-02-11 12:41:59 +01:00
UINT8 PLimitDict = 0 ;
UINT8 UnderVoltStep = 0 ;
2021-03-27 19:53:30 +01:00
bool DoubleFirstState = 0 ;
2021-02-11 12:41:59 +01:00
UINT8 MinMultiplier = 0 ;
UINT8 MaxMultiplier = 0 ;
UINT8 PluginType = 0 ;
2021-03-27 19:53:30 +01:00
GenerateClass Generate = GenerateClass ( ) ;
} ;
UINT64 ResetAddr = 0 ;
UINT8 ResetVal = 0 ;
bool SlpSmiEnable = 0 ;
bool FixHeaders = 0 ;
bool FixMCFG = 0 ;
bool NoASPM = 0 ;
bool smartUPS = 0 ;
bool PatchNMI = 0 ;
bool AutoMerge = 0 ;
XStringWArray DisabledAML = XStringWArray ( ) ;
XString8Array SortedACPI = XString8Array ( ) ;
XObjArray < ACPI_NAME_LIST > DeviceRename = XObjArray < ACPI_NAME_LIST > ( ) ;
XObjArray < ACPIDropTablesClass > ACPIDropTablesArray = XObjArray < ACPIDropTablesClass > ( ) ;
DSDTClass DSDT = DSDTClass ( ) ;
SSDTClass SSDT = SSDTClass ( ) ;
} ;
2021-02-02 10:02:21 +01:00
class GUIClass {
public :
2021-03-19 21:32:42 +01:00
class MouseClass {
public :
INTN PointerSpeed = 0 ;
2021-03-23 20:59:30 +01:00
bool PointerEnabled = 0 ;
2021-03-19 21:32:42 +01:00
UINT64 DoubleClickTime = 0 ;
2021-03-23 20:59:30 +01:00
bool PointerMirror = 0 ;
2021-03-27 19:53:30 +01:00
} ;
2021-03-19 21:32:42 +01:00
class ScanClass {
public :
2021-03-23 20:59:30 +01:00
bool DisableEntryScan = 0 ;
bool DisableToolScan = 0 ;
UINT8 KernelScan = 0 ;
bool LinuxScan = 0 ;
bool LegacyFirst = false ;
bool NoLegacy = false ;
2021-03-27 19:53:30 +01:00
} ;
INT32 Timezone = - 1 ;
XStringW Theme = XStringW ( ) ;
//bool DarkEmbedded = 0;
XString8 EmbeddedThemeType = XString8 ( ) ;
bool PlayAsync = 0 ;
bool CustomIcons = false ;
bool TextOnly = false ;
bool ShowOptimus = false ;
XStringW ScreenResolution = XStringW ( ) ;
bool ProvideConsoleGop = 0 ;
INTN ConsoleMode = 0 ;
LANGUAGES Language = english ;
bool KbdPrevLang = 0 ;
XString8Array HVHideStrings = XString8Array ( ) ;
ScanClass Scan = ScanClass ( ) ;
MouseClass Mouse = MouseClass ( ) ;
2021-03-22 13:40:01 +01:00
XObjArray < CUSTOM_LOADER_ENTRY_SETTINGS > CustomEntriesSettings = XObjArray < CUSTOM_LOADER_ENTRY_SETTINGS > ( ) ;
2021-03-23 20:59:30 +01:00
XObjArray < CUSTOM_LEGACY_ENTRY_SETTINGS > CustomLegacySettings = XObjArray < CUSTOM_LEGACY_ENTRY_SETTINGS > ( ) ;
XObjArray < CUSTOM_TOOL_ENTRY_SETTINGS > CustomToolSettings = XObjArray < CUSTOM_TOOL_ENTRY_SETTINGS > ( ) ;
2021-03-27 19:53:30 +01:00
bool getDarkEmbedded ( bool isDaylight ) const ;
2021-03-19 21:32:42 +01:00
2021-03-27 19:53:30 +01:00
} ;
2021-02-02 10:02:21 +01:00
2021-03-19 16:35:01 +01:00
class CPUClass {
public :
UINT16 QPI = 0 ;
UINT32 CpuFreqMHz = 0 ;
UINT16 CpuType = 0 ;
2021-03-26 10:43:15 +01:00
bool QEMU = 0 ;
bool UseARTFreq = 0 ;
2021-03-19 16:35:01 +01:00
UINT32 BusSpeed = 0 ; //in kHz
2021-03-26 10:43:15 +01:00
bool UserChange = 0 ;
2021-03-19 16:35:01 +01:00
UINT8 SavingMode = 0 ;
bool HWPEnable = false ;
undefinable_uint32 HWPValue = undefinable_uint32 ( ) ;
UINT8 TDP = 0 ;
2021-03-26 10:43:15 +01:00
bool TurboDisabled = 0 ;
2021-03-19 16:35:01 +01:00
undefinable_bool _EnableC6 = undefinable_bool ( ) ;
undefinable_bool _EnableC4 = undefinable_bool ( ) ;
undefinable_bool _EnableC2 = undefinable_bool ( ) ;
undefinable_uint16 _C3Latency = undefinable_uint16 ( ) ;
2021-03-27 19:53:30 +01:00
} ;
2021-03-19 16:35:01 +01:00
2021-03-25 15:32:56 +01:00
class SystemParametersClass {
public :
bool WithKexts = true ;
bool WithKextsIfNoFakeSMC = 0 ;
bool NoCaches = 0 ;
uint16_t BacklightLevel = 0xFFFF ;
bool BacklightLevelConfig = false ;
XString8 CustomUuid = XString8 ( ) ;
2021-03-27 19:53:30 +01:00
public : // temporary, must be protected:
UINT8 _InjectSystemID = 2 ; // 0=false, 1=true, other value = default.
2021-03-25 15:32:56 +01:00
public :
bool NvidiaWeb = 0 ;
friend class : : SETTINGS_DATA ;
friend unsigned long long : : GetUserSettings ( const TagDict * CfgDict , SETTINGS_DATA & gSettings ) ;
2021-03-27 19:53:30 +01:00
} ;
2021-03-26 10:43:15 +01:00
class GraphicsClass {
public :
class EDIDClass {
public :
bool InjectEDID = bool ( ) ;
XBuffer < UINT8 > CustomEDID = XBuffer < UINT8 > ( ) ;
UINT16 VendorEDID = UINT16 ( ) ;
UINT16 ProductEDID = UINT16 ( ) ;
UINT16 EdidFixHorizontalSyncPulseWidth = UINT16 ( ) ;
UINT8 EdidFixVideoInputSignal = UINT8 ( ) ;
2021-03-27 19:53:30 +01:00
} ;
2021-03-26 10:43:15 +01:00
class InjectAsDictClass {
public :
2021-03-28 22:13:43 +02:00
bool GraphicsInjector = bool ( ) ;
2021-03-26 10:43:15 +01:00
bool InjectIntel = bool ( ) ;
bool InjectATI = bool ( ) ;
bool InjectNVidia = bool ( ) ;
2021-03-27 19:53:30 +01:00
} ;
class GRAPHIC_CARD {
public :
UINT32 Signature = 0 ;
XString8 Model = XString8 ( ) ;
UINT32 Id = 0 ;
UINT32 SubId = 0 ;
UINT64 VideoRam = 0 ;
UINTN VideoPorts = 0 ;
bool LoadVBios = 0 ;
} ;
bool PatchVBios = bool ( ) ;
PatchVBiosBytesNewClass PatchVBiosBytes = PatchVBiosBytesNewClass ( ) ;
2021-03-28 22:13:43 +02:00
// undefinable_bool InjectAsBool = undefinable_bool();
2021-03-26 10:43:15 +01:00
bool RadeonDeInit = bool ( ) ;
bool LoadVBios = bool ( ) ;
UINT64 VRAM = bool ( ) ;
UINT32 RefCLK = UINT32 ( ) ;
XStringW FBName = XStringW ( ) ;
UINT16 VideoPorts = UINT16 ( ) ;
bool NvidiaGeneric = bool ( ) ;
bool NvidiaNoEFI = bool ( ) ;
bool NvidiaSingle = bool ( ) ;
UINT8 Dcfg [ 8 ] = { 0 } ;
UINT8 NVCAP [ 20 ] = { 0 } ;
INT8 BootDisplay = INT8 ( ) ;
UINT32 DualLink = UINT32 ( ) ;
UINT32 IgPlatform = UINT32 ( ) ; //could also be snb-platform-id
2021-03-27 19:53:30 +01:00
EDIDClass EDID = EDIDClass ( ) ;
InjectAsDictClass InjectAsDict = InjectAsDictClass ( ) ;
2021-03-28 22:13:43 +02:00
XObjArray < GRAPHIC_CARD > ATICardList = XObjArray < GRAPHIC_CARD > ( ) ;
XObjArray < GRAPHIC_CARD > NVIDIACardList = XObjArray < GRAPHIC_CARD > ( ) ;
2021-03-26 10:43:15 +01:00
2021-03-27 19:53:30 +01:00
//bool getGraphicsInjector() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.GraphicsInjector; }
2021-03-28 22:13:43 +02:00
//bool InjectIntel() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectIntel; }
//bool InjectATI() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectATI; }
//bool InjectNVidia() const { return InjectAsBool.isDefined() ? InjectAsBool.value() : InjectAsDict.InjectNVidia; }
2021-03-26 10:43:15 +01:00
2021-03-27 19:53:30 +01:00
} ;
2021-03-26 10:43:15 +01:00
class DevicesClass {
public :
class AudioClass {
public :
2021-03-29 10:50:02 +02:00
bool ResetHDA = bool ( ) ;
bool HDAInjection = bool ( ) ;
INT32 HDALayoutId = INT32 ( ) ;
UINT8 AFGLowPowerState = UINT8 ( ) ;
} ;
class USBClass {
public :
bool USBInjection = bool ( ) ;
bool USBFixOwnership = bool ( ) ;
bool InjectClockID = bool ( ) ;
bool HighCurrent = bool ( ) ;
bool NameEH00 = bool ( ) ;
bool NameXH00 = bool ( ) ;
} ;
class PropertiesClass {
public :
XString8 cDeviceProperties = XString8 ( ) ;
} ;
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
} ;
bool StringInjector = bool ( ) ;
bool IntelMaxBacklight = bool ( ) ;
bool IntelBacklight = bool ( ) ;
UINT32 IntelMaxValue = UINT32 ( ) ;
bool LANInjection = bool ( ) ;
bool HDMIInjection = bool ( ) ;
bool NoDefaultProperties = bool ( ) ;
bool UseIntelHDMI = bool ( ) ;
bool ForceHPET = bool ( ) ;
UINT32 DisableFunctions = UINT32 ( ) ;
XString8 AirportBridgeDeviceName = XString8 ( ) ;
AudioClass Audio = AudioClass ( ) ;
USBClass USB = USBClass ( ) ;
PropertiesClass Properties = PropertiesClass ( ) ;
FakeIDClass FakeID = FakeIDClass ( ) ;
// UINTN NrAddProperties;
// DEV_PROPERTY *AddProperties;
XObjArray < DEV_ADDPROPERTY > AddProperties = XObjArray < DEV_ADDPROPERTY > ( ) ;
DEV_PROPERTY * ArbProperties = 0 ;
2021-03-26 10:43:15 +01:00
2021-03-27 19:53:30 +01:00
} ;
2021-03-26 10:43:15 +01:00
2021-03-25 15:32:56 +01:00
class QuirksClass {
public :
2021-03-28 22:13:43 +02:00
class MMIOWhiteList
{
public :
UINTN address = 0 ;
XString8 comment = XString8 ( ) ;
bool enabled = 0 ;
} ;
2021-03-29 10:50:02 +02:00
bool FuzzyMatch = bool ( ) ;
XString8 OcKernelCache = XString8 ( ) ;
2021-03-28 22:13:43 +02:00
// UINTN MaxSlide;
2021-03-29 10:50:02 +02:00
OC_KERNEL_QUIRKS OcKernelQuirks = OC_KERNEL_QUIRKS ( ) ;
OC_BOOTER_QUIRKS ocBooterQuirks = OC_BOOTER_QUIRKS ( ) ;
2021-03-28 22:13:43 +02:00
XObjArray < MMIOWhiteList > mmioWhiteListArray = XObjArray < MMIOWhiteList > ( ) ;
2021-03-29 10:50:02 +02:00
UINT32 QuirksMask = 0 ;
2021-03-27 19:53:30 +01:00
} ;
2021-03-28 22:13:43 +02:00
2021-03-26 10:43:15 +01:00
class RtVariablesClass {
public :
2021-03-27 19:53:30 +01:00
class RT_VARIABLES
{
public :
2021-03-28 11:12:43 +02:00
bool Disabled = bool ( ) ;
2021-03-27 19:53:30 +01:00
XString8 Comment = XStringW ( ) ;
XStringW Name = XStringW ( ) ;
2021-03-28 11:12:43 +02:00
EFI_GUID Guid = { 0 , 0 , 0 , { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } } ;
2021-03-27 19:53:30 +01:00
} ;
XString8 RtROMAsString = XString8 ( ) ;
XBuffer < UINT8 > RtROMAsData = XBuffer < UINT8 > ( ) ;
XString8 RtMLBSetting = XString8 ( ) ;
UINT32 CsrActiveConfig = UINT32 ( ) ;
UINT16 BooterConfig = UINT16 ( ) ;
XString8 BooterCfgStr = XString8 ( ) ;
2021-03-28 11:12:43 +02:00
XObjArray < RT_VARIABLES > BlockRtVariableArray = XObjArray < RT_VARIABLES > ( ) ;
2021-03-27 19:53:30 +01:00
bool GetLegacyLanAddress ( ) const {
return RtROMAsString . equalIC ( " UseMacAddr0 " ) | | RtROMAsString . equalIC ( " UseMacAddr1 " ) ;
}
2021-03-26 10:43:15 +01:00
2021-03-27 19:53:30 +01:00
} ;
2021-03-26 10:43:15 +01:00
2021-03-27 19:53:30 +01:00
BootClass Boot = BootClass ( ) ;
ACPIClass ACPI = ACPIClass ( ) ;
GUIClass GUI = GUIClass ( ) ;
CPUClass CPU = CPUClass ( ) ;
SystemParametersClass SystemParameters = SystemParametersClass ( ) ;
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches = KERNEL_AND_KEXT_PATCHES ( ) ;
GraphicsClass Graphics = GraphicsClass ( ) ;
XStringWArray DisabledDriverArray = XStringWArray ( ) ;
QuirksClass Quirks = QuirksClass ( ) ;
RtVariablesClass RtVariables = RtVariablesClass ( ) ;
DevicesClass Devices = DevicesClass ( ) ;
2021-03-25 15:32:56 +01:00
2020-04-16 09:15:26 +02:00
// SMBIOS TYPE0
2020-08-15 15:47:56 +02:00
XString8 VendorName ;
XString8 RomVersion ;
2020-08-12 17:15:47 +02:00
XString8 EfiVersion ;
2020-08-15 15:47:56 +02:00
XString8 ReleaseDate ;
2020-04-16 09:15:26 +02:00
// SMBIOS TYPE1
2020-08-15 15:47:56 +02:00
XString8 ManufactureName ;
XString8 ProductName ;
XString8 VersionNr ;
XString8 SerialNr ;
2020-09-23 15:47:47 +02:00
XString8 SmUUID ;
2020-08-15 15:47:56 +02:00
//CHAR8 Uuid;
//CHAR8 SKUNumber;
XString8 FamilyName ;
XString8 OEMProduct ;
XString8 OEMVendor ;
2020-04-16 09:15:26 +02:00
// SMBIOS TYPE2
2020-08-15 15:47:56 +02:00
XString8 BoardManufactureName ;
XString8 BoardSerialNumber ;
XString8 BoardNumber ; //Board-ID
XString8 LocationInChassis ;
XString8 BoardVersion ;
XString8 OEMBoard ;
2020-04-16 09:15:26 +02:00
UINT8 BoardType ;
// SMBIOS TYPE3
BOOLEAN Mobile ;
UINT8 ChassisType ;
2020-08-15 15:47:56 +02:00
XString8 ChassisManufacturer ;
XString8 ChassisAssetTag ;
2020-04-16 09:15:26 +02:00
// SMBIOS TYPE4
UINT8 EnabledCores ;
// SMBIOS TYPE17
UINT16 SmbiosVersion ;
INT8 Attribute ;
2020-08-15 15:47:56 +02:00
XString8 MemoryManufacturer ;
XString8 MemorySerialNumber ;
XString8 MemoryPartNumber ;
XString8 MemorySpeed ;
2020-04-16 09:15:26 +02:00
// SMBIOS TYPE131
// SMBIOS TYPE132
2021-03-19 16:35:01 +01:00
BOOLEAN TrustSMBIOS = 0 ;
2020-04-16 09:15:26 +02:00
BOOLEAN InjectMemoryTables ;
2020-08-13 14:07:40 +02:00
2020-04-16 09:15:26 +02:00
// SMBIOS TYPE133
UINT64 PlatformFeature ;
// PatchTableType11
BOOLEAN NoRomInfo ;
// OS parameters
2020-08-15 15:47:56 +02:00
XString8 Language ;
2020-04-16 09:15:26 +02:00
2021-02-02 10:02:21 +01:00
2020-04-16 09:15:26 +02:00
//Monitor
//Boot options
BOOLEAN MemoryFix ;
BOOLEAN FakeSMCFound ;
// GUI parameters
BOOLEAN Debug ;
UINT32 DefaultBackgroundColor ;
//ACPI
// BOOLEAN DropMCFG;
//Injections
//Graphics
// UINT16 PCIRootUID;
BOOLEAN LpcTune ;
2020-05-09 11:15:03 +02:00
UINT16 DropOEM_DSM ; //vacant
2021-03-26 10:43:15 +01:00
2020-04-16 09:15:26 +02:00
// USB DeviceTree injection
//SkyLake
//Volumes hiding
// KernelAndKextPatches
BOOLEAN KextPatchesAllowed ;
BOOLEAN KernelPatchesAllowed ; //From GUI: Only for user patches, not internal Clover
// Pre-language
// SysVariables
// Multi-config
CHAR16 ConfigName [ 30 ] ;
2020-08-13 14:57:05 +02:00
// XString8 MainConfigName;
2020-04-16 09:15:26 +02:00
//Drivers
//SMC keys
CHAR8 RPlt [ 8 ] ;
CHAR8 RBr [ 8 ] ;
UINT8 EPCI [ 4 ] ;
UINT8 REV [ 6 ] ;
//other devices
BOOLEAN SlpWak ;
BOOLEAN UseIntelHDMI ;
//Add custom properties
//BlackListed kexts
CHAR16 BlockKexts [ 64 ] ;
// Disable inject kexts
// UINT32 DisableInjectKextCount;
// CHAR16 **DisabledInjectKext;
// INPUT_ITEM *InjectKextMenuItem;
//ACPI tables
//other
// UINT32 AudioVolume;
// boot.efi
UINT32 OptionsBits ;
UINT32 FlagsBits ;
UINT32 UIScale ;
UINT32 EFILoginHiDPI ;
UINT8 flagstate [ 32 ] ;
2020-07-15 19:29:27 +02:00
2020-09-29 14:15:11 +02:00
2020-08-11 14:43:53 +02:00
2020-09-23 15:47:47 +02:00
SETTINGS_DATA ( ) : VendorName ( ) , RomVersion ( ) , EfiVersion ( ) , ReleaseDate ( ) , ManufactureName ( ) , ProductName ( ) , VersionNr ( ) , SerialNr ( ) , SmUUID ( ) ,
2021-03-26 10:43:15 +01:00
FamilyName ( ) , OEMProduct ( ) , OEMVendor ( ) , BoardManufactureName ( ) , BoardSerialNumber ( ) , BoardNumber ( ) , LocationInChassis ( ) ,
BoardVersion ( ) , OEMBoard ( ) , BoardType ( 0 ) , Mobile ( 0 ) , ChassisType ( 0 ) , ChassisManufacturer ( ) , ChassisAssetTag ( ) ,
EnabledCores ( 0 ) , SmbiosVersion ( 0 ) , Attribute ( 0 ) , MemoryManufacturer ( ) ,
2021-03-19 16:35:01 +01:00
MemorySerialNumber ( ) , MemoryPartNumber ( ) , MemorySpeed ( ) , InjectMemoryTables ( 0 ) ,
2021-03-25 15:32:56 +01:00
PlatformFeature ( 0 ) , NoRomInfo ( 0 ) , Language ( ) ,
2021-03-29 10:50:02 +02:00
MemoryFix ( 0 ) ,
FakeSMCFound ( 0 ) , Debug ( 0 ) , DefaultBackgroundColor ( 0 ) ,
2021-03-26 10:43:15 +01:00
LpcTune ( 0 ) , DropOEM_DSM ( 0 ) ,
KextPatchesAllowed ( 0 ) ,
2021-03-29 10:50:02 +02:00
KernelPatchesAllowed ( 0 ) ,
2021-03-26 10:43:15 +01:00
ConfigName { 0 } , /*MainConfigName(0),*/ /*BlackListCount(0),*/ RPlt { 0 } , RBr { 0 } , EPCI { 0 } , REV { 0 } ,
2021-03-29 10:50:02 +02:00
SlpWak ( 0 ) , UseIntelHDMI ( 0 ) ,
BlockKexts { 0 } ,
OptionsBits ( 0 ) , FlagsBits ( 0 ) , UIScale ( 0 ) , EFILoginHiDPI ( 0 ) , flagstate { 0 }
2020-08-11 14:43:53 +02:00
{ } ;
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
2020-08-13 14:07:40 +02:00
2021-02-11 12:41:59 +01:00
// XBuffer<UINT8> serialize() const;
2020-08-13 14:07:40 +02:00
2020-08-11 14:43:53 +02:00
~ SETTINGS_DATA ( ) { }
2020-09-23 15:47:47 +02:00
const XString8 & getUUID ( ) ;
const XString8 & getUUID ( EFI_GUID * efiGuid ) ;
2020-11-18 22:49:02 +01:00
// If CustomUuid is defined, return false by default
// If SmUUID is defined, return true by default.
2020-09-23 15:47:47 +02:00
bool ShouldInjectSystemID ( ) {
2021-03-28 11:12:43 +02:00
if ( SystemParameters . CustomUuid . notEmpty ( ) & & SystemParameters . CustomUuid ! = nullGuidAsString ) {
2021-03-27 19:53:30 +01:00
if ( SystemParameters . _InjectSystemID = = 2 ) return false ;
else return SystemParameters . _InjectSystemID ;
2020-09-23 15:47:47 +02:00
}
2021-03-28 11:12:43 +02:00
if ( SmUUID . isEmpty ( ) | | SmUUID = = nullGuidAsString ) return false ;
2021-03-27 19:53:30 +01:00
if ( SystemParameters . _InjectSystemID = = 2 ) return true ;
return SystemParameters . _InjectSystemID ;
2020-09-23 15:47:47 +02:00
}
2021-03-27 19:53:30 +01:00
bool getEnableC6 ( ) const {
if ( CPU . _EnableC6 . isDefined ( ) ) return CPU . _EnableC6 . value ( ) ;
return ACPI . SSDT . _EnableC6 ;
}
bool getEnableC4 ( ) const {
if ( CPU . _EnableC4 . isDefined ( ) ) return CPU . _EnableC4 . value ( ) ;
return ACPI . SSDT . _EnableC4 ;
}
bool getEnableC2 ( ) const {
if ( CPU . _EnableC2 . isDefined ( ) ) return CPU . _EnableC2 . value ( ) ;
return ACPI . SSDT . _EnableC2 ;
}
bool getC3Latency ( ) const {
if ( CPU . _C3Latency . isDefined ( ) ) return CPU . _C3Latency . value ( ) ;
return ACPI . SSDT . _C3Latency ;
}
2020-08-11 14:43:53 +02:00
} ;
2020-04-16 09:15:26 +02:00
2020-08-15 15:47:56 +02:00
//#pragma GCC diagnostic ignored "-Wpadded"
2020-08-13 14:07:40 +02:00
2020-04-16 09:15:26 +02:00
typedef struct _DRIVERS_FLAGS {
BOOLEAN EmuVariableLoaded ;
BOOLEAN VideoLoaded ;
BOOLEAN PartitionLoaded ;
BOOLEAN MemFixLoaded ;
BOOLEAN AptioFixLoaded ;
BOOLEAN AptioFix2Loaded ;
BOOLEAN AptioFix3Loaded ;
BOOLEAN AptioMemFixLoaded ;
BOOLEAN HFSLoaded ;
BOOLEAN APFSLoaded ;
} DRIVERS_FLAGS ;
typedef struct {
UINT16 SegmentGroupNum ;
UINT8 BusNum ;
UINT8 DevFuncNum ;
BOOLEAN Valid ;
//UINT8 DeviceN;
UINT8 SlotID ;
UINT8 SlotType ;
CHAR8 SlotName [ 31 ] ;
} SLOT_DEVICE ;
// ACPI/PATCHED/AML
2020-08-09 17:55:30 +02:00
class ACPI_PATCHED_AML
2020-04-16 09:15:26 +02:00
{
2020-08-09 17:55:30 +02:00
public :
2021-03-23 20:59:30 +01:00
XString8 FileName = XString8 ( ) ;
INPUT_ITEM MenuItem = INPUT_ITEM ( ) ;
2020-08-09 17:55:30 +02:00
2021-03-23 20:59:30 +01:00
ACPI_PATCHED_AML ( ) { } ;
2020-08-09 17:55:30 +02:00
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 ( ) { }
2020-04-16 09:15:26 +02:00
} ;
// syscl - Side load kext
2020-08-09 17:55:30 +02:00
class SIDELOAD_KEXT
{
public :
2020-09-16 01:01:53 +02:00
XObjArray < SIDELOAD_KEXT > PlugInList ;
2021-02-11 12:41:59 +01:00
XStringW FileName = XStringW ( ) ;
XStringW KextDirNameUnderOEMPath = XStringW ( ) ;
XStringW Version = XStringW ( ) ;
2021-02-06 18:16:46 +01:00
INPUT_ITEM MenuItem = INPUT_ITEM ( ) ;
2020-08-09 17:55:30 +02:00
2021-02-11 12:41:59 +01:00
SIDELOAD_KEXT ( ) : PlugInList ( ) { } ;
2020-08-09 17:55:30 +02:00
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
2020-09-16 01:01:53 +02:00
~ SIDELOAD_KEXT ( ) { }
2020-04-16 09:15:26 +02:00
} ;
2020-08-31 08:22:21 +02:00
2021-03-26 10:43:15 +01:00
//extern XObjArray<RT_VARIABLES> gSettings.RtVariables.BlockRtVariableArray;
2020-08-31 09:07:36 +02:00
extern XObjArray < HDA_OUTPUTS > AudioList ;
2020-04-04 14:27:02 +02:00
2020-08-31 09:22:11 +02:00
extern XStringWArray ThemeNameArray ;
2020-04-04 14:27:02 +02:00
extern CHAR16 * ConfigsList [ 20 ] ;
extern CHAR16 * DsdtsList [ 20 ] ;
extern UINTN DsdtsNum ;
extern UINTN ConfigsNum ;
2020-05-26 19:12:54 +02:00
//extern INTN ScrollButtonsHeight;
//extern INTN ScrollBarDecorationsHeight;
//extern INTN ScrollScrollDecorationsHeight;
//extern INTN LayoutBannerOffset;
//extern INTN LayoutButtonOffset;
//extern INTN LayoutTextOffset;
2020-04-04 14:27:02 +02:00
// this should go in a globals, not in settings
extern INTN OldChosenTheme ;
extern INTN OldChosenConfig ;
extern INTN OldChosenDsdt ;
extern UINTN OldChosenAudio ;
extern BOOLEAN SavePreBootLog ;
extern UINT8 DefaultAudioVolume ;
2020-02-29 08:30:21 +01:00
2020-04-16 09:15:26 +02:00
extern GFX_PROPERTIES gGraphics [ ] ;
extern HDA_PROPERTIES gAudios [ ] ;
extern UINTN NGFX ;
extern UINTN NHDA ;
//extern UINT16 gCPUtype;
extern SETTINGS_DATA gSettings ;
extern BOOLEAN gFirmwareClover ;
extern DRIVERS_FLAGS gDriversFlags ;
extern SLOT_DEVICE SlotDevices [ ] ;
extern EFI_EDID_DISCOVERED_PROTOCOL * EdidDiscovered ;
//extern UINT8 *gEDID;
extern UINTN gEvent ;
extern UINT16 gBacklightLevel ;
2020-05-11 08:30:45 +02:00
//extern BOOLEAN defDSM;
//extern UINT16 dropDSM;
2020-04-16 09:15:26 +02:00
2020-08-25 17:35:19 +02:00
extern TagDict * gConfigDict [ ] ;
2020-04-16 09:15:26 +02:00
// ACPI/PATCHED/AML
2021-03-23 20:59:30 +01:00
extern XObjArray < ACPI_PATCHED_AML > ACPIPatchedAML ;
2020-04-16 09:15:26 +02:00
// SysVariables
//extern SYSVARIABLES *SysVariables;
// Hold theme fixed IconFormat / extension
extern CHAR16 * IconFormat ;
2020-04-16 13:19:37 +02:00
2020-04-16 09:15:26 +02:00
extern CONST CHAR16 * gFirmwareRevision ;
2020-04-16 13:19:37 +02:00
extern CONST CHAR8 * gRevisionStr ;
2020-04-16 14:24:21 +02:00
extern CONST CHAR8 * gFirmwareBuildDate ;
extern CONST CHAR8 * gBuildInfo ;
2020-10-28 18:11:50 +01:00
extern const LString8 gBuildId ;
extern const LString8 path_independant ;
extern const LString8 gBuildIdGrepTag ;
2020-04-16 09:15:26 +02:00
extern BOOLEAN ResumeFromCoreStorage ;
2021-03-25 15:32:56 +01:00
//extern BOOLEAN gRemapSmBiosIsRequire; // syscl: pass argument for Dell SMBIOS here
2020-04-16 09:15:26 +02:00
extern EMU_VARIABLE_CONTROL_PROTOCOL * gEmuVariableControl ;
2020-04-26 11:39:41 +02:00
//
// config module
//
2020-08-09 17:55:30 +02:00
class REFIT_CONFIG
{
public :
2021-03-22 13:40:01 +01:00
UINTN DisableFlags = 0 ; //to disable some volume types (optical, firewire etc)
BOOLEAN Quiet = true ;
BOOLEAN SpecialBootMode = false ; // content of nvram var "aptiofixflag"
2020-08-09 17:55:30 +02:00
2021-02-06 18:16:46 +01:00
BOOLEAN gBootChanged = FALSE ;
BOOLEAN gThemeChanged = FALSE ;
BOOLEAN NeedPMfix = FALSE ;
2021-02-11 12:41:59 +01:00
ACPI_DROP_TABLE * ACPIDropTables = NULL ;
2021-02-06 18:16:46 +01:00
2021-03-20 15:29:34 +01:00
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)
2021-03-15 10:02:34 +01:00
XImage * CustomLogo = 0 ;
2021-02-06 18:16:46 +01:00
2021-03-15 10:02:34 +01:00
bool DropSSDT = 0 ; // init with gSettings.Boot.DropSSDTSetting. Put back to false is one table is dropped (see afterGetUserSettings)
UINT8 SecureBoot = 0 ;
UINT8 SecureBootSetupMode = 0 ;
2021-02-06 18:16:46 +01:00
2021-03-19 14:04:19 +01:00
BOOLEAN SetTable132 = 0 ;
2021-03-19 16:35:01 +01:00
BOOLEAN HWP = 0 ;
bool EnableC6 = 0 ;
bool EnableC4 = 0 ;
bool EnableC2 = 0 ;
uint16_t C3Latency = 0 ;
2021-03-19 14:04:19 +01:00
2021-03-22 13:40:01 +01:00
XObjArray < CUSTOM_LOADER_ENTRY > CustomEntries = XObjArray < CUSTOM_LOADER_ENTRY > ( ) ;
2021-03-23 20:59:30 +01:00
XObjArray < CUSTOM_LEGACY_ENTRY > CustomLegacyEntries = XObjArray < CUSTOM_LEGACY_ENTRY > ( ) ;
XObjArray < CUSTOM_TOOL_ENTRY > CustomToolsEntries = XObjArray < CUSTOM_TOOL_ENTRY > ( ) ;
INTN Codepage = 0xC0 ;
INTN CodepageSize = 0xC0 ;
2021-03-22 13:40:01 +01:00
2021-03-25 15:32:56 +01:00
bool KPKernelPm = bool ( ) ;
bool KPAppleIntelCPUPM = bool ( ) ;
2021-03-26 10:43:15 +01:00
XBuffer < UINT8 > RtROM = XBuffer < UINT8 > ( ) ;
XString8 RtMLB = XString8 ( ) ;
2021-03-27 19:53:30 +01:00
bool Turbo = true ;
2021-03-22 13:40:01 +01:00
REFIT_CONFIG ( ) { } ;
2020-09-27 13:52:38 +02:00
REFIT_CONFIG ( const REFIT_CONFIG & other ) = delete ; // Can be defined if needed
2020-08-09 17:55:30 +02:00
const REFIT_CONFIG & operator = ( const REFIT_CONFIG & ) = delete ; // Can be defined if needed
~ REFIT_CONFIG ( ) { }
2021-02-02 10:02:21 +01:00
bool isFastBoot ( ) { return SpecialBootMode | | gSettings . Boot . FastBoot ; }
2020-08-09 17:55:30 +02:00
} ;
2020-04-26 11:39:41 +02:00
extern REFIT_CONFIG GlobalConfig ;
2020-04-16 09:15:26 +02:00
2020-02-29 08:30:21 +01:00
EFI_STATUS
SetFSInjection (
IN LOADER_ENTRY * Entry
) ;
2020-10-03 19:02:31 +02:00
void
2020-02-29 08:30:21 +01:00
SetDevices (
LOADER_ENTRY * Entry
) ;
//
// check if this entry corresponds to Boot# variable and then set BootCurrent
//
2020-10-03 19:02:31 +02:00
void
2020-03-10 10:45:17 +01:00
SetBootCurrent ( REFIT_MENU_ITEM_BOOTNUM * LoadedEntry ) ;
2020-02-29 08:30:21 +01:00
2021-02-04 15:04:31 +01:00
XString8 GetAuthRootDmg ( const EFI_FILE & dir , const XStringW & path ) ;
2020-02-29 08:30:21 +01:00
2021-02-04 15:04:31 +01:00
MacOsVersion GetMacOSVersionFromFolder ( const EFI_FILE & dir , const XStringW & path ) ;
2021-01-31 10:50:23 +01:00
MacOsVersion GetOSVersion ( int LoaderType , const XStringW & APFSTargetUUID , const REFIT_VOLUME * Volume , XString8 * BuildVersionPtr ) ;
inline MacOsVersion GetOSVersion ( IN LOADER_ENTRY * Entry ) { return GetOSVersion ( Entry - > LoaderType , Entry - > APFSTargetUUID , Entry - > Volume , & Entry - > BuildVersion ) ; } ;
2020-04-04 14:27:02 +02:00
2020-04-16 09:15:26 +02:00
UINT32
GetCrc32 (
UINT8 * Buffer ,
UINTN Size
) ;
2020-10-03 19:02:31 +02:00
void
GetDevices ( void ) ;
2020-04-16 09:15:26 +02:00
2020-04-27 11:50:49 +02:00
CONST XStringW
GetOSIconName (
2020-11-12 22:25:56 +01:00
const MacOsVersion & OSVersion
2020-04-16 09:15:26 +02:00
) ;
EFI_STATUS
GetRootUUID (
IN OUT REFIT_VOLUME * Volume
) ;
EFI_STATUS
GetEarlyUserSettings (
2021-02-06 18:16:46 +01:00
const TagDict * CfgDict ,
SETTINGS_DATA & gSettings
2020-04-16 09:15:26 +02:00
) ;
EFI_STATUS
2021-02-06 18:16:46 +01:00
GetUserSettings ( const TagDict * CfgDict , SETTINGS_DATA & gSettings ) ;
2020-04-16 09:15:26 +02:00
2020-08-09 17:55:30 +02:00
XStringW
2020-04-16 09:15:26 +02:00
GetOtherKextsDir ( BOOLEAN On ) ;
2020-11-12 22:25:56 +01:00
XStringW GetOSVersionKextsDir ( const MacOsVersion & OSVersion ) ;
2020-04-16 09:15:26 +02:00
EFI_STATUS
InjectKextsFromDir (
EFI_STATUS Status ,
CHAR16 * SrcDir
) ;
2020-10-03 19:02:31 +02:00
void
2020-04-16 09:15:26 +02:00
ParseLoadOptions (
2020-08-09 17:55:30 +02:00
OUT XStringW * ConfName ,
2020-08-25 17:35:19 +02:00
OUT TagDict * * Dict
2020-04-16 09:15:26 +02:00
) ;
EFI_STATUS
2020-10-03 19:02:31 +02:00
SaveSettings ( void ) ;
2020-04-16 09:15:26 +02:00
/** return true if a given os contains '.' as separator,
and then match components of the current booted OS . Also allow 10.10 . x format meaning all revisions
of the 10.10 OS */
2020-11-12 22:25:56 +01:00
//BOOLEAN IsOSValid(const XString8& MatchOS, const MacOsVersion& CurrOS);
2020-04-16 09:15:26 +02:00
//get default boot
2020-10-03 19:02:31 +02:00
void GetBootFromOption ( void ) ;
2020-04-16 09:15:26 +02:00
EFI_STATUS
LoadUserSettings (
2020-08-09 17:55:30 +02:00
const XStringW & ConfName ,
2020-08-25 17:35:19 +02:00
TagDict * * dict
2020-04-16 09:15:26 +02:00
) ;
2020-10-03 19:02:31 +02:00
void
2020-04-16 09:15:26 +02:00
ParseSMBIOSSettings (
2020-08-25 17:35:19 +02:00
const TagDict * dictPointer
2020-04-16 09:15:26 +02:00
) ;
2020-04-04 14:27:02 +02:00
2020-08-25 17:35:19 +02:00
void testConfigPlist ( ) ;
2020-04-04 14:27:02 +02:00
# endif