1 #pragma once 2 3 #include <libpdbg.h> 4 5 #include <analyzer/callout.hpp> 6 7 #include <string> 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 } 16 17 namespace util 18 { 19 20 namespace pdbg 21 { 22 23 /** Chip target types. */ 24 enum TargetType_t : uint8_t 25 { 26 TYPE_DIMM = 0x03, 27 TYPE_PROC = 0x05, 28 TYPE_CORE = 0x07, 29 TYPE_NX = 0x1e, 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, 44 }; 45 46 /** @return The target associated with the given chip. */ 47 pdbg_target* getTrgt(const libhei::Chip& i_chip); 48 49 /** @return The target associated with the given devtree path. */ 50 pdbg_target* getTrgt(const std::string& i_path); 51 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. */ 56 const char* getPath(const libhei::Chip& i_chip); 57 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 64 /** @return The unit position of a target within a chip. */ 65 uint8_t getUnitPos(pdbg_target* i_trgt); 66 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 73 /** @return The parent chip target of the given unit target. */ 74 pdbg_target* getParentChip(pdbg_target* i_unitTarget); 75 76 /** @return The parent processor chip target of the given target. */ 77 pdbg_target* getParentProcessor(pdbg_target* i_target); 78 79 /** @return The unit target within chip of the given unit type and position 80 * relative to the chip. */ 81 pdbg_target* getChipUnit(pdbg_target* i_parentChip, TargetType_t i_unitType, 82 uint8_t i_unitPos); 83 84 /** 85 * @return The connected target on the other side of the given bus. 86 * @param i_rxTarget The target on the receiving side (RX) of the bus. 87 * @param i_busType The bus type. 88 */ 89 pdbg_target* getConnectedTarget(pdbg_target* i_rxTarget, 90 const analyzer::callout::BusType& i_busType); 91 92 /** 93 * @return The pib target associated with the given proc target. 94 * @note Will assert the given target is a proc target. 95 * @note Will assert the returned pib target it not nullptr. 96 */ 97 pdbg_target* getPibTrgt(pdbg_target* i_procTrgt); 98 99 /** 100 * @return The fsi target associated with the given proc target. 101 * @note Will assert the given target is a proc target. 102 * @note Will assert the returned fsi target it not nullptr. 103 */ 104 pdbg_target* getFsiTrgt(pdbg_target* i_procTrgt); 105 106 /** 107 * @brief Reads a SCOM register. 108 * @param i_trgt Given target. 109 * @param i_addr Given address. 110 * @param o_val The returned value of the register. 111 * @return 0 if successful, non-0 otherwise. 112 * @note Will assert the given target is a proc target. 113 */ 114 int getScom(pdbg_target* i_trgt, uint64_t i_addr, uint64_t& o_val); 115 116 /** 117 * @brief Reads a CFAM FSI register. 118 * @param i_trgt Given target. 119 * @param i_addr Given address. 120 * @param o_val The returned value of the register. 121 * @return 0 if successful, non-0 otherwise. 122 * @note Will assert the given target is a proc target. 123 */ 124 int getCfam(pdbg_target* i_trgt, uint32_t i_addr, uint32_t& o_val); 125 126 /** 127 * @brief Returns the list of all active chips in the system. 128 * @param o_chips The returned list of chips. 129 */ 130 void getActiveChips(std::vector<libhei::Chip>& o_chips); 131 132 /** 133 * @brief Returns the list of all active processor chips in the system. 134 * @param o_chips The returned list of chips. 135 */ 136 void getActiveProcessorChips(std::vector<pdbg_target*>& o_chips); 137 138 /** 139 * @return The primary processor (i.e. the processor connected to the BMC). 140 */ 141 pdbg_target* getPrimaryProcessor(); 142 143 /** 144 * @return True, if hardware analysis is supported on this system. False, 145 * otherwise. 146 * @note Support for hardware analysis from the BMC started with P10 systems 147 * and is not supported on any older chip generations. 148 */ 149 bool queryHardwareAnalysisSupported(); 150 151 /** 152 * @return A string containing the FRU location code of the given chip. An empty 153 * string indicates the target was null or the attribute does not exist 154 * for this target. 155 * @note This function requires PHAL APIs that are only available in certain 156 * environments. If they do not exist the devtree path of the target is 157 * returned. 158 */ 159 std::string getLocationCode(pdbg_target* trgt); 160 161 /** 162 * @return A string containing the physical device path (entity path) of the 163 * given chip. An empty string indicates the target was null or the 164 * attribute does not exist for this target. 165 * @note This function requires PHAL APIs that are only available in certain 166 * environments. If they do not exist the devtree path of the target is 167 * returned. 168 */ 169 std::string getPhysDevPath(pdbg_target* trgt); 170 171 /** 172 * @return A vector of bytes representing the numerical values of the physical 173 * device path (entity path) of the given target. An empty vector 174 * indicates the target was null or the attribute does not exist for 175 * this target or any parent targets along the device tree path. 176 * @note This function requires PHAL APIs that are only available in certain 177 * environments. If they do not exist, an empty vector is returned. 178 */ 179 std::vector<uint8_t> getPhysBinPath(pdbg_target* trgt); 180 181 /** 182 * @brief Uses an SBE chip-op to query if there has been an LPC timeout. 183 * @return True, if there was an LPC timeout. False, otherwise. 184 */ 185 bool queryLpcTimeout(pdbg_target* target); 186 187 } // namespace pdbg 188 189 } // namespace util 190