diff options
Diffstat (limited to 'test/openpower-pels/pel_utils.cpp')
-rw-r--r-- | test/openpower-pels/pel_utils.cpp | 151 |
1 files changed, 76 insertions, 75 deletions
diff --git a/test/openpower-pels/pel_utils.cpp b/test/openpower-pels/pel_utils.cpp index 109c1ce..0af9bf5 100644 --- a/test/openpower-pels/pel_utils.cpp +++ b/test/openpower-pels/pel_utils.cpp @@ -15,15 +15,14 @@ std::filesystem::path CleanPELFiles::pelIDFile{}; std::filesystem::path CleanPELFiles::repoPath{}; std::filesystem::path CleanPELFiles::registryPath{}; -constexpr uint8_t simplePEL[] = { - // private header section header +const std::vector<uint8_t> privateHeaderSection{ + // section header 0x50, 0x48, // ID 'PH' 0x00, 0x30, // Size 0x01, 0x02, // version, subtype 0x03, 0x04, // comp ID - // private header - 0x20, 0x30, 0x05, 0x09, 0x11, 0x1E, 0x1, 0x63, // create timestamp + 0x20, 0x30, 0x05, 0x09, 0x11, 0x1E, 0x1, 0x63, // create timestamp 0x20, 0x31, 0x06, 0x0F, 0x09, 0x22, 0x3A, 0x00, // commit timestamp 0xAA, // creatorID 0x00, // logtype @@ -32,40 +31,56 @@ constexpr uint8_t simplePEL[] = { 0x90, 0x91, 0x92, 0x93, // OpenBMC log ID 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, // creator version 0x50, 0x51, 0x52, 0x53, // plid - 0x80, 0x81, 0x82, 0x83, // id + 0x80, 0x81, 0x82, 0x83}; - // user header section header +const std::vector<uint8_t> userHeaderSection{ + // section header 0x55, 0x48, // ID 'UH' 0x00, 0x18, // Size 0x01, 0x0A, // version, subtype 0x0B, 0x0C, // comp ID - // user header 0x10, 0x04, // subsystem, scope 0x20, 0x00, // severity, type 0x00, 0x00, 0x00, 0x00, // reserved 0x03, 0x04, // problem domain, vector 0x80, 0xC0, // action flags 0x00, 0x00, 0x00, 0x00 // reserved - - // Add more as the code supports more }; -std::vector<uint8_t> srcFRUIdentityCallout{ +const std::vector<uint8_t> srcSectionNoCallouts{ + + // Header + 'P', 'S', 0x00, 0x80, 0x01, 0x01, 0x02, 0x02, + + 0x02, 0x00, 0x00, // version, flags, reserved + 0x09, 0x00, 0x00, // hex word count, reserved2B + 0x00, 0x48, // SRC structure size + + // Hex words 2 - 9 + 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, + 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, + 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, + // ASCII string + 'B', 'D', '8', 'D', '5', '6', '7', '8', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' '}; + +const std::vector<uint8_t> srcFRUIdentityCallout{ 'I', 'D', 0x1C, 0x1D, // type, size, flags '1', '2', '3', '4', // PN '5', '6', '7', 0x00, 'A', 'A', 'A', 'A', // CCIN '1', '2', '3', '4', '5', '6', '7', '8', // SN '9', 'A', 'B', 'C'}; -std::vector<uint8_t> srcPCEIdentityCallout{ +const std::vector<uint8_t> srcPCEIdentityCallout{ 'P', 'E', 0x24, 0x00, // type, size, flags 'T', 'T', 'T', 'T', '-', 'M', 'M', 'M', // MTM '1', '2', '3', '4', '5', '6', '7', // SN '8', '9', 'A', 'B', 'C', 'P', 'C', 'E', // Name + null padded 'N', 'A', 'M', 'E', '1', '2', 0x00, 0x00, 0x00}; -std::vector<uint8_t> srcMRUCallout{ +const std::vector<uint8_t> srcMRUCallout{ 'M', 'R', 0x28, 0x04, // ID, size, flags 0x00, 0x00, 0x00, 0x00, // Reserved 0x00, 0x00, 0x00, 'H', // priority 0 @@ -78,44 +93,62 @@ std::vector<uint8_t> srcMRUCallout{ 0x04, 0x04, 0x04, 0x04, // MRU ID 3 }; -std::vector<uint8_t> srcSectionNoCallouts{ - - // Header - 'P', 'S', 0x00, 0x80, 0x01, 0x01, 0x02, 0x02, - - // SRC - 0x02, 0x00, 0x00, // version, flags, reserved - 0x09, 0x00, 0x00, // hex word count, reserved2B - 0x00, 0x48, // SRC structure size - - // Hex words 2 - 9 - 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, - 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, - 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, - // ASCII string - 'B', 'D', '8', 'D', '5', '6', '7', '8', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', ' '}; +constexpr size_t sectionCountOffset = 27; -std::unique_ptr<std::vector<uint8_t>> pelDataFactory(TestPelType type) +std::vector<uint8_t> pelDataFactory(TestPELType type) { - std::unique_ptr<std::vector<uint8_t>> data; + std::vector<uint8_t> data; + switch (type) { - case TestPelType::pelSimple: - data = std::make_unique<std::vector<uint8_t>>( - simplePEL, simplePEL + sizeof(simplePEL)); + case TestPELType::pelSimple: + data.insert(data.end(), privateHeaderSection.begin(), + privateHeaderSection.end()); + data.insert(data.end(), userHeaderSection.begin(), + userHeaderSection.end()); + data.at(sectionCountOffset) = 2; break; - case TestPelType::privateHeaderSimple: - data = std::make_unique<std::vector<uint8_t>>( - simplePEL, simplePEL + PrivateHeader::flattenedSize()); + case TestPELType::privateHeaderSection: + data.insert(data.end(), privateHeaderSection.begin(), + privateHeaderSection.end()); break; - case TestPelType::userHeaderSimple: - data = std::make_unique<std::vector<uint8_t>>( - simplePEL + PrivateHeader::flattenedSize(), - simplePEL + PrivateHeader::flattenedSize() + - UserHeader::flattenedSize()); + case TestPELType::userHeaderSection: + data.insert(data.end(), userHeaderSection.begin(), + userHeaderSection.end()); break; + case TestPELType::primarySRCSection: + data.insert(data.end(), srcSectionNoCallouts.begin(), + srcSectionNoCallouts.end()); + break; + case TestPELType::primarySRCSection2Callouts: + { + // Start with the no-callouts SRC, and add the callouts section + // from above. + auto src = srcSectionNoCallouts; + auto callouts = + srcDataFactory(TestSRCType::calloutSection2Callouts); + + src.insert(src.end(), callouts.begin(), callouts.end()); + + // Set the flag that says there are callouts + // One byte after the 8B header + src[8 + 1] |= 0x01; + + // Set the new sizes + uint16_t size = src.size(); + Stream stream{src}; + + stream.offset(2); // In the header + stream << size; + + // In the SRC - the size field doesn't include the header + size -= 8; + stream.offset(8 + 6); + stream << size; + + data.insert(data.end(), src.begin(), src.end()); + break; + } } return data; } @@ -187,38 +220,6 @@ std::vector<uint8_t> srcDataFactory(TestSRCType type) return data; } - case TestSRCType::primarySRCNoCallouts: - { - return srcSectionNoCallouts; - } - case TestSRCType::primarySRC2Callouts: - { - // Start with the no-callouts SRC, and add the callouts section - // from above. - auto src = srcSectionNoCallouts; - auto callouts = - srcDataFactory(TestSRCType::calloutSection2Callouts); - - src.insert(src.end(), callouts.begin(), callouts.end()); - - // Set the flag that says there are callouts - // One byte after the 8B header - src[8 + 1] |= 0x01; - - // Set the new sizes - uint16_t size = src.size(); - Stream stream{src}; - - stream.offset(2); // In the header - stream << size; - - // In the SRC - the size field doesn't include the header - size -= 8; - stream.offset(8 + 6); - stream << size; - - return src; - } } return {}; } |