xref: /openbmc/openpower-hw-diags/analyzer/create_pel.cpp (revision 27dd6368d4e6b1fd03610503356f24eb08a16c02)
1d3b9bac9SZane Shelley #include <unistd.h>
2d3b9bac9SZane Shelley 
34ed4be56SZane Shelley #include <analyzer/service_data.hpp>
48f60a621SZane Shelley #include <analyzer/util.hpp>
5d3b9bac9SZane Shelley #include <hei_main.hpp>
6d3b9bac9SZane Shelley #include <phosphor-logging/elog.hpp>
7d3b9bac9SZane Shelley #include <sdbusplus/bus.hpp>
8b1106b5dSZane Shelley #include <util/bin_stream.hpp>
97029e525SBen Tyner #include <util/dbus.hpp>
10d3b9bac9SZane Shelley #include <util/ffdc_file.hpp>
11d3b9bac9SZane Shelley #include <util/pdbg.hpp>
12d3b9bac9SZane Shelley #include <util/trace.hpp>
13d3b9bac9SZane Shelley #include <xyz/openbmc_project/Logging/Create/server.hpp>
14d3b9bac9SZane Shelley #include <xyz/openbmc_project/Logging/Entry/server.hpp>
15d3b9bac9SZane Shelley 
16021dab3cSZane Shelley #include <fstream>
17021dab3cSZane Shelley #include <memory>
18021dab3cSZane Shelley 
19d3b9bac9SZane Shelley namespace LogSvr = sdbusplus::xyz::openbmc_project::Logging::server;
20d3b9bac9SZane Shelley 
21d3b9bac9SZane Shelley namespace analyzer
22d3b9bac9SZane Shelley {
23021dab3cSZane Shelley //------------------------------------------------------------------------------
24021dab3cSZane Shelley 
25021dab3cSZane Shelley enum FfdcSubType_t : uint8_t
26021dab3cSZane Shelley {
27021dab3cSZane Shelley     FFDC_SIGNATURES = 0x01,
288f60a621SZane Shelley     FFDC_REGISTER_DUMP = 0x02,
292d114321SZane Shelley     FFDC_CALLOUT_FFDC = 0x03,
30c18ba8fbSZane Shelley     FFDC_HB_SCRATCH_REGS = 0x04,
317a465259SCaleb Palmer     FFDC_SCRATCH_SIG = 0x05,
32021dab3cSZane Shelley 
33021dab3cSZane Shelley     // For the callout section, the value of '0xCA' is required per the
34021dab3cSZane Shelley     // phosphor-logging openpower-pel extention spec.
35021dab3cSZane Shelley     FFDC_CALLOUTS = 0xCA,
36021dab3cSZane Shelley };
37021dab3cSZane Shelley 
38021dab3cSZane Shelley enum FfdcVersion_t : uint8_t
39021dab3cSZane Shelley {
40021dab3cSZane Shelley     FFDC_VERSION1 = 0x01,
41021dab3cSZane Shelley };
42021dab3cSZane Shelley 
43021dab3cSZane Shelley //------------------------------------------------------------------------------
44021dab3cSZane Shelley 
__getSrc(const libhei::Signature & i_signature,uint32_t & o_word6,uint32_t & o_word7,uint32_t & o_word8)45021dab3cSZane Shelley void __getSrc(const libhei::Signature& i_signature, uint32_t& o_word6,
46021dab3cSZane Shelley               uint32_t& o_word7, uint32_t& o_word8)
47d3b9bac9SZane Shelley {
48a08d1c37SZane Shelley     o_word6 = o_word7 = o_word8 = 0; // default
49a08d1c37SZane Shelley 
50a08d1c37SZane Shelley     // Note that the chip could be null if there was no root cause attention
51a08d1c37SZane Shelley     // found during analysis.
52a08d1c37SZane Shelley     if (nullptr != i_signature.getChip().getChip())
53a08d1c37SZane Shelley     {
54d3b9bac9SZane Shelley         // [ 0:15] chip model
55d3b9bac9SZane Shelley         // [16:23] reserved space in chip ID
56d3b9bac9SZane Shelley         // [24:31] chip EC level
57021dab3cSZane Shelley         o_word6 = i_signature.getChip().getType();
58d3b9bac9SZane Shelley 
59d3b9bac9SZane Shelley         // [ 0:15] chip position
60ff068a15SZane Shelley         // [16:23] node position
61d3b9bac9SZane Shelley         // [24:31] signature attention type
62ff068a15SZane Shelley         auto chipPos = util::pdbg::getChipPos(i_signature.getChip());
63ff068a15SZane Shelley         uint8_t nodePos = 0; // TODO: multi-node support
64021dab3cSZane Shelley         auto attn = i_signature.getAttnType();
65d3b9bac9SZane Shelley 
66*27dd6368SPatrick Williams         o_word7 = (chipPos & 0xffff) << 16 | (nodePos & 0xff) << 8 |
67*27dd6368SPatrick Williams                   (attn & 0xff);
68d3b9bac9SZane Shelley 
69d3b9bac9SZane Shelley         // [ 0:15] signature ID
70d3b9bac9SZane Shelley         // [16:23] signature instance
71d3b9bac9SZane Shelley         // [24:31] signature bit position
72021dab3cSZane Shelley         o_word8 = i_signature.toUint32();
73d3b9bac9SZane Shelley 
74d3b9bac9SZane Shelley         // Word 9 is currently unused
75021dab3cSZane Shelley     }
76a08d1c37SZane Shelley }
77021dab3cSZane Shelley 
78021dab3cSZane Shelley //------------------------------------------------------------------------------
79021dab3cSZane Shelley 
__setSrc(const libhei::Signature & i_rootCause,std::map<std::string,std::string> & io_logData)80021dab3cSZane Shelley void __setSrc(const libhei::Signature& i_rootCause,
81021dab3cSZane Shelley               std::map<std::string, std::string>& io_logData)
82021dab3cSZane Shelley {
83021dab3cSZane Shelley     uint32_t word6 = 0, word7 = 0, word8 = 0;
84021dab3cSZane Shelley     __getSrc(i_rootCause, word6, word7, word8);
85d3b9bac9SZane Shelley 
86d3b9bac9SZane Shelley     io_logData["SRC6"] = std::to_string(word6);
87d3b9bac9SZane Shelley     io_logData["SRC7"] = std::to_string(word7);
88d3b9bac9SZane Shelley     io_logData["SRC8"] = std::to_string(word8);
89d3b9bac9SZane Shelley }
90d3b9bac9SZane Shelley 
91d3b9bac9SZane Shelley //------------------------------------------------------------------------------
92d3b9bac9SZane Shelley 
__addCalloutList(const ServiceData & i_servData,std::vector<util::FFDCFile> & io_userDataFiles)934ed4be56SZane Shelley void __addCalloutList(const ServiceData& i_servData,
944ed4be56SZane Shelley                       std::vector<util::FFDCFile>& io_userDataFiles)
954ed4be56SZane Shelley {
964ed4be56SZane Shelley     // Create a new entry for the user data section containing the callout list.
974ed4be56SZane Shelley     io_userDataFiles.emplace_back(util::FFDCFormat::JSON, FFDC_CALLOUTS,
984ed4be56SZane Shelley                                   FFDC_VERSION1);
994ed4be56SZane Shelley 
1004ed4be56SZane Shelley     // Use a file stream to write the JSON to file.
1014ed4be56SZane Shelley     std::ofstream o{io_userDataFiles.back().getPath()};
102c85716caSZane Shelley     o << i_servData.getCalloutList();
1034ed4be56SZane Shelley }
1044ed4be56SZane Shelley 
1054ed4be56SZane Shelley //------------------------------------------------------------------------------
1064ed4be56SZane Shelley 
__addCalloutFFDC(const ServiceData & i_servData,std::vector<util::FFDCFile> & io_userDataFiles)1072d114321SZane Shelley void __addCalloutFFDC(const ServiceData& i_servData,
1082d114321SZane Shelley                       std::vector<util::FFDCFile>& io_userDataFiles)
1092d114321SZane Shelley {
1102d114321SZane Shelley     // Create a new entry for the user data section containing the FFDC.
1112d114321SZane Shelley     io_userDataFiles.emplace_back(util::FFDCFormat::Custom, FFDC_CALLOUT_FFDC,
1122d114321SZane Shelley                                   FFDC_VERSION1);
1132d114321SZane Shelley 
1142d114321SZane Shelley     // Use a file stream to write the JSON to file.
1152d114321SZane Shelley     std::ofstream o{io_userDataFiles.back().getPath()};
1162d114321SZane Shelley     o << i_servData.getCalloutFFDC();
1172d114321SZane Shelley }
1182d114321SZane Shelley 
1192d114321SZane Shelley //------------------------------------------------------------------------------
1202d114321SZane Shelley 
__captureSignatureList(const libhei::IsolationData & i_isoData,std::vector<util::FFDCFile> & io_userDataFiles)121d3b9bac9SZane Shelley void __captureSignatureList(const libhei::IsolationData& i_isoData,
122d3b9bac9SZane Shelley                             std::vector<util::FFDCFile>& io_userDataFiles)
123d3b9bac9SZane Shelley {
124021dab3cSZane Shelley     // Create a new entry for this user data section regardless if there are any
125021dab3cSZane Shelley     // signatures in the list.
126021dab3cSZane Shelley     io_userDataFiles.emplace_back(util::FFDCFormat::Custom, FFDC_SIGNATURES,
127021dab3cSZane Shelley                                   FFDC_VERSION1);
128021dab3cSZane Shelley 
129b1106b5dSZane Shelley     // Create a streamer for easy writing to the FFDC file.
130b1106b5dSZane Shelley     auto path = io_userDataFiles.back().getPath();
131b1106b5dSZane Shelley     util::BinFileWriter stream{path};
132b1106b5dSZane Shelley 
133b1106b5dSZane Shelley     // The first 4 bytes in the FFDC contains the number of signatures in the
134b1106b5dSZane Shelley     // list. Then, the list of signatures will follow.
135b1106b5dSZane Shelley 
136021dab3cSZane Shelley     auto list = i_isoData.getSignatureList();
137021dab3cSZane Shelley 
138021dab3cSZane Shelley     uint32_t numSigs = list.size();
139b1106b5dSZane Shelley     stream << numSigs;
140021dab3cSZane Shelley 
141021dab3cSZane Shelley     for (const auto& sig : list)
142021dab3cSZane Shelley     {
143b1106b5dSZane Shelley         // Each signature will use the same format as the SRC (12 bytes each).
144b1106b5dSZane Shelley         uint32_t word6 = 0, word7 = 0, word8 = 0;
145021dab3cSZane Shelley         __getSrc(sig, word6, word7, word8);
146b1106b5dSZane Shelley         stream << word6 << word7 << word8;
147021dab3cSZane Shelley     }
148021dab3cSZane Shelley 
149b1106b5dSZane Shelley     // If the stream failed for any reason, remove the FFDC file.
150b1106b5dSZane Shelley     if (!stream.good())
151021dab3cSZane Shelley     {
152b1106b5dSZane Shelley         trace::err("Unable to write signature list FFDC file: %s",
153b1106b5dSZane Shelley                    path.string().c_str());
154b1106b5dSZane Shelley         io_userDataFiles.pop_back();
155021dab3cSZane Shelley     }
156d3b9bac9SZane Shelley }
157d3b9bac9SZane Shelley 
158d3b9bac9SZane Shelley //------------------------------------------------------------------------------
159d3b9bac9SZane Shelley 
__captureRegisterDump(const libhei::IsolationData & i_isoData,std::vector<util::FFDCFile> & io_userDataFiles)1608f60a621SZane Shelley void __captureRegisterDump(const libhei::IsolationData& i_isoData,
1618f60a621SZane Shelley                            std::vector<util::FFDCFile>& io_userDataFiles)
1628f60a621SZane Shelley {
1638f60a621SZane Shelley     // Create a new entry for this user data section regardless if there are any
1648f60a621SZane Shelley     // registers in the dump.
1658f60a621SZane Shelley     io_userDataFiles.emplace_back(util::FFDCFormat::Custom, FFDC_REGISTER_DUMP,
1668f60a621SZane Shelley                                   FFDC_VERSION1);
1678f60a621SZane Shelley 
1688f60a621SZane Shelley     // Create a streamer for easy writing to the FFDC file.
1698f60a621SZane Shelley     auto path = io_userDataFiles.back().getPath();
1708f60a621SZane Shelley     util::BinFileWriter stream{path};
1718f60a621SZane Shelley 
1728f60a621SZane Shelley     // The first 4 bytes in the FFDC contains the number of chips with register
1738f60a621SZane Shelley     // data. Then the data for each chip will follow.
1748f60a621SZane Shelley 
1758f60a621SZane Shelley     auto dump = i_isoData.getRegisterDump();
1768f60a621SZane Shelley 
1778f60a621SZane Shelley     uint32_t numChips = dump.size();
1788f60a621SZane Shelley     stream << numChips;
1798f60a621SZane Shelley 
1808f60a621SZane Shelley     for (const auto& entry : dump)
1818f60a621SZane Shelley     {
1828f60a621SZane Shelley         auto chip = entry.first;
1838f60a621SZane Shelley         auto regList = entry.second;
1848f60a621SZane Shelley 
1858f60a621SZane Shelley         // Each chip will have the following information:
1868f60a621SZane Shelley         //   4 byte chip model/EC
1878f60a621SZane Shelley         //   2 byte chip position
188ff068a15SZane Shelley         //   1 byte node position
1898f60a621SZane Shelley         //   4 byte number of registers
1908f60a621SZane Shelley         // Then the data for each register will follow.
1918f60a621SZane Shelley 
1928f60a621SZane Shelley         uint32_t chipType = chip.getType();
1938f60a621SZane Shelley         uint16_t chipPos = util::pdbg::getChipPos(chip);
194ff068a15SZane Shelley         uint8_t nodePos = 0; // TODO: multi-node support
1958f60a621SZane Shelley         uint32_t numRegs = regList.size();
196ff068a15SZane Shelley         stream << chipType << chipPos << nodePos << numRegs;
1978f60a621SZane Shelley 
1988f60a621SZane Shelley         for (const auto& reg : regList)
1998f60a621SZane Shelley         {
2008f60a621SZane Shelley             // Each register will have the following information:
2018f60a621SZane Shelley             //   3 byte register ID
2028f60a621SZane Shelley             //   1 byte register instance
2038f60a621SZane Shelley             //   1 byte data size
2048f60a621SZane Shelley             //   * byte data buffer (* depends on value of data size)
2058f60a621SZane Shelley 
2068f60a621SZane Shelley             libhei::RegisterId_t regId = reg.regId;   // 3 byte
2078f60a621SZane Shelley             libhei::Instance_t regInst = reg.regInst; // 1 byte
2088f60a621SZane Shelley 
2098f60a621SZane Shelley             auto tmp = libhei::BitString::getMinBytes(reg.data->getBitLen());
2108f60a621SZane Shelley             if (255 < tmp)
2118f60a621SZane Shelley             {
2128f60a621SZane Shelley                 trace::inf("Register data execeeded 255 and was truncated: "
2138f60a621SZane Shelley                            "regId=0x%06x regInst=%u",
2148f60a621SZane Shelley                            regId, regInst);
2158f60a621SZane Shelley                 tmp = 255;
2168f60a621SZane Shelley             }
2178f60a621SZane Shelley             uint8_t dataSize = tmp;
2188f60a621SZane Shelley 
2198f60a621SZane Shelley             stream << regId << regInst << dataSize;
2208f60a621SZane Shelley 
2218f60a621SZane Shelley             stream.write(reg.data->getBufAddr(), dataSize);
2228f60a621SZane Shelley         }
2238f60a621SZane Shelley     }
2248f60a621SZane Shelley 
2258f60a621SZane Shelley     // If the stream failed for any reason, remove the FFDC file.
2268f60a621SZane Shelley     if (!stream.good())
2278f60a621SZane Shelley     {
2288f60a621SZane Shelley         trace::err("Unable to write register dump FFDC file: %s",
2298f60a621SZane Shelley                    path.string().c_str());
2308f60a621SZane Shelley         io_userDataFiles.pop_back();
2318f60a621SZane Shelley     }
2328f60a621SZane Shelley }
2338f60a621SZane Shelley 
2348f60a621SZane Shelley //------------------------------------------------------------------------------
2358f60a621SZane Shelley 
__captureHostbootScratchRegisters(std::vector<util::FFDCFile> & io_userDataFiles)236c18ba8fbSZane Shelley void __captureHostbootScratchRegisters(
237c18ba8fbSZane Shelley     std::vector<util::FFDCFile>& io_userDataFiles)
238c18ba8fbSZane Shelley {
239c18ba8fbSZane Shelley     // Get the Hostboot scratch registers from the primary processor.
240c18ba8fbSZane Shelley 
241c18ba8fbSZane Shelley     uint32_t cfamAddr = 0x283C;
242c18ba8fbSZane Shelley     uint32_t cfamValue = 0;
243c18ba8fbSZane Shelley 
244c18ba8fbSZane Shelley     uint64_t scomAddr = 0x4602F489;
245c18ba8fbSZane Shelley     uint64_t scomValue = 0;
246c18ba8fbSZane Shelley 
247c18ba8fbSZane Shelley     auto priProc = util::pdbg::getPrimaryProcessor();
248c18ba8fbSZane Shelley     if (nullptr == priProc)
249c18ba8fbSZane Shelley     {
250c18ba8fbSZane Shelley         trace::err("Unable to get primary processor");
251c18ba8fbSZane Shelley     }
252c18ba8fbSZane Shelley     else
253c18ba8fbSZane Shelley     {
254c18ba8fbSZane Shelley         if (0 != util::pdbg::getCfam(priProc, cfamAddr, cfamValue))
255c18ba8fbSZane Shelley         {
256c18ba8fbSZane Shelley             cfamValue = 0; // just in case
257c18ba8fbSZane Shelley         }
258c18ba8fbSZane Shelley 
259c18ba8fbSZane Shelley         if (0 != util::pdbg::getScom(priProc, scomAddr, scomValue))
260c18ba8fbSZane Shelley         {
261c18ba8fbSZane Shelley             scomValue = 0; // just in case
262c18ba8fbSZane Shelley         }
263c18ba8fbSZane Shelley     }
264c18ba8fbSZane Shelley 
265c18ba8fbSZane Shelley     // Create a new entry for this user data section.
266c18ba8fbSZane Shelley     io_userDataFiles.emplace_back(util::FFDCFormat::Custom,
267c18ba8fbSZane Shelley                                   FFDC_HB_SCRATCH_REGS, FFDC_VERSION1);
268c18ba8fbSZane Shelley 
269c18ba8fbSZane Shelley     // Create a streamer for easy writing to the FFDC file.
270c18ba8fbSZane Shelley     auto path = io_userDataFiles.back().getPath();
271c18ba8fbSZane Shelley     util::BinFileWriter stream{path};
272c18ba8fbSZane Shelley 
273c18ba8fbSZane Shelley     // Add the data (CFAM addr/val, then SCOM addr/val).
274c18ba8fbSZane Shelley     stream << cfamAddr << cfamValue << scomAddr << scomValue;
275c18ba8fbSZane Shelley 
276c18ba8fbSZane Shelley     // If the stream failed for any reason, remove the FFDC file.
277c18ba8fbSZane Shelley     if (!stream.good())
278c18ba8fbSZane Shelley     {
279c18ba8fbSZane Shelley         trace::err("Unable to write register dump FFDC file: %s",
280c18ba8fbSZane Shelley                    path.string().c_str());
281c18ba8fbSZane Shelley         io_userDataFiles.pop_back();
282c18ba8fbSZane Shelley     }
283c18ba8fbSZane Shelley }
284c18ba8fbSZane Shelley 
285c18ba8fbSZane Shelley //------------------------------------------------------------------------------
286c18ba8fbSZane Shelley 
__captureScratchRegSignature(std::vector<util::FFDCFile> & io_userDataFiles)2877a465259SCaleb Palmer void __captureScratchRegSignature(std::vector<util::FFDCFile>& io_userDataFiles)
2887a465259SCaleb Palmer {
2897a465259SCaleb Palmer     // If analysis was interrupted by a system checkstop, there may exist an
2907a465259SCaleb Palmer     // error signature within Hostboot scratch registers 9 (scom: 0x00050180,
2917a465259SCaleb Palmer     // fsi: 0x2980) and 10 (scom: 0x00050181, fsi: 0x2981) which indicates the
2927a465259SCaleb Palmer     // signature from the interrupted analysis. If data exists within those
2937a465259SCaleb Palmer     // registers a user data section will be created in the PEL to record it.
2947a465259SCaleb Palmer 
2957a465259SCaleb Palmer     uint32_t reg9Addr = 0x2980;
2967a465259SCaleb Palmer     uint32_t reg10Addr = 0x2981;
2977a465259SCaleb Palmer 
2987a465259SCaleb Palmer     uint32_t chipId = 0; // stored in reg9
2997a465259SCaleb Palmer     uint32_t sigId = 0;  // stored in reg10
3007a465259SCaleb Palmer 
3017a465259SCaleb Palmer     auto priProc = util::pdbg::getPrimaryProcessor();
3027a465259SCaleb Palmer     if (nullptr == priProc)
3037a465259SCaleb Palmer     {
3047a465259SCaleb Palmer         trace::err("Unable to get primary processor");
3057a465259SCaleb Palmer     }
3067a465259SCaleb Palmer     else
3077a465259SCaleb Palmer     {
3087a465259SCaleb Palmer         if (0 != util::pdbg::getCfam(priProc, reg9Addr, chipId))
3097a465259SCaleb Palmer         {
3107a465259SCaleb Palmer             chipId = 0; // just in case
3117a465259SCaleb Palmer         }
3127a465259SCaleb Palmer 
3137a465259SCaleb Palmer         if (0 != util::pdbg::getCfam(priProc, reg10Addr, sigId))
3147a465259SCaleb Palmer         {
3157a465259SCaleb Palmer             sigId = 0; // just in case
3167a465259SCaleb Palmer         }
3177a465259SCaleb Palmer     }
3187a465259SCaleb Palmer 
3197a465259SCaleb Palmer     // If any non-zero data was found in the registers, add them to the FFDC.
3207a465259SCaleb Palmer     if (0 != chipId || 0 != sigId)
3217a465259SCaleb Palmer     {
3227a465259SCaleb Palmer         // Create a new entry for this user data section.
3237a465259SCaleb Palmer         io_userDataFiles.emplace_back(util::FFDCFormat::Custom,
3247a465259SCaleb Palmer                                       FFDC_SCRATCH_SIG, FFDC_VERSION1);
3257a465259SCaleb Palmer 
3267a465259SCaleb Palmer         // Create a streamer for easy writing to the FFDC file.
3277a465259SCaleb Palmer         auto path = io_userDataFiles.back().getPath();
3287a465259SCaleb Palmer         util::BinFileWriter stream{path};
3297a465259SCaleb Palmer 
3307a465259SCaleb Palmer         stream << chipId << sigId;
3317a465259SCaleb Palmer 
3327a465259SCaleb Palmer         // If the stream failed for any reason, remove the FFDC file.
3337a465259SCaleb Palmer         if (!stream.good())
3347a465259SCaleb Palmer         {
3357a465259SCaleb Palmer             trace::err("Unable to write register dump FFDC file: %s",
3367a465259SCaleb Palmer                        path.string().c_str());
3377a465259SCaleb Palmer             io_userDataFiles.pop_back();
3387a465259SCaleb Palmer         }
3397a465259SCaleb Palmer     }
3407a465259SCaleb Palmer }
3417a465259SCaleb Palmer 
3427a465259SCaleb Palmer //------------------------------------------------------------------------------
3437a465259SCaleb Palmer 
__getMessageRegistry(AnalysisType i_type)344f17bf3e5SZane Shelley std::string __getMessageRegistry(AnalysisType i_type)
345d3b9bac9SZane Shelley {
346f17bf3e5SZane Shelley     if (AnalysisType::SYSTEM_CHECKSTOP == i_type)
347f17bf3e5SZane Shelley     {
348f17bf3e5SZane Shelley         return "org.open_power.HwDiags.Error.Checkstop";
349f17bf3e5SZane Shelley     }
350f17bf3e5SZane Shelley     else if (AnalysisType::TERMINATE_IMMEDIATE == i_type)
351f17bf3e5SZane Shelley     {
352f17bf3e5SZane Shelley         return "org.open_power.HwDiags.Error.Predictive";
353f17bf3e5SZane Shelley     }
354f17bf3e5SZane Shelley 
355f17bf3e5SZane Shelley     return "org.open_power.HwDiags.Error.Informational"; // default
356d3b9bac9SZane Shelley }
357d3b9bac9SZane Shelley 
358d3b9bac9SZane Shelley //------------------------------------------------------------------------------
359d3b9bac9SZane Shelley 
__getMessageSeverity(AnalysisType i_type)360f17bf3e5SZane Shelley std::string __getMessageSeverity(AnalysisType i_type)
361d3b9bac9SZane Shelley {
362f17bf3e5SZane Shelley     // Default severity is informational (no service action required).
363f17bf3e5SZane Shelley     LogSvr::Entry::Level severity = LogSvr::Entry::Level::Informational;
364d3b9bac9SZane Shelley 
365f17bf3e5SZane Shelley     if (AnalysisType::SYSTEM_CHECKSTOP == i_type)
366f17bf3e5SZane Shelley     {
367f17bf3e5SZane Shelley         // System checkstops are always unrecoverable errors (service action
368f17bf3e5SZane Shelley         // required).
369d3b9bac9SZane Shelley         severity = LogSvr::Entry::Level::Error;
370f17bf3e5SZane Shelley     }
371f17bf3e5SZane Shelley     else if (AnalysisType::TERMINATE_IMMEDIATE == i_type)
372f17bf3e5SZane Shelley     {
373f17bf3e5SZane Shelley         // TIs will be reported as a predicive error (service action required).
374f17bf3e5SZane Shelley         severity = LogSvr::Entry::Level::Warning;
375f17bf3e5SZane Shelley     }
376d3b9bac9SZane Shelley 
377d3b9bac9SZane Shelley     // Convert the message severity to a string.
378d3b9bac9SZane Shelley     return LogSvr::Entry::convertLevelToString(severity);
379d3b9bac9SZane Shelley }
380d3b9bac9SZane Shelley 
381d3b9bac9SZane Shelley //------------------------------------------------------------------------------
382d3b9bac9SZane Shelley 
commitPel(const ServiceData & i_servData)383c1e1c000SBen Tyner uint32_t commitPel(const ServiceData& i_servData)
384d3b9bac9SZane Shelley {
385611b3442SZane Shelley     uint32_t o_plid = 0; // default, zero indicates PEL was not created
386611b3442SZane Shelley 
387d3b9bac9SZane Shelley     // The message registry will require additional log data to fill in keywords
388d3b9bac9SZane Shelley     // and additional log data.
389d3b9bac9SZane Shelley     std::map<std::string, std::string> logData;
390d3b9bac9SZane Shelley 
391d3b9bac9SZane Shelley     // Keep track of the temporary files associated with the user data FFDC.
392d3b9bac9SZane Shelley     // WARNING: Once the objects stored in this vector go out of scope, the
393d3b9bac9SZane Shelley     //          temporary files will be deleted. So they must remain in scope
394d3b9bac9SZane Shelley     //          until the PEL is submitted.
395d3b9bac9SZane Shelley     std::vector<util::FFDCFile> userDataFiles;
396d3b9bac9SZane Shelley 
39755e7fec3SZane Shelley     // Set the subsystem in the primary SRC.
39855e7fec3SZane Shelley     i_servData.addSrcSubsystem(logData);
39955e7fec3SZane Shelley 
400d3b9bac9SZane Shelley     // Set words 6-9 of the SRC.
4018af9e46fSZane Shelley     __setSrc(i_servData.getRootCause(), logData);
402d3b9bac9SZane Shelley 
4034ed4be56SZane Shelley     // Add the list of callouts to the PEL.
4044ed4be56SZane Shelley     __addCalloutList(i_servData, userDataFiles);
4054ed4be56SZane Shelley 
406c18ba8fbSZane Shelley     // Add the Hostboot scratch register to the PEL.
407c18ba8fbSZane Shelley     __captureHostbootScratchRegisters(userDataFiles);
408c18ba8fbSZane Shelley 
4097a465259SCaleb Palmer     // Add the signature stored in the scratch regs if it exists.
4107a465259SCaleb Palmer     __captureScratchRegSignature(userDataFiles);
4117a465259SCaleb Palmer 
4122d114321SZane Shelley     // Add the callout FFDC to the PEL.
4132d114321SZane Shelley     __addCalloutFFDC(i_servData, userDataFiles);
4142d114321SZane Shelley 
415d3b9bac9SZane Shelley     // Capture the complete signature list.
41662adf5c2SZane Shelley     __captureSignatureList(i_servData.getIsolationData(), userDataFiles);
417d3b9bac9SZane Shelley 
4188f60a621SZane Shelley     // Capture the complete signature list.
41962adf5c2SZane Shelley     __captureRegisterDump(i_servData.getIsolationData(), userDataFiles);
4208f60a621SZane Shelley 
421d3b9bac9SZane Shelley     // Now, that all of the user data files have been created, transform the
422d3b9bac9SZane Shelley     // data into the proper format for the PEL.
423d3b9bac9SZane Shelley     std::vector<util::FFDCTuple> userData;
424d3b9bac9SZane Shelley     util::transformFFDC(userDataFiles, userData);
425d3b9bac9SZane Shelley 
426d3b9bac9SZane Shelley     // Get the message registry entry for this failure.
427f17bf3e5SZane Shelley     auto message = __getMessageRegistry(i_servData.getAnalysisType());
428d3b9bac9SZane Shelley 
429d3b9bac9SZane Shelley     // Get the message severity for this failure.
430f17bf3e5SZane Shelley     auto severity = __getMessageSeverity(i_servData.getAnalysisType());
431d3b9bac9SZane Shelley 
432c1e1c000SBen Tyner     // Create the PEL
433c1e1c000SBen Tyner     o_plid = util::dbus::createPel(message, severity, logData, userData);
434d3b9bac9SZane Shelley 
435c1e1c000SBen Tyner     if (0 == o_plid)
4367029e525SBen Tyner     {
437c1e1c000SBen Tyner         trace::err("Error while creating event log entry");
4387029e525SBen Tyner     }
4397029e525SBen Tyner 
440611b3442SZane Shelley     // Return the platorm log ID of the error.
441611b3442SZane Shelley     return o_plid;
442d3b9bac9SZane Shelley }
443d3b9bac9SZane Shelley 
444d3b9bac9SZane Shelley } // namespace analyzer
445