Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions ibm_vpd_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <iterator>
#include <regex>
#include <thread>
#include <chrono>

using namespace std;
using namespace openpower::vpd;
Expand Down Expand Up @@ -932,8 +933,9 @@ std::variant<KeywordVpdMap, openpower::vpd::Store>
break;
}
}

executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeGetDataInVector.txt");
Binary vpdVector = getVpdDataInVector(js, vpdFilePath);
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterGetDataInVector.txt");

ParserInterface* parser = ParserFactory::getParser(
vpdVector,
Expand Down Expand Up @@ -998,6 +1000,7 @@ void updateVpdDataOnHw(const std::string& vpdFilePath, nlohmann::json& js,
const std::string& recName, const std::string& kwName,
const Binary& kwdData)
{
std::cout<<"test_ updateVpdDataOnHw called "<<std::endl;
const std::string& fruInvPath =
js["frus"][vpdFilePath][0]["inventoryPath"]
.get_ref<const nlohmann::json::string_t&>();
Expand Down Expand Up @@ -1034,6 +1037,7 @@ void updateVpdDataOnHw(const std::string& vpdFilePath, nlohmann::json& js,
void restoreSystemVPD(Parsed& vpdMap, const string& objectPath,
nlohmann::json& js, bool isBackupOnCache = true)
{
std::cout<<"Restore system VPD called"<<std::endl;
std::string systemVpdBackupPath{};
std::string backupVpdInvPath{};
Parsed backupVpdMap{};
Expand Down Expand Up @@ -1207,6 +1211,7 @@ void restoreSystemVPD(Parsed& vpdMap, const string& objectPath,
// to the cache & hardware in the same code path.
if (!isBackupOnCache)
{
std::cout<<"test_ Back up is not on cache"<<std::endl;
// copy backup VPD on to system backplane
// EEPROM file.
updateVpdDataOnHw(systemVpdFilePath, js, recordName,
Expand Down Expand Up @@ -1235,6 +1240,7 @@ void restoreSystemVPD(Parsed& vpdMap, const string& objectPath,
else if ((kwdDataInBinary != defaultValue) &&
(!isBackupOnCache))
{
std::cout<<"test_ BAck up and restore 2"<<std::endl;
// update primary VPD on to backup VPD file
updateVpdDataOnHw(systemVpdBackupPath, js,
backupVpdRecName, backupVpdKwName,
Expand Down Expand Up @@ -1739,6 +1745,8 @@ int main(int argc, char** argv)
isSystemVpd = true;
}

std::cout<<"test_ file path being processed is ="<<file<<std::endl;

// Check if input file is not empty.
if ((file.empty()) || (driver.empty()))
{
Expand Down Expand Up @@ -1866,14 +1874,20 @@ int main(int argc, char** argv)
if (!needsRecollection(js, file))
{
std::cout << "Skip VPD recollection for: " << file << std::endl;
return 0;
// return 0;
}

try
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeParse.txt");
variant<KeywordVpdMap, Store> parseResult;
parseResult = parseVpdFile(file, js);

std::cout<<"test_ parsing done, sleeping for 10s to check file content"<<std::endl;
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterParse.txt");
using namespace std::chrono_literals;
std::this_thread::sleep_for(10s);

if (isSystemVpd)
{
// Get the value of systemVpdBackupPath field from json
Expand Down
47 changes: 45 additions & 2 deletions impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ RecordOffset Impl::getVtocOffset() const
#ifdef IPZ_PARSER
int Impl::vhdrEccCheck()
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeHDRECC_IPZ.txt");
int rc = eccStatus::SUCCESS;
auto vpdPtr = vpd.cbegin();

Expand All @@ -88,13 +89,17 @@ int Impl::vhdrEccCheck()
{
try
{
std::cout<<"Correction HDR ERR"<<std::endl;
vpdFileStream.open(vpdFilePath,
std::ios::in | std::ios::out | std::ios::binary);
if (vpdFileStream.is_open())
{
vpdFileStream.seekp(vpdStartOffset + offsets::VHDR_RECORD,
std::ios::beg);
vpdFileStream.write(
reinterpret_cast<const char*>(&vpd[offsets::VHDR_RECORD]),
lengths::VHDR_RECORD_LENGTH);
vpdFileStream.close();
}
else
{
Expand All @@ -113,12 +118,14 @@ int Impl::vhdrEccCheck()
{
rc = eccStatus::FAILED;
}
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterHRDECC_IPZ.txt");

return rc;
}

int Impl::vtocEccCheck()
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeTOCECC_IPZ.txt");
int rc = eccStatus::SUCCESS;
// Use another pointer to get ECC information from VHDR,
// actual pointer is pointing to VTOC data
Expand Down Expand Up @@ -150,12 +157,17 @@ int Impl::vtocEccCheck()
{
try
{
std::cout<<"Correction TOC ERR"<<std::endl;
vpdFileStream.open(vpdFilePath,
std::ios::in | std::ios::out | std::ios::binary);

if (vpdFileStream.is_open())
{
vpdFileStream.seekp(vpdStartOffset + vtocOffset, std::ios::beg);
vpdFileStream.write(
reinterpret_cast<const char*>(&vpdPtr[vtocOffset]),
vtocLength);
vpdFileStream.close();
}
else
{
Expand All @@ -174,7 +186,7 @@ int Impl::vtocEccCheck()
{
rc = eccStatus::FAILED;
}

executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterTOCECC_IPZ.txt");
return rc;
}

Expand All @@ -193,18 +205,27 @@ int Impl::recordEccCheck(Binary::const_iterator iterator)
std::advance(iterator, sizeof(ECCOffset));
auto eccLength = readUInt16LE(iterator);

std::cout<<"recordOffset"<<(int)recordOffset<<std::endl;
std::cout<<"recordLength"<<(int)recordLength<<std::endl;
std::cout<<"eccOffset"<<(int)eccOffset<<std::endl;
std::cout<<"eccLength"<<(int)eccLength<<std::endl;


if (eccLength == 0 || eccOffset == 0)
{
std::cout<<"ECC Exception thrown"<<std::endl;
throw(VpdEccException(
"Could not find ECC's offset or Length for Record:"));
}

if (recordOffset == 0 || recordLength == 0)
{
std::cout<<"Data Exception thrown"<<std::endl;
throw(VpdDataException("Could not find VPD record offset or VPD record "
"length for Record:"));
}


auto vpdPtr = vpd.cbegin();

auto l_status = vpdecc_check_data(
Expand All @@ -214,13 +235,19 @@ int Impl::recordEccCheck(Binary::const_iterator iterator)
{
try
{
std::cout<<"Correction REC ERR"<<std::endl;
vpdFileStream.open(vpdFilePath,
std::ios::in | std::ios::out | std::ios::binary);

if (vpdFileStream.is_open())
{
vpdFileStream.seekp(vpdStartOffset + recordOffset,
std::ios::beg);
vpdFileStream.write(
reinterpret_cast<const char*>(&vpdPtr[recordOffset]),
recordLength);

vpdFileStream.close();
}
else
{
Expand All @@ -237,6 +264,7 @@ int Impl::recordEccCheck(Binary::const_iterator iterator)
}
else if (l_status != VPD_ECC_OK)
{
std::cout<<"Ecc check failed"<<std::endl;
rc = eccStatus::FAILED;
}

Expand All @@ -246,6 +274,7 @@ int Impl::recordEccCheck(Binary::const_iterator iterator)

void Impl::checkHeader()
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeCheckHeader_IPZ.txt");
if (vpd.empty() || (lengths::RECORD_MIN > vpd.size()))
{
throw(VpdDataException("Malformed VPD"));
Expand All @@ -271,10 +300,12 @@ void Impl::checkHeader()
}
#endif
}
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterCheckHeader_IPZ.txt");
}

std::size_t Impl::readTOC(Binary::const_iterator& iterator)
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeReadTOC_IPZ.txt");
// The offset to VTOC could be 1 or 2 bytes long
RecordOffset vtocOffset = getVtocOffset();

Expand Down Expand Up @@ -310,6 +341,7 @@ std::size_t Impl::readTOC(Binary::const_iterator& iterator)
std::size_t ptLen = *iterator;
// Skip past PT size
std::advance(iterator, sizeof(KwSize));
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterReadTOC_IPZ.txt");

// length of PT keyword
return ptLen;
Expand All @@ -318,6 +350,7 @@ std::size_t Impl::readTOC(Binary::const_iterator& iterator)
internal::OffsetList Impl::readPT(Binary::const_iterator iterator,
std::size_t ptLength)
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeReadPT_IPZ.txt");
internal::OffsetList offsets{};

auto end = iterator;
Expand All @@ -343,9 +376,10 @@ internal::OffsetList Impl::readPT(Binary::const_iterator iterator,

try
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeRecordEccCheck_IPZ.txt");
// Verify the ECC for this Record
int rc = recordEccCheck(iterator);

executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterRecordEccCheck_IPZ.txt");
if (rc != eccStatus::SUCCESS)
{
std::string errorMsg = std::string(
Expand Down Expand Up @@ -380,11 +414,13 @@ internal::OffsetList Impl::readPT(Binary::const_iterator iterator,
sizeof(ECCOffset) + sizeof(ECCLength));
}

executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterReadPT_IPZ.txt");
return offsets;
}

void Impl::processRecord(std::size_t recordOffset)
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeProcessRecord_IPZ.txt");
// Jump to record name
auto nameOffset = recordOffset + sizeof(RecordId) + sizeof(RecordSize) +
// Skip past the RT keyword, which contains
Expand Down Expand Up @@ -415,6 +451,8 @@ void Impl::processRecord(std::size_t recordOffset)
// to the parsed vpd output.
out.emplace(std::move(name), std::move(kwMap));

executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterProcessRecord_IPZ.txt");

#ifndef IPZ_PARSER
}
#endif
Expand Down Expand Up @@ -518,6 +556,7 @@ std::string Impl::readKwData(const internal::KeywordInfo& keyword,

internal::KeywordMap Impl::readKeywords(Binary::const_iterator iterator)
{
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeReadKWD_IPZ.txt");
internal::KeywordMap map{};
while (true)
{
Expand Down Expand Up @@ -576,6 +615,8 @@ internal::KeywordMap Impl::readKeywords(Binary::const_iterator iterator)
std::advance(iterator, length);
}

executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterReadKWD_IPZ.txt");

return map;
}

Expand All @@ -596,6 +637,8 @@ Store Impl::run()
{
processRecord(offset);
}


// Return a Store object, which has interfaces to
// access parsed VPD by record:keyword
return Store(std::move(out));
Expand Down
6 changes: 4 additions & 2 deletions impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ class Impl
#endif
try
{
vpdFileStream.open(vpdFilePath,
std::ios::in | std::ios::out | std::ios::binary);
// executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_beforeOpeningStream_IPZ.txt");
/* vpdFileStream.open(vpdFilePath,
std::ios::in | std::ios::out | std::ios::binary);*/
// executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterOpeningStream_IPZ.txt");
}
catch (const std::fstream::failure& fail)
{
Expand Down
1 change: 1 addition & 0 deletions vpd-manager/editor_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ static void disableRebootGuard()
void EditorImpl::updateKeyword(const Binary& kwdData, uint32_t offset,
const bool& updCache)
{
std::cout<<"test_ editor update keyword called"<<std::endl;
try
{
startOffset = offset;
Expand Down
1 change: 1 addition & 0 deletions vpd-parser/ipz_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ std::variant<kwdVpdMap, Store> IpzVpdParser::parse()
{
Impl p(vpd, inventoryPath, vpdFilePath, vpdStartOffset);
Store s = p.run();
executeCmd("hexdump -C -s 196608 -n 1024 /sys/bus/spi/drivers/at25/spi42.0/eeprom > /tmp/spi42_afterallParsingDone_IPZ.txt");
return s;
}

Expand Down