diff --git a/common/descriptor.h b/common/descriptor.h index edd324f..aaf426c 100644 --- a/common/descriptor.h +++ b/common/descriptor.h @@ -34,6 +34,22 @@ typedef struct FLASH_DESCRIPTOR_HEADER_ { // Maximum base value in descriptor map #define FLASH_DESCRIPTOR_MAX_BASE 0xE0 +// Descriptor version was reserved in older firmware +#define FLASH_DESCRIPTOR_VERSION_INVALID 0xFFFFFFFF + +// Descriptor version present in Coffee Lake and newer +typedef struct _FLASH_DESCRIPTOR_VERSION_V3 { + UINT32 Reserved : 14; + UINT32 VersionMinor : 7; + UINT32 VersionMajor : 11; +} FLASH_DESCRIPTOR_VERSION_V3; + +// Descripror version +typedef union _FLASH_DESCRIPTOR_VERSION { + UINT32 RawValue; + FLASH_DESCRIPTOR_VERSION_V3 V3; +} FLASH_DESCRIPTOR_VERSION; + // Descriptor map // Base fields are storing bits [11:4] of actual base addresses, all other bits are 0 typedef struct FLASH_DESCRIPTOR_MAP_ { @@ -54,6 +70,8 @@ typedef struct FLASH_DESCRIPTOR_MAP_ { UINT32 ProcStrapsBase : 8; UINT32 NumberOfProcStraps : 8; // One-based number of UINT32s to read as processor straps, min=0, max=255 (1 Kb) UINT32 : 16; + // FLMAP 3 + FLASH_DESCRIPTOR_VERSION Version; // Reserved prior to v3 } FLASH_DESCRIPTOR_MAP; // Component section diff --git a/common/ffsparser.cpp b/common/ffsparser.cpp index db47964..f13c34c 100644 --- a/common/ffsparser.cpp +++ b/common/ffsparser.cpp @@ -317,9 +317,11 @@ USTATUS FfsParser::parseIntelImage(const UByteArray & intelImage, const UINT32 l const FLASH_DESCRIPTOR_REGION_SECTION* regionSection = (const FLASH_DESCRIPTOR_REGION_SECTION*)calculateAddress8((UINT8*)descriptor, descriptorMap->RegionBase); const FLASH_DESCRIPTOR_COMPONENT_SECTION* componentSection = (const FLASH_DESCRIPTOR_COMPONENT_SECTION*)calculateAddress8((UINT8*)descriptor, descriptorMap->ComponentBase); - // Check descriptor version by getting hardcoded value of FlashParameters.ReadClockFrequency UINT8 descriptorVersion = 0; - if (componentSection->FlashParameters.ReadClockFrequency == FLASH_FREQUENCY_20MHZ) // Old descriptor + if (descriptorMap->Version.RawValue != FLASH_DESCRIPTOR_VERSION_INVALID) // Kaby Lake+ descriptor + descriptorVersion = 3; + // Check descriptor version by getting hardcoded value of FlashParameters.ReadClockFrequency + else if (componentSection->FlashParameters.ReadClockFrequency == FLASH_FREQUENCY_20MHZ) // Old descriptor descriptorVersion = 1; else // Skylake+ descriptor descriptorVersion = 2;