1 #pragma once 2 3 #include <libpdbg.h> 4 5 #include <string> 6 #include <vector> 7 8 // Forward reference to avoid pulling the libhei library into everything that 9 // includes this header. 10 namespace libhei 11 { 12 class Chip; 13 } 14 15 namespace util 16 { 17 18 namespace pdbg 19 { 20 21 /** Chip target types. */ 22 enum TargetType_t : uint8_t 23 { 24 TYPE_PROC = 0x05, 25 TYPE_OCMB = 0x4b, 26 }; 27 28 /** @return The target associated with the given chip. */ 29 pdbg_target* getTrgt(const libhei::Chip& i_chip); 30 31 /** @return A string representing the given target's devtree path. */ 32 const char* getPath(pdbg_target* i_trgt); 33 34 /** @return A string representing the given chip's devtree path. */ 35 const char* getPath(const libhei::Chip& i_chip); 36 37 /** @return The absolute position of the given target. */ 38 uint32_t getChipPos(pdbg_target* i_trgt); 39 40 /** @return The absolute position of the given chip. */ 41 uint32_t getChipPos(const libhei::Chip& i_chip); 42 43 /** @return The target type of the given target. */ 44 uint8_t getTrgtType(pdbg_target* i_trgt); 45 46 /** @return The target type of the given chip. */ 47 uint8_t getTrgtType(const libhei::Chip& i_chip); 48 49 /** 50 * @return The pib target associated with the given proc target. 51 * @note Will assert the given target is a proc target. 52 * @note Will assert the returned pib target it not nullptr. 53 */ 54 pdbg_target* getPibTrgt(pdbg_target* i_procTrgt); 55 56 /** 57 * @return The fsi target associated with the given proc target. 58 * @note Will assert the given target is a proc target. 59 * @note Will assert the returned fsi target it not nullptr. 60 */ 61 pdbg_target* getFsiTrgt(pdbg_target* i_procTrgt); 62 63 /** 64 * @brief Reads a CFAM FSI register. 65 * @param i_trgt Given target. 66 * @param i_addr Given address. 67 * @param o_val The returned value of the register. 68 * @return 0 if successful, non-0 otherwise. 69 * @note Will assert the given target is a proc target. 70 */ 71 int getCfam(pdbg_target* i_trgt, uint32_t i_addr, uint32_t& o_val); 72 73 /** 74 * @brief Returns the list of all active chips in the system. 75 * @param o_chips The returned list of chips. 76 */ 77 void getActiveChips(std::vector<libhei::Chip>& o_chips); 78 79 /** 80 * @return True, if hardware analysis is supported on this system. False, 81 * otherwise. 82 * @note Support for hardware analysis from the BMC started with P10 systems 83 * and is not supported on any older chip generations. 84 */ 85 bool queryHardwareAnalysisSupported(); 86 87 /** 88 * @return A string containing the FRU location code of the given chip. An empty 89 * string indicates the target was null or the attribute does not exist 90 * for this target. 91 * @note This function requires PHAL APIs that are only available in certain 92 * environments. If they do not exist the devtree path of the target is 93 * returned. 94 */ 95 std::string getLocationCode(pdbg_target* trgt); 96 97 /** 98 * @return A string containing the physical device path (entity path) of the 99 * given chip. An empty string indicates the target was null or the 100 * attribute does not exist for this target. 101 * @note This function requires PHAL APIs that are only available in certain 102 * environments. If they do not exist the devtree path of the target is 103 * returned. 104 */ 105 std::string getPhysDevPath(pdbg_target* trgt); 106 107 } // namespace pdbg 108 109 } // namespace util 110