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