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 | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 5 | #include <string> |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 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 | } |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 14 | |
| 15 | namespace util |
| 16 | { |
| 17 | |
| 18 | namespace pdbg |
| 19 | { |
| 20 | |
Zane Shelley | 35171d9 | 2020-12-03 13:31:13 -0600 | [diff] [blame] | 21 | /** Chip target types. */ |
| 22 | enum TargetType_t : uint8_t |
| 23 | { |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 24 | TYPE_PROC = 0x05, |
| 25 | TYPE_IOLINK = 0x47, |
| 26 | TYPE_OMI = 0x48, |
| 27 | TYPE_OCMB = 0x4b, |
Zane Shelley | be619c0 | 2021-09-30 17:56:42 -0500 | [diff] [blame] | 28 | TYPE_IOHS = 0x51, |
Zane Shelley | 35171d9 | 2020-12-03 13:31:13 -0600 | [diff] [blame] | 29 | }; |
| 30 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 31 | /** @return The target associated with the given chip. */ |
| 32 | pdbg_target* getTrgt(const libhei::Chip& i_chip); |
| 33 | |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 34 | /** @return The target associated with the given devtree path. */ |
| 35 | pdbg_target* getTrgt(const std::string& i_path); |
| 36 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 37 | /** @return A string representing the given target's devtree path. */ |
| 38 | const char* getPath(pdbg_target* i_trgt); |
| 39 | |
| 40 | /** @return A string representing the given chip's devtree path. */ |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 41 | const char* getPath(const libhei::Chip& i_chip); |
| 42 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 43 | /** @return The absolute position of the given target. */ |
| 44 | uint32_t getChipPos(pdbg_target* i_trgt); |
| 45 | |
| 46 | /** @return The absolute position of the given chip. */ |
| 47 | uint32_t getChipPos(const libhei::Chip& i_chip); |
| 48 | |
| 49 | /** @return The target type of the given target. */ |
| 50 | uint8_t getTrgtType(pdbg_target* i_trgt); |
| 51 | |
| 52 | /** @return The target type of the given chip. */ |
| 53 | uint8_t getTrgtType(const libhei::Chip& i_chip); |
| 54 | |
Zane Shelley | 171a2e0 | 2020-11-13 13:56:13 -0600 | [diff] [blame] | 55 | /** |
| 56 | * @return The pib target associated with the given proc target. |
| 57 | * @note Will assert the given target is a proc target. |
| 58 | * @note Will assert the returned pib target it not nullptr. |
| 59 | */ |
| 60 | pdbg_target* getPibTrgt(pdbg_target* i_procTrgt); |
| 61 | |
| 62 | /** |
Zane Shelley | ff76b6b | 2020-11-18 13:54:26 -0600 | [diff] [blame] | 63 | * @return The fsi target associated with the given proc target. |
| 64 | * @note Will assert the given target is a proc target. |
| 65 | * @note Will assert the returned fsi target it not nullptr. |
| 66 | */ |
| 67 | pdbg_target* getFsiTrgt(pdbg_target* i_procTrgt); |
| 68 | |
| 69 | /** |
Zane Shelley | c18ba8f | 2021-12-01 16:29:20 -0600 | [diff] [blame] | 70 | * @brief Reads a SCOM register. |
| 71 | * @param i_trgt Given target. |
| 72 | * @param i_addr Given address. |
| 73 | * @param o_val The returned value of the register. |
| 74 | * @return 0 if successful, non-0 otherwise. |
| 75 | * @note Will assert the given target is a proc target. |
| 76 | */ |
| 77 | int getScom(pdbg_target* i_trgt, uint64_t i_addr, uint64_t& o_val); |
| 78 | |
| 79 | /** |
Zane Shelley | 35171d9 | 2020-12-03 13:31:13 -0600 | [diff] [blame] | 80 | * @brief Reads a CFAM FSI 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 getCfam(pdbg_target* i_trgt, uint32_t i_addr, uint32_t& o_val); |
| 88 | |
| 89 | /** |
Zane Shelley | 171a2e0 | 2020-11-13 13:56:13 -0600 | [diff] [blame] | 90 | * @brief Returns the list of all active chips in the system. |
| 91 | * @param o_chips The returned list of chips. |
| 92 | */ |
| 93 | void getActiveChips(std::vector<libhei::Chip>& o_chips); |
| 94 | |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 95 | /** |
Zane Shelley | c18ba8f | 2021-12-01 16:29:20 -0600 | [diff] [blame] | 96 | * @return The primary processor (i.e. the processor connected to the BMC). |
| 97 | */ |
| 98 | pdbg_target* getPrimaryProcessor(); |
| 99 | |
| 100 | /** |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 101 | * @return True, if hardware analysis is supported on this system. False, |
| 102 | * otherwise. |
| 103 | * @note Support for hardware analysis from the BMC started with P10 systems |
| 104 | * and is not supported on any older chip generations. |
| 105 | */ |
| 106 | bool queryHardwareAnalysisSupported(); |
| 107 | |
Zane Shelley | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 108 | /** |
| 109 | * @return A string containing the FRU location code of the given chip. An empty |
| 110 | * string indicates the target was null or the attribute does not exist |
| 111 | * for this target. |
| 112 | * @note This function requires PHAL APIs that are only available in certain |
| 113 | * environments. If they do not exist the devtree path of the target is |
| 114 | * returned. |
| 115 | */ |
| 116 | std::string getLocationCode(pdbg_target* trgt); |
| 117 | |
| 118 | /** |
| 119 | * @return A string containing the physical device path (entity path) of the |
| 120 | * given chip. An empty string indicates the target was null or the |
| 121 | * attribute does not exist 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 getPhysDevPath(pdbg_target* trgt); |
| 127 | |
Zane Shelley | bf3326f | 2021-11-12 13:41:39 -0600 | [diff] [blame] | 128 | /** |
| 129 | * @return A vector of bytes representing the numerical values of the physical |
| 130 | * device path (entity path) of the given target. An empty vector |
| 131 | * indicates the target was null or the attribute does not exist for |
| 132 | * this target or any parent targets along the device tree path. |
| 133 | * @note This function requires PHAL APIs that are only available in certain |
| 134 | * environments. If they do not exist, an empty vector is returned. |
| 135 | */ |
| 136 | std::vector<uint8_t> getPhysBinPath(pdbg_target* trgt); |
| 137 | |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 138 | } // namespace pdbg |
| 139 | |
| 140 | } // namespace util |