SunnySrivastava1984 | a739259 | 2020-03-09 10:19:33 -0500 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 3 | #include "editor_impl.hpp" |
| 4 | |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 5 | #include "common_utility.hpp" |
Sunny Srivastava | 6c71c9d | 2021-04-15 04:43:54 -0500 | [diff] [blame] | 6 | #include "ibm_vpd_utils.hpp" |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 7 | #include "ipz_parser.hpp" |
| 8 | #include "parser_factory.hpp" |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 9 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 10 | #include "vpdecc/vpdecc.h" |
| 11 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 12 | using namespace openpower::vpd::parser::interface; |
| 13 | using namespace openpower::vpd::constants; |
| 14 | using namespace openpower::vpd::parser::factory; |
| 15 | using namespace openpower::vpd::ipz::parser; |
| 16 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 17 | namespace openpower |
| 18 | { |
| 19 | namespace vpd |
| 20 | { |
| 21 | namespace manager |
| 22 | { |
| 23 | namespace editor |
| 24 | { |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 25 | |
| 26 | void EditorImpl::checkPTForRecord(Binary::const_iterator& iterator, |
| 27 | Byte ptLength) |
| 28 | { |
| 29 | // auto iterator = ptRecord.cbegin(); |
| 30 | auto end = std::next(iterator, ptLength + 1); |
| 31 | |
| 32 | // Look at each entry in the PT keyword for the record name |
| 33 | while (iterator < end) |
| 34 | { |
| 35 | auto stop = std::next(iterator, lengths::RECORD_NAME); |
| 36 | std::string record(iterator, stop); |
| 37 | |
| 38 | if (record == thisRecord.recName) |
| 39 | { |
| 40 | // Skip record name and record type |
| 41 | std::advance(iterator, lengths::RECORD_NAME + sizeof(RecordType)); |
| 42 | |
| 43 | // Get record offset |
| 44 | thisRecord.recOffset = readUInt16LE(iterator); |
| 45 | |
| 46 | // pass the record offset length to read record length |
| 47 | std::advance(iterator, lengths::RECORD_OFFSET); |
| 48 | thisRecord.recSize = readUInt16LE(iterator); |
| 49 | |
| 50 | std::advance(iterator, lengths::RECORD_LENGTH); |
| 51 | thisRecord.recECCoffset = readUInt16LE(iterator); |
| 52 | |
| 53 | ECCLength len; |
| 54 | std::advance(iterator, lengths::RECORD_ECC_OFFSET); |
| 55 | len = readUInt16LE(iterator); |
| 56 | thisRecord.recECCLength = len; |
| 57 | |
| 58 | // once we find the record we don't need to look further |
| 59 | return; |
| 60 | } |
| 61 | else |
| 62 | { |
| 63 | // Jump the record |
| 64 | std::advance(iterator, lengths::RECORD_NAME + sizeof(RecordType) + |
| 65 | sizeof(RecordOffset) + |
| 66 | sizeof(RecordLength) + |
| 67 | sizeof(ECCOffset) + sizeof(ECCLength)); |
| 68 | } |
| 69 | } |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 70 | // imples the record was not found |
| 71 | throw std::runtime_error("Record not found"); |
| 72 | } |
| 73 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 74 | void EditorImpl::updateData(const Binary& kwdData) |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 75 | { |
| 76 | std::size_t lengthToUpdate = kwdData.size() <= thisRecord.kwdDataLength |
| 77 | ? kwdData.size() |
| 78 | : thisRecord.kwdDataLength; |
| 79 | |
| 80 | auto iteratorToNewdata = kwdData.cbegin(); |
| 81 | auto end = iteratorToNewdata; |
| 82 | std::advance(end, lengthToUpdate); |
| 83 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 84 | // update data in file buffer as it will be needed to update ECC |
| 85 | // avoiding extra stream operation here |
| 86 | auto iteratorToKWdData = vpdFile.begin(); |
| 87 | std::advance(iteratorToKWdData, thisRecord.kwDataOffset); |
| 88 | std::copy(iteratorToNewdata, end, iteratorToKWdData); |
| 89 | |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 90 | #ifdef ManagerTest |
| 91 | auto startItr = vpdFile.begin(); |
| 92 | std::advance(iteratorToKWdData, thisRecord.kwDataOffset); |
| 93 | auto endItr = startItr; |
| 94 | std::advance(endItr, thisRecord.kwdDataLength); |
| 95 | |
| 96 | Binary updatedData(startItr, endItr); |
| 97 | if (updatedData == kwdData) |
| 98 | { |
| 99 | throw std::runtime_error("Data updated successfully"); |
| 100 | } |
| 101 | #else |
| 102 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 103 | // update data in EEPROM as well. As we will not write complete file back |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 104 | vpdFileStream.seekp(startOffset + thisRecord.kwDataOffset, std::ios::beg); |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 105 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 106 | iteratorToNewdata = kwdData.cbegin(); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 107 | std::copy(iteratorToNewdata, end, |
| 108 | std::ostreambuf_iterator<char>(vpdFileStream)); |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 109 | |
| 110 | // get a hold to new data in case encoding is needed |
| 111 | thisRecord.kwdUpdatedData.resize(thisRecord.kwdDataLength); |
| 112 | auto itrToKWdData = vpdFile.cbegin(); |
| 113 | std::advance(itrToKWdData, thisRecord.kwDataOffset); |
| 114 | auto kwdDataEnd = itrToKWdData; |
| 115 | std::advance(kwdDataEnd, thisRecord.kwdDataLength); |
| 116 | std::copy(itrToKWdData, kwdDataEnd, thisRecord.kwdUpdatedData.begin()); |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 117 | #endif |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | void EditorImpl::checkRecordForKwd() |
| 121 | { |
| 122 | RecordOffset recOffset = thisRecord.recOffset; |
| 123 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 124 | // Amount to skip for record ID, size, and the RT keyword |
| 125 | constexpr auto skipBeg = sizeof(RecordId) + sizeof(RecordSize) + |
| 126 | lengths::KW_NAME + sizeof(KwSize); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 127 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 128 | auto iterator = vpdFile.cbegin(); |
| 129 | std::advance(iterator, recOffset + skipBeg + lengths::RECORD_NAME); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 130 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 131 | auto end = iterator; |
| 132 | std::advance(end, thisRecord.recSize); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 133 | std::size_t dataLength = 0; |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 134 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 135 | while (iterator < end) |
| 136 | { |
| 137 | // Note keyword name |
| 138 | std::string kw(iterator, iterator + lengths::KW_NAME); |
| 139 | |
| 140 | // Check if the Keyword starts with '#' |
| 141 | char kwNameStart = *iterator; |
| 142 | std::advance(iterator, lengths::KW_NAME); |
| 143 | |
| 144 | // if keyword starts with # |
| 145 | if (POUND_KW == kwNameStart) |
| 146 | { |
| 147 | // Note existing keyword data length |
| 148 | dataLength = readUInt16LE(iterator); |
| 149 | |
| 150 | // Jump past 2Byte keyword length + data |
| 151 | std::advance(iterator, sizeof(PoundKwSize)); |
| 152 | } |
| 153 | else |
| 154 | { |
| 155 | // Note existing keyword data length |
| 156 | dataLength = *iterator; |
| 157 | |
| 158 | // Jump past keyword length and data |
| 159 | std::advance(iterator, sizeof(KwSize)); |
| 160 | } |
| 161 | |
| 162 | if (thisRecord.recKWd == kw) |
| 163 | { |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 164 | thisRecord.kwDataOffset = std::distance(vpdFile.cbegin(), iterator); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 165 | thisRecord.kwdDataLength = dataLength; |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 166 | return; |
| 167 | } |
| 168 | |
| 169 | // jump the data of current kwd to point to next kwd name |
| 170 | std::advance(iterator, dataLength); |
| 171 | } |
| 172 | |
| 173 | throw std::runtime_error("Keyword not found"); |
| 174 | } |
| 175 | |
| 176 | void EditorImpl::updateRecordECC() |
| 177 | { |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 178 | auto itrToRecordData = vpdFile.cbegin(); |
| 179 | std::advance(itrToRecordData, thisRecord.recOffset); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 180 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 181 | auto itrToRecordECC = vpdFile.cbegin(); |
| 182 | std::advance(itrToRecordECC, thisRecord.recECCoffset); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 183 | |
| 184 | auto l_status = vpdecc_create_ecc( |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 185 | const_cast<uint8_t*>(&itrToRecordData[0]), thisRecord.recSize, |
| 186 | const_cast<uint8_t*>(&itrToRecordECC[0]), &thisRecord.recECCLength); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 187 | if (l_status != VPD_ECC_OK) |
| 188 | { |
| 189 | throw std::runtime_error("Ecc update failed"); |
| 190 | } |
| 191 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 192 | auto end = itrToRecordECC; |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 193 | std::advance(end, thisRecord.recECCLength); |
| 194 | |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 195 | #ifndef ManagerTest |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 196 | vpdFileStream.seekp(startOffset + thisRecord.recECCoffset, std::ios::beg); |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 197 | std::copy(itrToRecordECC, end, |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 198 | std::ostreambuf_iterator<char>(vpdFileStream)); |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 199 | #endif |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | auto EditorImpl::getValue(offsets::Offsets offset) |
| 203 | { |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 204 | auto itr = vpdFile.cbegin(); |
| 205 | std::advance(itr, offset); |
| 206 | LE2ByteData lowByte = *itr; |
| 207 | LE2ByteData highByte = *(itr + 1); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 208 | lowByte |= (highByte << 8); |
| 209 | |
| 210 | return lowByte; |
| 211 | } |
| 212 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 213 | void EditorImpl::checkECC(Binary::const_iterator& itrToRecData, |
| 214 | Binary::const_iterator& itrToECCData, |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 215 | RecordLength recLength, ECCLength eccLength) |
| 216 | { |
| 217 | auto l_status = |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 218 | vpdecc_check_data(const_cast<uint8_t*>(&itrToRecData[0]), recLength, |
| 219 | const_cast<uint8_t*>(&itrToECCData[0]), eccLength); |
| 220 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 221 | if (l_status != VPD_ECC_OK) |
| 222 | { |
| 223 | throw std::runtime_error("Ecc check failed for VTOC"); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | void EditorImpl::readVTOC() |
| 228 | { |
| 229 | // read VTOC offset |
| 230 | RecordOffset tocOffset = getValue(offsets::VTOC_PTR); |
| 231 | |
| 232 | // read VTOC record length |
| 233 | RecordLength tocLength = getValue(offsets::VTOC_REC_LEN); |
| 234 | |
| 235 | // read TOC ecc offset |
| 236 | ECCOffset tocECCOffset = getValue(offsets::VTOC_ECC_OFF); |
| 237 | |
| 238 | // read TOC ecc length |
| 239 | ECCLength tocECCLength = getValue(offsets::VTOC_ECC_LEN); |
| 240 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 241 | auto itrToRecord = vpdFile.cbegin(); |
| 242 | std::advance(itrToRecord, tocOffset); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 243 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 244 | auto iteratorToECC = vpdFile.cbegin(); |
| 245 | std::advance(iteratorToECC, tocECCOffset); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 246 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 247 | // validate ecc for the record |
| 248 | checkECC(itrToRecord, iteratorToECC, tocLength, tocECCLength); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 249 | |
| 250 | // to get to the record name. |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 251 | std::advance(itrToRecord, sizeof(RecordId) + sizeof(RecordSize) + |
| 252 | // Skip past the RT keyword, which contains |
| 253 | // the record name. |
| 254 | lengths::KW_NAME + sizeof(KwSize)); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 255 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 256 | std::string recordName(itrToRecord, itrToRecord + lengths::RECORD_NAME); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 257 | |
| 258 | if ("VTOC" != recordName) |
| 259 | { |
| 260 | throw std::runtime_error("VTOC record not found"); |
| 261 | } |
| 262 | |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 263 | // jump to length of PT kwd |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 264 | std::advance(itrToRecord, lengths::RECORD_NAME + lengths::KW_NAME); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 265 | |
| 266 | // Note size of PT |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 267 | Byte ptLen = *itrToRecord; |
| 268 | std::advance(itrToRecord, 1); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 269 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 270 | checkPTForRecord(itrToRecord, ptLen); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 271 | } |
| 272 | |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 273 | template <typename T> |
| 274 | void EditorImpl::makeDbusCall(const std::string& object, |
| 275 | const std::string& interface, |
| 276 | const std::string& property, |
| 277 | const std::variant<T>& data) |
| 278 | { |
| 279 | auto bus = sdbusplus::bus::new_default(); |
SunnySrivastava1984 | a739259 | 2020-03-09 10:19:33 -0500 | [diff] [blame] | 280 | auto properties = |
| 281 | bus.new_method_call(INVENTORY_MANAGER_SERVICE, object.c_str(), |
| 282 | "org.freedesktop.DBus.Properties", "Set"); |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 283 | properties.append(interface); |
| 284 | properties.append(property); |
| 285 | properties.append(data); |
| 286 | |
| 287 | auto result = bus.call(properties); |
| 288 | |
| 289 | if (result.is_method_error()) |
| 290 | { |
| 291 | throw std::runtime_error("bus call failed"); |
| 292 | } |
| 293 | } |
| 294 | |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 295 | void EditorImpl::processAndUpdateCI(const std::string& objectPath) |
| 296 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 297 | inventory::ObjectMap objects; |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 298 | for (auto& commonInterface : jsonFile["commonInterfaces"].items()) |
| 299 | { |
| 300 | for (auto& ciPropertyList : commonInterface.value().items()) |
| 301 | { |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 302 | if (ciPropertyList.value().type() == |
| 303 | nlohmann::json::value_t::object) |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 304 | { |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 305 | if ((ciPropertyList.value().value("recordName", "") == |
| 306 | thisRecord.recName) && |
| 307 | (ciPropertyList.value().value("keywordName", "") == |
| 308 | thisRecord.recKWd)) |
| 309 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 310 | inventory::PropertyMap prop; |
| 311 | inventory::InterfaceMap interfaces; |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 312 | std::string kwdData(thisRecord.kwdUpdatedData.begin(), |
| 313 | thisRecord.kwdUpdatedData.end()); |
| 314 | |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 315 | prop.emplace(ciPropertyList.key(), move(kwdData)); |
| 316 | interfaces.emplace(commonInterface.key(), move(prop)); |
| 317 | objects.emplace(objectPath, move(interfaces)); |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 318 | } |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | } |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 322 | // Notify PIM |
| 323 | common::utility::callPIM(move(objects)); |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | void EditorImpl::processAndUpdateEI(const nlohmann::json& Inventory, |
| 327 | const inventory::Path& objPath) |
| 328 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 329 | inventory::ObjectMap objects; |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 330 | for (const auto& extraInterface : Inventory["extraInterfaces"].items()) |
| 331 | { |
| 332 | if (extraInterface.value() != NULL) |
| 333 | { |
| 334 | for (const auto& eiPropertyList : extraInterface.value().items()) |
| 335 | { |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 336 | if (eiPropertyList.value().type() == |
| 337 | nlohmann::json::value_t::object) |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 338 | { |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 339 | if ((eiPropertyList.value().value("recordName", "") == |
| 340 | thisRecord.recName) && |
| 341 | ((eiPropertyList.value().value("keywordName", "") == |
| 342 | thisRecord.recKWd))) |
| 343 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 344 | inventory::PropertyMap prop; |
| 345 | inventory::InterfaceMap interfaces; |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 346 | std::string kwdData(thisRecord.kwdUpdatedData.begin(), |
| 347 | thisRecord.kwdUpdatedData.end()); |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 348 | encodeKeyword(kwdData, eiPropertyList.value().value( |
| 349 | "encoding", "")); |
| 350 | |
| 351 | prop.emplace(eiPropertyList.key(), move(kwdData)); |
| 352 | interfaces.emplace(extraInterface.key(), move(prop)); |
| 353 | objects.emplace(objPath, move(interfaces)); |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 354 | } |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 355 | } |
| 356 | } |
| 357 | } |
| 358 | } |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 359 | // Notify PIM |
| 360 | common::utility::callPIM(move(objects)); |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | void EditorImpl::updateCache() |
| 364 | { |
| 365 | const std::vector<nlohmann::json>& groupEEPROM = |
| 366 | jsonFile["frus"][vpdFilePath].get_ref<const nlohmann::json::array_t&>(); |
| 367 | |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 368 | inventory::ObjectMap objects; |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 369 | // iterate through all the inventories for this file path |
| 370 | for (const auto& singleInventory : groupEEPROM) |
| 371 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 372 | inventory::PropertyMap prop; |
| 373 | inventory::InterfaceMap interfaces; |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 374 | // by default inherit property is true |
| 375 | bool isInherit = true; |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 376 | bool isInheritEI = true; |
| 377 | bool isCpuModuleOnly = false; |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 378 | |
| 379 | if (singleInventory.find("inherit") != singleInventory.end()) |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 380 | { |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 381 | isInherit = singleInventory["inherit"].get<bool>(); |
| 382 | } |
| 383 | |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 384 | if (singleInventory.find("inheritEI") != singleInventory.end()) |
| 385 | { |
| 386 | isInheritEI = singleInventory["inheritEI"].get<bool>(); |
| 387 | } |
| 388 | |
| 389 | // "type" exists only in CPU module and FRU |
| 390 | if (singleInventory.find("type") != singleInventory.end()) |
| 391 | { |
| 392 | if (singleInventory["type"] == "moduleOnly") |
| 393 | { |
| 394 | isCpuModuleOnly = true; |
| 395 | } |
| 396 | } |
| 397 | |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 398 | if (isInherit) |
| 399 | { |
| 400 | // update com interface |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 401 | // For CPU- update com interface only when isCI true |
| 402 | if ((!isCpuModuleOnly) || (isCpuModuleOnly && isCI)) |
| 403 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 404 | prop.emplace(thisRecord.recKWd, thisRecord.kwdUpdatedData); |
| 405 | interfaces.emplace( |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 406 | (IPZ_INTERFACE + (std::string) "." + thisRecord.recName), |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 407 | move(prop)); |
| 408 | objects.emplace( |
| 409 | (singleInventory["inventoryPath"].get<std::string>()), |
| 410 | move(interfaces)); |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 411 | } |
SunnySrivastava1984 | d076da8 | 2020-03-05 05:33:35 -0600 | [diff] [blame] | 412 | |
| 413 | // process Common interface |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 414 | processAndUpdateCI(singleInventory["inventoryPath"] |
| 415 | .get_ref<const nlohmann::json::string_t&>()); |
| 416 | } |
| 417 | |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 418 | if (isInheritEI) |
| 419 | { |
| 420 | if (isCpuModuleOnly) |
| 421 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 422 | prop.emplace(thisRecord.recKWd, thisRecord.kwdUpdatedData); |
| 423 | interfaces.emplace( |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 424 | (IPZ_INTERFACE + (std::string) "." + thisRecord.recName), |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 425 | move(prop)); |
| 426 | objects.emplace( |
| 427 | (singleInventory["inventoryPath"].get<std::string>()), |
| 428 | move(interfaces)); |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | // process extra interfaces |
| 432 | processAndUpdateEI(singleInventory, |
| 433 | singleInventory["inventoryPath"] |
| 434 | .get_ref<const nlohmann::json::string_t&>()); |
| 435 | } |
Sunny Srivastava | 26d6c14 | 2021-11-03 15:19:02 -0500 | [diff] [blame^] | 436 | |
| 437 | // check if we need to copy some specific records in this case. |
| 438 | if (singleInventory.find("copyRecords") != singleInventory.end()) |
| 439 | { |
| 440 | if (find(singleInventory["copyRecords"].begin(), |
| 441 | singleInventory["copyRecords"].end(), |
| 442 | thisRecord.recName) != |
| 443 | singleInventory["copyRecords"].end()) |
| 444 | { |
| 445 | prop.emplace(thisRecord.recKWd, thisRecord.kwdUpdatedData); |
| 446 | interfaces.emplace( |
| 447 | (IPZ_INTERFACE + std::string{"."} + thisRecord.recName), |
| 448 | move(prop)); |
| 449 | objects.emplace( |
| 450 | (singleInventory["inventoryPath"].get<std::string>()), |
| 451 | move(interfaces)); |
| 452 | } |
| 453 | } |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 454 | } |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 455 | // Notify PIM |
| 456 | common::utility::callPIM(move(objects)); |
SunnySrivastava1984 | b421bfd | 2020-03-02 08:59:32 -0600 | [diff] [blame] | 457 | } |
| 458 | |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 459 | void EditorImpl::expandLocationCode(const std::string& locationCodeType) |
| 460 | { |
| 461 | std::string propertyFCorTM{}; |
| 462 | std::string propertySE{}; |
| 463 | |
| 464 | if (locationCodeType == "fcs") |
| 465 | { |
| 466 | propertyFCorTM = |
| 467 | readBusProperty(SYSTEM_OBJECT, "com.ibm.ipzvpd.VCEN", "FC"); |
| 468 | propertySE = |
| 469 | readBusProperty(SYSTEM_OBJECT, "com.ibm.ipzvpd.VCEN", "SE"); |
| 470 | } |
| 471 | else if (locationCodeType == "mts") |
| 472 | { |
| 473 | propertyFCorTM = |
| 474 | readBusProperty(SYSTEM_OBJECT, "com.ibm.ipzvpd.VSYS", "TM"); |
| 475 | propertySE = |
| 476 | readBusProperty(SYSTEM_OBJECT, "com.ibm.ipzvpd.VSYS", "SE"); |
| 477 | } |
| 478 | |
| 479 | const nlohmann::json& groupFRUS = |
| 480 | jsonFile["frus"].get_ref<const nlohmann::json::object_t&>(); |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 481 | inventory::ObjectMap objects; |
| 482 | |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 483 | for (const auto& itemFRUS : groupFRUS.items()) |
| 484 | { |
| 485 | const std::vector<nlohmann::json>& groupEEPROM = |
| 486 | itemFRUS.value().get_ref<const nlohmann::json::array_t&>(); |
| 487 | for (const auto& itemEEPROM : groupEEPROM) |
| 488 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 489 | inventory::PropertyMap prop; |
| 490 | inventory::InterfaceMap interfaces; |
| 491 | const auto& objectPath = itemEEPROM["inventoryPath"]; |
| 492 | sdbusplus::message::object_path object(objectPath); |
| 493 | |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 494 | // check if the given item implements location code interface |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 495 | if (itemEEPROM["extraInterfaces"].find(IBM_LOCATION_CODE_INF) != |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 496 | itemEEPROM["extraInterfaces"].end()) |
| 497 | { |
| 498 | const std::string& unexpandedLocationCode = |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 499 | itemEEPROM["extraInterfaces"][IBM_LOCATION_CODE_INF] |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 500 | ["LocationCode"] |
| 501 | .get_ref<const nlohmann::json::string_t&>(); |
| 502 | std::size_t idx = unexpandedLocationCode.find(locationCodeType); |
| 503 | if (idx != std::string::npos) |
| 504 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 505 | std::string expandedLocationCode(unexpandedLocationCode); |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 506 | |
| 507 | if (locationCodeType == "fcs") |
| 508 | { |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 509 | expandedLocationCode.replace( |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 510 | idx, 3, |
| 511 | propertyFCorTM.substr(0, 4) + ".ND0." + propertySE); |
| 512 | } |
| 513 | else if (locationCodeType == "mts") |
| 514 | { |
| 515 | std::replace(propertyFCorTM.begin(), |
| 516 | propertyFCorTM.end(), '-', '.'); |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 517 | expandedLocationCode.replace( |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 518 | idx, 3, propertyFCorTM + "." + propertySE); |
| 519 | } |
| 520 | |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 521 | // update the DBUS interface COM as well as XYZ path |
| 522 | prop.emplace("LocationCode", expandedLocationCode); |
| 523 | // TODO depricate this com.ibm interface later |
| 524 | interfaces.emplace(IBM_LOCATION_CODE_INF, prop); |
| 525 | interfaces.emplace(XYZ_LOCATION_CODE_INF, move(prop)); |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 526 | } |
| 527 | } |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 528 | objects.emplace(move(object), move(interfaces)); |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 529 | } |
| 530 | } |
Alpana Kumari | 414d5ae | 2021-03-04 21:06:35 +0000 | [diff] [blame] | 531 | // Notify PIM |
| 532 | common::utility::callPIM(move(objects)); |
SunnySrivastava1984 | 4330654 | 2020-04-01 02:50:20 -0500 | [diff] [blame] | 533 | } |
| 534 | |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 535 | string EditorImpl::getSysPathForThisFruType(const string& moduleObjPath, |
| 536 | const string& fruType) |
| 537 | { |
| 538 | string fruVpdPath; |
| 539 | |
| 540 | // get all FRUs list |
| 541 | for (const auto& eachFru : jsonFile["frus"].items()) |
| 542 | { |
| 543 | bool moduleObjPathMatched = false; |
| 544 | bool expectedFruFound = false; |
| 545 | |
| 546 | for (const auto& eachInventory : eachFru.value()) |
| 547 | { |
| 548 | const auto& thisObjectPath = eachInventory["inventoryPath"]; |
| 549 | |
| 550 | // "type" exists only in CPU module and FRU |
| 551 | if (eachInventory.find("type") != eachInventory.end()) |
| 552 | { |
| 553 | // If inventory type is fruAndModule then set flag |
| 554 | if (eachInventory["type"] == fruType) |
| 555 | { |
| 556 | expectedFruFound = true; |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | if (thisObjectPath == moduleObjPath) |
| 561 | { |
| 562 | moduleObjPathMatched = true; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | // If condition satisfies then collect this sys path and exit |
| 567 | if (expectedFruFound && moduleObjPathMatched) |
| 568 | { |
| 569 | fruVpdPath = eachFru.key(); |
| 570 | break; |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | return fruVpdPath; |
| 575 | } |
| 576 | |
| 577 | void EditorImpl::getVpdPathForCpu() |
| 578 | { |
| 579 | isCI = false; |
| 580 | // keep a backup In case we need it later |
| 581 | inventory::Path vpdFilePathBackup = vpdFilePath; |
| 582 | |
| 583 | // TODO 1:Temp hardcoded list. create it dynamically. |
| 584 | std::vector<std::string> commonIntVINIKwds = {"PN", "SN", "DR"}; |
| 585 | std::vector<std::string> commonIntVR10Kwds = {"DC"}; |
| 586 | std::unordered_map<std::string, std::vector<std::string>> |
| 587 | commonIntRecordsList = {{"VINI", commonIntVINIKwds}, |
| 588 | {"VR10", commonIntVR10Kwds}}; |
| 589 | |
| 590 | // If requested Record&Kw is one among CI, then update 'FRU' type sys |
| 591 | // path, SPI2 |
| 592 | unordered_map<std::string, vector<string>>::const_iterator isCommonInt = |
| 593 | commonIntRecordsList.find(thisRecord.recName); |
| 594 | |
| 595 | if ((isCommonInt != commonIntRecordsList.end()) && |
| 596 | (find(isCommonInt->second.begin(), isCommonInt->second.end(), |
| 597 | thisRecord.recKWd) != isCommonInt->second.end())) |
| 598 | { |
| 599 | isCI = true; |
| 600 | vpdFilePath = getSysPathForThisFruType(objPath, "fruAndModule"); |
| 601 | } |
| 602 | else |
| 603 | { |
| 604 | for (const auto& eachFru : jsonFile["frus"].items()) |
| 605 | { |
| 606 | for (const auto& eachInventory : eachFru.value()) |
| 607 | { |
| 608 | if (eachInventory.find("type") != eachInventory.end()) |
| 609 | { |
| 610 | const auto& thisObjectPath = eachInventory["inventoryPath"]; |
| 611 | if ((eachInventory["type"] == "moduleOnly") && |
| 612 | (eachInventory.value("inheritEI", true)) && |
| 613 | (thisObjectPath == static_cast<string>(objPath))) |
| 614 | { |
| 615 | vpdFilePath = eachFru.key(); |
| 616 | } |
| 617 | } |
| 618 | } |
| 619 | } |
| 620 | } |
| 621 | // If it is not a CPU fru then go ahead with default vpdFilePath from |
| 622 | // fruMap |
| 623 | if (vpdFilePath.empty()) |
| 624 | { |
| 625 | vpdFilePath = vpdFilePathBackup; |
| 626 | } |
| 627 | } |
| 628 | |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 629 | void EditorImpl::updateKeyword(const Binary& kwdData, const bool& updCache) |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 630 | { |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 631 | startOffset = 0; |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 632 | #ifndef ManagerTest |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 633 | |
| 634 | getVpdPathForCpu(); |
| 635 | |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 636 | // check if offset present? |
| 637 | for (const auto& item : jsonFile["frus"][vpdFilePath]) |
| 638 | { |
| 639 | if (item.find("offset") != item.end()) |
| 640 | { |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 641 | startOffset = item["offset"]; |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 642 | } |
| 643 | } |
| 644 | |
| 645 | // TODO: Figure out a better way to get max possible VPD size. |
| 646 | Binary completeVPDFile; |
| 647 | completeVPDFile.resize(65504); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 648 | vpdFileStream.open(vpdFilePath, |
| 649 | std::ios::in | std::ios::out | std::ios::binary); |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 650 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 651 | vpdFileStream.seekg(startOffset, ios_base::cur); |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 652 | vpdFileStream.read(reinterpret_cast<char*>(&completeVPDFile[0]), 65504); |
| 653 | completeVPDFile.resize(vpdFileStream.gcount()); |
| 654 | vpdFileStream.clear(std::ios_base::eofbit); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 655 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 656 | vpdFile = completeVPDFile; |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 657 | |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 658 | #else |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 659 | |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 660 | Binary completeVPDFile = vpdFile; |
Alpana Kumari | 920408d | 2020-05-14 00:07:03 -0500 | [diff] [blame] | 661 | |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 662 | #endif |
| 663 | if (vpdFile.empty()) |
| 664 | { |
| 665 | throw std::runtime_error("Invalid File"); |
| 666 | } |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 667 | auto iterator = vpdFile.cbegin(); |
| 668 | std::advance(iterator, IPZ_DATA_START); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 669 | |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 670 | Byte vpdType = *iterator; |
| 671 | if (vpdType == KW_VAL_PAIR_START_TAG) |
| 672 | { |
PriyangaRamasamy | 33c61c2 | 2021-04-06 11:15:57 -0500 | [diff] [blame] | 673 | ParserInterface* Iparser = ParserFactory::getParser(completeVPDFile); |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 674 | IpzVpdParser* ipzParser = dynamic_cast<IpzVpdParser*>(Iparser); |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 675 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 676 | try |
| 677 | { |
| 678 | if (ipzParser == nullptr) |
| 679 | { |
| 680 | throw std::runtime_error("Invalid cast"); |
| 681 | } |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 682 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 683 | ipzParser->processHeader(); |
| 684 | delete ipzParser; |
| 685 | ipzParser = nullptr; |
| 686 | // ParserFactory::freeParser(Iparser); |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 687 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 688 | // process VTOC for PTT rkwd |
| 689 | readVTOC(); |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 690 | |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 691 | // check record for keywrod |
| 692 | checkRecordForKwd(); |
| 693 | |
| 694 | // update the data to the file |
| 695 | updateData(kwdData); |
| 696 | |
| 697 | // update the ECC data for the record once data has been updated |
| 698 | updateRecordECC(); |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 699 | |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 700 | if (updCache) |
| 701 | { |
PriyangaRamasamy | c0d1c0a | 2021-04-16 09:45:06 -0500 | [diff] [blame] | 702 | #ifndef ManagerTest |
PriyangaRamasamy | c0a534f | 2020-08-24 21:29:18 +0530 | [diff] [blame] | 703 | // update the cache once data has been updated |
| 704 | updateCache(); |
SunnySrivastava1984 | a0d460e | 2020-06-03 07:49:26 -0500 | [diff] [blame] | 705 | #endif |
PriyangaRamasamy | c0d1c0a | 2021-04-16 09:45:06 -0500 | [diff] [blame] | 706 | } |
SunnySrivastava1984 | e12b181 | 2020-05-26 02:23:11 -0500 | [diff] [blame] | 707 | } |
| 708 | catch (const std::exception& e) |
| 709 | { |
| 710 | if (ipzParser != nullptr) |
| 711 | { |
| 712 | delete ipzParser; |
| 713 | } |
| 714 | throw std::runtime_error(e.what()); |
| 715 | } |
SunnySrivastava1984 | 6d8314d | 2020-05-15 09:34:58 -0500 | [diff] [blame] | 716 | return; |
| 717 | } |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 718 | } |
SunnySrivastava1984 | f6d541e | 2020-02-04 12:50:40 -0600 | [diff] [blame] | 719 | } // namespace editor |
| 720 | } // namespace manager |
| 721 | } // namespace vpd |
| 722 | } // namespace openpower |