summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/nest/nestHwpHelperFuncs.H
blob: fb35700b731b37a6b7df8388c359557e699724ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/nest/nestHwpHelperFuncs.H $                    */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2018                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

#ifndef _NEST_HWP_HELPER_FUNCS_H
#define _NEST_HWP_HELPER_FUNCS_H

/******************************************************************************/
// Includes
/******************************************************************************/
//  Integral and component ID support
#include <stdint.h>                // uint32_t
#include <hbotcompid.H>            // compId_t

//  Error handling support
#include <isteps/hwpisteperror.H>  // ISTEP_ERROR::IStepError

namespace ISTEP
{

/**
 *  @brief There seemed to be a lot of duplicated code (cut and paste) in
 *         different files.  I provide an interface to this duplicated code and
 *         consolidated it here, so if the protocol ever changes there is only
 *         one place to make changes.
 *
 *  @note  To take advantage of this consolidation, follow these guidelines
 *         1) Make sure that one of these methods will suffice for your needs
 *         2) Add an enum to HWP_CALL_TYPE that is specific to your needs (in
 *            this .H file).  This enum is the key to calling the correct HWP
 *            call you wish to perform (in this .H file).
 *         3) Add a string representation of the HWP call to
 *            hwpCallToStringMap (in .C file).
 *         4) Update method fapiHWPCallWrapper to accommodate and actually
 *            make the new HWP call (in .C file).
 *            NOTE: Don't forget to update include directives as well
 *         5) Finally call the method with the correct parameters in the file
 *            that you wish to make the HWP call
 */

/**
 *  @brief Enum specifying which HWP to call
 */
enum HWP_CALL_TYPE
{
    P9_CHIPLET_ENABLE_RIDI = 0, // Although it says chiplet, this uses proc chip
    P9_CHIPLET_FABRIC_SCOMINIT, // Although it says chiplet, this uses proc chip
    P9_CHIPLET_SCOMINIT,        // Although it says chiplet, this uses proc chip
    P9_FBC_EFF_CONFIG_LINKS_T_F, // process electrical(T), process optical(F)
    P9_FBC_EFF_CONFIG_LINKS_F_T, // process electrical(F), process optical(T)
    P9_IO_OBUS_SCOMINIT,
    P9_NPU_SCOMINIT,
    P9_PSI_SCOMINIT,
    P9_SYS_CHIPLET_SCOMINIT,  // Although it says chiplet, this uses proc chip
    P9_XBUS_ENABLE_RIDI,
};

/**
 *  @brief
 *      Handy utility to convert an enumeration to its equivalent string.
 *      This is a mapping of the HWP enumeration to its string representation
 *
 *  @param[in] i_hwpCall
 *      @see fapiHWPCallWrapper
 *
 *  @return
 *      Returned is the string equivalent of the enumeration supplied.  If the
 *      enumeration supplied is not valid, then an empty string is returned
 *
 *  @note
 *      Do not attempt to delete the returned string, it is immutable
 */
const char * hwpCallToString( HWP_CALL_TYPE i_hwpCall );

/**
 *  @brief
 *     This function is the function where the actual HWP calls are made.
 *     Currently this function iterates over chips and chiplets and calls
 *     the appropriate HWP call for that particular type.
 *
 *  @param[in] i_hwpCall
 *     An enumeration that specifies which HWP will be called
 *
 *  @param[out] o_stepError
 *  @param[in]  i_componentId
 *     @see hostboot/src/usr/isteps/istepHelperFuncs.H:captureError
 *
 *  @param[in]  i_targetType
 *     The targe type that determines to whether iterate over chips or chiplets
 *
 * @pre
 *     i_hwpCall is a valid HWP_CALL_TYPE. See enum HWP_CALL_TYPE above
 *     to determine which types are valid
 *
 * @post
 *     The HWP call, for the given i_hwpCall, is executed. If any error
 *     occurs, the details of the error will be contained in o_stepError.
 *
 *  @note
 *     If i_hwpCall is not a valid value the code will be halted via an assert.
 */
void fapiHWPCallWrapper(HWP_CALL_TYPE            i_hwpCall,
                        ISTEP_ERROR::IStepError &o_stepError,
                        compId_t                 i_componentId,
                        TARGETING::TYPE          i_targetType);

/**
 *  @brief
 *     This functions "handles" the call to fapiHWPCallWrapper.  If that call
 *     succeeds then true is returned else false is returned.  If
 *     fapiHWPCallWrapper fails this function will print an error message
 *     stating so.
 *
 *     This is mainly a pass-thru function call to method fapiHWPCallWrapper.
 *     It's main purpose is to return whether method fapiHWPCallWrapper
 *     succeded or failed and print an error message upon failure.
 *
 *  @param[in]  i_hwpCall
 *  @param[out] o_stepError
 *  @param[in]  i_componentId
 *  @param[in]  i_targetType
 *     @see fapiHWPCallWrapper
 *
 * @return true if call succeeds, false otherwise
 */
bool fapiHWPCallWrapperHandler(HWP_CALL_TYPE            i_hwpCall,
                               ISTEP_ERROR::IStepError &o_stepError,
                               compId_t                 i_componentId,
                               TARGETING::TYPE          i_targetType);

};  // end namespace ISTEP

#endif

OpenPOWER on IntegriCloud