| 1 | /** @file |
| 2 | This file contains definitions required for creation of |
| 3 | Memory S3 Save data, Memory Info data and Memory Platform |
| 4 | data hobs. |
| 5 | |
| 6 | @copyright |
| 7 | Copyright (c) 1999 - 2022, Intel Corporation. All rights reserved.<BR> |
| 8 | This program and the accompanying materials are licensed and made available under |
| 9 | the terms and conditions of the BSD License that accompanies this distribution. |
| 10 | The full text of the license may be found at |
| 11 | http://opensource.org/licenses/bsd-license.php. |
| 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, |
| 13 | |
| 14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. |
| 15 | |
| 16 | @par Specification Reference: |
| 17 | **/ |
| 18 | #ifndef _MEM_INFO_HOB_H_ |
| 19 | #define _MEM_INFO_HOB_H_ |
| 20 | |
| 21 | |
| 22 | #pragma pack (push, 1) |
| 23 | |
| 24 | extern EFI_GUID gSiMemoryS3DataGuid; |
| 25 | extern EFI_GUID gSiMemoryInfoDataGuid; |
| 26 | extern EFI_GUID gSiMemoryPlatformDataGuid; |
| 27 | |
| 28 | #define MAX_NODE 2 |
| 29 | #define MAX_CH 4 |
| 30 | #define MAX_DIMM 2 |
| 31 | // Must match definitions in |
| 32 | // Intel\ClientOneSiliconPkg\IpBlock\MemoryInit\Mtl\Include\MrcInterface.h |
| 33 | #define HOB_MAX_SAGV_POINTS 4 |
| 34 | |
| 35 | /// |
| 36 | /// Host reset states from MRC. |
| 37 | /// |
| 38 | #define WARM_BOOT 2 |
| 39 | |
| 40 | #define R_MC_CHNL_RANK_PRESENT 0x7C |
| 41 | #define B_RANK0_PRS BIT0 |
| 42 | #define B_RANK1_PRS BIT1 |
| 43 | #define B_RANK2_PRS BIT4 |
| 44 | #define B_RANK3_PRS BIT5 |
| 45 | |
| 46 | // @todo remove and use the MdePkg\Include\Pi\PiHob.h |
| 47 | #if !defined(_PEI_HOB_H_) && !defined(__PI_HOB_H__) |
| 48 | #ifndef __HOB__H__ |
| 49 | typedef struct _EFI_HOB_GENERIC_HEADER { |
| 50 | UINT16 HobType; |
| 51 | UINT16 HobLength; |
| 52 | UINT32 Reserved; |
| 53 | } EFI_HOB_GENERIC_HEADER; |
| 54 | |
| 55 | typedef struct _EFI_HOB_GUID_TYPE { |
| 56 | EFI_HOB_GENERIC_HEADER Header; |
| 57 | EFI_GUID Name; |
| 58 | /// |
| 59 | /// Guid specific data goes here |
| 60 | /// |
| 61 | } EFI_HOB_GUID_TYPE; |
| 62 | #endif |
| 63 | #endif |
| 64 | |
| 65 | /// |
| 66 | /// Defines taken from MRC so avoid having to include MrcInterface.h |
| 67 | /// |
| 68 | |
| 69 | // |
| 70 | // Matches MAX_SPD_SAVE define in MRC |
| 71 | // |
| 72 | #ifndef MAX_SPD_SAVE |
| 73 | #define MAX_SPD_SAVE 29 |
| 74 | #endif |
| 75 | |
| 76 | // |
| 77 | // MRC version description. |
| 78 | // |
| 79 | typedef struct { |
| 80 | UINT8 Major; ///< Major version number |
| 81 | UINT8 Minor; ///< Minor version number |
| 82 | UINT8 Rev; ///< Revision number |
| 83 | UINT8 Build; ///< Build number |
| 84 | } SiMrcVersion; |
| 85 | |
| 86 | // |
| 87 | // Matches MrcChannelSts enum in MRC |
| 88 | // |
| 89 | #ifndef CHANNEL_NOT_PRESENT |
| 90 | #define CHANNEL_NOT_PRESENT 0 // There is no channel present on the controller. |
| 91 | #endif |
| 92 | #ifndef CHANNEL_DISABLED |
| 93 | #define CHANNEL_DISABLED 1 // There is a channel present but it is disabled. |
| 94 | #endif |
| 95 | #ifndef CHANNEL_PRESENT |
| 96 | #define CHANNEL_PRESENT 2 // There is a channel present and it is enabled. |
| 97 | #endif |
| 98 | |
| 99 | // |
| 100 | // Matches MrcDimmSts enum in MRC |
| 101 | // |
| 102 | #ifndef DIMM_ENABLED |
| 103 | #define DIMM_ENABLED 0 // DIMM/rank Pair is enabled, presence will be detected. |
| 104 | #endif |
| 105 | #ifndef DIMM_DISABLED |
| 106 | #define DIMM_DISABLED 1 // DIMM/rank Pair is disabled, regardless of presence. |
| 107 | #endif |
| 108 | #ifndef DIMM_PRESENT |
| 109 | #define DIMM_PRESENT 2 // There is a DIMM present in the slot/rank pair and it will be used. |
| 110 | #endif |
| 111 | #ifndef DIMM_NOT_PRESENT |
| 112 | #define DIMM_NOT_PRESENT 3 // There is no DIMM present in the slot/rank pair. |
| 113 | #endif |
| 114 | |
| 115 | // |
| 116 | // Matches MrcBootMode enum in MRC |
| 117 | // |
| 118 | #ifndef __MRC_BOOT_MODE__ |
| 119 | #define __MRC_BOOT_MODE__ //The below values are originated from MrcCommonTypes.h |
| 120 | #ifndef INT32_MAX |
| 121 | #define INT32_MAX (0x7FFFFFFF) |
| 122 | #endif //INT32_MAX |
| 123 | typedef enum { |
| 124 | bmCold, ///< Cold boot |
| 125 | bmWarm, ///< Warm boot |
| 126 | bmS3, ///< S3 resume |
| 127 | bmFast, ///< Fast boot |
| 128 | MrcBootModeMax, ///< MRC_BOOT_MODE enumeration maximum value. |
| 129 | MrcBootModeDelim = INT32_MAX ///< This value ensures the enum size is consistent on both sides of the PPI. |
| 130 | } MRC_BOOT_MODE; |
| 131 | #endif //__MRC_BOOT_MODE__ |
| 132 | |
| 133 | // |
| 134 | // Matches MrcDdrType enum in MRC |
| 135 | // |
| 136 | #ifndef MRC_DDR_TYPE_DDR5 |
| 137 | #define MRC_DDR_TYPE_DDR5 1 |
| 138 | #endif |
| 139 | #ifndef MRC_DDR_TYPE_LPDDR5 |
| 140 | #define MRC_DDR_TYPE_LPDDR5 2 |
| 141 | #endif |
| 142 | #ifndef MRC_DDR_TYPE_LPDDR4 |
| 143 | #define MRC_DDR_TYPE_LPDDR4 3 |
| 144 | #endif |
| 145 | #ifndef MRC_DDR_TYPE_UNKNOWN |
| 146 | #define MRC_DDR_TYPE_UNKNOWN 4 |
| 147 | #endif |
| 148 | |
| 149 | #define MAX_PROFILE_NUM 7 // number of memory profiles supported |
| 150 | #define MAX_XMP_PROFILE_NUM 5 // number of XMP profiles supported |
| 151 | |
| 152 | #define MAX_TRACE_REGION 5 |
| 153 | #define MAX_TRACE_CACHE_TYPE 2 |
| 154 | |
| 155 | // |
| 156 | // DIMM timings |
| 157 | // |
| 158 | typedef struct { |
| 159 | UINT32 tCK; ///< Memory cycle time, in femtoseconds. |
| 160 | UINT16 NMode; ///< Number of tCK cycles for the channel DIMM's command rate mode. |
| 161 | UINT16 tCL; ///< Number of tCK cycles for the channel DIMM's CAS latency. |
| 162 | UINT16 tCWL; ///< Number of tCK cycles for the channel DIMM's minimum CAS write latency time. |
| 163 | UINT16 tFAW; ///< Number of tCK cycles for the channel DIMM's minimum four activate window delay time. |
| 164 | UINT16 tRAS; ///< Number of tCK cycles for the channel DIMM's minimum active to precharge delay time. |
| 165 | UINT16 tRCDtRP; ///< Number of tCK cycles for the channel DIMM's minimum RAS# to CAS# delay time and Row Precharge delay time. |
| 166 | UINT16 tREFI; ///< Number of tCK cycles for the channel DIMM's minimum Average Periodic Refresh Interval. |
| 167 | UINT16 tRFC; ///< Number of tCK cycles for the channel DIMM's minimum refresh recovery delay time. |
| 168 | UINT16 tRFCpb; ///< Number of tCK cycles for the channel DIMM's minimum per bank refresh recovery delay time. |
| 169 | UINT16 tRFC2; ///< Number of tCK cycles for the channel DIMM's minimum refresh recovery delay time. |
| 170 | UINT16 tRFC4; ///< Number of tCK cycles for the channel DIMM's minimum refresh recovery delay time. |
| 171 | UINT16 tRPab; ///< Number of tCK cycles for the channel DIMM's minimum row precharge delay time for all banks. |
| 172 | UINT16 tRRD; ///< Number of tCK cycles for the channel DIMM's minimum row active to row active delay time. |
| 173 | UINT16 tRRD_L; ///< Number of tCK cycles for the channel DIMM's minimum row active to row active delay time for same bank groups. |
| 174 | UINT16 tRRD_S; ///< Number of tCK cycles for the channel DIMM's minimum row active to row active delay time for different bank groups. |
| 175 | UINT16 tRTP; ///< Number of tCK cycles for the channel DIMM's minimum internal read to precharge command delay time. |
| 176 | UINT16 tWR; ///< Number of tCK cycles for the channel DIMM's minimum write recovery time. |
| 177 | UINT16 tWTR; ///< Number of tCK cycles for the channel DIMM's minimum internal write to read command delay time. |
| 178 | UINT16 tWTR_L; ///< Number of tCK cycles for the channel DIMM's minimum internal write to read command delay time for same bank groups. |
| 179 | UINT16 tWTR_S; ///< Number of tCK cycles for the channel DIMM's minimum internal write to read command delay time for different bank groups. |
| 180 | UINT16 tCCD_L; ///< Number of tCK cycles for the channel DIMM's minimum CAS-to-CAS delay for same bank group. |
| 181 | } MRC_CH_TIMING; |
| 182 | |
| 183 | typedef struct { |
| 184 | UINT16 tRDPRE; ///< Read CAS to Precharge cmd delay |
| 185 | } MRC_IP_TIMING; |
| 186 | |
| 187 | /// |
| 188 | /// Memory SMBIOS & OC Memory Data Hob |
| 189 | /// |
| 190 | typedef struct { |
| 191 | UINT8 Status; ///< See MrcDimmStatus for the definition of this field. |
| 192 | UINT8 DimmId; |
| 193 | UINT32 DimmCapacity; ///< DIMM size in MBytes. |
| 194 | UINT16 MfgId; |
| 195 | UINT8 ModulePartNum[20]; ///< Module part number for DDR3 is 18 bytes however for DRR4 20 bytes as per JEDEC Spec, so reserving 20 bytes |
| 196 | UINT8 RankInDimm; ///< The number of ranks in this DIMM. |
| 197 | UINT8 SpdDramDeviceType; ///< Save SPD DramDeviceType information needed for SMBIOS structure creation. |
| 198 | UINT8 SpdModuleType; ///< Save SPD ModuleType information needed for SMBIOS structure creation. |
| 199 | UINT8 SpdModuleMemoryBusWidth; ///< Save SPD ModuleMemoryBusWidth information needed for SMBIOS structure creation. |
| 200 | UINT8 SpdSave[MAX_SPD_SAVE]; ///< Save SPD Manufacturing information needed for SMBIOS structure creation. |
| 201 | UINT16 Speed; ///< The maximum capable speed of the device, in MHz |
| 202 | UINT8 MdSocket; ///< MdSocket: 0 = Memory Down, 1 = Socketed. Needed for SMBIOS structure creation. |
| 203 | } DIMM_INFO; |
| 204 | |
| 205 | typedef struct { |
| 206 | UINT8 Status; ///< Indicates whether this channel should be used. |
| 207 | UINT8 ChannelId; |
| 208 | UINT8 DimmCount; ///< Number of valid DIMMs that exist in the channel. |
| 209 | MRC_CH_TIMING Timing[MAX_PROFILE_NUM]; ///< The channel timing values. |
| 210 | DIMM_INFO DimmInfo[MAX_DIMM]; ///< Save the DIMM output characteristics. |
| 211 | } CHANNEL_INFO; |
| 212 | |
| 213 | typedef struct { |
| 214 | UINT8 Status; ///< Indicates whether this controller should be used. |
| 215 | UINT16 DeviceId; ///< The PCI device id of this memory controller. |
| 216 | UINT8 RevisionId; ///< The PCI revision id of this memory controller. |
| 217 | UINT8 ChannelCount; ///< Number of valid channels that exist on the controller. |
| 218 | CHANNEL_INFO ChannelInfo[MAX_CH]; ///< The following are channel level definitions. |
| 219 | } CONTROLLER_INFO; |
| 220 | |
| 221 | typedef struct { |
| 222 | UINT64 BaseAddress; ///< Trace Base Address |
| 223 | UINT64 TotalSize; ///< Total Trace Region of Same Cache type |
| 224 | UINT8 CacheType; ///< Trace Cache Type |
| 225 | UINT8 ErrorCode; ///< Trace Region Allocation Fail Error code |
| 226 | UINT8 Rsvd[2]; |
| 227 | } PSMI_MEM_INFO; |
| 228 | |
| 229 | /// This data structure contains per-SaGv timing values that are considered output by the MRC. |
| 230 | typedef struct { |
| 231 | UINT32 DataRate; ///< The memory rate for the current SaGv Point in units of MT/s |
| 232 | MRC_CH_TIMING JedecTiming; ///< Timings used for this entry's corresponding SaGv Point - derived from JEDEC SPD spec |
| 233 | MRC_IP_TIMING IpTiming; ///< Timings used for this entry's corresponding SaGv Point - IP specific |
| 234 | } HOB_SAGV_TIMING_OUT; |
| 235 | |
| 236 | /// This data structure contains SAGV config values that are considered output by the MRC. |
| 237 | typedef struct { |
| 238 | UINT32 NumSaGvPointsEnabled; ///< Count of the total number of SAGV Points enabled. |
| 239 | UINT32 SaGvPointMask; ///< Bit mask where each bit indicates an enabled SAGV point. |
| 240 | HOB_SAGV_TIMING_OUT SaGvTiming[HOB_MAX_SAGV_POINTS]; |
| 241 | } HOB_SAGV_INFO; |
| 242 | |
| 243 | typedef struct { |
| 244 | UINT8 Revision; |
| 245 | UINT16 DataWidth; ///< Data width, in bits, of this memory device |
| 246 | /** As defined in SMBIOS 3.0 spec |
| 247 | Section 7.18.2 and Table 75 |
| 248 | **/ |
| 249 | UINT8 MemoryType; ///< DDR type: DDR3, DDR4, or LPDDR3 |
| 250 | UINT16 MaximumMemoryClockSpeed;///< The maximum capable speed of the device, in megahertz (MHz) |
| 251 | UINT16 ConfiguredMemoryClockSpeed; ///< The configured clock speed to the memory device, in megahertz (MHz) |
| 252 | /** As defined in SMBIOS 3.0 spec |
| 253 | Section 7.17.3 and Table 72 |
| 254 | **/ |
| 255 | UINT8 ErrorCorrectionType; |
| 256 | |
| 257 | SiMrcVersion Version; |
| 258 | BOOLEAN EccSupport; |
| 259 | UINT8 MemoryProfile; |
| 260 | UINT8 IsDMBRunning; ///< Deprecated. |
| 261 | UINT32 TotalPhysicalMemorySize; |
| 262 | UINT32 DefaultXmptCK[MAX_XMP_PROFILE_NUM];///< Stores the tCK value read from SPD XMP profiles if they exist. |
| 263 | /// |
| 264 | /// Set of bit flags showing XMP and User Profile capability status for the DIMMs detected in system. For each bit, 1 is supported, 0 is unsupported. |
| 265 | /// Bit 0: XMP Profile 1 capability status |
| 266 | /// Bit 1: XMP Profile 2 capability status |
| 267 | /// Bit 2: XMP Profile 3 capability status |
| 268 | /// Bit 3: User Profile 4 capability status |
| 269 | /// Bit 4: User Profile 5 capability status |
| 270 | /// |
| 271 | UINT8 XmpProfileEnable; |
| 272 | UINT8 XmpConfigWarning; ///< If XMP capable DIMMs config support only 1DPC, but 2DPC is installed |
| 273 | UINT8 Ratio; ///< DDR Frequency Ratio, Max Value 255 |
| 274 | UINT8 RefClk; |
| 275 | UINT32 VddVoltage[MAX_PROFILE_NUM]; |
| 276 | UINT32 VddqVoltage[MAX_PROFILE_NUM]; |
| 277 | UINT32 VppVoltage[MAX_PROFILE_NUM]; |
| 278 | CONTROLLER_INFO Controller[MAX_NODE]; |
| 279 | UINT16 Ratio_UINT16; ///< DDR Frequency Ratio, used for programs that require ratios higher then 255 |
| 280 | UINT32 NumPopulatedChannels; ///< Total number of memory channels populated |
| 281 | HOB_SAGV_INFO SagvConfigInfo; ///< This data structure contains SAGV config values that are considered output by the MRC. |
| 282 | UINT16 TotalMemWidth; ///< Total Memory Width in bits from all populated channels |
| 283 | BOOLEAN MemorySpeedReducedWrongDimmSlot; ///< Can be used by OEM BIOS to display a warning on the screen that DDR speed was reduced due to wrong DIMM population |
| 284 | BOOLEAN MemorySpeedReducedMixedConfig; ///< Can be used by OEM BIOS to display a warning on the screen that DDR speed was reduced due to mixed DIMM config |
| 285 | BOOLEAN DynamicMemoryBoostTrainingFailed; ///< TRUE if Dynamic Memory Boost failed to train and was force disabled on the last full training boot. FALSE otherwise. |
| 286 | } MEMORY_INFO_DATA_HOB; |
| 287 | |
| 288 | /** |
| 289 | Memory Platform Data Hob |
| 290 | |
| 291 | <b>Revision 1:</b> |
| 292 | - Initial version. |
| 293 | <b>Revision 2:</b> |
| 294 | - Added TsegBase, PrmrrSize, PrmrrBase, Gttbase, MmioSize, PciEBaseAddress fields |
| 295 | **/ |
| 296 | typedef struct { |
| 297 | UINT8 Revision; |
| 298 | UINT8 Reserved[3]; |
| 299 | UINT32 BootMode; |
| 300 | UINT32 TsegSize; |
| 301 | UINT32 TsegBase; |
| 302 | UINT32 PrmrrSize; |
| 303 | UINT64 PrmrrBase; |
| 304 | UINT32 GttBase; |
| 305 | UINT32 MmioSize; |
| 306 | UINT32 PciEBaseAddress; |
| 307 | PSMI_MEM_INFO PsmiInfo[MAX_TRACE_CACHE_TYPE]; |
| 308 | PSMI_MEM_INFO PsmiRegionInfo[MAX_TRACE_REGION]; |
| 309 | BOOLEAN MrcBasicMemoryTestPass; |
| 310 | } MEMORY_PLATFORM_DATA; |
| 311 | |
| 312 | typedef struct { |
| 313 | EFI_HOB_GUID_TYPE EfiHobGuidType; |
| 314 | MEMORY_PLATFORM_DATA Data; |
| 315 | UINT8 *Buffer; |
| 316 | } MEMORY_PLATFORM_DATA_HOB; |
| 317 | |
| 318 | #pragma pack (pop) |
| 319 | |
| 320 | #endif // _MEM_INFO_HOB_H_ |