Merge pull request #274 from LongSoft/PR/fpt_header_21

Add support for Intel ME FPT header version 2.1
This commit is contained in:
Nikolaj Schlej 2022-08-25 09:27:32 +02:00 committed by GitHub
commit 4c74232688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 81 additions and 24 deletions

View File

@ -107,6 +107,9 @@ UString jedecIdToUString(UINT8 vendorId, UINT8 deviceId0, UINT8 deviceId1)
case 0x204013: return UString("Micron M45PE40");
case 0x204014: return UString("Micron M45PE80");
case 0x204015: return UString("Micron M45PE16");
case 0x204017: return UString("Micron XM25QH64C");
case 0x204018: return UString("Micron XM25QH128C");
case 0x204019: return UString("Micron XM25QH256C");
case 0x207114: return UString("Micron M25PX80");
case 0x207115: return UString("Micron M25PX16");
case 0x207116: return UString("Micron M25PX32");

View File

@ -162,7 +162,7 @@ UString bpdtEntryTypeToUString(const UINT16 type)
case BPDT_ENTRY_TYPE_IFP_OVERRIDE: return UString("IFP Override");
case BPDT_ENTRY_TYPE_DEBUG_TOKENS: return UString("Debug Tokens");
case BPDT_ENTRY_TYPE_USF_PHY_CONFIG: return UString("USF Phy Config");
case BPDT_ENTRY_TYPE_USB_GPP_LUN_ID: return UString("USF GPP LUN ID");
case BPDT_ENTRY_TYPE_USF_GPP_LUN_ID: return UString("USF GPP LUN ID");
case BPDT_ENTRY_TYPE_PMC: return UString("PMC");
case BPDT_ENTRY_TYPE_IUNIT: return UString("iUnit");
case BPDT_ENTRY_TYPE_NVM_CONFIG: return UString("NVM Config");
@ -175,6 +175,8 @@ UString bpdtEntryTypeToUString(const UINT16 type)
case BPDT_ENTRY_TYPE_TCSS_FW_IOM: return UString("TCSS FW IOM");
case BPDT_ENTRY_TYPE_TCSS_FW_PHY: return UString("TCSS FW PHY");
case BPDT_ENTRY_TYPE_TBT: return UString("TCSS TBT");
case BPDT_ENTRY_TYPE_USB_PHY: return UString("USB PHY");
case BPDT_ENTRY_TYPE_PCHC: return UString("PCHC");
case BPDT_ENTRY_TYPE_SAMF: return UString("SAMF");
case BPDT_ENTRY_TYPE_PPHY: return UString("PPHY");
default: return usprintf("Unknown %u", type);

View File

