| 1 | /***************************************************************************** |
| 2 | * |
| 3 | * Copyright (c) 2008 - 2017, Advanced Micro Devices, Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are met: |
| 8 | * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 14 | * its contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY |
| 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | * |
| 28 | ***************************************************************************/ |
| 29 | |
| 30 | /** |
| 31 | * This code is based on the src/vendorcode/amd/pi/00670F00/AGESA.h. |
| 32 | * SoC-family-specific defines were moved to soc_dmi_info.h file. |
| 33 | */ |
| 34 | |
| 35 | #include <soc_dmi_info.h> |
| 36 | #include <smbios.h> |
| 37 | |
| 38 | #define AMD_FSP_DMI_HOB_GUID {0x4118FC0E, 0x353D, 0x4726, { 0x97, 0xC0, 0x53, 0xCD, 0x92, 0xB6, 0x49, 0x25}} |
| 39 | |
| 40 | // Our ACPI HOB max payload, accounting for the size of the HOB header as well as the information structure |
| 41 | #define HOB_MAX_SIZE 0xFFF8 |
| 42 | #define HOB_GUID_EXTENSION_SIZE (HOB_MAX_SIZE - sizeof (EFI_HOB_GUID_TYPE)) |
| 43 | |
| 44 | /// DMI Type 16 offset 04h - Location |
| 45 | typedef enum { |
| 46 | OtherLocation = 0x01, ///< Assign 01 to Other |
| 47 | UnknownLocation, ///< Assign 02 to Unknown |
| 48 | SystemboardOrMotherboard, ///< Assign 03 to systemboard or motherboard |
| 49 | IsaAddonCard, ///< Assign 04 to ISA add-on card |
| 50 | EisaAddonCard, ///< Assign 05 to EISA add-on card |
| 51 | PciAddonCard, ///< Assign 06 to PCI add-on card |
| 52 | McaAddonCard, ///< Assign 07 to MCA add-on card |
| 53 | PcmciaAddonCard, ///< Assign 08 to PCMCIA add-on card |
| 54 | ProprietaryAddonCard, ///< Assign 09 to proprietary add-on card |
| 55 | NuBus, ///< Assign 0A to NuBus |
| 56 | Pc98C20AddonCard, ///< Assign 0A0 to PC-98/C20 add-on card |
| 57 | Pc98C24AddonCard, ///< Assign 0A1 to PC-98/C24 add-on card |
| 58 | Pc98EAddoncard, ///< Assign 0A2 to PC-98/E add-on card |
| 59 | Pc98LocalBusAddonCard ///< Assign 0A3 to PC-98/Local bus add-on card |
| 60 | } DMI_T16_LOCATION; |
| 61 | |
| 62 | /// DMI Type 16 offset 05h - Memory Error Correction |
| 63 | typedef enum { |
| 64 | OtherUse = 0x01, ///< Assign 01 to Other |
| 65 | UnknownUse, ///< Assign 02 to Unknown |
| 66 | SystemMemory, ///< Assign 03 to system memory |
| 67 | VideoMemory, ///< Assign 04 to video memory |
| 68 | FlashMemory, ///< Assign 05 to flash memory |
| 69 | NonvolatileRam, ///< Assign 06 to non-volatile RAM |
| 70 | CacheMemory ///< Assign 07 to cache memory |
| 71 | } DMI_T16_USE; |
| 72 | |
| 73 | /// DMI Type 16 offset 07h - Maximum Capacity |
| 74 | typedef enum { |
| 75 | Dmi16OtherErrCorrection = 0x01, ///< Assign 01 to Other |
| 76 | Dmi16UnknownErrCorrection, ///< Assign 02 to Unknown |
| 77 | Dmi16NoneErrCorrection, ///< Assign 03 to None |
| 78 | Dmi16Parity, ///< Assign 04 to parity |
| 79 | Dmi16SingleBitEcc, ///< Assign 05 to Single-bit ECC |
| 80 | Dmi16MultiBitEcc, ///< Assign 06 to Multi-bit ECC |
| 81 | Dmi16Crc ///< Assign 07 to CRC |
| 82 | } DMI_T16_ERROR_CORRECTION; |
| 83 | |
| 84 | /// DMI Type 16 - Physical Memory Array |
| 85 | typedef struct { |
| 86 | OUT DMI_T16_LOCATION Location; ///< The physical location of the Memory Array, |
| 87 | ///< whether on the system board or an add-in board. |
| 88 | OUT DMI_T16_USE Use; ///< Identifies the function for which the array |
| 89 | ///< is used. |
| 90 | OUT DMI_T16_ERROR_CORRECTION MemoryErrorCorrection; ///< The primary hardware error correction or |
| 91 | ///< detection method supported by this memory array. |
| 92 | OUT UINT16 NumberOfMemoryDevices; ///< The number of slots or sockets available |
| 93 | ///< for memory devices in this array. |
| 94 | } TYPE16_DMI_INFO; |
| 95 | |
| 96 | /// DMI Type 17 offset 13h - Type Detail |
| 97 | typedef struct { |
| 98 | OUT UINT16 Reserved1:1; ///< Reserved |
| 99 | OUT UINT16 Other:1; ///< Other |
| 100 | OUT UINT16 Unknown:1; ///< Unknown |
| 101 | OUT UINT16 FastPaged:1; ///< Fast-Paged |
| 102 | OUT UINT16 StaticColumn:1; ///< Static column |
| 103 | OUT UINT16 PseudoStatic:1; ///< Pseudo-static |
| 104 | OUT UINT16 Rambus:1; ///< RAMBUS |
| 105 | OUT UINT16 Synchronous:1; ///< Synchronous |
| 106 | OUT UINT16 Cmos:1; ///< CMOS |
| 107 | OUT UINT16 Edo:1; ///< EDO |
| 108 | OUT UINT16 WindowDram:1; ///< Window DRAM |
| 109 | OUT UINT16 CacheDram:1; ///< Cache Dram |
| 110 | OUT UINT16 NonVolatile:1; ///< Non-volatile |
| 111 | OUT UINT16 Registered:1; ///< Registered (Buffered) |
| 112 | OUT UINT16 Unbuffered:1; ///< Unbuffered (Unregistered) |
| 113 | OUT UINT16 LRDIMM:1; ///< LRDIMM |
| 114 | } DMI_T17_TYPE_DETAIL; |
| 115 | |
| 116 | /// DMI Type 17 offset 28h - Memory Technology |
| 117 | typedef enum { |
| 118 | OtherType = 0x01, ///< Assign 01 to Other |
| 119 | UnknownType = 0x02, ///< Assign 02 to Unknown |
| 120 | DramType = 0x03, ///< Assign 03 to DRAM |
| 121 | NvDimmNType = 0x04, ///< Assign 04 to NVDIMM-N |
| 122 | NvDimmFType = 0x05, ///< Assign 05 to NVDIMM-F |
| 123 | NvDimmPType = 0x06, ///< Assign 06 to NVDIMM-P |
| 124 | IntelPersistentMemoryType = 0x07, ///< Assign 07 to Intel persistent memory |
| 125 | } DMI_T17_MEMORY_TECHNOLOGY; |
| 126 | |
| 127 | /// DMI Type 17 offset 29h - Memory Operating Mode Capability |
| 128 | typedef struct { |
| 129 | OUT UINT16 Reserved1:1; ///< Reserved, set to 0 |
| 130 | OUT UINT16 Other:1; ///< Other |
| 131 | OUT UINT16 Unknown:1; ///< Unknown |
| 132 | OUT UINT16 VolatileMemory:1; ///< Volatile memory |
| 133 | OUT UINT16 ByteAccessiblePersistentMemory:1; ///< Byte-accessible persistent memory |
| 134 | OUT UINT16 BlockAccessiblePersistentMemory:1; ///< Block-accessible persistent memory |
| 135 | OUT UINT16 Reserved2:10; ///< Reserved, set to 0 |
| 136 | } DMI_T17_MEMORY_OPERATING_MODE_CAPABILITY; |
| 137 | |
| 138 | typedef union { |
| 139 | DMI_T17_MEMORY_OPERATING_MODE_CAPABILITY AsBitmap; |
| 140 | UINT16 AsUint16; |
| 141 | } DMI_T17_MEMORY_OPERATING_MODE_CAPABILITY_VAR; |
| 142 | |
| 143 | /// DMI Type 17 - Memory Device |
| 144 | typedef struct { |
| 145 | OUT UINT16 Handle; ///< The temporary handle, or instance number, associated with the structure |
| 146 | OUT UINT16 TotalWidth; ///< Total Width, in bits, of this memory device, including any check or error-correction bits. |
| 147 | OUT UINT16 DataWidth; ///< Data Width, in bits, of this memory device. |
| 148 | OUT UINT16 MemorySize; ///< The size of the memory device. |
| 149 | OUT smbios_memory_form_factor FormFactor; ///< The implementation form factor for this memory device. |
| 150 | OUT UINT8 DeviceSet; ///< Identifies when the Memory Device is one of a set of |
| 151 | ///< Memory Devices that must be populated with all devices of |
| 152 | ///< the same type and size, and the set to which this device belongs. |
| 153 | OUT CHAR8 DeviceLocator[8]; ///< The string number of the string that identifies the physically labeled socket or board position where the memory device is located. |
| 154 | OUT CHAR8 BankLocator[13]; ///< The string number of the string that identifies the physically labeled bank where the memory device is located. |
| 155 | OUT smbios_memory_type MemoryType; ///< The type of memory used in this device. |
| 156 | OUT DMI_T17_TYPE_DETAIL TypeDetail; ///< Additional detail on the memory device type |
| 157 | OUT UINT16 Speed; ///< Identifies the speed of the device, in megahertz (MHz). |
| 158 | OUT UINT64 ManufacturerIdCode; ///< Manufacturer ID code. |
| 159 | OUT CHAR8 SerialNumber[9]; ///< Serial Number. |
| 160 | OUT CHAR8 PartNumber[AGESA_STRUCT_PART_NUMBER_SIZE]; ///< Part Number. |
| 161 | OUT UINT8 Attributes; ///< Bits 7-4: Reserved, Bits 3-0: rank. |
| 162 | OUT UINT32 ExtSize; ///< Extended Size. |
| 163 | OUT UINT16 ConfigSpeed; ///< Configured memory clock speed |
| 164 | OUT UINT16 MinimumVoltage; ///< Minimum operating voltage for this device, in millivolts |
| 165 | OUT UINT16 MaximumVoltage; ///< Maximum operating voltage for this device, in millivolts |
| 166 | OUT UINT16 ConfiguredVoltage; ///< Configured voltage for this device, in millivolts |
| 167 | // SMBIOS 3.2 |
| 168 | #ifdef SMBIOS_3_2_3_3_SUPPORT |
| 169 | OUT UINT8 MemoryTechnology; ///< Memory technology type for this memory device |
| 170 | OUT DMI_T17_MEMORY_OPERATING_MODE_CAPABILITY_VAR MemoryOperatingModeCapability; ///< The operating modes supported by this memory device |
| 171 | OUT CHAR8 FirmwareVersion[10]; ///< String number for the firmware version of this memory device |
| 172 | OUT UINT16 ModuleManufacturerId; ///< The two-byte module manufacturer ID found in the SPD of this memory device; LSB first. |
| 173 | OUT UINT16 ModuleProductId; ///< The two-byte module product ID found in the SPD of this memory device; LSB first |
| 174 | OUT UINT16 MemorySubsystemControllerManufacturerId; //< The two-byte memory subsystem controller manufacturer ID found in the SPD of this memory device; LSB first |
| 175 | OUT UINT16 MemorySubsystemControllerProductId; //< The two-byte memory subsystem controller product ID found in the SPD of this memory device; LSB first |
| 176 | OUT UINT64 NonvolatileSize; ///< Size of the Non-volatile portion of the memory device in Bytes, if any. |
| 177 | OUT UINT64 VolatileSize; ///< Size of the Volatile portion of the memory device in Bytes, if any. |
| 178 | OUT UINT64 CacheSize; ///< Size of the Cache portion of the memory device in Bytes, if any. |
| 179 | OUT UINT64 LogicalSize; ///< Size of the Logical memory device in Bytes. |
| 180 | // SMBIOS 3.3 |
| 181 | OUT UINT32 ExtendedSpeed; ///< Extended Speed |
| 182 | OUT UINT32 ExtendedConfiguredMemorySpeed; ///< Extended Configured memory speed |
| 183 | #endif |
| 184 | } __packed TYPE17_DMI_INFO; |
| 185 | |
| 186 | /// Collection of pointers to the DMI records |
| 187 | typedef struct { |
| 188 | OUT TYPE16_DMI_INFO T16; ///< Type 16 struc |
| 189 | OUT TYPE17_DMI_INFO T17[AGESA_STRUCT_SOCKET_COUNT][AGESA_STRUCT_CHANNELS_PER_SOCKET][AGESA_STRUCT_DIMMS_PER_CHANNEL]; ///< Type 17 struc |
| 190 | } DMI_INFO; |