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