1f685afd6SZane Shelley #pragma once 2f685afd6SZane Shelley 382be3ab5SZane Shelley #include <analyzer/analyzer_main.hpp> 4c85716caSZane Shelley #include <analyzer/callout.hpp> 58af9e46fSZane Shelley #include <hei_main.hpp> 6f685afd6SZane Shelley #include <nlohmann/json.hpp> 737acb289SZane Shelley #include <util/pdbg.hpp> 8f685afd6SZane Shelley 9710101c0SPatrick Williams #include <format> 10710101c0SPatrick Williams 11f685afd6SZane Shelley namespace analyzer 12f685afd6SZane Shelley { 13f685afd6SZane Shelley 1464791cf7SZane Shelley /** 1564791cf7SZane Shelley * @brief Data regarding required service actions based on the hardware error 1664791cf7SZane Shelley * analysis. 1764791cf7SZane Shelley */ 1864791cf7SZane Shelley class ServiceData 1964791cf7SZane Shelley { 2064791cf7SZane Shelley public: 218af9e46fSZane Shelley /** 228af9e46fSZane Shelley * @brief Constructor from components. 2362adf5c2SZane Shelley * @param i_rootCause The signature of the root cause attention. 2462adf5c2SZane Shelley * @param i_analysisType The type of analysis to perform. 2562adf5c2SZane Shelley * @param i_isoData The data found during isolation. 268af9e46fSZane Shelley */ ServiceData(const libhei::Signature & i_rootCause,AnalysisType i_analysisType,const libhei::IsolationData & i_isoData)2782be3ab5SZane Shelley ServiceData(const libhei::Signature& i_rootCause, 2862adf5c2SZane Shelley AnalysisType i_analysisType, 2962adf5c2SZane Shelley const libhei::IsolationData& i_isoData) : 30*a0c724d3SPatrick Williams iv_rootCause(i_rootCause), iv_analysisType(i_analysisType), 31*a0c724d3SPatrick Williams iv_isoData(i_isoData) 328af9e46fSZane Shelley {} 3364791cf7SZane Shelley 3464791cf7SZane Shelley /** @brief Destructor. */ 3564791cf7SZane Shelley ~ServiceData() = default; 3664791cf7SZane Shelley 3764791cf7SZane Shelley /** @brief Copy constructor. */ 3864791cf7SZane Shelley ServiceData(const ServiceData&) = default; 3964791cf7SZane Shelley 4064791cf7SZane Shelley /** @brief Assignment operator. */ 4164791cf7SZane Shelley ServiceData& operator=(const ServiceData&) = default; 4264791cf7SZane Shelley 4364791cf7SZane Shelley private: 448af9e46fSZane Shelley /** The signature of the root cause attention. */ 458af9e46fSZane Shelley const libhei::Signature iv_rootCause; 468af9e46fSZane Shelley 4782be3ab5SZane Shelley /** The type of analysis to perform. */ 4882be3ab5SZane Shelley const AnalysisType iv_analysisType; 49ca496198SZane Shelley 5062adf5c2SZane Shelley /** The data found during isolation. */ 5162adf5c2SZane Shelley const libhei::IsolationData iv_isoData; 5262adf5c2SZane Shelley 5364791cf7SZane Shelley /** The list of callouts that will be added to a PEL. */ 54c85716caSZane Shelley nlohmann::json iv_calloutList = nlohmann::json::array(); 5564791cf7SZane Shelley 562d114321SZane Shelley /** FFDC for callouts that would otherwise not be available in the 572d114321SZane Shelley * callout list (unit paths, bus types, etc.). */ 582d114321SZane Shelley nlohmann::json iv_calloutFFDC = nlohmann::json::array(); 592d114321SZane Shelley 6064791cf7SZane Shelley public: 618af9e46fSZane Shelley /** @return The signature of the root cause attention. */ getRootCause() const628af9e46fSZane Shelley const libhei::Signature& getRootCause() const 638af9e46fSZane Shelley { 648af9e46fSZane Shelley return iv_rootCause; 658af9e46fSZane Shelley } 668af9e46fSZane Shelley 6782be3ab5SZane Shelley /** @return The type of analysis to perform. */ getAnalysisType() const6882be3ab5SZane Shelley AnalysisType getAnalysisType() const 69ca496198SZane Shelley { 7082be3ab5SZane Shelley return iv_analysisType; 71ca496198SZane Shelley } 72ca496198SZane Shelley 7362adf5c2SZane Shelley /** @return The data found during isolation. */ getIsolationData() const7462adf5c2SZane Shelley const libhei::IsolationData& getIsolationData() const 7562adf5c2SZane Shelley { 7662adf5c2SZane Shelley return iv_isoData; 7762adf5c2SZane Shelley } 7862adf5c2SZane Shelley 79bf3326fbSZane Shelley /** @return Returns the guard type based on current analysis policies. */ queryGuardPolicy() const80bf3326fbSZane Shelley callout::GuardType queryGuardPolicy() const 81bf3326fbSZane Shelley { 8282be3ab5SZane Shelley if (AnalysisType::SYSTEM_CHECKSTOP == iv_analysisType) 8382be3ab5SZane Shelley { 8482be3ab5SZane Shelley return callout::GuardType::UNRECOVERABLE; 8582be3ab5SZane Shelley } 8682be3ab5SZane Shelley else if (AnalysisType::TERMINATE_IMMEDIATE == iv_analysisType) 8782be3ab5SZane Shelley { 8882be3ab5SZane Shelley return callout::GuardType::PREDICTIVE; 8982be3ab5SZane Shelley } 90bf3326fbSZane Shelley 9182be3ab5SZane Shelley return callout::GuardType::NONE; 92bf3326fbSZane Shelley } 93bf3326fbSZane Shelley 94c85716caSZane Shelley /** 9537acb289SZane Shelley * @brief Add callout for a pdbg_target. 9637acb289SZane Shelley * @param i_target The chip or unit target to add to the callout list. 9737acb289SZane Shelley * @param i_priority The callout priority. 9837acb289SZane Shelley * @param i_guard True if guard is required. False, otherwise. 9937acb289SZane Shelley */ 1009980d489SZane Shelley void calloutTarget(pdbg_target* i_target, callout::Priority i_priority, 1019980d489SZane Shelley bool i_guard); 10237acb289SZane Shelley 10337acb289SZane Shelley /** 10437acb289SZane Shelley * @brief Add callout for a connected target on the other side of a bus. 10537acb289SZane Shelley * @param i_rxTarget The target on the receiving side (RX) of the bus. 10637acb289SZane Shelley * @param i_busType The bus type. 10737acb289SZane Shelley * @param i_priority The callout priority. 10837acb289SZane Shelley * @param i_guard True if guard is required. False, otherwise. 10937acb289SZane Shelley */ 11037acb289SZane Shelley void calloutConnected(pdbg_target* i_rxTarget, 11137acb289SZane Shelley const callout::BusType& i_busType, 1129980d489SZane Shelley callout::Priority i_priority, bool i_guard); 11337acb289SZane Shelley 11437acb289SZane Shelley /** 11537acb289SZane Shelley * @brief Add callout for an entire bus. 11637acb289SZane Shelley * @param i_rxTarget The target on the receiving side (RX) of the bus. 11737acb289SZane Shelley * @param i_busType The bus type. 11837acb289SZane Shelley * @param i_priority The callout priority. 11937acb289SZane Shelley * @param i_guard True if guard is required. False, otherwise. 12037acb289SZane Shelley */ 12137acb289SZane Shelley void calloutBus(pdbg_target* i_rxTarget, const callout::BusType& i_busType, 1229980d489SZane Shelley callout::Priority i_priority, bool i_guard); 12337acb289SZane Shelley 12437acb289SZane Shelley /** 12537acb289SZane Shelley * @brief Add callout for a clock. 12637acb289SZane Shelley * @param i_clockType The clock type. 12737acb289SZane Shelley * @param i_priority The callout priority. 12837acb289SZane Shelley * @param i_guard True if guard is required. False, otherwise. 12937acb289SZane Shelley */ 13037acb289SZane Shelley void calloutClock(const callout::ClockType& i_clockType, 1319980d489SZane Shelley callout::Priority i_priority, bool i_guard); 13237acb289SZane Shelley 13337acb289SZane Shelley /** 13437acb289SZane Shelley * @brief Add callout for a service procedure. 13537acb289SZane Shelley * @param i_procedure The procedure type. 13637acb289SZane Shelley * @param i_priority The callout priority. 13737acb289SZane Shelley */ 13837acb289SZane Shelley void calloutProcedure(const callout::Procedure& i_procedure, 1399980d489SZane Shelley callout::Priority i_priority); 14037acb289SZane Shelley 141a4134770SZane Shelley /** 142a4134770SZane Shelley * @brief Add callout for part type. 143a4134770SZane Shelley * @param i_part The part type. 144a4134770SZane Shelley * @param i_priority The callout priority. 145a4134770SZane Shelley */ 146a4134770SZane Shelley void calloutPart(const callout::PartType& i_part, 1479980d489SZane Shelley callout::Priority i_priority); 148a4134770SZane Shelley 14937acb289SZane Shelley /** @brief Accessor to iv_calloutList. */ getCalloutList() const15037acb289SZane Shelley const nlohmann::json& getCalloutList() const 15137acb289SZane Shelley { 15237acb289SZane Shelley return iv_calloutList; 15337acb289SZane Shelley } 15437acb289SZane Shelley 15537acb289SZane Shelley /** @brief Accessor to iv_calloutFFDC. */ getCalloutFFDC() const15637acb289SZane Shelley const nlohmann::json& getCalloutFFDC() const 15737acb289SZane Shelley { 15837acb289SZane Shelley return iv_calloutFFDC; 15937acb289SZane Shelley } 16037acb289SZane Shelley 16155e7fec3SZane Shelley /** 16255e7fec3SZane Shelley * @brief Adds the SRC subsystem to the given additional PEL data. 16355e7fec3SZane Shelley * @param io_additionalData The additional PEL data. 16455e7fec3SZane Shelley */ addSrcSubsystem(std::map<std::string,std::string> & io_additionalData) const16555e7fec3SZane Shelley void addSrcSubsystem( 16655e7fec3SZane Shelley std::map<std::string, std::string>& io_additionalData) const 16755e7fec3SZane Shelley { 168710101c0SPatrick Williams io_additionalData["PEL_SUBSYSTEM"] = std::format( 169c3fb2062SCaleb Palmer "0x{:02x}", static_cast<uint8_t>(iv_srcSubsystem.first)); 17055e7fec3SZane Shelley } 17155e7fec3SZane Shelley 17255e7fec3SZane Shelley /** @brief Accessor to iv_srcSubsystem. */ getSubsys() const17355e7fec3SZane Shelley const std::pair<callout::SrcSubsystem, callout::Priority> getSubsys() const 17455e7fec3SZane Shelley { 17555e7fec3SZane Shelley return iv_srcSubsystem; 17655e7fec3SZane Shelley } 17755e7fec3SZane Shelley 17837acb289SZane Shelley private: 17937acb289SZane Shelley /** 180c85716caSZane Shelley * @brief Add callout information to the callout list. 181c85716caSZane Shelley * @param The JSON object for this callout. 182c85716caSZane Shelley */ 183979e2871SZane Shelley void addCallout(const nlohmann::json& i_callout); 18464791cf7SZane Shelley 1859513582bSZane Shelley /** 1862d114321SZane Shelley * @brief Add FFDC for a callout that would otherwise not be available in 1872d114321SZane Shelley * the callout list (unit paths, bus types, etc.). 1882d114321SZane Shelley * @param The JSON object for this callout. 1892d114321SZane Shelley */ addCalloutFFDC(const nlohmann::json & i_ffdc)1902d114321SZane Shelley void addCalloutFFDC(const nlohmann::json& i_ffdc) 1912d114321SZane Shelley { 1922d114321SZane Shelley iv_calloutFFDC.push_back(i_ffdc); 1932d114321SZane Shelley } 1942d114321SZane Shelley 19537acb289SZane Shelley /** 19637acb289SZane Shelley * @brief A simple helper function for all the callout functions that need 19737acb289SZane Shelley * to callout a target (callout only, no FFDC). 19837acb289SZane Shelley * @param i_target The chip or unit target to add to the callout list. 19937acb289SZane Shelley * @param i_priority The callout priority. 20037acb289SZane Shelley * @param i_guard True if guard is required. False, otherwise. 20137acb289SZane Shelley */ 2029980d489SZane Shelley void addTargetCallout(pdbg_target* i_target, callout::Priority i_priority, 2039980d489SZane Shelley bool i_guard); 2045f6e3debSZane Shelley 20537acb289SZane Shelley /** 20637acb289SZane Shelley * @brief A simple helper function for all the callout functions that need 20737acb289SZane Shelley * to callout a the backplane (callout only, no FFDC). 20837acb289SZane Shelley * @param i_priority The callout priority. 20937acb289SZane Shelley */ 2109980d489SZane Shelley void addBackplaneCallout(callout::Priority i_priority); 21155e7fec3SZane Shelley 21255e7fec3SZane Shelley private: 21355e7fec3SZane Shelley /** 21455e7fec3SZane Shelley * @brief Compares the current SRC subsystem type with the given SRC 21555e7fec3SZane Shelley * subsystem type and stores the highest priority callout subsystem. 21655e7fec3SZane Shelley * If the two subsystems are of equal priority. The stored subsystem 21755e7fec3SZane Shelley * is used. 21855e7fec3SZane Shelley * @param i_subsystem The given subsystem type. 21955e7fec3SZane Shelley * @param i_priority The callout priority associated with the given 22055e7fec3SZane Shelley * subsystem. 22155e7fec3SZane Shelley */ 22255e7fec3SZane Shelley void setSrcSubsystem(callout::SrcSubsystem i_subsystem, 22355e7fec3SZane Shelley callout::Priority i_priority); 22455e7fec3SZane Shelley 22555e7fec3SZane Shelley /** 22655e7fec3SZane Shelley * @brief Returns the appropriate SRC subsystem based on the input target. 22755e7fec3SZane Shelley * @param i_trgt The given pdbg target. 22855e7fec3SZane Shelley */ 22955e7fec3SZane Shelley callout::SrcSubsystem getTargetSubsystem(pdbg_target* i_target); 23055e7fec3SZane Shelley 23155e7fec3SZane Shelley /** The SRC subsystem field (2nd byte of the primary SRC) is based on the 23255e7fec3SZane Shelley * callouts the PEL. As callouts are to the service data, we'll need to 23355e7fec3SZane Shelley * keep track of the highest priority callout subsystem. */ 23455e7fec3SZane Shelley std::pair<callout::SrcSubsystem, callout::Priority> iv_srcSubsystem = { 23555e7fec3SZane Shelley callout::SrcSubsystem::CEC_HARDWARE, callout::Priority::LOW}; 23664791cf7SZane Shelley }; 23764791cf7SZane Shelley 238f685afd6SZane Shelley } // namespace analyzer 239