blob: 5d6314d602ab6019e46ed1ae5a7956ae1db710e3 [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 Shelley7ae9c8c2020-12-02 20:10:31 -06005#include <vector>
6
7// Forward reference to avoid pulling the libhei library into everything that
8// includes this header.
9namespace libhei
10{
11class Chip;
12}
Zane Shelleyf4bd5ff2020-11-05 22:26:04 -060013
14namespace util
15{
16
17namespace pdbg
18{
19
Zane Shelley35171d92020-12-03 13:31:13 -060020/** Chip target types. */
21enum TargetType_t : uint8_t
22{
23 TYPE_PROC = 0x05,
24 TYPE_OCMB = 0x4b,
25};
26
Zane Shelleya0299852020-11-13 13:38:04 -060027/** @return The target associated with the given chip. */
28pdbg_target* getTrgt(const libhei::Chip& i_chip);
29
30/** @return A string representing the given target's devtree path. */
31const char* getPath(pdbg_target* i_trgt);
32
33/** @return A string representing the given chip's devtree path. */
Zane Shelleyf4bd5ff2020-11-05 22:26:04 -060034const char* getPath(const libhei::Chip& i_chip);
35
Zane Shelleya0299852020-11-13 13:38:04 -060036/** @return The absolute position of the given target. */
37uint32_t getChipPos(pdbg_target* i_trgt);
38
39/** @return The absolute position of the given chip. */
40uint32_t getChipPos(const libhei::Chip& i_chip);
41
42/** @return The target type of the given target. */
43uint8_t getTrgtType(pdbg_target* i_trgt);
44
45/** @return The target type of the given chip. */
46uint8_t getTrgtType(const libhei::Chip& i_chip);
47
Zane Shelley171a2e02020-11-13 13:56:13 -060048/**
49 * @return The pib target associated with the given proc target.
50 * @note Will assert the given target is a proc target.
51 * @note Will assert the returned pib target it not nullptr.
52 */
53pdbg_target* getPibTrgt(pdbg_target* i_procTrgt);
54
55/**
Zane Shelleyff76b6b2020-11-18 13:54:26 -060056 * @return The fsi target associated with the given proc target.
57 * @note Will assert the given target is a proc target.
58 * @note Will assert the returned fsi target it not nullptr.
59 */
60pdbg_target* getFsiTrgt(pdbg_target* i_procTrgt);
61
62/**
Zane Shelley35171d92020-12-03 13:31:13 -060063 * @brief Reads a CFAM FSI register.
64 * @param i_trgt Given target.
65 * @param i_addr Given address.
66 * @param o_val The returned value of the register.
67 * @return 0 if successful, non-0 otherwise.
68 * @note Will assert the given target is a proc target.
69 */
70int getCfam(pdbg_target* i_trgt, uint32_t i_addr, uint32_t& o_val);
71
72/**
Zane Shelley171a2e02020-11-13 13:56:13 -060073 * @brief Returns the list of all active chips in the system.
74 * @param o_chips The returned list of chips.
75 */
76void getActiveChips(std::vector<libhei::Chip>& o_chips);
77
Zane Shelley7ae9c8c2020-12-02 20:10:31 -060078/**
79 * @return True, if hardware analysis is supported on this system. False,
80 * otherwise.
81 * @note Support for hardware analysis from the BMC started with P10 systems
82 * and is not supported on any older chip generations.
83 */
84bool queryHardwareAnalysisSupported();
85
Zane Shelleyf4bd5ff2020-11-05 22:26:04 -060086} // namespace pdbg
87
88} // namespace util