summaryrefslogtreecommitdiffstats
path: root/src/include/usr/fapi2/plat_utils.H
blob: 4295b119ef33f83900413e6ee4a313597c0641d4 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/fapi2/plat_utils.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                                                     */
///
/// @file plat_utils.H
///
/// @brief FAPI2 utility functions
///
/// Note that platform code must provide the implementation.
///

#ifndef PLAT_UTILS_H_
#define PLAT_UTILS_H_

#include <return_code.H>
#include <common_ringId.H>

namespace fapi2
{

// max ring size in centaur is 76490 bits - allocate a 10k byte
// buffer as the max size
#define MAX_CENTAUR_RING_SIZE 10 * 1024

///
///  @brief This function answers the question, is scand tracing turned on?
///  The implementation of this function is specific to the platform.
///
///  @returns Boolean indication
///
bool platIsScanTraceEnabled();

///
/// @brief Converts a fapi2::ReturnCode to a HostBoot PLAT error log
///
/// @param[io] io_rc Reference to ReturnCode (set to success after function)
/// @param[in] i_sev Error log severity defaulted to unrecoverable
///
/// @return errlHndl_t (NULL if Return Code contained success)
///
errlHndl_t rcToErrl(ReturnCode & io_rc,
                    ERRORLOG::errlSeverity_t i_sev =
                        ERRORLOG::ERRL_SEV_UNRECOVERABLE);


///
/// @brief Enable/Disable special wakeup on processor chip core(s)
///
/// Special Wakeup Enable must be done when a HWP is doing an operation that
/// requires core(s) to be awake (e.g. modifying the Hcode image). For
/// each Special Wakeup Enable call, there must be a subsequent Special Wakeup
/// Disable call.
///
/// @param[in] i_target
///              TARGET_TYPE_PROC_CHIP: Enables/Disables Special Wakeup on all
///                cores (EX,EQ chiplets) of the specified chip target.
///              TARGET_TYPE_CORE: Enables/Disables Special Wakeup on the
///                specified core target (EX,EQ chiplets)
///              TARGET_TYPE_EX: Enables/Disables Special Wakeup on the
///                specified EX target.
///              TARGET_TYPE_EQ: Enables/Disables Special Wakeup on the
///                specified EQ target.
///
/// @param[in] i_enable true = enable. false = disable.
///
/// @return ReturnCode. FAPI2_RC_SUCCESS on success, else platform specified error.
///
///
ReturnCode platSpecialWakeup( const Target<TARGET_TYPE_ALL>& i_target,
                              bool i_enable );

///
/// @brief return uncompressed ring data from the hardware image for a
///        given ring ID.
///
/// @param[in] i_target -
///              TARGET_TYPE_MEMB_CHIP: uses centaur hw image data
/// @param[in] i_ringId      - which ring to get data for
/// @param[in] o_ringData    - ring data
/// @param[in] o_ringAddress - scan address
///
/// @return ReturnCode. FAPI2_RC_SUCCESS on success, else platform
///                     specified error.
///
/// NODE: Currenlty only supported for centaur membuf targets
///
template<fapi2::TargetType T>
ReturnCode get_ring(fapi2::Target<T> i_target,
        const RingId_t i_ringId,
        unsigned char *&o_ringData,
        uint64_t &o_ringLength,
        uint64_t &o_ringAddress);

///
/// @brief Returns child targets to Callout/Deconfigure/GARD
///
/// @param[i] i_parentTarget FAPI2 Parent Target
/// @param[i] i_childType    FAPI2 Child Type
/// @param[i] i_childPort    Child Port Number
///                            For DIMMs: MBA Port Number
///                            Else unused
/// @param[i] i_childNum     Child Number
///                            For DIMMs: DIMM Socket Number
///                            For Chips: Chip Position
///                            For Chiplets: Chiplet Position
/// @param[o] o_childTargets List of child targets matching input
//                             criteria.
///
void getChildTargetsForCDG(
             const fapi2::Target<fapi2::TARGET_TYPE_ALL>& i_parentTarget,
             const fapi2::TargetType i_childType,
             const uint8_t i_childPort,
             const uint8_t i_childNum,
             TARGETING::TargetHandleList & o_childTargets);

} // End namespace fapi2


#endif // PLAT_UTILS_H_
OpenPOWER on IntegriCloud