#include <Guid/MicrocodeFmp.h>\r
\r
#include <Protocol/FirmwareManagement.h>\r
+#include <Protocol/MpService.h>\r
\r
#include <Library/BaseLib.h>\r
#include <Library/BaseMemoryLib.h>\r
BOOLEAN InUse;\r
} MICROCODE_INFO;\r
\r
+typedef struct {\r
+ UINTN CpuIndex;\r
+ UINT32 ProcessorSignature;\r
+ UINT8 PlatformId;\r
+ UINT32 MicrocodeRevision;\r
+ UINTN MicrocodeIndex;\r
+} PROCESSOR_INFO;\r
+\r
+typedef struct {\r
+ UINT64 Address;\r
+ UINT32 Revision;\r
+} MICROCODE_LOAD_BUFFER;\r
+\r
struct _MICROCODE_FMP_PRIVATE_DATA {\r
UINT32 Signature;\r
EFI_FIRMWARE_MANAGEMENT_PROTOCOL Fmp;\r
UINT32 PackageVersion;\r
CHAR16 *PackageVersionName;\r
MICROCODE_FMP_LAST_ATTEMPT_VARIABLE LastAttempt;\r
+ EFI_MP_SERVICES_PROTOCOL *MpService;\r
+ UINTN BspIndex;\r
+ UINTN ProcessorCount;\r
+ PROCESSOR_INFO *ProcessorInfo;\r
};\r
\r
typedef struct _MICROCODE_FMP_PRIVATE_DATA MICROCODE_FMP_PRIVATE_DATA;\r
OUT UINTN *MicrocodePatchRegionSize\r
);\r
\r
+/**\r
+ Collect processor information.\r
+ The function prototype for invoking a function on an Application Processor.\r
+\r
+ @param[in,out] Buffer The pointer to private data buffer.\r
+**/\r
+VOID\r
+EFIAPI\r
+CollectProcessorInfo (\r
+ IN OUT VOID *Buffer\r
+ );\r
+\r
/**\r
Get current Microcode information.\r
\r
- NOTE: The DescriptorCount/ImageDescriptor/MicrocodeInfo in MicrocodeFmpPrivate\r
- are not avaiable in this function.\r
+ The ProcessorInformation (BspIndex/ProcessorCount/ProcessorInfo)\r
+ in MicrocodeFmpPrivate must be initialized.\r
+\r
+ The MicrocodeInformation (DescriptorCount/ImageDescriptor/MicrocodeInfo)\r
+ in MicrocodeFmpPrivate may not be avaiable in this function.\r
\r
@param[in] MicrocodeFmpPrivate The Microcode driver private data\r
@param[in] DescriptorCount The count of Microcode ImageDescriptor allocated.\r
OUT MICROCODE_INFO *MicrocodeInfo OPTIONAL\r
);\r
\r
+/**\r
+ Verify Microcode.\r
+\r
+ Caution: This function may receive untrusted input.\r
+\r
+ @param[in] MicrocodeFmpPrivate The Microcode driver private data\r
+ @param[in] Image The Microcode image buffer.\r
+ @param[in] ImageSize The size of Microcode image buffer in bytes.\r
+ @param[in] TryLoad Try to load Microcode or not.\r
+ @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\r
+ @param[out] AbortReason A pointer to a pointer to a null-terminated string providing more\r
+ details for the aborted operation. The buffer is allocated by this function\r
+ with AllocatePool(), and it is the caller's responsibility to free it with a\r
+ call to FreePool().\r
+ @param[in, out] TargetCpuIndex On input, the index of target CPU which tries to match the Microcode. (UINTN)-1 means to try all.\r
+ On output, the index of target CPU which matches the Microcode.\r
+\r
+ @retval EFI_SUCCESS The Microcode image passes verification.\r
+ @retval EFI_VOLUME_CORRUPTED The Microcode image is corrupt.\r
+ @retval EFI_INCOMPATIBLE_VERSION The Microcode image version is incorrect.\r
+ @retval EFI_UNSUPPORTED The Microcode ProcessorSignature or ProcessorFlags is incorrect.\r
+ @retval EFI_SECURITY_VIOLATION The Microcode image fails to load.\r
+**/\r
+EFI_STATUS\r
+VerifyMicrocode (\r
+ IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate,\r
+ IN VOID *Image,\r
+ IN UINTN ImageSize,\r
+ IN BOOLEAN TryLoad,\r
+ OUT UINT32 *LastAttemptStatus,\r
+ OUT CHAR16 **AbortReason, OPTIONAL\r
+ IN OUT UINTN *TargetCpuIndex OPTIONAL\r
+ );\r
+\r
/**\r
Write Microcode.\r
\r
OUT CHAR16 **AbortReason\r
);\r
\r
+/**\r
+ Dump private information.\r
+\r
+ @param[in] MicrocodeFmpPrivate private data structure.\r
+**/\r
+VOID\r
+DumpPrivateInfo (\r
+ IN MICROCODE_FMP_PRIVATE_DATA *MicrocodeFmpPrivate\r
+ );\r
+\r
/**\r
Returns information about the current firmware image(s) of the device.\r
\r