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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/htmgt/htmgt_utility.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2014,2016 */
/* [+] 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 HTMGT_UTILITY_H
#define HTMGT_UTILITY_H
#include <stdint.h>
#include <trace/interface.H>
#include <errl/errlmanager.H>
#include <console/consoleif.H>
#include "htmgt_occcmd.H"
#define TMGT_DBG( _fmt_, _args_...) \
TRACDCOMP( g_trac_htmgt, "D>" _fmt_, ##_args_ )
#define TMGT_INF( _fmt_, _args_...) \
TRACFCOMP( g_trac_htmgt, _fmt_, ##_args_ )
#define TMGT_WRN( _fmt_, _args_...) \
TRACFCOMP( g_trac_htmgt, "W>" _fmt_, ##_args_ )
#define TMGT_ERR( _fmt_, _args_...) \
TRACFCOMP( g_trac_htmgt, "E>" _fmt_, ##_args_ )
#define TMGT_DBG_BIN( _fmt_, _args_...) \
TRACDBIN( g_trac_htmgt, "D>" _fmt_, ##_args_ )
#define TMGT_BIN( _fmt_, _args_...) \
TRACFBIN( g_trac_htmgt, _fmt_, ##_args_ )
#if defined(CONFIG_CONSOLE) && !defined(__HOSTBOOT_RUNTIME)
#define TMGT_CONSOLE( _fmt_, _args_...) \
CONSOLE::displayf( HTMGT_COMP_NAME, _fmt_, ##_args_ )
#else
#define TMGT_CONSOLE(_fmt_, _args_...)
#endif
inline uint16_t UINT16_GET(const uint8_t * i_ptr)
{
return (*i_ptr) << 8 | *(i_ptr+1);
}
inline uint32_t UINT32_GET(const uint8_t * i_ptr)
{
return (UINT16_GET(i_ptr) << 16) | UINT16_GET(i_ptr + 2);
}
inline void UINT16_PUT(uint8_t * i_ptr, uint16_t i_value)
{
*i_ptr = (uint8_t) (i_value >> 8);
*(i_ptr + 1) = (uint8_t) (i_value);
}
inline void UINT32_PUT(uint8_t * i_ptr, uint32_t i_value)
{
*i_ptr = (uint8_t)(i_value >> 24);
*(i_ptr + 1) = (uint8_t)(i_value >> 16);
*(i_ptr + 2) = (uint8_t)(i_value >> 8);
*(i_ptr + 3) = (uint8_t)(i_value);
}
namespace HTMGT
{
// Trace definition
extern trace_desc_t* g_trac_htmgt;
// Debug flags
extern uint32_t G_debug_data;
enum debugTraceTypes
{
// Types are bit flags so can enable multiple at once
DEBUG_TRACE_OFF = 0x00,
DEBUG_TRACE_OCCCMD = 0x01, // OCC command tracing
DEBUG_TRACE_OCCCMD_FULL = 0x02, // full OCC command tracing
DEBUG_TRACE_FULL_NONVERBOSE = 0x7FFFFFFF,
DEBUG_TRACE_VERBOSE = 0x80000000, // verbose tracing
DEBUG_TRACE_FULL = 0xFFFFFFFF
};
extern uint32_t G_debug_trace;
enum internalFlagTypes
{
FLAG_HALT_ON_OCC_SRC = 0x00800000, // Prevent resets after SRC
FLAG_HALT_ON_RESET_FAIL = 0x00000100, // Stop additional resets
FLAG_EXT_RESET_DISABLED = 0x00000080, // Ignore opal-prd/BMC resets
FLAG_DISABLE_MEM_THROTTLE = 0x00000040,
FLAG_IGNORE_OCC_STATE = 0x00000020,
FLAG_HOLD_OCCS_IN_RESET = 0x00000010, // Ignore load/start status
FLAG_LOAD_REQUEST_DISABLED = 0x00000008,
FLAG_TERMINATE_ON_ERROR = 0x00000004,
FLAG_RESET_DISABLED = 0x00000002, // Ignore any OCC reset
FLAG_EXTERNAL_OVERRIDE = 0x00000001
};
enum tmgtElogSubsecTypes
{
// Values selected to be common with FSP from tmgt_elog_parser.H
//SUBSEC_MSG_DATA_TYPE = 0x01,
//SUBSEC_ERROR_DATA_TYPE = 0x06,
//SUBSEC_ENERGYSCALE_DATA_TYPE = 0x08,
//SUBSEC_OCC_ELOG_DATA_TYPE = 0x0A,
//SUBSEC_OCC_FFDC_DATA_TYPE = 0x0B,
SUBSEC_ADDITIONAL_SRC = 0x0C,
SUBSEC_OCC_CMD_DATA = 0x0D,
SUBSEC_OCC_RSP_DATA = 0x0E,
//SUBSEC_ELOG_TYPE_TOIF_RESET = 0x10,
//SUBSEC_ELOG_TYPE_OCC_RESET = 0x11,
//SUBSEC_ELOG_TYPE_PCAP_DATA = 0x12,
//SUBSEC_ELOG_TYPE_THERMAL_DATA = 0x13,
//SUBSEC_PROC_SCOM_REGISTERS = 0x14,
// 0xE0-0xEF are reserved for OCC Exceptions
};
enum htmgtPassThruCmds
{
PASSTHRU_OCC_STATUS = 0x01,
PASSTHRU_INTERNAL_FLAG = 0x02, // get or set internal flags
PASSTHRU_SEND_OCC_COMMAND = 0x03, // send raw OCC command
PASSTHRU_CLEAR_RESET_COUNTS = 0x04,
PASSTHRU_EXIT_SAFE_MODE = 0x05,
PASSTHRU_GENERATE_MFG_PSTATE = 0x81,
PASSTHRU_LOAD_PSTATE = 0x82,
PASSTHRU_DUMP_ATTRIBUTE = 0x83
};
enum htmgtAttrName
{
ATTR_PSTATE = 0x01,
ATTR_PSTATE_MFG = 0x02,
ATTR_RAW = 0xFF
};
/**
* @brief Create/Build an Error log and add HTMGT component trace
*
* @param[in,out] io_err Error handle to use or NULL to create new handle
* @param[in] i_modid Module ID
* @param[in] i_rc Return Code
* @param[in] i_data1 User data word 1
* @param[in] i_data2 User data word 2
* @param[in] i_data3 User data word 3
* @param[in] i_data4 User data word 4
* @param[in] i_sev Error severity
* @param[in] i_addFwCallout true if a FW Callout should be added
*/
void bldErrLog(errlHndl_t & io_err,
const uint8_t i_modid,
const uint16_t i_rc,
const uint32_t i_data1 = 0,
const uint32_t i_data2 = 0,
const uint32_t i_data3 = 0,
const uint32_t i_data4 = 0,
const ERRORLOG::errlSeverity_t i_sev =
ERRORLOG::ERRL_SEV_INFORMATIONAL,
const bool i_addFwCallout = false);
/**
* @brief Internal utility to convert OCC command type to a string
*
* @param[in] i_cmd OCC command type
*
* @return text string description of command
*/
const char *command_string(const uint8_t i_cmd);
/**
* Helper function to return the DIMM number as the OCC sees it.
* There can be 8 DIMMs per Centaur.
*
* @param i_mba - the MBA the DIMM is on
* @param i_dimm - the DIMM
* @return - a number 0-7
*/
uint8_t getOCCDIMMPos(const TARGETING::TargetHandle_t i_mba,
const TARGETING::TargetHandle_t i_dimm);
/**
* @brief Internal utility function to convert the OCC state to a string
*
* @param[in] i_state - OCC state
*
* @return text string description of state
*/
const char *state_string(const uint8_t i_state);
/**
* @brief Retrieve the internal flag (attribute) value
*
* @return the flag value (on error will return 0)
*/
uint32_t get_int_flags();
/**
* @brief Update internal flags to specified value
*
* @param[in] i_value - new value for internal flags
*/
void set_int_flags(const uint32_t i_value);
/**
* @brief Query if specified internal flag(s) are set
*
* @param[in] i_mask - bits to query the internalFlags
*
* @return true if all of the bits of i_mask are set in internalFlags
*/
bool int_flags_set(const uint32_t i_mask);
} // end namespace
#endif
|