TianoCore EDK2 master
Loading...
Searching...
No Matches
MicrocodeLib.c File Reference

Go to the source code of this file.

Functions

UINT32 EFIAPI GetProcessorMicrocodeSignature (VOID)
 
VOID EFIAPI GetProcessorMicrocodeCpuId (EDKII_PEI_MICROCODE_CPU_ID *MicrocodeCpuId)
 
UINT32 EFIAPI GetMicrocodeLength (IN CPU_MICROCODE_HEADER *Microcode)
 
VOID EFIAPI LoadMicrocode (IN CPU_MICROCODE_HEADER *Microcode)
 
BOOLEAN IsProcessorMatchedMicrocode (IN UINT32 ProcessorSignature, IN UINT32 ProcessorFlags, IN EDKII_PEI_MICROCODE_CPU_ID *MicrocodeCpuId, IN UINTN MicrocodeCpuIdCount)
 
BOOLEAN EFIAPI IsValidMicrocode (IN CPU_MICROCODE_HEADER *Microcode, IN UINTN MicrocodeLength, IN UINT32 MinimumRevision, IN EDKII_PEI_MICROCODE_CPU_ID *MicrocodeCpuIds, IN UINTN MicrocodeCpuIdCount, IN BOOLEAN VerifyChecksum)
 

Detailed Description

Implementation of MicrocodeLib.

Copyright (c) 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file MicrocodeLib.c.

Function Documentation

◆ GetMicrocodeLength()

UINT32 EFIAPI GetMicrocodeLength ( IN CPU_MICROCODE_HEADER Microcode)

Return the total size of the microcode entry.

Logic follows pseudo code in SDM as below:

N = 512 If (Update.DataSize != 00000000H) N = Update.TotalSize / 4

If Microcode is NULL, then ASSERT.

Parameters
MicrocodePointer to the microcode entry.
Returns
The microcode total size.

Definition at line 73 of file MicrocodeLib.c.

◆ GetProcessorMicrocodeCpuId()

VOID EFIAPI GetProcessorMicrocodeCpuId ( EDKII_PEI_MICROCODE_CPU_ID MicrocodeCpuId)

Get the processor signature and platform ID for current processor.

Parameters
MicrocodeCpuIdReturn the processor signature and platform ID.

Definition at line 43 of file MicrocodeLib.c.

◆ GetProcessorMicrocodeSignature()

UINT32 EFIAPI GetProcessorMicrocodeSignature ( VOID  )

Get microcode update signature of currently loaded microcode update.

Returns
Microcode signature.

Definition at line 24 of file MicrocodeLib.c.

◆ IsProcessorMatchedMicrocode()

BOOLEAN IsProcessorMatchedMicrocode ( IN UINT32  ProcessorSignature,
IN UINT32  ProcessorFlags,
IN EDKII_PEI_MICROCODE_CPU_ID MicrocodeCpuId,
IN UINTN  MicrocodeCpuIdCount 
)

Determine if a microcode patch matchs the specific processor signature and flag.

Parameters
[in]ProcessorSignatureThe processor signature field value in a microcode patch.
[in]ProcessorFlagsThe processor flags field value in a microcode patch.
[in]MicrocodeCpuIdA pointer to an array of EDKII_PEI_MICROCODE_CPU_ID structures.
[in]MicrocodeCpuIdCountNumber of elements in MicrocodeCpuId array.
Return values
TRUEThe specified microcode patch matches to one of the MicrocodeCpuId.
FALSEThe specified microcode patch doesn't match to any of the MicrocodeCpuId.

Definition at line 122 of file MicrocodeLib.c.

◆ IsValidMicrocode()

BOOLEAN EFIAPI IsValidMicrocode ( IN CPU_MICROCODE_HEADER Microcode,
IN UINTN  MicrocodeLength,
IN UINT32  MinimumRevision,
IN EDKII_PEI_MICROCODE_CPU_ID MicrocodeCpuIds,
IN UINTN  MicrocodeCpuIdCount,
IN BOOLEAN  VerifyChecksum 
)

Detect whether specified processor can find matching microcode patch and load it.

Microcode format is as below: +-------------------------------------—+----------------------------------------------—+ | CPU_MICROCODE_HEADER | | +-------------------------------------—+ V | Update Data | CPU_MICROCODE_HEADER.Checksum +-------------------------------------—+----—+ ^ | CPU_MICROCODE_EXTENDED_TABLE_HEADER | | | +-------------------------------------—+ V | | CPU_MICROCODE_EXTENDED_TABLE[0] | CPU_MICROCODE_EXTENDED_TABLE_HEADER.Checksum | | CPU_MICROCODE_EXTENDED_TABLE[1] | ^ | | ... | | | +-------------------------------------—+----—+--------------------------------------—+

There may by multiple CPU_MICROCODE_EXTENDED_TABLE in this format. The count of CPU_MICROCODE_EXTENDED_TABLE is indicated by ExtendedSignatureCount of CPU_MICROCODE_EXTENDED_TABLE_HEADER structure.

If Microcode is NULL, then ASSERT.

Parameters
MicrocodePointer to a microcode entry.
MicrocodeLengthThe total length of the microcode entry.
MinimumRevisionThe microcode whose revision <= MinimumRevision is treated as invalid. Caller can supply value get from GetProcessorMicrocodeSignature() to check whether the microcode is newer than loaded one. Caller can supply 0 to treat any revision (except 0) microcode as valid.
MicrocodeCpuIdsPointer to an array of processor signature and platform ID that represents a set of processors. Caller can supply zero-element array to skip the processor signature and platform ID check.
MicrocodeCpuIdCountThe number of elements in MicrocodeCpuIds.
VerifyChecksumFALSE to skip all the checksum verifications.
Return values
TRUEThe microcode is valid.
FALSEThe microcode is invalid.

Definition at line 186 of file MicrocodeLib.c.

◆ LoadMicrocode()

VOID EFIAPI LoadMicrocode ( IN CPU_MICROCODE_HEADER Microcode)

Load the microcode to the processor.

If Microcode is NULL, then ASSERT.

Parameters
MicrocodePointer to the microcode entry.

Definition at line 98 of file MicrocodeLib.c.