1 #pragma once 2 3 #include <cstdint> 4 #include <iostream> 5 #include <vector> 6 namespace vpd 7 { 8 namespace constants 9 { 10 static constexpr auto KEYWORD_SIZE = 2; 11 static constexpr auto RECORD_SIZE = 4; 12 13 static constexpr uint8_t IPZ_DATA_START = 11; 14 static constexpr uint8_t IPZ_DATA_START_TAG = 0x84; 15 static constexpr uint8_t IPZ_RECORD_END_TAG = 0x78; 16 17 static constexpr uint8_t KW_VPD_DATA_START = 0; 18 static constexpr uint8_t KW_VPD_START_TAG = 0x82; 19 static constexpr uint8_t KW_VPD_PAIR_START_TAG = 0x84; 20 static constexpr uint8_t ALT_KW_VPD_PAIR_START_TAG = 0x90; 21 static constexpr uint8_t KW_VPD_END_TAG = 0x78; 22 static constexpr uint8_t KW_VAL_PAIR_END_TAG = 0x79; 23 static constexpr uint8_t AMM_ENABLED_IN_VPD = 2; 24 static constexpr uint8_t AMM_DISABLED_IN_VPD = 1; 25 26 static constexpr auto DDIMM_11S_BARCODE_START = 416; 27 static constexpr auto DDIMM_11S_BARCODE_START_TAG = "11S"; 28 static constexpr auto DDIMM_11S_FORMAT_LEN = 3; 29 static constexpr auto DDIMM_11S_BARCODE_LEN = 26; 30 static constexpr auto PART_NUM_LEN = 7; 31 static constexpr auto SERIAL_NUM_LEN = 12; 32 static constexpr auto CCIN_LEN = 4; 33 static constexpr auto CONVERT_MB_TO_KB = 1024; 34 static constexpr auto CONVERT_GB_TO_KB = 1024 * 1024; 35 36 static constexpr auto SPD_BYTE_2 = 2; 37 static constexpr auto SPD_BYTE_3 = 3; 38 static constexpr auto SPD_BYTE_4 = 4; 39 static constexpr auto SPD_BYTE_6 = 6; 40 static constexpr auto SPD_BYTE_12 = 12; 41 static constexpr auto SPD_BYTE_13 = 13; 42 static constexpr auto SPD_BYTE_18 = 18; 43 static constexpr auto SPD_BYTE_234 = 234; 44 static constexpr auto SPD_BYTE_235 = 235; 45 static constexpr auto SPD_BYTE_BIT_0_3_MASK = 0x0F; 46 static constexpr auto SPD_BYTE_MASK = 0xFF; 47 static constexpr auto SPD_MODULE_TYPE_DDIMM = 0x0A; 48 static constexpr auto SPD_DRAM_TYPE_DDR5 = 0x12; 49 static constexpr auto SPD_DRAM_TYPE_DDR4 = 0x0C; 50 51 static constexpr auto JEDEC_SDRAM_CAP_MASK = 0x0F; 52 static constexpr auto JEDEC_PRI_BUS_WIDTH_MASK = 0x07; 53 static constexpr auto JEDEC_SDRAM_WIDTH_MASK = 0x07; 54 static constexpr auto JEDEC_NUM_RANKS_MASK = 0x38; 55 static constexpr auto JEDEC_DIE_COUNT_MASK = 0x70; 56 static constexpr auto JEDEC_SINGLE_LOAD_STACK = 0x02; 57 static constexpr auto JEDEC_SIGNAL_LOADING_MASK = 0x03; 58 59 static constexpr auto JEDEC_SDRAMCAP_MULTIPLIER = 256; 60 static constexpr auto JEDEC_PRI_BUS_WIDTH_MULTIPLIER = 8; 61 static constexpr auto JEDEC_SDRAM_WIDTH_MULTIPLIER = 4; 62 static constexpr auto JEDEC_SDRAMCAP_RESERVED = 7; 63 static constexpr auto JEDEC_RESERVED_BITS = 3; 64 static constexpr auto JEDEC_DIE_COUNT_RIGHT_SHIFT = 4; 65 66 static constexpr auto LAST_KW = "PF"; 67 static constexpr auto POUND_KW = '#'; 68 static constexpr auto POUND_KW_PREFIX = "PD_"; 69 static constexpr auto MB_YEAR_END = 4; 70 static constexpr auto MB_MONTH_END = 7; 71 static constexpr auto MB_DAY_END = 10; 72 static constexpr auto MB_HOUR_END = 13; 73 static constexpr auto MB_MIN_END = 16; 74 static constexpr auto MB_RESULT_LEN = 19; 75 static constexpr auto MB_LEN_BYTES = 8; 76 static constexpr auto UUID_LEN_BYTES = 16; 77 static constexpr auto UUID_TIME_LOW_END = 8; 78 static constexpr auto UUID_TIME_MID_END = 13; 79 static constexpr auto UUID_TIME_HIGH_END = 18; 80 static constexpr auto UUID_CLK_SEQ_END = 23; 81 static constexpr auto MAC_ADDRESS_LEN_BYTES = 6; 82 static constexpr auto ONE_BYTE = 1; 83 static constexpr auto TWO_BYTES = 2; 84 85 static constexpr auto VALUE_0 = 0; 86 static constexpr auto VALUE_1 = 1; 87 static constexpr auto VALUE_2 = 2; 88 static constexpr auto VALUE_3 = 3; 89 static constexpr auto VALUE_4 = 4; 90 static constexpr auto VALUE_5 = 5; 91 static constexpr auto VALUE_6 = 6; 92 static constexpr auto VALUE_7 = 7; 93 static constexpr auto VALUE_8 = 8; 94 static constexpr auto VALUE_21 = 21; 95 96 static constexpr auto MASK_BYTE_BITS_01 = 0x03; 97 static constexpr auto MASK_BYTE_BITS_345 = 0x38; 98 static constexpr auto MASK_BYTE_BITS_012 = 0x07; 99 static constexpr auto MASK_BYTE_BITS_567 = 0xE0; 100 static constexpr auto MASK_BYTE_BITS_01234 = 0x1F; 101 102 static constexpr auto MASK_BYTE_BIT_6 = 0x40; 103 static constexpr auto MASK_BYTE_BIT_7 = 0x80; 104 105 static constexpr auto SHIFT_BITS_0 = 0; 106 static constexpr auto SHIFT_BITS_3 = 3; 107 static constexpr auto SHIFT_BITS_5 = 5; 108 109 static constexpr auto ASCII_OF_SPACE = 32; 110 111 // Size of 8 EQs' in CP00's PG keyword 112 static constexpr auto SIZE_OF_8EQ_IN_PG = 24; 113 114 // Zero based index position of first EQ in CP00's PG keyword 115 static constexpr auto INDEX_OF_EQ0_IN_PG = 97; 116 117 static constexpr auto HEX_VALUE_50 = 0x50; 118 static constexpr auto HEX_VALUE_30 = 0x30; 119 static constexpr auto HEX_VALUE_10 = 0x10; 120 static constexpr auto HEX_VALUE_00 = 0x00; 121 122 constexpr auto systemInvPath = "/xyz/openbmc_project/inventory/system"; 123 constexpr auto rainierPlanarInvPath = 124 "/xyz/openbmc_project/inventory/system/chassis/motherboard"; 125 constexpr auto pimPath = "/xyz/openbmc_project/inventory"; 126 constexpr auto pimIntf = "xyz.openbmc_project.Inventory.Manager"; 127 constexpr auto ipzVpdInf = "com.ibm.ipzvpd."; 128 constexpr auto kwdVpdInf = "com.ibm.ipzvpd.VINI"; 129 constexpr auto vsysInf = "com.ibm.ipzvpd.VSYS"; 130 constexpr auto utilInf = "com.ibm.ipzvpd.UTIL"; 131 constexpr auto vcenInf = "com.ibm.ipzvpd.VCEN"; 132 constexpr auto viniInf = "com.ibm.ipzvpd.VINI"; 133 constexpr auto vsbpInf = "com.ibm.ipzvpd.VSBP"; 134 constexpr auto kwdCCIN = "CC"; 135 constexpr auto kwdRG = "RG"; 136 constexpr auto kwdAMM = "MM"; 137 constexpr auto kwdClearNVRAM_CreateLPAR = "BA"; 138 constexpr auto kwdKeepAndClear = "BA"; 139 constexpr auto kwdFC = "FC"; 140 constexpr auto kwdTM = "TM"; 141 constexpr auto kwdSE = "SE"; 142 constexpr auto kwdHW = "HW"; 143 constexpr auto kwdIM = "IM"; 144 constexpr auto kwdPN = "PN"; 145 constexpr auto kwdFN = "FN"; 146 constexpr auto recVSYS = "VSYS"; 147 constexpr auto recVCEN = "VCEN"; 148 constexpr auto recVSBP = "VSBP"; 149 constexpr auto locationCodeInf = "com.ibm.ipzvpd.Location"; 150 constexpr auto xyzLocationCodeInf = 151 "xyz.openbmc_project.Inventory.Decorator.LocationCode"; 152 constexpr auto operationalStatusInf = 153 "xyz.openbmc_project.State.Decorator.OperationalStatus"; 154 constexpr auto enableInf = "xyz.openbmc_project.Object.Enable"; 155 constexpr auto assetInf = "xyz.openbmc_project.Inventory.Decorator.Asset"; 156 constexpr auto inventoryItemInf = "xyz.openbmc_project.Inventory.Item"; 157 constexpr auto pldmServiceName = "xyz.openbmc_project.PLDM"; 158 constexpr auto pimServiceName = "xyz.openbmc_project.Inventory.Manager"; 159 constexpr auto biosConfigMgrObjPath = 160 "/xyz/openbmc_project/bios_config/manager"; 161 constexpr auto biosConfigMgrService = "xyz.openbmc_project.BIOSConfigManager"; 162 constexpr auto biosConfigMgrInterface = 163 "xyz.openbmc_project.BIOSConfig.Manager"; 164 constexpr auto objectMapperService = "xyz.openbmc_project.ObjectMapper"; 165 constexpr auto objectMapperPath = "/xyz/openbmc_project/object_mapper"; 166 constexpr auto objectMapperInf = "xyz.openbmc_project.ObjectMapper"; 167 constexpr auto systemVpdInvPath = systemInvPath; 168 constexpr auto motherboardInterface = 169 "xyz.openbmc_project.Inventory.Item.Board.Motherboard"; 170 constexpr auto assetTagInf = "xyz.openbmc_project.Inventory.Decorator.AssetTag"; 171 constexpr auto hostObjectPath = "/xyz/openbmc_project/state/host0"; 172 constexpr auto hostInterface = "xyz.openbmc_project.State.Host"; 173 constexpr auto hostService = "xyz.openbmc_project.State.Host"; 174 constexpr auto hostRunningState = 175 "xyz.openbmc_project.State.Host.HostState.Running"; 176 constexpr auto imageUpdateService = "xyz.openbmc_project.Software.BMC.Updater"; 177 constexpr auto imagePrirotyInf = 178 "xyz.openbmc_project.Software.RedundancyPriority"; 179 constexpr auto imageExtendedVerInf = 180 "xyz.openbmc_project.Software.ExtendedVersion"; 181 constexpr auto functionalImageObjPath = 182 "/xyz/openbmc_project/software/functional"; 183 constexpr auto associationInterface = "xyz.openbmc_project.Association"; 184 constexpr auto powerVsImagePrefix_MY = "MY"; 185 constexpr auto powerVsImagePrefix_MZ = "MZ"; 186 constexpr auto powerVsImagePrefix_NY = "NY"; 187 constexpr auto powerVsImagePrefix_NZ = "NZ"; 188 constexpr auto badVpdDir = "/var/lib/vpd/dumps/"; 189 constexpr auto bmcPositionFile = "/run/openbmc/bmc_position"; 190 191 static constexpr auto BD_YEAR_END = 4; 192 static constexpr auto BD_MONTH_END = 7; 193 static constexpr auto BD_DAY_END = 10; 194 static constexpr auto BD_HOUR_END = 13; 195 196 constexpr uint8_t UNEXP_LOCATION_CODE_MIN_LENGTH = 4; 197 constexpr uint8_t EXP_LOCATION_CODE_MIN_LENGTH = 17; 198 static constexpr auto SE_KWD_LENGTH = 7; 199 static constexpr auto INVALID_NODE_NUMBER = -1; 200 201 static constexpr auto CMD_BUFFER_LENGTH = 256; 202 203 // To be explicitly used for string comparision. 204 static constexpr auto STR_CMP_SUCCESS = 0; 205 206 // Just a random value. Can be adjusted as required. 207 static constexpr uint8_t MAX_THREADS = 10; 208 209 static constexpr auto FAILURE = -1; 210 static constexpr auto SUCCESS = 0; 211 212 constexpr auto bmcStateService = "xyz.openbmc_project.State.BMC"; 213 constexpr auto bmcZeroStateObject = "/xyz/openbmc_project/state/bmc0"; 214 constexpr auto bmcStateInterface = "xyz.openbmc_project.State.BMC"; 215 constexpr auto currentBMCStateProperty = "CurrentBMCState"; 216 constexpr auto bmcReadyState = "xyz.openbmc_project.State.BMC.BMCState.Ready"; 217 218 static constexpr auto eventLoggingServiceName = "xyz.openbmc_project.Logging"; 219 static constexpr auto eventLoggingObjectPath = "/xyz/openbmc_project/logging"; 220 static constexpr auto eventLoggingInterface = 221 "xyz.openbmc_project.Logging.Create"; 222 223 static constexpr auto systemdService = "org.freedesktop.systemd1"; 224 static constexpr auto systemdObjectPath = "/org/freedesktop/systemd1"; 225 static constexpr auto systemdManagerInterface = 226 "org.freedesktop.systemd1.Manager"; 227 228 static constexpr auto vpdCollectionInterface = 229 "xyz.openbmc_project.Common.Progress"; 230 231 // enumerated values of collection Status D-bus property defined under 232 // xyz.openbmc_project.Common.Progress interface. 233 static constexpr auto vpdCollectionCompleted = 234 "xyz.openbmc_project.Common.Progress.OperationStatus.Completed"; 235 static constexpr auto vpdCollectionFailed = 236 "xyz.openbmc_project.Common.Progress.OperationStatus.Failed"; 237 static constexpr auto vpdCollectionInProgress = 238 "xyz.openbmc_project.Common.Progress.OperationStatus.InProgress"; 239 static constexpr auto vpdCollectionNotStarted = 240 "xyz.openbmc_project.Common.Progress.OperationStatus.NotStarted"; 241 static constexpr auto power_vs_50003_json = 242 "/usr/share/vpd/50003_power_vs.json"; 243 static constexpr auto power_vs_50001_json = 244 "/usr/share/vpd/50001_power_vs.json"; 245 246 static constexpr auto rbmcPositionInterface = 247 "xyz.openbmc_project.Inventory.Decorator.Position"; 248 static std::vector<uint8_t> rbmcPrototypeSystemImValue{118, 0, 32, 0}; 249 250 static constexpr auto fileModeDirectoryPath = "/var/lib/vpd/file"; 251 static constexpr auto pimBackupPath = 252 "/var/lib/phosphor-data-sync/bmc_data_bkp/var/lib/phosphor-inventory-manager"; 253 static constexpr auto pimPrimaryPath = "/var/lib/phosphor-inventory-manager"; 254 } // namespace constants 255 } // namespace vpd 256