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