Update field names in microcode struct as in EDK II

This commit is contained in:
vit9696 2019-09-06 23:16:26 +03:00
parent 967375243c
commit f2e343d8bf
2 changed files with 40 additions and 40 deletions

View File

@ -1233,8 +1233,8 @@ BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeade
} }
// Check CpuFlags reserved bytes to be zero // Check CpuFlags reserved bytes to be zero
for (UINT32 i = 0; i < sizeof(ucodeHeader->CpuFlagsReserved); i++) { for (UINT32 i = 0; i < sizeof(ucodeHeader->ProcessorFlagsReserved); i++) {
if (ucodeHeader->CpuFlagsReserved[i] != 0x00) { if (ucodeHeader->ProcessorFlagsReserved[i] != 0x00) {
reservedBytesValid = false; reservedBytesValid = false;
break; break;
} }
@ -1280,12 +1280,12 @@ BOOLEAN FfsParser::microcodeHeaderValid(const INTEL_MICROCODE_HEADER* ucodeHeade
ucodeHeader->DateYear > 0x2049) { ucodeHeader->DateYear > 0x2049) {
return FALSE; return FALSE;
} }
// Check UpdateVersion to be 1. // Check HeaderVersion to be 1.
if (ucodeHeader->UpdateVersion != 1) { if (ucodeHeader->HeaderVersion != 1) {
return FALSE; return FALSE;
} }
// Check LoaderVersion to be 1. // Check LoaderRevision to be 1.
if (ucodeHeader->LoaderVersion != 1) { if (ucodeHeader->LoaderRevision != 1) {
return FALSE; return FALSE;
} }
@ -3845,8 +3845,8 @@ USTATUS FfsParser::parseFitEntryMicrocode(const UByteArray & microcode, const UI
// Valid microcode found // Valid microcode found
info = usprintf("CpuSignature: %08Xh, Revision: %08Xh, Date: %02X.%02X.%04X", info = usprintf("CpuSignature: %08Xh, Revision: %08Xh, Date: %02X.%02X.%04X",
ucodeHeader->CpuSignature, ucodeHeader->ProcessorSignature,
ucodeHeader->Revision, ucodeHeader->UpdateRevision,
ucodeHeader->DateDay, ucodeHeader->DateDay,
ucodeHeader->DateMonth, ucodeHeader->DateMonth,
ucodeHeader->DateYear); ucodeHeader->DateYear);
@ -4343,13 +4343,13 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const
// Recalculate checksum after patching // Recalculate checksum after patching
tempUcodeHeader->Checksum = 0; tempUcodeHeader->Checksum = 0;
tempUcodeHeader->CpuFlags = entry->CpuFlags; tempUcodeHeader->ProcessorFlags = entry->ProcessorFlags;
tempUcodeHeader->CpuSignature = entry->CpuSignature; tempUcodeHeader->ProcessorSignature = entry->ProcessorSignature;
UINT32 entryCalculated = calculateChecksum32((const UINT32*)tempMicrocode.constData(), sizeof(INTEL_MICROCODE_HEADER) + dataSize); UINT32 entryCalculated = calculateChecksum32((const UINT32*)tempMicrocode.constData(), sizeof(INTEL_MICROCODE_HEADER) + dataSize);
extendedHeaderInfo += usprintf("\nCPU signature #%u: %08Xh\nCPU flags #%u: %02Xh\nChecksum #%u: %08Xh, ", extendedHeaderInfo += usprintf("\nCPU signature #%u: %08Xh\nCPU flags #%u: %02Xh\nChecksum #%u: %08Xh, ",
i + 1, entry->CpuSignature, i + 1, entry->ProcessorSignature,
i + 1, entry->CpuFlags, i + 1, entry->ProcessorFlags,
i + 1, entry->Checksum) i + 1, entry->Checksum)
+ (entry->Checksum == entryCalculated ? UString("valid") : usprintf("invalid, should be %08Xh", entryCalculated)); + (entry->Checksum == entryCalculated ? UString("valid") : usprintf("invalid, should be %08Xh", entryCalculated));
} }
@ -4367,9 +4367,9 @@ USTATUS FfsParser::parseIntelMicrocodeHeader(const UByteArray & microcode, const
ucodeHeader->DateDay, ucodeHeader->DateDay,
ucodeHeader->DateMonth, ucodeHeader->DateMonth,
ucodeHeader->DateYear, ucodeHeader->DateYear,
ucodeHeader->CpuSignature, ucodeHeader->ProcessorSignature,
ucodeHeader->Revision, ucodeHeader->UpdateRevision,
ucodeHeader->CpuFlags, ucodeHeader->ProcessorFlags,
ucodeHeader->Checksum) ucodeHeader->Checksum)
+ (ucodeHeader->Checksum == calculated ? UString("valid") : usprintf("invalid, should be %08Xh", calculated)) + (ucodeHeader->Checksum == calculated ? UString("valid") : usprintf("invalid, should be %08Xh", calculated))
+ extendedHeaderInfo; + extendedHeaderInfo;

