blob: 7288ebc70ded6ead21073695ae7d12ffa756c557 [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{
Zane Shelley5d63cef2021-09-17 18:10:17 -050024 TYPE_PROC = 0x05,
25 TYPE_IOLINK = 0x47,
26 TYPE_OMI = 0x48,
27 TYPE_OCMB = 0x4b,
Zane Shelley35171d92020-12-03 13:31:13 -060028};
29
Zane Shelleya0299852020-11-13 13:38:04 -060030/** @return The target associated with the given chip. */
31pdbg_target* getTrgt(const libhei::Chip& i_chip);
32
Zane Shelley236bb732021-03-24 17:07:46 -050033/** @return The target associated with the given devtree path. */
34pdbg_target* getTrgt(const std::string& i_path);
35
Zane Shelleya0299852020-11-13 13:38:04 -060036/** @return A string representing the given target's devtree path. */
37const char* getPath(pdbg_target* i_trgt);
38
39/** @return A string representing the given chip's devtree path. */
Zane Shelleyf4bd5ff2020-11-05 22:26:04 -060040const char* getPath(const libhei::Chip& i_chip);
41
Zane Shelleya0299852020-11-13 13:38:04 -060042/** @return The absolute position of the given target. */
43uint32_t getChipPos(pdbg_target* i_trgt);
44
45/** @return The absolute position of the given chip. */
46uint32_t getChipPos(const libhei::Chip& i_chip);
47
48/** @return The target type of the given target. */
49uint8_t getTrgtType(pdbg_target* i_trgt);
50
51/** @return The target type of the given chip. */
52uint8_t getTrgtType(const libhei::Chip& i_chip);
53
Zane Shelley171a2e02020-11-13 13:56:13 -060054/**
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 */
59pdbg_target* getPibTrgt(pdbg_target* i_procTrgt);
60
61/**
Zane Shelleyff76b6b2020-11-18 13:54:26 -060062 * @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 */
66pdbg_target* getFsiTrgt(pdbg_target* i_procTrgt);
67
68/**
Zane Shelley35171d92020-12-03 13:31:13 -060069 * @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 */
76int getCfam(pdbg_target* i_trgt, uint32_t i_addr, uint32_t& o_val);
77
78/**
Zane Shelley171a2e02020-11-13 13:56:13 -060079 * @brief Returns the list of all active chips in the system.
80 * @param o_chips The returned list of chips.
81 */
82void getActiveChips(std::vector<libhei::Chip>& o_chips);
83
Zane Shelley7ae9c8c2020-12-02 20:10:31 -060084/**
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 */
90bool queryHardwareAnalysisSupported();
91
Zane Shelley3a851082021-03-23 16:45:28 -050092/**
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 */
100std::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 */
110std::string getPhysDevPath(pdbg_target* trgt);
111
Zane Shelleyf4bd5ff2020-11-05 22:26:04 -0600112} // namespace pdbg
113
114} // namespace util