Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 3 | #include <libpdbg.h> |
| 4 | |
Zane Shelley | 38501e1 | 2022-01-10 15:42:28 -0600 | [diff] [blame] | 5 | #include <analyzer/callout.hpp> |
| 6 | |
Zane Shelley | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 7 | #include <string> |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
| 10 | // Forward reference to avoid pulling the libhei library into everything that |
| 11 | // includes this header. |
| 12 | namespace libhei |
| 13 | { |
| 14 | class Chip; |
| 15 | } |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 16 | |
| 17 | namespace util |
| 18 | { |
| 19 | |
| 20 | namespace pdbg |
| 21 | { |
| 22 | |
Zane Shelley | 35171d9 | 2020-12-03 13:31:13 -0600 | [diff] [blame] | 23 | /** Chip target types. */ |
| 24 | enum TargetType_t : uint8_t |
| 25 | { |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 26 | TYPE_DIMM = 0x03, |
| 27 | TYPE_PROC = 0x05, |
| 28 | TYPE_CORE = 0x07, |
Caleb Palmer | bc94bde | 2022-02-18 09:03:37 -0600 | [diff] [blame] | 29 | TYPE_NX = 0x1e, |
Zane Shelley | 55e7fec | 2022-01-28 15:29:44 -0600 | [diff] [blame] | 30 | TYPE_EQ = 0x23, |
| 31 | TYPE_PEC = 0x2d, |
| 32 | TYPE_PHB = 0x2e, |
| 33 | TYPE_MC = 0x44, |
| 34 | TYPE_IOLINK = 0x47, |
| 35 | TYPE_OMI = 0x48, |
| 36 | TYPE_MCC = 0x49, |
| 37 | TYPE_OMIC = 0x4a, |
| 38 | TYPE_OCMB = 0x4b, |
| 39 | TYPE_MEM_PORT = 0x4c, |
| 40 | TYPE_NMMU = 0x4f, |
| 41 | TYPE_PAU = 0x50, |
| 42 | TYPE_IOHS = 0x51, |
| 43 | TYPE_PAUC = 0x52, |
Zane Shelley | 35171d9 | 2020-12-03 13:31:13 -0600 | [diff] [blame] | 44 | }; |
| 45 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 46 | /** @return The target associated with the given chip. */ |
| 47 | pdbg_target* getTrgt(const libhei::Chip& i_chip); |
| 48 | |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 49 | /** @return The target associated with the given devtree path. */ |
| 50 | pdbg_target* getTrgt(const std::string& i_path); |
| 51 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 52 | /** @return A string representing the given target's devtree path. */ |
| 53 | const char* getPath(pdbg_target* i_trgt); |
| 54 | |
| 55 | /** @return A string representing the given chip's devtree path. */ |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 56 | const char* getPath(const libhei::Chip& i_chip); |
| 57 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 58 | /** @return The absolute position of the given target. */ |
| 59 | uint32_t getChipPos(pdbg_target* i_trgt); |
| 60 | |
| 61 | /** @return The absolute position of the given chip. */ |
| 62 | uint32_t getChipPos(const libhei::Chip& i_chip); |
| 63 | |
Zane Shelley | 2a394cb | 2022-02-17 22:01:39 -0600 | [diff] [blame] | 64 | /** @return The unit position of a target within a chip. */ |
| 65 | uint8_t getUnitPos(pdbg_target* i_trgt); |
| 66 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 67 | /** @return The target type of the given target. */ |
| 68 | uint8_t getTrgtType(pdbg_target* i_trgt); |
| 69 | |
| 70 | /** @return The target type of the given chip. */ |
| 71 | uint8_t getTrgtType(const libhei::Chip& i_chip); |
| 72 | |
Zane Shelley | 2a394cb | 2022-02-17 22:01:39 -0600 | [diff] [blame] | 73 | /** @return The parent chip target of the given unit target. */ |
| 74 | pdbg_target* getParentChip(pdbg_target* i_unitTarget); |
| 75 | |
| 76 | /** @return The unit target within chip of the given unit type and position |
| 77 | * relative to the chip. */ |
| 78 | pdbg_target* getChipUnit(pdbg_target* i_parentChip, TargetType_t i_unitType, |
| 79 | uint8_t i_unitPos); |
| 80 | |
Zane Shelley | 171a2e0 | 2020-11-13 13:56:13 -0600 | [diff] [blame] | 81 | /** |
Zane Shelley | 38501e1 | 2022-01-10 15:42:28 -0600 | [diff] [blame] | 82 | * @return The connected target on the other side of the given bus. |
| 83 | * @param i_rxTarget The target on the receiving side (RX) of the bus. |
| 84 | * @param i_busType The bus type. |
| 85 | */ |
| 86 | pdbg_target* getConnectedTarget(pdbg_target* i_rxTarget, |
| 87 | const analyzer::callout::BusType& i_busType); |
| 88 | |
| 89 | /** |
Zane Shelley | 171a2e0 | 2020-11-13 13:56:13 -0600 | [diff] [blame] | 90 | * @return The pib target associated with the given proc target. |
| 91 | * @note Will assert the given target is a proc target. |
| 92 | * @note Will assert the returned pib target it not nullptr. |
| 93 | */ |
| 94 | pdbg_target* getPibTrgt(pdbg_target* i_procTrgt); |
| 95 | |
| 96 | /** |
Zane Shelley | ff76b6b | 2020-11-18 13:54:26 -0600 | [diff] [blame] | 97 | * @return The fsi target associated with the given proc target. |
| 98 | * @note Will assert the given target is a proc target. |
| 99 | * @note Will assert the returned fsi target it not nullptr. |
| 100 | */ |
| 101 | pdbg_target* getFsiTrgt(pdbg_target* i_procTrgt); |
| 102 | |
| 103 | /** |
Zane Shelley | c18ba8f | 2021-12-01 16:29:20 -0600 | [diff] [blame] | 104 | * @brief Reads a SCOM register. |
| 105 | * @param i_trgt Given target. |
| 106 | * @param i_addr Given address. |
| 107 | * @param o_val The returned value of the register. |
| 108 | * @return 0 if successful, non-0 otherwise. |
| 109 | * @note Will assert the given target is a proc target. |
| 110 | */ |
| 111 | int getScom(pdbg_target* i_trgt, uint64_t i_addr, uint64_t& o_val); |
| 112 | |
| 113 | /** |
Zane Shelley | 35171d9 | 2020-12-03 13:31:13 -0600 | [diff] [blame] | 114 | * @brief Reads a CFAM FSI register. |
| 115 | * @param i_trgt Given target. |
| 116 | * @param i_addr Given address. |
| 117 | * @param o_val The returned value of the register. |
| 118 | * @return 0 if successful, non-0 otherwise. |
| 119 | * @note Will assert the given target is a proc target. |
| 120 | */ |
| 121 | int getCfam(pdbg_target* i_trgt, uint32_t i_addr, uint32_t& o_val); |
| 122 | |
| 123 | /** |
Zane Shelley | 171a2e0 | 2020-11-13 13:56:13 -0600 | [diff] [blame] | 124 | * @brief Returns the list of all active chips in the system. |
| 125 | * @param o_chips The returned list of chips. |
| 126 | */ |
| 127 | void getActiveChips(std::vector<libhei::Chip>& o_chips); |
| 128 | |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 129 | /** |
Zane Shelley | 3f363d4 | 2022-02-10 16:20:37 -0600 | [diff] [blame] | 130 | * @brief Returns the list of all active processor chips in the system. |
| 131 | * @param o_chips The returned list of chips. |
| 132 | */ |
| 133 | void getActiveProcessorChips(std::vector<pdbg_target*>& o_chips); |
| 134 | |
| 135 | /** |
Zane Shelley | c18ba8f | 2021-12-01 16:29:20 -0600 | [diff] [blame] | 136 | * @return The primary processor (i.e. the processor connected to the BMC). |
| 137 | */ |
| 138 | pdbg_target* getPrimaryProcessor(); |
| 139 | |
| 140 | /** |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 141 | * @return True, if hardware analysis is supported on this system. False, |
| 142 | * otherwise. |
| 143 | * @note Support for hardware analysis from the BMC started with P10 systems |
| 144 | * and is not supported on any older chip generations. |
| 145 | */ |
| 146 | bool queryHardwareAnalysisSupported(); |
| 147 | |
Zane Shelley | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 148 | /** |
| 149 | * @return A string containing the FRU location code of the given chip. An empty |
| 150 | * string indicates the target was null or the attribute does not exist |
| 151 | * for this target. |
| 152 | * @note This function requires PHAL APIs that are only available in certain |
| 153 | * environments. If they do not exist the devtree path of the target is |
| 154 | * returned. |
| 155 | */ |
| 156 | std::string getLocationCode(pdbg_target* trgt); |
| 157 | |
| 158 | /** |
| 159 | * @return A string containing the physical device path (entity path) of the |
| 160 | * given chip. An empty string indicates the target was null or the |
| 161 | * attribute does not exist for this target. |
| 162 | * @note This function requires PHAL APIs that are only available in certain |
| 163 | * environments. If they do not exist the devtree path of the target is |
| 164 | * returned. |
| 165 | */ |
| 166 | std::string getPhysDevPath(pdbg_target* trgt); |
| 167 | |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 168 | /** |
| 169 | * @return A vector of bytes representing the numerical values of the physical |
| 170 | * device path (entity path) of the given target. An empty vector |
| 171 | * indicates the target was null or the attribute does not exist for |
| 172 | * this target or any parent targets along the device tree path. |
| 173 | * @note This function requires PHAL APIs that are only available in certain |
| 174 | * environments. If they do not exist, an empty vector is returned. |
| 175 | */ |
| 176 | std::vector<uint8_t> getPhysBinPath(pdbg_target* trgt); |
| 177 | |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 178 | /** |
| 179 | * @brief Uses an SBE chip-op to query if there has been an LPC timeout. |
| 180 | * @return True, if there was an LPC timeout. False, otherwise. |
| 181 | */ |
| 182 | bool queryLpcTimeout(pdbg_target* target); |
| 183 | |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 184 | } // namespace pdbg |
| 185 | |
| 186 | } // namespace util |