xref: /openbmc/openpower-hw-diags/attn/attn_common.hpp (revision 27dd6368d4e6b1fd03610503356f24eb08a16c02)
1  #pragma once
2  
3  #include <util/ffdc.hpp>
4  
5  namespace attn
6  {
7  
8  // number of seconds to wait for power fault handling
9  constexpr int POWER_FAULT_WAIT = 10;
10  
11  /** @brief Attention handler return codes */
12  enum ReturnCodes
13  {
14      RC_SUCCESS = 0,
15      RC_NOT_HANDLED = 1,
16      RC_ANALYZER_ERROR = 2,
17      RC_CFAM_ERROR = 3,
18      RC_DBUS_ERROR = 4
19  };
20  
21  /** @brief Code seciton for error reporing */
22  enum class AttnSection
23  {
24      reserved = 0x0000,
25      attnHandler = 0x0100,
26      tiHandler = 0x0200,
27      handlePhypTi = 0x0300,
28      handleHbTi = 0x0400,
29      addHbStatusRegs = 0x0500,
30      attnLogging = 0x0600
31  };
32  
33  /** @brief Attention handler error reason codes */
34  enum AttnCodes
35  {
36      ATTN_NO_ERROR = 0,
37      ATTN_INFO_NULL = 1,
38      ATTN_PDBG_CFAM = 2,
39      ATTN_PDBG_SCOM = 3,
40      ATTN_INVALID_KEY = 4
41  };
42  
43  /**
44   * @brief Traces some regs for hostboot
45   *
46   * When we receive a Checkstop or special Attention Term Immediate,
47   * hostboot wants some regs added to the error log. We will do this
48   * by tracing them and then the traces will get added to the error
49   * log later.
50   *
51   * @return nothing
52   */
53  void addHbStatusRegs();
54  
55  /** @brief Capture some scratch registers for PRD
56   *
57   * Capture some scratch register data that PRD can use to handle
58   * cases where analysis may have been interrupted. The data will
59   * be traced and also written to the user data section of a PEL.
60   *
61   * @param[out] o_files vector of FFDC files
62   *
63   * @return nothing
64   */
65  void addPrdScratchRegs(std::vector<util::FFDCFile>& o_files);
66  
67  /**
68   * @brief Check for recoverable errors present
69   *
70   * @return true if any recoverable errors are present, else false
71   */
72  bool recoverableErrors();
73  
74  /**
75   * @brief sleep for n-seconds
76   *
77   * @param[in] seconds number of seconds to sleep
78   */
79  void sleepSeconds(const unsigned int seconds);
80  
81  } // namespace attn
82