MicrocodeLib.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /** @file
  2. Public include file for Microcode library.
  3. Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef MICROCODE_LIB_H_
  7. #define MICROCODE_LIB_H_
  8. #include <Register/Intel/Microcode.h>
  9. #include <Ppi/ShadowMicrocode.h>
  10. /**
  11. Get microcode update signature of currently loaded microcode update.
  12. @return Microcode signature.
  13. **/
  14. UINT32
  15. EFIAPI
  16. GetProcessorMicrocodeSignature (
  17. VOID
  18. );
  19. /**
  20. Get the processor signature and platform ID for current processor.
  21. @param MicrocodeCpuId Return the processor signature and platform ID.
  22. **/
  23. VOID
  24. EFIAPI
  25. GetProcessorMicrocodeCpuId (
  26. EDKII_PEI_MICROCODE_CPU_ID *MicrocodeCpuId
  27. );
  28. /**
  29. Return the total size of the microcode entry.
  30. Logic follows pseudo code in SDM as below:
  31. N = 512
  32. If (Update.DataSize != 00000000H)
  33. N = Update.TotalSize / 4
  34. If Microcode is NULL, then ASSERT.
  35. @param Microcode Pointer to the microcode entry.
  36. @return The microcode total size.
  37. **/
  38. UINT32
  39. EFIAPI
  40. GetMicrocodeLength (
  41. IN CPU_MICROCODE_HEADER *Microcode
  42. );
  43. /**
  44. Load the microcode to the processor.
  45. If Microcode is NULL, then ASSERT.
  46. @param Microcode Pointer to the microcode entry.
  47. **/
  48. VOID
  49. EFIAPI
  50. LoadMicrocode (
  51. IN CPU_MICROCODE_HEADER *Microcode
  52. );
  53. /**
  54. Detect whether specified processor can find matching microcode patch and load it.
  55. Microcode format is as below:
  56. +----------------------------------------+-------------------------------------------------+
  57. | CPU_MICROCODE_HEADER | |
  58. +----------------------------------------+ V
  59. | Update Data | CPU_MICROCODE_HEADER.Checksum
  60. +----------------------------------------+-------+ ^
  61. | CPU_MICROCODE_EXTENDED_TABLE_HEADER | | |
  62. +----------------------------------------+ V |
  63. | CPU_MICROCODE_EXTENDED_TABLE[0] | CPU_MICROCODE_EXTENDED_TABLE_HEADER.Checksum |
  64. | CPU_MICROCODE_EXTENDED_TABLE[1] | ^ |
  65. | ... | | |
  66. +----------------------------------------+-------+-----------------------------------------+
  67. There may by multiple CPU_MICROCODE_EXTENDED_TABLE in this format.
  68. The count of CPU_MICROCODE_EXTENDED_TABLE is indicated by ExtendedSignatureCount
  69. of CPU_MICROCODE_EXTENDED_TABLE_HEADER structure.
  70. If Microcode is NULL, then ASSERT.
  71. @param Microcode Pointer to a microcode entry.
  72. @param MicrocodeLength The total length of the microcode entry.
  73. @param MinimumRevision The microcode whose revision <= MinimumRevision is treated as invalid.
  74. Caller can supply value get from GetProcessorMicrocodeSignature() to check
  75. whether the microcode is newer than loaded one.
  76. Caller can supply 0 to treat any revision (except 0) microcode as valid.
  77. @param MicrocodeCpuIds Pointer to an array of processor signature and platform ID that represents
  78. a set of processors.
  79. Caller can supply zero-element array to skip the processor signature and
  80. platform ID check.
  81. @param MicrocodeCpuIdCount The number of elements in MicrocodeCpuIds.
  82. @param VerifyChecksum FALSE to skip all the checksum verifications.
  83. @retval TRUE The microcode is valid.
  84. @retval FALSE The microcode is invalid.
  85. **/
  86. BOOLEAN
  87. EFIAPI
  88. IsValidMicrocode (
  89. IN CPU_MICROCODE_HEADER *Microcode,
  90. IN UINTN MicrocodeLength,
  91. IN UINT32 MinimumRevision,
  92. IN EDKII_PEI_MICROCODE_CPU_ID *MicrocodeCpuIds,
  93. IN UINTN MicrocodeCpuIdCount,
  94. IN BOOLEAN VerifyChecksum
  95. );
  96. #endif