2021-04-28 20:30:34 +02:00
/*
* ConfigPlist . h
*
* Created on : Oct 9 , 2020
* Author : jief
*/
# ifndef _SMBIOSPLISTCLASS_H_
# define _SMBIOSPLISTCLASS_H_
# include "../../include/VolumeTypes.h"
# include "../../include/OSTypes.h"
# include "../../include/OSFlags.h"
# include "../../include/BootTypes.h"
# include "../../include/Languages.h"
# include "../../include/Devices.h"
# include "../../include/QuirksCodes.h"
# include "../../include/TagTypes.h"
# include "../../include/Pci.h"
# include "../../entry_scan/loader.h" // for KERNEL_SCAN_xxx constants
# include <IndustryStandard/SmBios.h> // for Smbios memory type
# include "../../Platform/guid.h"
2022-04-26 00:55:56 +02:00
# include "../../include/Guid++.h"
2021-04-28 20:30:34 +02:00
# include "../../Platform/platformdata.h"
2021-10-02 19:44:16 +02:00
# include "../../Platform/smbios.h"
2021-10-19 19:57:27 +02:00
# include "../../Platform/VersionString.h" // for AsciiStrVersionToUint64
2023-06-22 21:50:58 +02:00
//#include "../../Platform/Settings.h"
2021-04-28 20:30:34 +02:00
//#include "../cpu.h"
# include "../../cpp_lib/undefinable.h"
# include "../../cpp_lib/XmlLiteSimpleTypes.h"
# include "../../cpp_lib/XmlLiteCompositeTypes.h"
# include "../../cpp_lib/XmlLiteDictTypes.h"
# include "../../cpp_lib/XmlLiteArrayTypes.h"
# include "../../cpp_lib/XmlLiteUnionTypes.h"
# include "../../cpp_lib/XmlLiteParser.h"
# include "../../cpp_foundation/XString.h"
# include "../../cpp_foundation/XStringArray.h"
# include "../../cpp_foundation/XArray.h"
# include "../../cpp_foundation/XObjArray.h"
# include "../../Platform/Utils.h"
# include "ConfigPlistAbstract.h"
2023-06-16 23:44:39 +02:00
extern XStringWArray ThemeNameArray ;
extern XStringWArray ConfigsList ;
extern XStringWArray DsdtsList ;
extern XStringWArray SmbiosList ;
extern INTN OldChosenTheme ;
extern INTN OldChosenConfig ;
extern INTN OldChosenSmbios ;
2023-06-22 21:50:58 +02:00
extern UINT32 gFakeCPUID ;
2023-06-16 23:44:39 +02:00
2021-04-28 20:30:34 +02:00
class SmbiosPlistClass : public ConfigPlistAbstractClass
{
using super = ConfigPlistAbstractClass ;
public :
// #include "Config_SMBIOS.h"
class SmbiosDictClass : public XmlDict
{
using super = XmlDict ;
public :
class MemoryDictClass : public XmlDict
{
using super = XmlDict ;
public :
class ModuleDictClass : public XmlDict
{
using super = XmlDict ;
public :
static ModuleDictClass NullValue ;
2021-10-02 19:44:16 +02:00
class SlotIndexClass : public XmlUInt8
2021-04-28 20:30:34 +02:00
{
2021-10-02 19:44:16 +02:00
using super = XmlUInt8 ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
if ( value ( ) > = MAX_RAM_SLOTS ) b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Slot cannot >= MAX_RAM_SLOTS. It must a number between 0 and %d at '%s:%d' " , MAX_RAM_SLOTS - 1 , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
return b ;
2021-04-28 20:30:34 +02:00
}
} ;
class TypeClass : public XmlString8AllowEmpty {
using super = XmlString8AllowEmpty ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
if ( xstring8 . isEqualIC ( " DDR " ) ) return b ;
if ( xstring8 . isEqualIC ( " DDR2 " ) ) return b ;
if ( xstring8 . isEqualIC ( " DDR3 " ) ) return b ;
if ( xstring8 . isEqualIC ( " DDR4 " ) ) return b ;
b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Type must be \" DDR \" , \" DDR2 \" , \" DDR3 \" or \" DDR4 \" in dict '%s:%d' " , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
return b ;
2021-04-28 20:30:34 +02:00
}
public :
2021-10-02 19:44:16 +02:00
} ;
SlotIndexClass SlotIndex = SlotIndexClass ( ) ;
XmlUInt32 Size = XmlUInt32 ( ) ;
XmlUInt32 Frequency = XmlUInt32 ( ) ;
XmlString8AllowEmpty Vendor = XmlString8AllowEmpty ( ) ;
XmlString8AllowEmpty Part = XmlString8AllowEmpty ( ) ;
XmlString8AllowEmpty Serial = XmlString8AllowEmpty ( ) ;
TypeClass Type = TypeClass ( ) ;
2021-04-28 20:30:34 +02:00
XmlDictField m_fields [ 7 ] = {
2021-10-02 19:44:16 +02:00
{ " Slot " , SlotIndex } ,
2021-04-28 20:30:34 +02:00
{ " Size " , Size } ,
{ " Frequency " , Frequency } ,
{ " Vendor " , Vendor } ,
{ " Part " , Part } ,
{ " Serial " , Serial } ,
{ " Type " , Type } ,
} ;
virtual void getFields ( XmlDictField * * fields , size_t * nb ) override { * fields = m_fields ; * nb = sizeof ( m_fields ) / sizeof ( m_fields [ 0 ] ) ; } ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-02 19:44:16 +02:00
XBool b = true ;
if ( ! super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ) b = false ;
if ( ! SlotIndex . isDefined ( ) ) b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Slot must be defined as a number between 0 and %d at '%s:%d' " , MAX_RAM_SLOTS - 1 , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
if ( ! Size . isDefined ( ) ) b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Size must be defined at '%s:%d' " , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
return b ;
2021-04-28 20:30:34 +02:00
}
2021-10-02 19:44:16 +02:00
// Currently a UInt8, so value is 0..255. Careful if you change for a bigger uint type !
const decltype ( SlotIndex ) : : ValueType & dgetSlotIndex ( ) const { return SlotIndex . isDefined ( ) ? SlotIndex . value ( ) : SlotIndex . nullValue ; } ;
2021-04-28 20:30:34 +02:00
const decltype ( Size ) : : ValueType & dgetModuleSize ( ) const { return Size . isDefined ( ) ? Size . value ( ) : Size . nullValue ; } ;
const decltype ( Frequency ) : : ValueType & dgetFrequency ( ) const { return Frequency . isDefined ( ) ? Frequency . value ( ) : Frequency . nullValue ; } ;
const decltype ( Vendor ) : : ValueType & dgetVendor ( ) const { return Vendor . isDefined ( ) ? Vendor . value ( ) : Vendor . nullValue ; } ;
const decltype ( Part ) : : ValueType & dgetPartNo ( ) const { return Part . isDefined ( ) ? Part . value ( ) : Part . nullValue ; } ;
const decltype ( Serial ) : : ValueType & dgetSerialNo ( ) const { return Serial . isDefined ( ) ? Serial . value ( ) : Serial . nullValue ; } ;
UINT8 dgetType ( ) const {
// if ( !Type.isDefined() ) return dgetModuleSize() > 0 ? MemoryTypeDdr3: 0;
if ( ! Type . isDefined ( ) ) return MemoryTypeDdr3 ;
if ( Type . value ( ) . isEqualIC ( " DDR2 " ) ) {
return MemoryTypeDdr2 ;
} else if ( Type . value ( ) . isEqualIC ( " DDR3 " ) ) {
return MemoryTypeDdr3 ;
} else if ( Type . value ( ) . isEqualIC ( " DDR4 " ) ) {
return MemoryTypeDdr4 ;
} else if ( Type . value ( ) . isEqualIC ( " DDR " ) ) {
return MemoryTypeDdr ;
}
// Cannot happen if validate has been done properly.
2023-06-22 21:50:58 +02:00
panic ( " invalid DDRx value " ) ;
2021-04-28 20:30:34 +02:00
}
} ;
class ModuleArrayClass : public XmlArray < ModuleDictClass >
{
2021-10-02 19:44:16 +02:00
using super = XmlArray < ModuleDictClass > ;
2021-04-28 20:30:34 +02:00
public :
2021-10-02 19:44:16 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2021-10-02 19:44:16 +02:00
if ( size ( ) > UINT8_MAX ) {
xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " You cannot declare more then 256 memory modules in dict '%s:%d' " , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
while ( size ( ) > 256 ) RemoveAtIndex ( size ( ) - 1 ) ;
}
for ( size_t i = 0 ; i < size ( ) ; i + + ) {
for ( size_t j = i + 1 ; j < size ( ) ; ) {
if ( ElementAt ( i ) . SlotIndex . value ( ) > = ElementAt ( j ) . SlotIndex . value ( ) ) {
xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Ignore duplicate memory module for slot %d at '%s:%d' " , ElementAt ( i ) . SlotIndex . value ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
RemoveAtIndex ( j ) ;
} else {
j + + ;
}
}
}
2021-10-21 11:53:15 +02:00
return b ;
2021-10-02 19:44:16 +02:00
}
decltype ( ModuleDictClass : : SlotIndex ) : : ValueType dgetCalculatedSlotCount ( ) const {
if ( ! isDefined ( ) ) return 0 ;
uint8_t max = 0 ;
for ( size_t idx = 0 ; idx < size ( ) ; + + idx ) {
if ( ElementAt ( idx ) . dgetModuleSize ( ) > 0 ) {
if ( ElementAt ( idx ) . dgetSlotIndex ( ) > max ) max = ElementAt ( idx ) . dgetSlotIndex ( ) ;
}
}
return max + 1 ;
} ;
2023-09-04 20:56:03 +02:00
const ModuleDictClass & dgetSlotAtIndex ( size_t slotIndex ) const {
2021-04-28 20:30:34 +02:00
for ( size_t idx = 0 ; idx < size ( ) ; + + idx ) {
2021-10-02 19:44:16 +02:00
if ( ElementAt ( idx ) . dgetSlotIndex ( ) = = slotIndex )
2021-04-28 20:30:34 +02:00
return ElementAt ( idx ) ;
}
return ModuleDictClass : : NullValue ;
}
} ;
2023-06-16 23:44:39 +02:00
2021-04-28 20:30:34 +02:00
XmlUInt8 SlotCount = XmlUInt8 ( ) ;
XmlUInt8 Channels = XmlUInt8 ( ) ;
ModuleArrayClass Modules = ModuleArrayClass ( ) ;
XmlDictField m_fields [ 3 ] = {
{ " SlotCount " , SlotCount } ,
{ " Channels " , Channels } ,
{ " Modules " , Modules } ,
} ;
virtual void getFields ( XmlDictField * * fields , size_t * nb ) override { * fields = m_fields ; * nb = sizeof ( m_fields ) / sizeof ( m_fields [ 0 ] ) ; } ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2021-10-17 13:20:36 +02:00
if ( Modules . size ( ) = = 0 ) {
// whatever if SlotCount is defined or not, and whatever value, it's ok.
return b ;
2021-10-02 19:44:16 +02:00
}
2021-10-17 13:20:36 +02:00
if ( ! SlotCount . isDefined ( ) ) {
xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " SlotCount is not defined in SMBIOS, but you defined memory modules. SlotCount adjusted to %d, which maybe wrong. " , Modules . dgetCalculatedSlotCount ( ) ) ) ; // do not set b to false because value is auto-corrected, so it's now ok.
2021-10-02 19:44:16 +02:00
SlotCount . setUInt8Value ( Modules . dgetCalculatedSlotCount ( ) ) ;
2021-10-17 13:20:36 +02:00
} else {
for ( size_t i = 0 ; i < Modules . size ( ) ; ) {
if ( Modules [ i ] . SlotIndex . value ( ) > = SlotCount . value ( ) ) {
xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Ignored memory module with slot >= SlotCount at '%s:%d' " , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ; // do not set b to false because value is auto-corrected, so it's now ok.
Modules . RemoveAtIndex ( i ) ;
} else {
i + + ;
}
}
if ( SlotCount . value ( ) < Modules . dgetCalculatedSlotCount ( ) ) {
log_technical_bug ( " SlotCount.value() < Modules.dgetCalculatedSlotCount() " ) ;
SlotCount . setUInt8Value ( Modules . dgetCalculatedSlotCount ( ) ) ;
}
2021-10-02 19:44:16 +02:00
}
2021-04-28 20:30:34 +02:00
return b ;
}
2021-10-02 19:44:16 +02:00
decltype ( SlotCount ) : : ValueType dgetSlotCount ( ) const { return SlotCount . isDefined ( ) ? SlotCount . value ( ) : 0 ; } ;
2021-04-28 20:30:34 +02:00
const decltype ( Channels ) : : ValueType & dgetUserChannels ( ) const { return Channels . isDefined ( ) ? Channels . value ( ) : Channels . nullValue ; } ;
} ;
class SlotDeviceDictClass : public XmlDict
{
using super = XmlDict ;
public :
static SlotDeviceDictClass NullValue ;
class DeviceClass : public XmlString8AllowEmpty {
using super = XmlString8AllowEmpty ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
if ( xstring8 . isEqualIC ( " ATI " ) ) return b ;
if ( xstring8 . isEqualIC ( " NVidia " ) ) return b ;
if ( xstring8 . isEqualIC ( " IntelGFX " ) ) return b ;
if ( xstring8 . isEqualIC ( " LAN " ) ) return b ;
if ( xstring8 . isEqualIC ( " WIFI " ) ) return b ;
if ( xstring8 . isEqualIC ( " Firewire " ) ) return b ;
if ( xstring8 . isEqualIC ( " HDMI " ) ) return b ;
if ( xstring8 . isEqualIC ( " USB " ) ) return b ;
if ( xstring8 . isEqualIC ( " NVME " ) ) return b ;
b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Type must be \" ATI \" , \" NVidia \" , \" IntelGFX \" , \" LAN \" , \" WIFI \" , \" Firewire \" , \" HDMI \" , \" USB \" or \" NVME \" in dict '%s:%d' " , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
return b ;
2021-04-28 20:30:34 +02:00
}
} Device = DeviceClass ( ) ;
XmlUInt8 ID = XmlUInt8 ( ) ;
XmlUInt8 Type = XmlUInt8 ( ) ;
XmlString8AllowEmpty Name = XmlString8AllowEmpty ( ) ;
XmlDictField m_fields [ 4 ] = {
{ " Device " , Device } ,
{ " ID " , ID } ,
{ " Type " , Type } ,
{ " Name " , Name } ,
} ;
virtual void getFields ( XmlDictField * * fields , size_t * nb ) override { * fields = m_fields ; * nb = sizeof ( m_fields ) / sizeof ( m_fields [ 0 ] ) ; } ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2021-04-28 20:30:34 +02:00
return b ;
}
const decltype ( Device ) : : ValueType & dgetDevice ( ) const { return Device . isDefined ( ) ? Device . value ( ) : Device . nullValue ; } ;
2021-05-08 11:34:17 +02:00
uint8_t dgetDeviceN ( ) const {
2021-04-28 20:30:34 +02:00
if ( ! Device . isDefined ( ) ) return 0 ;
if ( Device . value ( ) . isEqualIC ( " ATI " ) ) {
return 0 ;
} else if ( Device . value ( ) . isEqualIC ( " NVidia " ) ) {
return 1 ;
} else if ( Device . value ( ) . isEqualIC ( " IntelGFX " ) ) {
return 2 ;
} else if ( Device . value ( ) . isEqualIC ( " LAN " ) ) {
return 5 ;
} else if ( Device . value ( ) . isEqualIC ( " WIFI " ) ) {
return 6 ;
} else if ( Device . value ( ) . isEqualIC ( " Firewire " ) ) {
return 12 ;
} else if ( Device . value ( ) . isEqualIC ( " HDMI " ) ) {
return 4 ;
} else if ( Device . value ( ) . isEqualIC ( " USB " ) ) {
return 11 ;
} else if ( Device . value ( ) . isEqualIC ( " NVME " ) ) {
return 13 ;
} else {
panic ( " %s: invalid value. Check validate method. " , __PRETTY_FUNCTION__ ) ;
}
}
decltype ( ID ) : : ValueType dgetSlotID ( ) const { return ID . isDefined ( ) ? ID . value ( ) : dgetDeviceN ( ) ; } ;
MISC_SLOT_TYPE dgetSlotType ( ) const {
if ( ! Type . isDefined ( ) ) return Device . isDefined ( ) ? SlotTypePci : MISC_SLOT_TYPE ( 0 ) ;
switch ( Type . value ( ) ) {
case 0 :
return SlotTypePci ;
case 1 :
return SlotTypePciExpressX1 ;
case 2 :
return SlotTypePciExpressX2 ;
case 4 :
return SlotTypePciExpressX4 ;
case 8 :
return SlotTypePciExpressX8 ;
case 16 :
return SlotTypePciExpressX16 ;
default :
return SlotTypePciExpress ;
}
}
2021-05-08 11:34:17 +02:00
decltype ( Name ) : : ValueType dgetSlotName ( ) const { return Name . isDefined ( ) ? Name . value ( ) : Device . isDefined ( ) ? S8Printf ( " PCI Slot %hhd " , dgetDeviceN ( ) ) : NullXString8 ; } ;
2021-04-28 20:30:34 +02:00
} ;
class SlotDeviceArrayClass : public XmlArray < SlotDeviceDictClass >
{
public :
const SlotDeviceDictClass & dgetSoltDevice ( INTN slotNo ) const {
for ( size_t idx = 0 ; idx < size ( ) ; + + idx ) {
if ( ElementAt ( idx ) . dgetDeviceN ( ) = = slotNo )
return ElementAt ( idx ) ;
}
return SlotDeviceDictClass : : NullValue ;
}
} ;
class SmUUIDClass : public XmlString8AllowEmpty
{
using super = XmlString8AllowEmpty ;
protected :
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2022-04-26 00:55:56 +02:00
if ( ! EFI_GUID : : IsValidGuidString ( xstring8 ) ) b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Invalid SmUUID '%s' - should be in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX in dict '%s:%d' " , xstring8 . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
2021-10-21 11:53:15 +02:00
return b ;
2021-04-28 20:30:34 +02:00
}
} ;
class ProductNameClass : public XmlString8Trimed
{
using super = XmlString8Trimed ;
public :
ProductNameClass ( ) : super ( true ) { } ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2021-10-18 21:06:19 +02:00
MacModel Model ;
2021-04-28 20:30:34 +02:00
Model = GetModelFromString ( xstring8 ) ;
2021-10-21 11:53:15 +02:00
if ( Model = = MaxMacModel ) b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Invalid ProductName '%s' in dict '%s:%d' " , xstring8 . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
return b ;
2021-10-19 19:57:27 +02:00
}
} ;
class BiosVersionClass : public XmlString8Trimed
{
using super = XmlString8Trimed ;
public :
BiosVersionClass ( ) : super ( true ) { } ;
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2021-10-19 19:57:27 +02:00
if ( ! value ( ) . contains ( " . " ) ) {
2021-10-21 11:53:15 +02:00
b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " BiosVersion '%s' doesn't contains a dot in dict '%s:%d'. " , value ( ) . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
} else {
size_t rindex = value ( ) . rindexOf ( " . " ) ;
if ( value ( ) . length ( ) - rindex < 7 ) {
b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " Last part of BiosVersion '%s' must be at least 6 chars in dict '%s:%d'. " , value ( ) . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
}
// Should we check the format of these 6 last chars ?
2021-10-19 19:57:27 +02:00
}
2021-10-21 11:53:15 +02:00
return b ;
2021-10-19 19:57:27 +02:00
}
} ;
class BiosReleaseDateClass : public XmlString8Trimed
{
using super = XmlString8Trimed ;
public :
BiosReleaseDateClass ( ) : super ( true ) { } ;
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2021-10-19 19:57:27 +02:00
if ( value ( ) . length ( ) ! = 8 & & value ( ) . length ( ) ! = 10 ) {
2021-10-21 11:53:15 +02:00
b = xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " BiosReleaseDate '%s' must 8 or 10 chars in dict '%s:%d'. " , value ( ) . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
2021-10-19 19:57:27 +02:00
}
// Should we check the format of these 8 or 10 last chars ?
2021-10-21 11:53:15 +02:00
return b ;
2021-04-28 20:30:34 +02:00
}
} ;
protected :
XmlString8Trimed BiosVendor = XmlString8Trimed ( true ) ; // true = allow empty
2021-10-19 19:57:27 +02:00
BiosVersionClass BiosVersion = BiosVersionClass ( ) ; // RomVersion
2021-04-28 20:30:34 +02:00
XmlString8AllowEmpty EfiVersion = XmlString8AllowEmpty ( ) ;
2021-10-19 19:57:27 +02:00
BiosReleaseDateClass BiosReleaseDate = BiosReleaseDateClass ( ) ;
2021-04-28 20:30:34 +02:00
XmlString8Trimed Manufacturer = XmlString8Trimed ( true ) ;
ProductNameClass ProductName = ProductNameClass ( ) ;
XmlString8Trimed Version = XmlString8Trimed ( true ) ;
XmlString8Trimed SerialNumber = XmlString8Trimed ( true ) ;
SmUUIDClass SmUUID = SmUUIDClass ( ) ;
XmlString8Trimed Family = XmlString8Trimed ( true ) ;
XmlString8Trimed BoardManufacturer = XmlString8Trimed ( ) ;
XmlString8Trimed BoardSerialNumber = XmlString8Trimed ( ) ;
XmlString8Trimed BoardID = XmlString8Trimed ( true ) ;
XmlString8Trimed LocationInChassis = XmlString8Trimed ( true ) ;
XmlString8Trimed BoardVersion = XmlString8Trimed ( true ) ;
XmlUInt8 BoardType = XmlUInt8 ( ) ;
XmlBool Mobile = XmlBool ( ) ;
XmlUInt8 ChassisType = XmlUInt8 ( ) ;
XmlString8Trimed ChassisManufacturer = XmlString8Trimed ( true ) ;
XmlString8Trimed ChassisAssetTag = XmlString8Trimed ( true ) ;
XmlUInt16 SmbiosVersion = XmlUInt16 ( ) ;
XmlInt8 MemoryRank = XmlInt8 ( ) ; // Attribute
XmlBool Trust = XmlBool ( ) ;
XmlUInt64 PlatformFeature = XmlUInt64 ( ) ;
XmlBool NoRomInfo = XmlBool ( ) ;
2023-06-22 21:50:58 +02:00
XmlUInt32 FakeCPUID = XmlUInt32 ( ) ;
2021-04-28 20:30:34 +02:00
XmlUInt32 FirmwareFeatures = XmlUInt32 ( ) ; // gFwFeatures
XmlUInt32 FirmwareFeaturesMask = XmlUInt32 ( ) ;
2021-09-25 13:33:16 +02:00
XmlUInt64 ExtendedFirmwareFeatures = XmlUInt64 ( ) ; // gFwFeatures
XmlUInt64 ExtendedFirmwareFeaturesMask = XmlUInt64 ( ) ;
2021-04-28 20:30:34 +02:00
public :
2021-10-19 19:57:27 +02:00
MacModel defaultMacModel = MaxMacModel ;
2021-04-28 20:30:34 +02:00
MemoryDictClass Memory = MemoryDictClass ( ) ;
SlotDeviceArrayClass Slots = SlotDeviceArrayClass ( ) ;
2023-06-22 21:50:58 +02:00
XmlDictField m_fields [ 32 ] = { //32 up to FakeCPUID
2021-04-28 20:30:34 +02:00
{ " Trust " , Trust } ,
{ " MemoryRank " , MemoryRank } ,
{ " Memory " , Memory } ,
{ " Slots " , Slots } ,
{ " ProductName " , ProductName } ,
{ " SmbiosVersion " , SmbiosVersion } ,
{ " BiosVersion " , BiosVersion } ,
{ " BiosReleaseDate " , BiosReleaseDate } ,
{ " EfiVersion " , EfiVersion } ,
{ " FirmwareFeatures " , FirmwareFeatures } ,
{ " FirmwareFeaturesMask " , FirmwareFeaturesMask } ,
2021-09-25 13:33:16 +02:00
{ " ExtendedFirmwareFeatures " , ExtendedFirmwareFeatures } ,
{ " ExtendedFirmwareFeaturesMask " , ExtendedFirmwareFeaturesMask } ,
2021-04-28 20:30:34 +02:00
{ " PlatformFeature " , PlatformFeature } ,
{ " BiosVendor " , BiosVendor } ,
{ " Manufacturer " , Manufacturer } ,
{ " Version " , Version } ,
{ " Family " , Family } ,
{ " SerialNumber " , SerialNumber } ,
{ " SmUUID " , SmUUID } ,
{ " BoardManufacturer " , BoardManufacturer } ,
{ " BoardSerialNumber " , BoardSerialNumber } ,
{ " Board-ID " , BoardID } ,
{ " BoardVersion " , BoardVersion } ,
{ " BoardType " , BoardType } ,
{ " Mobile " , Mobile } ,
{ " LocationInChassis " , LocationInChassis } ,
{ " ChassisManufacturer " , ChassisManufacturer } ,
{ " ChassisAssetTag " , ChassisAssetTag } ,
{ " ChassisType " , ChassisType } ,
{ " NoRomInfo " , NoRomInfo } ,
2023-06-22 21:50:58 +02:00
{ " FakeCPUID " , FakeCPUID } ,
2021-04-28 20:30:34 +02:00
} ;
virtual void getFields ( XmlDictField * * fields , size_t * nb ) override { * fields = m_fields ; * nb = sizeof ( m_fields ) / sizeof ( m_fields [ 0 ] ) ; } ;
2021-09-28 15:54:31 +02:00
virtual XBool validate ( XmlLiteParser * xmlLiteParser , const XString8 & xmlPath , const XmlParserPosition & keyPos , XBool generateErrors ) override {
2021-10-21 11:53:15 +02:00
bool b = super : : validate ( xmlLiteParser , xmlPath , keyPos , generateErrors ) ;
2021-10-19 19:57:27 +02:00
if ( ! ProductName . isDefined ( ) ) {
2021-10-10 19:08:20 +02:00
// return xmlLiteParser->addWarning(generateErrors, S8Printf("ProductName is not defined, the whole SMBIOS dict is ignored at line %d.", keyPos.getLine()));
2021-10-30 08:58:43 +02:00
// if ( defaultMacModel < MaxMacModel ) {
// ProductName.setStringValue(MachineModelName[defaultMacModel]);
// }
2021-10-19 19:57:27 +02:00
}
2021-10-30 08:58:43 +02:00
if ( dgetModel ( ) < MaxMacModel ) {
2021-10-19 19:57:27 +02:00
if ( BiosVersion . isDefined ( ) ) {
2021-10-30 08:58:43 +02:00
if ( ! is2ndBiosVersionGreaterThan1st ( ApplePlatformDataArray [ dgetModel ( ) ] . firmwareVersion , BiosVersion . value ( ) ) ) {
xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " BiosVersion '%s' is before than default ('%s') -> ignored. Dict '%s:%d'. " , BiosVersion . value ( ) . c_str ( ) , ApplePlatformDataArray [ dgetModel ( ) ] . firmwareVersion . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ; // Do not set b to false : we don't want to invalidate the whole dict
xmlLiteParser - > productNameNeeded = ! getProductName ( ) . isDefined ( ) ;
2021-04-28 20:30:34 +02:00
BiosVersion . reset ( ) ;
2021-10-29 21:56:32 +02:00
} else
2021-10-30 08:58:43 +02:00
if ( is2ndBiosVersionEqual ( ApplePlatformDataArray [ dgetModel ( ) ] . firmwareVersion , BiosVersion . value ( ) ) ) {
2021-10-29 21:56:32 +02:00
xmlLiteParser - > addInfo ( generateErrors , S8Printf ( " BiosVersion '%s' is the same as default. Dict '%s:%d'. " , BiosVersion . value ( ) . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ; // Do not set b to false : we don't want to invalidate the whole dict
2021-10-30 08:58:43 +02:00
xmlLiteParser - > productNameNeeded = ! getProductName ( ) . isDefined ( ) ;
2021-10-29 21:56:32 +02:00
BiosVersion . reset ( ) ;
2021-04-28 20:30:34 +02:00
}
}
2021-10-19 19:57:27 +02:00
if ( BiosReleaseDate . isDefined ( ) ) {
2021-10-30 08:58:43 +02:00
int compareReleaseDateResult = compareReleaseDate ( GetReleaseDate ( dgetModel ( ) ) , BiosReleaseDate . value ( ) ) ;
2021-10-30 06:39:10 +02:00
if ( compareReleaseDateResult = = 1 ) {
2021-10-30 08:58:43 +02:00
xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " BiosReleaseDate '%s' is older than default ('%s') -> ignored. Dict '%s:%d'. " , BiosReleaseDate . value ( ) . c_str ( ) , GetReleaseDate ( dgetModel ( ) ) . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ; // Do not set b to false : we don't want to invalidate the whole dict
xmlLiteParser - > productNameNeeded = ! getProductName ( ) . isDefined ( ) ;
2021-10-30 06:39:10 +02:00
BiosReleaseDate . reset ( ) ;
} else
2021-10-19 19:57:27 +02:00
if ( compareReleaseDateResult = = 0 ) {
// This is just 'info'. It's useless but fine to define the same as default.
2021-10-29 21:56:32 +02:00
xmlLiteParser - > addInfo ( generateErrors , S8Printf ( " BiosReleaseDate '%s' is the same as default. Dict '%s:%d'. " , BiosReleaseDate . value ( ) . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ; // Do not set b to false : we don't want to invalidate the whole dict
2021-10-30 08:58:43 +02:00
xmlLiteParser - > productNameNeeded = ! getProductName ( ) . isDefined ( ) ;
2021-10-19 19:57:27 +02:00
BiosReleaseDate . reset ( ) ;
}
}
if ( EfiVersion . isDefined ( ) ) {
2023-05-30 23:17:19 +02:00
long long int result = AsciiStrVersionToUint64 ( ApplePlatformDataArray [ dgetModel ( ) ] . efiversion , 4 , 3 ) ;
long long int result2 = AsciiStrVersionToUint64 ( EfiVersion . value ( ) , 4 , 3 ) ;
if ( result > result2 ) {
2021-10-21 11:53:15 +02:00
xmlLiteParser - > addWarning ( generateErrors , S8Printf ( " EfiVersion '%s' is older than default ('%s') -> ignored. Dict '%s:%d'. " , EfiVersion . value ( ) . c_str ( ) , ApplePlatformDataArray [ dgetModel ( ) ] . efiversion . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ; // Do not set b to false : we don't want to invalidate the whole dict
2021-10-30 08:58:43 +02:00
xmlLiteParser - > productNameNeeded = ! getProductName ( ) . isDefined ( ) ;
2021-10-19 19:57:27 +02:00
EfiVersion . reset ( ) ;
2023-05-30 23:17:19 +02:00
} else if ( result = = result2 ) {
2021-10-29 21:56:32 +02:00
xmlLiteParser - > addInfo ( generateErrors , S8Printf ( " EfiVersion '%s' is the same as default. Dict '%s:%d'. " , EfiVersion . value ( ) . c_str ( ) , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ; // Do not set b to false : we don't want to invalidate the whole dict
2021-10-30 08:58:43 +02:00
xmlLiteParser - > productNameNeeded = ! getProductName ( ) . isDefined ( ) ;
2021-10-30 06:39:10 +02:00
EfiVersion . reset ( ) ;
2021-10-19 19:57:27 +02:00
}
}
} else {
// This is supposed to never happen within Clover, because Clover initialise defaultMacModel.
2021-10-30 08:58:43 +02:00
xmlLiteParser - > addInfo ( generateErrors , S8Printf ( " Cannot check validity of BiosVersion, BiosReleaseDate and EfiVersion because ProductName is not set in dict '%s:%d'. Define ProductName or run this tool with --productname=[your product name]. " , xmlPath . c_str ( ) , keyPos . getLine ( ) ) ) ;
2021-04-28 20:30:34 +02:00
}
2021-10-21 11:53:15 +02:00
return b ;
2021-04-28 20:30:34 +02:00
}
const decltype ( Trust ) & getTrust ( ) const { return Trust ; }
const decltype ( MemoryRank ) & getMemoryRank ( ) const { return MemoryRank ; }
const decltype ( Memory ) & getMemory ( ) const { return Memory ; }
const decltype ( Slots ) & getSlots ( ) const { return Slots ; }
const decltype ( ProductName ) & getProductName ( ) const { return ProductName ; }
const decltype ( SmbiosVersion ) & getSmbiosVersion ( ) const { return SmbiosVersion ; }
const decltype ( BiosVersion ) & getBiosVersion ( ) const { return BiosVersion ; }
const decltype ( BiosReleaseDate ) & getBiosReleaseDate ( ) const { return BiosReleaseDate ; }
const decltype ( EfiVersion ) & getEfiVersion ( ) const { return EfiVersion ; }
const decltype ( FirmwareFeatures ) & getFirmwareFeatures ( ) const { return FirmwareFeatures ; }
const decltype ( FirmwareFeaturesMask ) & getFirmwareFeaturesMask ( ) const { return FirmwareFeaturesMask ; }
2021-09-25 13:33:16 +02:00
const decltype ( ExtendedFirmwareFeatures ) & getExtendedFirmwareFeatures ( ) const { return ExtendedFirmwareFeatures ; }
const decltype ( ExtendedFirmwareFeaturesMask ) & getExtendedFirmwareFeaturesMask ( ) const { return ExtendedFirmwareFeaturesMask ; }
2021-04-28 20:30:34 +02:00
const decltype ( PlatformFeature ) & getPlatformFeature ( ) const { return PlatformFeature ; }
const decltype ( BiosVendor ) & getBiosVendor ( ) const { return BiosVendor ; }
const decltype ( Manufacturer ) & getManufacturer ( ) const { return Manufacturer ; }
const decltype ( Version ) & getVersion ( ) const { return Version ; }
const decltype ( Family ) & getFamily ( ) const { return Family ; }
const decltype ( SerialNumber ) & getSerialNumber ( ) const { return SerialNumber ; }
const decltype ( SmUUID ) & getSmUUID ( ) const { return SmUUID ; }
const decltype ( BoardManufacturer ) & getBoardManufacturer ( ) const { return BoardManufacturer ; }
const decltype ( BoardSerialNumber ) & getBoardSerialNumber ( ) const { return BoardSerialNumber ; }
const decltype ( BoardID ) & getBoardID ( ) const { return BoardID ; }
const decltype ( BoardVersion ) & getBoardVersion ( ) const { return BoardVersion ; }
const decltype ( BoardType ) & getBoardType ( ) const { return BoardType ; }
const decltype ( Mobile ) & getMobile ( ) const { return Mobile ; }
const decltype ( LocationInChassis ) & getLocationInChassis ( ) const { return LocationInChassis ; }
const decltype ( ChassisManufacturer ) & getChassisManufacturer ( ) const { return ChassisManufacturer ; }
const decltype ( ChassisAssetTag ) & getChassisAssetTag ( ) const { return ChassisAssetTag ; }
const decltype ( ChassisType ) & getChassisType ( ) const { return ChassisType ; }
const decltype ( NoRomInfo ) & getNoRomInfo ( ) const { return NoRomInfo ; }
2023-06-22 21:50:58 +02:00
// const decltype(FakeCPUID)& getFakeCPUID() const { return FakeCPUID.isDefined() ? FakeCPUID.value() : gSettings.KernelAndKextPatches.FakeCPUID; };
2021-04-28 20:30:34 +02:00
2021-10-18 21:06:19 +02:00
MacModel dgetModel ( ) const
2021-04-28 20:30:34 +02:00
{
2021-10-30 08:58:43 +02:00
if ( ProductName . isDefined ( ) ) return GetModelFromString ( ProductName . value ( ) ) ;
if ( defaultMacModel < MaxMacModel ) return defaultMacModel ;
return MaxMacModel ;
2021-04-28 20:30:34 +02:00
}
decltype ( BiosVendor ) : : ValueType dgetBiosVendor ( ) const {
if ( BiosVendor . isDefined ( ) ) return BiosVendor . value ( ) ;
return AppleBiosVendor ;
} ;
decltype ( BiosVersion ) : : ValueType dgetBiosVersion ( ) const {
if ( BiosVersion . isDefined ( ) ) return BiosVersion . value ( ) ;
2021-10-18 21:06:19 +02:00
return ApplePlatformDataArray [ dgetModel ( ) ] . firmwareVersion ;
2021-04-28 20:30:34 +02:00
} ;
decltype ( EfiVersion ) : : ValueType dgetEfiVersion ( ) const {
2021-10-18 21:06:19 +02:00
if ( ! EfiVersion . isDefined ( ) ) return ApplePlatformDataArray [ dgetModel ( ) ] . efiversion ;
2021-04-28 20:30:34 +02:00
XString8 returnValue ;
returnValue = EfiVersion . value ( ) ;
returnValue . trim ( ) ;
return returnValue ;
}
decltype ( BiosReleaseDate ) : : ValueType dgetBiosReleaseDate ( ) const
{
if ( BiosReleaseDate . isDefined ( ) ) return BiosReleaseDate . value ( ) ;
XString8 dBiosVersion = dgetBiosVersion ( ) ;
XString8 returnValue ;
if ( dBiosVersion . notEmpty ( ) ) {
if ( ! dBiosVersion . contains ( " . " ) ) {
log_technical_bug ( " !dBiosVersion.contains( \" . \" ) " ) ; // Must not happen, BiosVersion has been validated to have a '.' followed by 6 chars.
return NullXString8 ;
}
const char * i = dBiosVersion . c_str ( ) ;
i + = AsciiStrLen ( i ) ;
while ( * i ! = ' . ' ) i - - ;
if ( strlen ( i ) < 7 ) {
log_technical_bug ( " strlen(i) < 7 " ) ; // Must not happen, BiosVersion has been validated to have a '.' followed by 6 chars.
return NullXString8 ;
}
if ( isReleaseDateWithYear20 ( dgetModel ( ) ) ) {
returnValue . S8Printf ( " %c%c/%c%c/20%c%c " , i [ 3 ] , i [ 4 ] , i [ 5 ] , i [ 6 ] , i [ 1 ] , i [ 2 ] ) ;
} else {
returnValue . S8Printf ( " %c%c/%c%c/%c%c " , i [ 3 ] , i [ 4 ] , i [ 5 ] , i [ 6 ] , i [ 1 ] , i [ 2 ] ) ;
}
}
return returnValue ;
}
decltype ( Manufacturer ) : : ValueType dgetManufactureName ( ) const {
if ( Manufacturer . isDefined ( ) ) return Manufacturer . value ( ) ;
return AppleBiosVendor ;
} ;
const decltype ( ProductName ) : : ValueType & dgetProductName ( ) const { return ProductName . isDefined ( ) ? ProductName . value ( ) : ProductName . nullValue ; } ;
decltype ( Version ) : : ValueType dgetSystemVersion ( ) const {
if ( Version . isDefined ( ) ) return Version . value ( ) ;
2021-10-18 21:06:19 +02:00
return ApplePlatformDataArray [ dgetModel ( ) ] . systemVersion ;
2021-04-28 20:30:34 +02:00
} ;
2021-10-18 21:06:19 +02:00
const decltype ( SerialNumber ) : : ValueType dgetSerialNr ( ) const {
2021-04-28 20:30:34 +02:00
if ( SerialNumber . isDefined ( ) ) return SerialNumber . value ( ) ;
2021-10-18 21:06:19 +02:00
return ApplePlatformDataArray [ dgetModel ( ) ] . serialNumber ;
2021-04-28 20:30:34 +02:00
} ;
2022-04-26 00:55:56 +02:00
EFI_GUID dgetSmUUID ( ) const {
if ( ! SmUUID . isDefined ( ) ) return nullGuid ;
EFI_GUID g ;
2022-05-07 16:03:25 +02:00
g . takeValueFromBE ( SmUUID . value ( ) ) ;
2022-04-26 00:55:56 +02:00
if ( g . isNull ( ) ) panic ( " SmUUID is not valid. This could not happen because SmUUID is checked to be valid. Did you comment out the validation ? " ) ;
return g ;
}
2021-04-28 20:30:34 +02:00
decltype ( Family ) : : ValueType dgetFamilyName ( ) const {
if ( Family . isDefined ( ) ) return Family . value ( ) ;
2021-10-18 21:06:19 +02:00
return ApplePlatformDataArray [ dgetModel ( ) ] . productFamily ;
2021-04-28 20:30:34 +02:00
} ;
decltype ( BoardManufacturer ) : : ValueType dgetBoardManufactureName ( ) const {
if ( BoardManufacturer . isDefined ( ) ) return BoardManufacturer . value ( ) ;
return dgetBiosVendor ( ) ;
} ;
decltype ( BoardSerialNumber ) : : ValueType dgetBoardSerialNumber ( ) const {
if ( BoardSerialNumber . isDefined ( ) ) return BoardSerialNumber . value ( ) ;
return AppleBoardSN ;
} ;
decltype ( BoardID ) : : ValueType dgetBoardNumber ( ) const {
if ( BoardID . isDefined ( ) ) return BoardID . value ( ) ;
2021-10-18 21:06:19 +02:00
return ApplePlatformDataArray [ dgetModel ( ) ] . boardID ;
2021-04-28 20:30:34 +02:00
} ;
decltype ( LocationInChassis ) : : ValueType dgetLocationInChassis ( ) const {
if ( LocationInChassis . isDefined ( ) ) return LocationInChassis . value ( ) ;
return AppleBoardLocation ;
} ;
decltype ( BoardVersion ) : : ValueType dgetBoardVersion ( ) const {
return BoardVersion . isDefined ( ) ? BoardVersion . value ( ) : dgetProductName ( ) ;
} ;
decltype ( BoardType ) : : ValueType dgetBoardType ( ) const {
if ( BoardType . isDefined ( ) ) return BoardType . value ( ) ;
2021-10-18 21:06:19 +02:00
MacModel Model = dgetModel ( ) ;
2021-04-28 20:30:34 +02:00
if ( ( Model > MacPro31 ) & & ( Model < MacPro71 ) ) {
return BaseBoardTypeProcessorMemoryModule ; //0xB;
} else {
return BaseBoardTypeMotherBoard ; //0xA;
}
} ;
decltype ( Mobile ) : : ValueType dgetMobile ( ) const {
if ( Mobile . isDefined ( ) ) return Mobile . value ( ) ;
return GetMobile ( dgetModel ( ) ) ;
} ;
decltype ( ChassisType ) : : ValueType dgetChassisType ( ) const {
if ( ChassisType . isDefined ( ) ) return ChassisType . value ( ) ;
return GetChassisTypeFromModel ( dgetModel ( ) ) ;
} ;
decltype ( ChassisManufacturer ) : : ValueType dgetChassisManufacturer ( ) const {
if ( ChassisManufacturer . isDefined ( ) ) return ChassisManufacturer . value ( ) ;
return dgetBiosVendor ( ) ;
} ;
decltype ( ChassisAssetTag ) : : ValueType dgetChassisAssetTag ( ) const {
if ( ChassisAssetTag . isDefined ( ) ) return ChassisAssetTag . value ( ) ;
2021-10-18 21:06:19 +02:00
return ApplePlatformDataArray [ dgetModel ( ) ] . chassisAsset ;
2021-04-28 20:30:34 +02:00
} ;
decltype ( SmbiosVersion ) : : ValueType dgetSmbiosVersion ( ) const { return SmbiosVersion . isDefined ( ) ? SmbiosVersion . value ( ) : 0x204 ; } ;
decltype ( MemoryRank ) : : ValueType dgetAttribute ( ) const { return MemoryRank . isDefined ( ) ? MemoryRank . value ( ) : - 1 ; } ;
2021-09-28 15:54:31 +02:00
decltype ( Trust ) : : ValueType dgetTrustSMBIOS ( ) const { return Trust . isDefined ( ) ? Trust . value ( ) : XBool ( true ) ; } ;
2021-10-02 19:44:16 +02:00
XBool dgetInjectMemoryTables ( ) const { return Memory . Modules . isDefined ( ) & & Memory . Modules . size ( ) > 0 ? Memory . dgetSlotCount ( ) > 0 : false ; } ;
2021-04-28 20:30:34 +02:00
decltype ( PlatformFeature ) : : ValueType dgetgPlatformFeature ( ) const {
if ( PlatformFeature . isDefined ( ) ) return PlatformFeature . value ( ) ;
return GetPlatformFeature ( dgetModel ( ) ) ;
} ;
const decltype ( NoRomInfo ) : : ValueType & dgetNoRomInfo ( ) const { return NoRomInfo . isDefined ( ) ? NoRomInfo . value ( ) : NoRomInfo . nullValue ; } ;
2023-06-22 21:50:58 +02:00
const decltype ( FakeCPUID ) : : ValueType & dgetFakeCPUID ( ) const { return FakeCPUID . isDefined ( ) ? FakeCPUID . value ( ) : gFakeCPUID ; } ;
2021-04-28 20:30:34 +02:00
decltype ( FirmwareFeatures ) : : ValueType dgetFirmwareFeatures ( ) const {
if ( FirmwareFeatures . isDefined ( ) ) return FirmwareFeatures . value ( ) ;
return GetFwFeatures ( dgetModel ( ) ) ;
} ;
decltype ( FirmwareFeaturesMask ) : : ValueType dgetFirmwareFeaturesMask ( ) const {
if ( FirmwareFeaturesMask . isDefined ( ) ) return FirmwareFeaturesMask . value ( ) ;
return GetFwFeaturesMaskFromModel ( dgetModel ( ) ) ;
2021-09-25 13:33:16 +02:00
} ;
decltype ( ExtendedFirmwareFeatures ) : : ValueType dgetExtendedFirmwareFeatures ( ) const {
if ( ExtendedFirmwareFeatures . isDefined ( ) ) return ExtendedFirmwareFeatures . value ( ) ;
return GetExtFwFeatures ( dgetModel ( ) ) ;
} ;
decltype ( ExtendedFirmwareFeaturesMask ) : : ValueType dgetExtendedFirmwareFeaturesMask ( ) const {
if ( ExtendedFirmwareFeaturesMask . isDefined ( ) ) return ExtendedFirmwareFeaturesMask . value ( ) ;
return GetExtFwFeaturesMask ( dgetModel ( ) ) ;
2023-06-22 21:50:58 +02:00
} ;
2021-04-28 20:30:34 +02:00
} ;
SmbiosDictClass SMBIOS = SmbiosDictClass ( ) ;
2023-06-16 23:44:39 +02:00
SmbiosDictClass SMBIOS_lion = SmbiosDictClass ( ) ;
2023-06-18 20:54:30 +02:00
SmbiosDictClass SMBIOS_cougar = SmbiosDictClass ( ) ;
2023-06-16 23:44:39 +02:00
SmbiosDictClass SMBIOS_mav = SmbiosDictClass ( ) ;
2023-06-18 20:54:30 +02:00
SmbiosDictClass SMBIOS_yos = SmbiosDictClass ( ) ;
2023-06-16 23:44:39 +02:00
SmbiosDictClass SMBIOS_cap = SmbiosDictClass ( ) ;
2023-06-18 20:54:30 +02:00
SmbiosDictClass SMBIOS_sierra = SmbiosDictClass ( ) ;
2023-06-16 23:44:39 +02:00
SmbiosDictClass SMBIOS_hsierra = SmbiosDictClass ( ) ;
SmbiosDictClass SMBIOS_moja = SmbiosDictClass ( ) ;
SmbiosDictClass SMBIOS_cata = SmbiosDictClass ( ) ;
SmbiosDictClass SMBIOS_bigsur = SmbiosDictClass ( ) ;
SmbiosDictClass SMBIOS_monterey = SmbiosDictClass ( ) ;
SmbiosDictClass SMBIOS_ventura = SmbiosDictClass ( ) ;
SmbiosDictClass SMBIOS_sonoma = SmbiosDictClass ( ) ;
2021-04-28 20:30:34 +02:00
2023-06-18 20:54:30 +02:00
XmlDictField m_fields [ 14 ] = {
2021-04-28 20:30:34 +02:00
{ " SMBIOS " , SMBIOS } ,
2023-06-16 23:44:39 +02:00
{ " SMBIOS_lion " , SMBIOS_lion } ,
2023-06-18 20:54:30 +02:00
{ " SMBIOS_cougar " , SMBIOS_cougar } ,
2023-06-16 23:44:39 +02:00
{ " SMBIOS_mav " , SMBIOS_mav } ,
2023-06-18 20:54:30 +02:00
{ " SMBIOS_yos " , SMBIOS_yos } ,
2023-06-16 23:44:39 +02:00
{ " SMBIOS_cap " , SMBIOS_cap } ,
2023-06-18 20:54:30 +02:00
{ " SMBIOS_sierra " , SMBIOS_sierra } ,
2023-06-16 23:44:39 +02:00
{ " SMBIOS_hsierra " , SMBIOS_hsierra } ,
{ " SMBIOS_moja " , SMBIOS_moja } ,
{ " SMBIOS_cata " , SMBIOS_cata } ,
{ " SMBIOS_bigsur " , SMBIOS_bigsur } ,
{ " SMBIOS_monterey " , SMBIOS_monterey } ,
{ " SMBIOS_ventura " , SMBIOS_ventura } ,
{ " SMBIOS_sonoma " , SMBIOS_sonoma } ,
2021-04-28 20:30:34 +02:00
} ;
public :
virtual void getFields ( XmlDictField * * fields , size_t * nb ) override { * fields = m_fields ; * nb = sizeof ( m_fields ) / sizeof ( m_fields [ 0 ] ) ; } ;
public :
SmbiosPlistClass ( ) { } ;
2023-06-16 23:44:39 +02:00
const decltype ( SMBIOS ) & getSMBIOS ( ) const {
for ( size_t i = 0 ; i < sizeof ( m_fields ) / sizeof ( m_fields [ 0 ] ) ; i + + ) {
XStringW h ;
h . takeValueFrom ( m_fields [ i ] . m_name ) ;
if ( SmbiosList . size ( ) > 0 & & SmbiosList [ OldChosenSmbios ] = = h ) {
return static_cast < SmbiosDictClass & > ( m_fields [ i ] . xmlAbstractType ) ;
}
}
return SMBIOS ;
} ;
2021-04-28 20:30:34 +02:00
} ;
# endif /* _SMBIOSPLISTCLASS_H_ */