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