blob: ffd597797601f194a4bf1cba9507737654bd80d6 [file] [log] [blame]
Chirag Sharmaa2576932020-12-05 23:17:41 -06001#pragma once
2
3#include <libipl.H>
4
Andrew Geissler5c3f9252021-06-10 10:53:05 -05005extern "C"
6{
7#include <libpdbg.h>
8}
9
Chirag Sharmaa2576932020-12-05 23:17:41 -060010namespace openpower
11{
12namespace phal
13{
14
15/**
16 * @brief This function will initialize required phal
17 * libraries.
18 * Throws an exception on error.
19 *
20 * @param[in] mode - IPL mode, default IPL_AUTOBOOT
21 *
22 */
23void phal_init(enum ipl_mode mode = IPL_AUTOBOOT);
24
Andrew Geissler5c3f9252021-06-10 10:53:05 -050025/**
26 * @brief Check if primary processor or not
27 *
Andrew Geissleraf48bed2021-06-24 10:01:35 -050028 * @param[in] procTarget - Processor target to check if primary or not
Andrew Geissler5c3f9252021-06-10 10:53:05 -050029 *
30 * @return True/False
31 */
32bool isPrimaryProc(struct pdbg_target* procTarget);
33
Andrew Geissler65c01012021-06-15 14:03:34 -050034/**
35 * @brief Read the input CFAM register
36 *
Andrew Geissleraf48bed2021-06-24 10:01:35 -050037 * @param[in] procTarget - Processor target to perform the operation on
Andrew Geissler65c01012021-06-15 14:03:34 -050038 * @param[in] reg - The register address to read
39 * @param[out] val - The value read from the register
40 *
41 * @return 0 on success, non-0 on failure
42 */
43uint32_t getCFAM(struct pdbg_target* procTarget, const uint32_t reg,
44 uint32_t& val);
45
Andrew Geissleraf48bed2021-06-24 10:01:35 -050046/**
47 * @brief Write the input CFAM register
48 *
49 * @param[in] procTarget - Processor target to perform the operation on
50 * @param[in] reg - The register address to write
51 * @param[out] val - The value to write to the register
52 *
53 * @return 0 on success, non-0 on failure
54 */
55uint32_t putCFAM(struct pdbg_target* procTarget, const uint32_t reg,
56 const uint32_t val);
57
58/**
59 * @brief Helper function to find FSI target needed for FSI operations
60 *
61 * @param[in] procTarget - Processor target to find the FSI target on
62 *
63 * @return Valid pointer to FSI target on success, nullptr on failure
64 */
65pdbg_target* getFsiTarget(struct pdbg_target* procTarget);
66
67/**
68 * @brief Helper function to probe the processor target
69 *
70 * The probe call only has to happen once per application start so ensure
71 * this function only probes once no matter how many times it's called.
72 *
73 * @param[in] procTarget - Processor target to probe
74 *
75 * @return 0 on success, non-0 on failure
76 */
77uint32_t probeTarget(struct pdbg_target* procTarget);
78
Jayanth Othayoth2de8c8d2021-07-16 06:40:33 -050079/**
80 * @brief Helper function to set PDBG_DTB
81 *
82 * PDBG_DTB environment variable set to CEC device tree path
83 */
84void setDevtreeEnv();
85
Chirag Sharmaa2576932020-12-05 23:17:41 -060086} // namespace phal
87} // namespace openpower