forked from ibm-openbmc/openpower-vpd-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
const.hpp
235 lines (217 loc) · 8.09 KB
/
const.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#pragma once
#include <cstdint>
#include <filesystem>
#include <iostream>
namespace openpower
{
namespace vpd
{
namespace constants
{
using RecordId = uint8_t;
using RecordOffset = uint16_t;
using RecordSize = uint16_t;
using RecordType = uint16_t;
using RecordLength = uint16_t;
using KwSize = uint8_t;
using PoundKwSize = uint16_t;
using ECCOffset = uint16_t;
using ECCLength = uint16_t;
using LE2ByteData = uint16_t;
using DataOffset = uint16_t;
static constexpr auto NEXT_64_KB = 65536;
static constexpr auto MAC_ADDRESS_LEN_BYTES = 6;
static constexpr auto LAST_KW = "PF";
static constexpr auto POUND_KW = '#';
static constexpr auto POUND_KW_PREFIX = "PD_";
static constexpr auto NUMERIC_KW_PREFIX = "N_";
static constexpr auto UUID_LEN_BYTES = 16;
static constexpr auto UUID_TIME_LOW_END = 8;
static constexpr auto UUID_TIME_MID_END = 13;
static constexpr auto UUID_TIME_HIGH_END = 18;
static constexpr auto UUID_CLK_SEQ_END = 23;
static constexpr auto MB_RESULT_LEN = 19;
static constexpr auto MB_LEN_BYTES = 8;
static constexpr auto MB_YEAR_END = 4;
static constexpr auto MB_MONTH_END = 7;
static constexpr auto MB_DAY_END = 10;
static constexpr auto MB_HOUR_END = 13;
static constexpr auto MB_MIN_END = 16;
static constexpr auto SYSTEM_OBJECT = "/system/chassis/motherboard";
static constexpr auto IBM_LOCATION_CODE_INF = "com.ibm.ipzvpd.Location";
static constexpr auto XYZ_LOCATION_CODE_INF =
"xyz.openbmc_project.Inventory.Decorator.LocationCode";
constexpr int IPZ_DATA_START = 11;
constexpr uint8_t KW_VAL_PAIR_START_TAG = 0x84;
constexpr uint8_t RECORD_END_TAG = 0x78;
constexpr int UNEXP_LOCATION_CODE_MIN_LENGTH = 4;
constexpr uint8_t EXP_LOCATIN_CODE_MIN_LENGTH = 17;
static constexpr auto SE_KWD_LENGTH = 7;
static constexpr auto INVALID_NODE_NUMBER = -1;
static constexpr auto RAINIER_2U = "50001001.json";
static constexpr auto RAINIER_2U_V2 = "50001001_v2.json";
static constexpr auto RAINIER_4U = "50001000.json";
static constexpr auto RAINIER_4U_V2 = "50001000_v2.json";
static constexpr auto RAINIER_1S4U = "50001002.json";
static constexpr auto EVEREST = "50003000.json";
static constexpr auto EVEREST_V2 = "50003000_v2.json";
static constexpr auto BONNELL = "50004000.json";
static constexpr auto BLUERIDGE_2U = "60001001.json";
static constexpr auto BLUERIDGE_2U_V2 = "60001001_v2.json";
static constexpr auto BLUERIDGE_4U = "60001000.json";
static constexpr auto BLUERIDGE_4U_V2 = "60001000_v2.json";
static constexpr auto BLUERIDGE_1S4U = "60001002.json";
static constexpr auto FUJI = "60002000.json";
static constexpr auto FUJI_V2 = "60002000_v2.json";
static constexpr auto HUYGENS = "70001000.json";
constexpr uint8_t KW_VPD_START_TAG = 0x82;
constexpr uint8_t KW_VPD_END_TAG = 0x78;
constexpr uint8_t ALT_KW_VAL_PAIR_START_TAG = 0x90;
constexpr uint8_t KW_VAL_PAIR_END_TAG = 0x79;
constexpr auto MEMORY_VPD_START_TAG = "11S";
constexpr int TWO_BYTES = 2;
constexpr int KW_VPD_DATA_START = 0;
constexpr auto MEMORY_VPD_DATA_START = 416;
constexpr auto FORMAT_11S_LEN = 3;
static constexpr auto PART_NUM_LEN = 7;
static constexpr auto SERIAL_NUM_LEN = 12;
static constexpr auto CCIN_LEN = 4;
static constexpr auto CONVERT_MB_TO_KB = 1024;
static constexpr auto CONVERT_GB_TO_KB = 1024 * 1024;
static constexpr auto SPD_BYTE_2 = 2;
static constexpr auto SPD_BYTE_3 = 3;
static constexpr auto SPD_BYTE_4 = 4;
static constexpr auto SPD_BYTE_6 = 6;
static constexpr auto SPD_BYTE_12 = 12;
static constexpr auto SPD_BYTE_13 = 13;
static constexpr auto SPD_BYTE_18 = 18;
static constexpr auto SPD_BYTE_234 = 234;
static constexpr auto SPD_BYTE_235 = 235;
static constexpr auto SPD_BYTE_BIT_0_3_MASK = 0x0F;
static constexpr auto SPD_BYTE_MASK = 0xFF;
static constexpr auto VALUE_0 = 0;
static constexpr auto VALUE_1 = 1;
static constexpr auto VALUE_2 = 2;
static constexpr auto VALUE_3 = 3;
static constexpr auto VALUE_4 = 4;
static constexpr auto VALUE_5 = 5;
static constexpr auto VALUE_6 = 6;
static constexpr auto VALUE_7 = 7;
static constexpr auto VALUE_8 = 8;
static constexpr auto VALUE_10 = 10;
static constexpr auto VALUE_100000 = 100000;
static constexpr auto MASK_BYTE_BITS_6 = 0x40;
static constexpr auto MASK_BYTE_BITS_7 = 0x80;
static constexpr auto MASK_BYTE_BITS_01 = 0x03;
static constexpr auto MASK_BYTE_BITS_345 = 0x38;
static constexpr auto MASK_BYTE_BITS_012 = 0x07;
static constexpr auto MASK_BYTE_BITS_567 = 0xE0;
static constexpr auto MASK_BYTE_BITS_0123 = 0x0F;
static constexpr auto MASK_BYTE_BITS_01234 = 0x1F;
static constexpr auto SHIFT_BITS_0 = 0;
static constexpr auto SHIFT_BITS_3 = 3;
static constexpr auto SHIFT_BITS_5 = 5;
static constexpr auto SPD_MODULE_TYPE_DDIMM = 0x0A;
static constexpr auto SPD_DRAM_TYPE_DDR5 = 0x12;
static constexpr auto SPD_DRAM_TYPE_DDR4 = 0x0C;
constexpr auto pimPath = "/xyz/openbmc_project/inventory";
constexpr auto pimIntf = "xyz.openbmc_project.Inventory.Manager";
constexpr auto pimService = "xyz.openbmc_project.Inventory.Manager";
constexpr auto kwdVpdInf = "com.ibm.ipzvpd.VINI";
constexpr auto memVpdInf = "com.ibm.ipzvpd.VINI";
constexpr auto ipzVpdInf = "com.ibm.ipzvpd.";
constexpr auto offsetJsonDirectory = "/var/lib/vpd/";
constexpr auto mapperObjectPath = "/xyz/openbmc_project/object_mapper";
constexpr auto mapperInterface = "xyz.openbmc_project.ObjectMapper";
constexpr auto mapperDestination = "xyz.openbmc_project.ObjectMapper";
constexpr auto loggerService = "xyz.openbmc_project.Logging";
constexpr auto loggerObjectPath = "/xyz/openbmc_project/logging";
constexpr auto loggerCreateInterface = "xyz.openbmc_project.Logging.Create";
constexpr auto errIntfForVPDDefault = "com.ibm.VPD.Error.DefaultValue";
constexpr auto errIntfForInvalidVPD = "com.ibm.VPD.Error.InvalidVPD";
constexpr auto errIntfForVPDMismatch = "com.ibm.VPD.Error.Mismatch";
constexpr auto errIntfForStreamFail = "com.ibm.VPD.Error.InvalidEepromPath";
constexpr auto errIntfForEccCheckFail = "com.ibm.VPD.Error.EccCheckFailed";
constexpr auto errIntfForJsonFailure = "com.ibm.VPD.Error.InvalidJson";
constexpr auto errIntfForBusFailure = "com.ibm.VPD.Error.DbusFailure";
constexpr auto errIntfForInvalidSystemType =
"com.ibm.VPD.Error.UnknownSytemType";
constexpr auto errIntfForEssentialFru = "com.ibm.VPD.Error.RequiredFRUMissing";
constexpr auto errIntfForGpioError = "com.ibm.VPD.Error.GPIOError";
constexpr auto motherBoardInterface =
"xyz.openbmc_project.Inventory.Item.Board.Motherboard";
constexpr auto systemVpdFilePath = "/sys/bus/i2c/drivers/at24/8-0050/eeprom";
constexpr auto i2cPathPrefix = "/sys/bus/i2c/drivers/";
constexpr auto spiPathPrefix = "/sys/bus/spi/drivers/";
constexpr auto at24driver = "at24";
constexpr auto at25driver = "at25";
constexpr auto ee1004driver = "ee1004";
constexpr auto invItemIntf = "xyz.openbmc_project.Inventory.Item";
constexpr auto invAssetIntf = "xyz.openbmc_project.Inventory.Decorator.Asset";
constexpr auto invOperationalStatusIntf =
"xyz.openbmc_project.State.Decorator.OperationalStatus";
static constexpr std::uintmax_t MAX_VPD_SIZE = 65504;
namespace lengths
{
enum Lengths
{
RECORD_NAME = 4,
KW_NAME = 2,
RECORD_OFFSET = 2,
RECORD_MIN = 44,
RECORD_LENGTH = 2,
RECORD_ECC_OFFSET = 2,
VHDR_ECC_LENGTH = 11,
VHDR_RECORD_LENGTH = 44
}; // enum Lengths
} // namespace lengths
namespace offsets
{
enum Offsets
{
VHDR = 17,
VHDR_TOC_ENTRY = 29,
VTOC_PTR = 35,
VTOC_REC_LEN = 37,
VTOC_ECC_OFF = 39,
VTOC_ECC_LEN = 41,
VTOC_DATA = 13,
VHDR_ECC = 0,
VHDR_RECORD = 11
};
} // namespace offsets
namespace eccStatus
{
enum Status
{
SUCCESS = 0,
FAILED = -1
};
} // namespace eccStatus
/**
* @brief Types of VPD
*/
enum vpdType
{
IPZ_VPD, /**< IPZ VPD type */
KEYWORD_VPD, /**< Keyword VPD type */
DDR4_DDIMM_MEMORY_VPD, /**< DDR4 DDIMM Memory VPD type */
DDR5_DDIMM_MEMORY_VPD, /**< DDR5 DDIMM Memory VPD type */
DDR4_ISDIMM_MEMORY_VPD, /**< DDR4 ISDIMM Memory VPD type */
DDR5_ISDIMM_MEMORY_VPD, /**< DDR5 ISDIMM Memory VPD type */
INVALID_VPD_FORMAT /**< Invalid VPD type Format */
};
enum PelSeverity
{
NOTICE,
INFORMATIONAL,
DEBUG,
WARNING,
CRITICAL,
EMERGENCY,
ALERT,
ERROR
};
} // namespace constants
} // namespace vpd
} // namespace openpower