View File

@ -60,18 +60,18 @@ typedef struct {
// This scructure is described in Section 9.11.1 of the Intel Software Developer manual Volume 3A Part 1 // This scructure is described in Section 9.11.1 of the Intel Software Developer manual Volume 3A Part 1
typedef struct INTEL_MICROCODE_HEADER_ { typedef struct INTEL_MICROCODE_HEADER_ {
UINT32 UpdateVersion; // 0x00000001 UINT32 HeaderVersion; // 0x00000001
UINT32 Revision; UINT32 UpdateRevision;
UINT16 DateYear; // BCD UINT16 DateYear; // BCD
UINT8 DateDay; // BCD UINT8 DateDay; // BCD
UINT8 DateMonth; // BCD UINT8 DateMonth; // BCD
UINT32 CpuSignature; UINT32 ProcessorSignature;
UINT32 Checksum; // Checksum of Update Data and Header. Used to verify the integrity of the update header and data. UINT32 Checksum; // Checksum of Update Data and Header. Used to verify the integrity of the update header and data.
// Checksum is correct when the summation of all the DWORDs (including the extended Processor Signature Table) // Checksum is correct when the summation of all the DWORDs (including the extended Processor Signature Table)
// that comprise the microcode update result in 00000000H. // that comprise the microcode update result in 00000000H.
UINT32 LoaderVersion; // 0x00000001 UINT32 LoaderRevision; // 0x00000001
UINT8 CpuFlags; UINT8 ProcessorFlags;
UINT8 CpuFlagsReserved[3]; // Zeroes UINT8 ProcessorFlagsReserved[3]; // Zeroes
UINT32 DataSize; // Specifies the size of the encrypted data in bytes, and must be a multiple of DWORDs. UINT32 DataSize; // Specifies the size of the encrypted data in bytes, and must be a multiple of DWORDs.
// If this value is 00000000H, then the microcode update encrypted data is 2000 bytes (or 500 DWORDs). // If this value is 00000000H, then the microcode update encrypted data is 2000 bytes (or 500 DWORDs).
// Sane values are less than 0x1000000 // Sane values are less than 0x1000000
@ -95,8 +95,8 @@ typedef struct INTEL_MICROCODE_EXTENDED_HEADER_ {
} INTEL_MICROCODE_EXTENDED_HEADER; } INTEL_MICROCODE_EXTENDED_HEADER;
typedef struct INTEL_MICROCODE_EXTENDED_HEADER_ENTRY_ { typedef struct INTEL_MICROCODE_EXTENDED_HEADER_ENTRY_ {
UINT32 CpuSignature; UINT32 ProcessorSignature;
UINT32 CpuFlags; UINT32 ProcessorFlags;
UINT32 Checksum; // To calculate the Checksum, substitute the Primary Processor Signature entry and the Processor Flags entry with the corresponding Extended Patch entry. UINT32 Checksum; // To calculate the Checksum, substitute the Primary Processor Signature entry and the Processor Flags entry with the corresponding Extended Patch entry.
// Delete the Extended Processor Signature Table entries. // Delete the Extended Processor Signature Table entries.
// Checksum is correct when the summation of all DWORDs that comprise the created Extended Processor Patch results in 00000000H. // Checksum is correct when the summation of all DWORDs that comprise the created Extended Processor Patch results in 00000000H.