@ -635,7 +635,7 @@ typedef struct BPDT_ENTRY_ {
#define BPDT_ENTRY_TYPE_IFP_OVERRIDE 10
#define BPDT_ENTRY_TYPE_DEBUG_TOKENS 11
#define BPDT_ENTRY_TYPE_USF_PHY_CONFIG 12
#define BPDT_ENTRY_TYPE_USB_GPP_LUN_ID 13
#define BPDT_ENTRY_TYPE_USF_GPP_LUN_ID 13
#define BPDT_ENTRY_TYPE_PMC 14
#define BPDT_ENTRY_TYPE_IUNIT 15
#define BPDT_ENTRY_TYPE_NVM_CONFIG 16
@ -648,6 +648,8 @@ typedef struct BPDT_ENTRY_ {
#define BPDT_ENTRY_TYPE_TCSS_FW_IOM 23
#define BPDT_ENTRY_TYPE_TCSS_FW_PHY 24
#define BPDT_ENTRY_TYPE_TBT 25
#define BPDT_ENTRY_TYPE_USB_PHY 31
#define BPDT_ENTRY_TYPE_PCHC 32
#define BPDT_ENTRY_TYPE_SAMF 41
#define BPDT_ENTRY_TYPE_PPHY 42

View File

@ -4648,6 +4648,8 @@ make_partition_table_consistent:
// TODO: make this generic again
if (partitions[i].ptEntry.Type > BPDT_ENTRY_TYPE_TBT
&& partitions[i].ptEntry.Type != BPDT_ENTRY_TYPE_USB_PHY
&& partitions[i].ptEntry.Type != BPDT_ENTRY_TYPE_PCHC
&& partitions[i].ptEntry.Type != BPDT_ENTRY_TYPE_SAMF
&& partitions[i].ptEntry.Type != BPDT_ENTRY_TYPE_PPHY) {
msg(usprintf("%s: BPDT entry of unknown type found", __FUNCTION__), partitionIndex);

View File

@ -34,23 +34,43 @@ const UByteArray ME_VERSION_SIGNATURE2("\x24\x4D\x4E\x32", 4); //$MN2
#define ME_ROM_BYPASS_VECTOR_SIZE 0x10
const UByteArray FPT_HEADER_SIGNATURE("\x24\x46\x50\x54", 4); //$FPT
// Header version 1.0 or 2.0, default
typedef struct FPT_HEADER_ {
UINT32 Signature;
UINT32 NumEntries;
UINT8 HeaderVersion;
UINT8 HeaderVersion; // 0x10 or 0x20
UINT8 EntryVersion;
UINT8 HeaderLength;
UINT8 Checksum; // One bit for Redundant before IFWI
UINT16 TicksToAdd;
UINT16 TokensToAdd;
UINT32 UmaSize; // Flags in SPS
UINT32 FlashLayout; // Crc32 before IFWI
UINT8 HeaderChecksum; // One bit for Redundant
UINT16 FlashCycleLife; // Maybe also TicksToAdd
UINT16 FlashCycleLimit;// Maybe also TokensToAdd
UINT32 UmaSize; // Maybe also Flags
UINT32 Flags; // Maybe also FlashLayout
UINT16 FitcMajor;
UINT16 FitcMinor;
UINT16 FitcHotfix;
UINT16 FitcBuild;
} FPT_HEADER;
// Header version 2.1, special case
#define FPT_HEADER_VERSION_21 0x21
typedef struct FPT_HEADER_21_ {
UINT32 Signature;
UINT32 NumEntries;
UINT8 HeaderVersion; // 0x21
UINT8 EntryVersion;
UINT8 HeaderLength;
UINT8 Flags; // One bit for Redundant
UINT16 TicksToAdd;
UINT16 TokensToAdd;
UINT32 SPSFlags;
UINT32 HeaderCrc32; // Header + Entries sums to 0
UINT16 FitcMajor;
UINT16 FitcMinor;
UINT16 FitcHotfix;
UINT16 FitcBuild;
} FPT_HEADER_21;
typedef struct FPT_HEADER_ENTRY_{
CHAR8 Name[4];
CHAR8 Owner[4];

View File

@ -131,22 +131,50 @@ USTATUS MeParser::parseFptRegion(const UByteArray & region, const UModelIndex &
UByteArray body = region.mid(header.size(), ptBodySize);
UString name = UString("FPT partition table");
UString info = usprintf("Full size: %Xh (%u)\nHeader size: %" PRIXQ "h (%" PRIuQ ")\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n"
"Header length: %02Xh\nTicks to add: %04Xh\nTokens to add: %04Xh\nUMA size: %Xh\nFlash layout: %Xh\nFITC version: %u.%u.%u.%u\nChecksum: %02Xh, ",
ptSize, ptSize,
header.size(), header.size(),
ptBodySize, ptBodySize,
(romBypassVectorSize ? "present" : "absent"),
ptHeader->NumEntries,
ptHeader->HeaderVersion,
ptHeader->EntryVersion,
ptHeader->HeaderLength,
ptHeader->TicksToAdd,
ptHeader->TokensToAdd,
ptHeader->UmaSize,
ptHeader->FlashLayout,
ptHeader->FitcMajor, ptHeader->FitcMinor, ptHeader->FitcHotfix, ptHeader->FitcBuild,
ptHeader->Checksum);
UString info;
// Special case of FPT header version 2.1
if (ptHeader->HeaderVersion == FPT_HEADER_VERSION_21) {
const FPT_HEADER_21* ptHeader21 = (const FPT_HEADER_21*)ptHeader;
info = usprintf("Full size: %Xh (%u)\nHeader size: %" PRIXQ "h (%" PRIuQ ")\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n"
"Header length: %02Xh\nFlags: %Xh\nTicks to add: %04Xh\nTokens to add: %04Xh\nSPS Flags: %Xh\nFITC version: %u.%u.%u.%u\nCRC32 Checksum: %08Xh",
ptSize, ptSize,
header.size(), header.size(),
ptBodySize, ptBodySize,
(romBypassVectorSize ? "present" : "absent"),
ptHeader21->NumEntries,
ptHeader21->HeaderVersion,
ptHeader21->EntryVersion,
ptHeader21->HeaderLength,
ptHeader21->Flags,
ptHeader21->TicksToAdd,
ptHeader21->TokensToAdd,
ptHeader21->SPSFlags,
ptHeader21->FitcMajor, ptHeader21->FitcMinor, ptHeader21->FitcHotfix, ptHeader21->FitcBuild,
ptHeader21->HeaderCrc32);
// TODO: verify header crc32
}
// Default handling for all other versions, may be too generic in some corner cases
else {
info = usprintf("Full size: %Xh (%u)\nHeader size: %" PRIXQ "h (%" PRIuQ ")\nBody size: %Xh (%u)\nROM bypass vector: %s\nNumber of entries: %u\nHeader version: %02Xh\nEntry version: %02Xh\n"
"Header length: %02Xh\nFlash cycle life: %04Xh\nFlash cycle limit: %04Xh\nUMA size: %Xh\nFlags: %Xh\nFITC version: %u.%u.%u.%u\nChecksum: %02Xh",
ptSize, ptSize,
header.size(), header.size(),
ptBodySize, ptBodySize,
(romBypassVectorSize ? "present" : "absent"),
ptHeader->NumEntries,
ptHeader->HeaderVersion,
ptHeader->EntryVersion,
ptHeader->HeaderLength,
ptHeader->FlashCycleLife,
ptHeader->FlashCycleLimit,
ptHeader->UmaSize,
ptHeader->Flags,
ptHeader->FitcMajor, ptHeader->FitcMinor, ptHeader->FitcHotfix, ptHeader->FitcBuild,
ptHeader->HeaderChecksum);
// TODO: verify header checksum8
}
// Add tree item
index = model->addItem(0, Types::FptStore, 0, name, UString(), info, header, body, UByteArray(), Fixed, parent);