]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Feature/Capsule/MicrocodeUpdateDxe/MicrocodeUpdate.h
UefiCpuPkg/MicrocodeUpdate: enhance flash write logic
[mirror_edk2.git] / UefiCpuPkg / Feature / Capsule / MicrocodeUpdateDxe / MicrocodeUpdate.h
index 77e8441955440660fb9305b8bae351d198198782..b4d1bac17dd2ebb565ce50a7bf1c7fe2bea1eaa5 100644 (file)
@@ -50,12 +50,21 @@ typedef struct {
   UINT32 LastAttemptStatus;\r
 } MICROCODE_FMP_LAST_ATTEMPT_VARIABLE;\r
 \r
+typedef struct {\r
+  CPU_MICROCODE_HEADER   *MicrocodeEntryPoint;\r
+  UINTN                  TotalSize;\r
+  BOOLEAN                InUse;\r
+} MICROCODE_INFO;\r
+\r
 struct _MICROCODE_FMP_PRIVATE_DATA {\r
   UINT32                               Signature;\r
   EFI_FIRMWARE_MANAGEMENT_PROTOCOL     Fmp;\r
   EFI_HANDLE                           Handle;\r
+  VOID                                 *MicrocodePatchAddress;\r
+  UINTN                                MicrocodePatchRegionSize;\r
   UINT8                                DescriptorCount;\r
   EFI_FIRMWARE_IMAGE_DESCRIPTOR        *ImageDescriptor;\r
+  MICROCODE_INFO                       *MicrocodeInfo;\r
   UINT32                               PackageVersion;\r
   CHAR16                               *PackageVersionName;\r
   MICROCODE_FMP_LAST_ATTEMPT_VARIABLE  LastAttempt;\r
@@ -84,63 +93,68 @@ typedef struct _MICROCODE_FMP_PRIVATE_DATA  MICROCODE_FMP_PRIVATE_DATA;
   )\r
 \r
 /**\r
-  Get current Microcode information.\r
+  Get Microcode Region.\r
 \r
-  @param[out]  ImageDescriptor  Microcode ImageDescriptor\r
-  @param[in]   DescriptorCount  The count of Microcode ImageDescriptor allocated.\r
+  @param[out] MicrocodePatchAddress      The address of Microcode\r
+  @param[out] MicrocodePatchRegionSize   The region size of Microcode\r
 \r
-  @return Microcode count\r
+  @retval TRUE   The Microcode region is returned.\r
+  @retval FALSE  No Microcode region.\r
 **/\r
-UINTN\r
-GetMicrocodeInfo (\r
-  OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR  *ImageDescriptor, OPTIONAL\r
-  IN  UINTN                          DescriptorCount   OPTIONAL\r
+BOOLEAN\r
+GetMicrocodeRegion (\r
+  OUT VOID     **MicrocodePatchAddress,\r
+  OUT UINTN    *MicrocodePatchRegionSize\r
   );\r
 \r
 /**\r
-  Read Microcode.\r
+  Get current Microcode information.\r
+\r
+  NOTE: The DescriptorCount/ImageDescriptor/MicrocodeInfo in MicrocodeFmpPrivate\r
+  are not avaiable in this function.\r
 \r
-  @param[in]       ImageIndex The index of Microcode image.\r
-  @param[in, out]  Image      The Microcode image buffer.\r
-  @param[in, out]  ImageSize  The size of Microcode image buffer in bytes.\r
+  @param[in]   MicrocodeFmpPrivate        The Microcode driver private data\r
+  @param[in]   DescriptorCount            The count of Microcode ImageDescriptor allocated.\r
+  @param[out]  ImageDescriptor            Microcode ImageDescriptor\r
+  @param[out]  MicrocodeInfo              Microcode information\r
 \r
-  @retval EFI_SUCCESS    The Microcode image is read.\r
-  @retval EFI_NOT_FOUND  The Microcode image is not found.\r
+  @return Microcode count\r
 **/\r
-EFI_STATUS\r
-MicrocodeRead (\r
-  IN UINTN      ImageIndex,\r
-  IN OUT VOID   *Image,\r
-  IN OUT UINTN  *ImageSize\r
+UINTN\r
+GetMicrocodeInfo (\r
+  IN  MICROCODE_FMP_PRIVATE_DATA     *MicrocodeFmpPrivate,\r
+  IN  UINTN                          DescriptorCount,  OPTIONAL\r
+  OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR  *ImageDescriptor, OPTIONAL\r
+  OUT MICROCODE_INFO                 *MicrocodeInfo    OPTIONAL\r
   );\r
 \r
 /**\r
   Write Microcode.\r
 \r
-  @param[in]   ImageIndex         The index of Microcode image.\r
-  @param[in]   Image              The Microcode image buffer.\r
-  @param[in]   ImageSize          The size of Microcode image buffer in bytes.\r
-  @param[out]  LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\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]   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[out]  LastAttemptVersion  The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.\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
 \r
   @retval EFI_SUCCESS               The Microcode image is written.\r
   @retval EFI_VOLUME_CORRUPTED      The Microcode image is corrupt.\r
   @retval EFI_INCOMPATIBLE_VERSION  The Microcode image version is incorrect.\r
   @retval EFI_SECURITY_VIOLATION    The Microcode image fails to load.\r
-  @retval EFI_WRITE_PROTECTED   The flash device is read only.\r
+  @retval EFI_WRITE_PROTECTED       The flash device is read only.\r
 **/\r
 EFI_STATUS\r
 MicrocodeWrite (\r
-  IN UINTN    ImageIndex,\r
-  IN VOID     *Image,\r
-  IN UINTN    ImageSize,\r
-  OUT UINT32  *LastAttemptVersion,\r
-  OUT UINT32  *LastAttemptStatus,\r
-  OUT CHAR16  **AbortReason\r
+  IN MICROCODE_FMP_PRIVATE_DATA    *MicrocodeFmpPrivate,\r
+  IN VOID                          *Image,\r
+  IN UINTN                         ImageSize,\r
+  OUT UINT32                       *LastAttemptVersion,\r
+  OUT UINT32                       *LastAttemptStatus,\r
+  OUT CHAR16                       **AbortReason\r
   );\r
 \r
 /**\r