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 | 35171d9 | 2020-12-03 13:31:13 -0600 | [diff] [blame] | 28 | }; |
| 29 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 30 | /** @return The target associated with the given chip. */ |
| 31 | pdbg_target* getTrgt(const libhei::Chip& i_chip); |
| 32 | |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 33 | /** @return The target associated with the given devtree path. */ |
| 34 | pdbg_target* getTrgt(const std::string& i_path); |
| 35 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 36 | /** @return A string representing the given target's devtree path. */ |
| 37 | const char* getPath(pdbg_target* i_trgt); |
| 38 | |
| 39 | /** @return A string representing the given chip's devtree path. */ |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 40 | const char* getPath(const libhei::Chip& i_chip); |
| 41 | |
Zane Shelley | a029985 | 2020-11-13 13:38:04 -0600 | [diff] [blame] | 42 | /** @return The absolute position of the given target. */ |
| 43 | uint32_t getChipPos(pdbg_target* i_trgt); |
| 44 | |
| 45 | /** @return The absolute position of the given chip. */ |
| 46 | uint32_t getChipPos(const libhei::Chip& i_chip); |
| 47 | |
| 48 | /** @return The target type of the given target. */ |
| 49 | uint8_t getTrgtType(pdbg_target* i_trgt); |
| 50 | |
| 51 | /** @return The target type of the given chip. */ |
| 52 | uint8_t getTrgtType(const libhei::Chip& i_chip); |
| 53 | |
Zane Shelley | 171a2e0 | 2020-11-13 13:56:13 -0600 | [diff] [blame] | 54 | /** |
| 55 | * @return The pib target associated with the given proc target. |
| 56 | * @note Will assert the given target is a proc target. |
| 57 | * @note Will assert the returned pib target it not nullptr. |
| 58 | */ |
| 59 | pdbg_target* getPibTrgt(pdbg_target* i_procTrgt); |
| 60 | |
| 61 | /** |
Zane Shelley | ff76b6b | 2020-11-18 13:54:26 -0600 | [diff] [blame] | 62 | * @return The fsi target associated with the given proc target. |
| 63 | * @note Will assert the given target is a proc target. |
| 64 | * @note Will assert the returned fsi target it not nullptr. |
| 65 | */ |
| 66 | pdbg_target* getFsiTrgt(pdbg_target* i_procTrgt); |
| 67 | |
| 68 | /** |
Zane Shelley | 35171d9 | 2020-12-03 13:31:13 -0600 | [diff] [blame] | 69 | * @brief Reads a CFAM FSI register. |
| 70 | * @param i_trgt Given target. |
| 71 | * @param i_addr Given address. |
| 72 | * @param o_val The returned value of the register. |
| 73 | * @return 0 if successful, non-0 otherwise. |
| 74 | * @note Will assert the given target is a proc target. |
| 75 | */ |
| 76 | int getCfam(pdbg_target* i_trgt, uint32_t i_addr, uint32_t& o_val); |
| 77 | |
| 78 | /** |
Zane Shelley | 171a2e0 | 2020-11-13 13:56:13 -0600 | [diff] [blame] | 79 | * @brief Returns the list of all active chips in the system. |
| 80 | * @param o_chips The returned list of chips. |
| 81 | */ |
| 82 | void getActiveChips(std::vector<libhei::Chip>& o_chips); |
| 83 | |
Zane Shelley | 7ae9c8c | 2020-12-02 20:10:31 -0600 | [diff] [blame] | 84 | /** |
| 85 | * @return True, if hardware analysis is supported on this system. False, |
| 86 | * otherwise. |
| 87 | * @note Support for hardware analysis from the BMC started with P10 systems |
| 88 | * and is not supported on any older chip generations. |
| 89 | */ |
| 90 | bool queryHardwareAnalysisSupported(); |
| 91 | |
Zane Shelley | 3a85108 | 2021-03-23 16:45:28 -0500 | [diff] [blame] | 92 | /** |
| 93 | * @return A string containing the FRU location code of the given chip. An empty |
| 94 | * string indicates the target was null or the attribute does not exist |
| 95 | * for this target. |
| 96 | * @note This function requires PHAL APIs that are only available in certain |
| 97 | * environments. If they do not exist the devtree path of the target is |
| 98 | * returned. |
| 99 | */ |
| 100 | std::string getLocationCode(pdbg_target* trgt); |
| 101 | |
| 102 | /** |
| 103 | * @return A string containing the physical device path (entity path) of the |
| 104 | * given chip. An empty string indicates the target was null or the |
| 105 | * attribute does not exist for this target. |
| 106 | * @note This function requires PHAL APIs that are only available in certain |
| 107 | * environments. If they do not exist the devtree path of the target is |
| 108 | * returned. |
| 109 | */ |
| 110 | std::string getPhysDevPath(pdbg_target* trgt); |
| 111 | |
Zane Shelley | f4bd5ff | 2020-11-05 22:26:04 -0600 | [diff] [blame] | 112 | } // namespace pdbg |
| 113 | |
| 114 | } // namespace util |