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_PROC = 0x05, 27 TYPE_IOLINK = 0x47, 28 TYPE_OMI = 0x48, 29 TYPE_OCMB = 0x4b, 30 TYPE_IOHS = 0x51, 31 }; 32 33 /** @return The target associated with the given chip. */ 34 pdbg_target* getTrgt(const libhei::Chip& i_chip); 35 36 /** @return The target associated with the given devtree path. */ 37 pdbg_target* getTrgt(const std::string& i_path); 38 39 /** @return A string representing the given target's devtree path. */ 40 const char* getPath(pdbg_target* i_trgt); 41 42 /** @return A string representing the given chip's devtree path. */ 43 const char* getPath(const libhei::Chip& i_chip); 44 45 /** @return The absolute position of the given target. */ 46 uint32_t getChipPos(pdbg_target* i_trgt); 47 48 /** @return The absolute position of the given chip. */ 49 uint32_t getChipPos(const libhei::Chip& i_chip); 50 51 /** @return The target type of the given target. */ 52 uint8_t getTrgtType(pdbg_target* i_trgt); 53 54 /** @return The target type of the given chip. */ 55 uint8_t getTrgtType(const libhei::Chip& i_chip); 56 57 /** 58 * @return The connected target on the other side of the given bus. 59 * @param i_rxTarget The target on the receiving side (RX) of the bus. 60 * @param i_busType The bus type. 61 */ 62 pdbg_target* getConnectedTarget(pdbg_target* i_rxTarget, 63 const analyzer::callout::BusType& i_busType); 64 65 /** 66 * @return The pib target associated with the given proc target. 67 * @note Will assert the given target is a proc target. 68 * @note Will assert the returned pib target it not nullptr. 69 */ 70 pdbg_target* getPibTrgt(pdbg_target* i_procTrgt); 71 72 /** 73 * @return The fsi target associated with the given proc target. 74 * @note Will assert the given target is a proc target. 75 * @note Will assert the returned fsi target it not nullptr. 76 */ 77 pdbg_target* getFsiTrgt(pdbg_target* i_procTrgt); 78 79 /** 80 * @brief Reads a SCOM register. 81 * @param i_trgt Given target. 82 * @param i_addr Given address. 83 * @param o_val The returned value of the register. 84 * @return 0 if successful, non-0 otherwise. 85 * @note Will assert the given target is a proc target. 86 */ 87 int getScom(pdbg_target* i_trgt, uint64_t i_addr, uint64_t& o_val); 88 89 /** 90 * @brief Reads a CFAM FSI register. 91 * @param i_trgt Given target. 92 * @param i_addr Given address. 93 * @param o_val The returned value of the register. 94 * @return 0 if successful, non-0 otherwise. 95 * @note Will assert the given target is a proc target. 96 */ 97 int getCfam(pdbg_target* i_trgt, uint32_t i_addr, uint32_t& o_val); 98 99 /** 100 * @brief Returns the list of all active chips in the system. 101 * @param o_chips The returned list of chips. 102 */ 103 void getActiveChips(std::vector<libhei::Chip>& o_chips); 104 105 /** 106 * @return The primary processor (i.e. the processor connected to the BMC). 107 */ 108 pdbg_target* getPrimaryProcessor(); 109 110 /** 111 * @return True, if hardware analysis is supported on this system. False, 112 * otherwise. 113 * @note Support for hardware analysis from the BMC started with P10 systems 114 * and is not supported on any older chip generations. 115 */ 116 bool queryHardwareAnalysisSupported(); 117 118 /** 119 * @return A string containing the FRU location code of the given chip. An empty 120 * string indicates the target was null or the attribute does not exist 121 * for this target. 122 * @note This function requires PHAL APIs that are only available in certain 123 * environments. If they do not exist the devtree path of the target is 124 * returned. 125 */ 126 std::string getLocationCode(pdbg_target* trgt); 127 128 /** 129 * @return A string containing the physical device path (entity path) of the 130 * given chip. An empty string indicates the target was null or the 131 * attribute does not exist for this target. 132 * @note This function requires PHAL APIs that are only available in certain 133 * environments. If they do not exist the devtree path of the target is 134 * returned. 135 */ 136 std::string getPhysDevPath(pdbg_target* trgt); 137 138 /** 139 * @return A vector of bytes representing the numerical values of the physical 140 * device path (entity path) of the given target. An empty vector 141 * indicates the target was null or the attribute does not exist for 142 * this target or any parent targets along the device tree path. 143 * @note This function requires PHAL APIs that are only available in certain 144 * environments. If they do not exist, an empty vector is returned. 145 */ 146 std::vector<uint8_t> getPhysBinPath(pdbg_target* trgt); 147 148 /** 149 * @brief Uses an SBE chip-op to query if there has been an LPC timeout. 150 * @return True, if there was an LPC timeout. False, otherwise. 151 */ 152 bool queryLpcTimeout(pdbg_target* target); 153 154 } // namespace pdbg 155 156 } // namespace util 157