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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: hwpf/fapi2/include/fapi2_hw_access.H $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* EKB Project */
/* */
/* COPYRIGHT 2012,2016 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* The source code for this program is not published or otherwise */
/* divested of its trade secrets, irrespective of what has been */
/* deposited with the U.S. Copyright Office. */
/* */
/* IBM_PROLOG_END_TAG */
///
/// @file fapi2_hw_access.H
/// @brief Common file that defines the hardware access functions that
/// platform code must implement.
///
#ifndef _FAPI2_COMMON_HWACCESS_H_
#define _FAPI2_COMMON_HWACCESS_H_
#ifdef FAPI_SUPPORT_SPY_AS_ENUM
#include <spy_ids.H>
typedef uint64_t spyId_t;
#endif
#include <stdint.h>
#include <buffer.H>
// variable_buffer isn't supported on PPE
#ifndef __PPE__
#include <variable_buffer.H>
#endif
#include <return_code.H>
#include <target.H>
#include <hw_access_def.H>
#include <plat_hw_access.H>
#include <p9_ringId.H>
namespace fapi2
{
//--------------------------------------------------------------------------
// PIB Error Functions
//--------------------------------------------------------------------------
/// @brief Sets the PIB error mask - platform dependant
/// @param[in] i_mask The new error mask
inline void setPIBErrorMask(uint8_t i_mask);
/// @brief Gets the PIB error mask - platform dependant
/// @return uint8_t The current PIB error mask
inline uint8_t getPIBErrorMask(void);
//--------------------------------------------------------------------------
// Operational Mode Error Functions
//--------------------------------------------------------------------------
/// @brief Sets the operational mode
/// @param[in] i_mode The new mode
inline void setOpMode(const OpModes i_mode);
/// @brief Gets the operational mode
/// @return the operational mode
inline OpModes getOpMode(void);
//--------------------------------------------------------------------------
// HW Communication Functions
//--------------------------------------------------------------------------
/// @brief Reads a SCOM register from a chip.
/// @tparam K template parameter, passed in target.
/// @param[in] i_target HW target to operate on.
/// @param[in] i_address SCOM register address to read from.
/// @param[out] o_data Buffer that holds data read from HW target.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode getScom(const Target<K>& i_target, const uint64_t i_address,
buffer<uint64_t>& o_data);
/// @brief Writes a SCOM register on a chip.
/// @tparam K template parameter, passed in target.
/// @param[in] i_target HW target to operate on.
/// @param[in] i_address SCOM register address to write to.
/// @param[in] i_data Buffer that holds data to write into address.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode putScom(const Target<K>& i_target, const uint64_t i_address,
const buffer<uint64_t> i_data);
/// @brief Writes a SCOM register under mask on a chip
/// @tparam K template parameter, passed in target.
/// @param[in] i_target HW target to operate on.
/// @param[in] i_address SCOM register address to write to.
/// @param[in] i_data Buffer that holds data to write into address.
/// @param[in] i_mask Buffer that holds the mask value.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode putScomUnderMask(const Target<K>& i_target,
const uint64_t i_address,
const buffer<uint64_t> i_data,
const buffer<uint64_t> i_mask);
/// @brief Reads a CFAM register from a chip.
/// CFAM register is 32-bit wide.
/// @tparam K template parameter, passed in target.
/// @param[in] i_target HW target to operate on.
/// @param[in] i_address CFAM register address to read from.
/// @param[out] o_data Buffer that holds data read from HW target.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode getCfamRegister(const Target<K>& i_target,
const uint32_t i_address,
buffer<uint32_t>& o_data);
/// @brief Writes a CFAM register on a chip.
/// CFAM register is 32-bit wide.
/// @tparam K template parameter, passed in target.
/// @param[in] i_target HW target to operate on.
/// @param[in] i_address CFAM register address to write to.
/// @param[in] i_data Buffer that holds data to write into address.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode putCfamRegister(const Target<K>& i_target,
const uint32_t i_address,
const buffer<uint32_t> i_data);
/// @brief Read-modify-write a CFAM register on a chip.
/// CFAM register is 32-bit wide.
/// @tparam K template parameter, passed in target.
/// @param[in] i_target HW target to operate on.
/// @param[in] i_address CFAM register address to modify.
/// @param[in] i_data Buffer that holds data to be modified.
/// @param[in] i_modifyMode The modify mode (or/and/xor).
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode modifyCfamRegister(const Target<K>& i_target,
const uint32_t i_address,
const buffer<uint32_t> i_data,
const ChipOpModifyMode i_modifyMode);
/// @brief Writes a ring to a chip.
/// @tparam K template parameter, passed in target.
/// @param[in] i_target Target to operate on.
/// @param[in] i_ringID Ring ID that will identify the Ring in the image.
/// @param[in] i_ringMode Ring operation mode.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode putRing(const Target<K>& i_target,
const RingID i_ringID,
const RingMode i_ringMode = RING_MODE_HEADER_CHECK);
// variable_buffer isn't supported on PPE
#ifndef __PPE__
/// @brief Reads a ring from a chip.
/// @tparam K template parameter, passed in target.
/// @param[in] i_target Target to operate on.
/// @param[in] i_address Ring address to read from.
/// @param[out] o_data Buffer that holds data read from HW target.
/// @param[in] i_ringMode Ring operation mode.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode getRing(const Target<K>& i_target,
const scanRingId_t i_address,
variable_buffer& o_data,
const RingMode i_ringMode = 0);
/// @brief Read-modify-write a ring on a chip.
/// @tparam K template parameter, passed in target.
/// @param[in] i_target Target to operate on.
/// @param[in] i_address Ring address to modify.
/// @param[in] i_data Buffer that contains RS4 compressed ring data
/// to be modified.
/// @param[in] i_modifyMode The modify mode (or/and/xor)
/// @param[in] i_ringMode Ring operation mode.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
template< TargetType K >
inline ReturnCode modifyRing(const Target<K>& i_target,
const scanRingId_t i_address,
const variable_buffer& i_data,
const ChipOpModifyMode i_modifyMode,
const RingMode i_ringMode = 0);
#endif
// --------------------------------------------------------------------------
// NOTE:
// Implement platform Spy access functions if platform supports them.
// --------------------------------------------------------------------------
// variable_buffer isn't supported on PPE
#ifndef __PPE__
/// @brief Reads a spy from a chip.
/// @tparam K template parameter, passed in target.
/// @param[in] TARGET Target to operate on.
/// @param[in] ID Id of the spy whose data to be read.
/// @param[out] DATA Buffer that holds data read from HW target.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
///
/// @note: The string version is only supported for cronus.
///
/// The fapi design to support both FSP and cronus use of get and
/// put spy functions is dependant on the SPY names being expanded
/// to resemble a valid C identifier. This design places some
/// restrictions on the SPY names which can be used.
///
/// 1. if the spy name contains a # procedure writers should replace
/// it with an __P__ for example -
///
/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
/// becomes
/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS
///
/// 2. if the spy name has a number following a "." it must have an
/// underscore prepended to the number.
///
/// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY
/// becomes
/// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY
///
/// Example SPY name:
/// The hardware procedure should call the function like:
///
/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
///
/// fapi2::ReturnCode rc = fapiGetSpy( targ,
/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data );
///
/// @note The ID is not in quotes the fapi code will handle adding
/// the quotes for the cronus environment
#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN)
#define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA)
template< TargetType K >
inline ReturnCode getSpy(const Target<K>& i_target,
const spyId_t i_spyId,
variable_buffer& o_data);
#endif
#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN)
#define FAPI_GET_SPY(TARGET, ID, DATA) fapi2::getSpy(TARGET, #ID, DATA)
template< TargetType K >
inline ReturnCode getSpy(const Target<K>& i_target,
const char* const i_spyId,
variable_buffer& o_data);
#endif
/// @brief Writes a spy on a chip.
/// @tparam K template parameter, passed in target.
/// @param[in] TARGET Target to operate on.
/// @param[in] ID Id of the spy to write data to.
/// @param[out] DATA Buffer that holds data to write into spy.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
///
/// @note: The string version is only supported for cronus.
///
/// The fapi design to support both FSP and cronus use of get and
/// put spy functions is dependent on the SPY names being expanded
/// to resemble a valid C identifier. This design places some
/// restrictions on the SPY names which can be used.
///
/// 1. if the spy name contains a # procedure writers should replace
/// is with an __P__ for example -
///
/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
/// becomes
/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS
///
/// 2. if the spy name has a number following a "." it must have an
/// underscore prepended to the number.
///
/// EH.TPCHIP.2KX100_ARY_CLK_EDGES_DLY
/// becomes
/// EH.TPCHIP._2KX100_ARY_CLK_EDGES_DLY
///
/// Example SPY name:
/// The hardware procedure should call the function like:
///
/// ABUS.RX0.RXPACKS#0.RXPACK.RD.LC.LC.ACT_DIS
///
/// fapi2::ReturnCode rc = fapiPutSpy( targ,
/// ABUS.RX0.RXPACKS__P__0.RXPACK.RD.LC.LC.ACT_DIS, data );
///
/// @note The ID is not in quotes the fapi code will handle adding
/// the quotes for the cronus environment
///
#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN)
#define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, FAPI_SPY_NAMES::ID.value, DATA)
template< TargetType K >
inline ReturnCode putSpy(const Target<K>& i_target,
const spyId_t i_spyId,
const variable_buffer& i_data);
#endif
#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN)
#define FAPI_PUT_SPY(TARGET, ID, DATA) fapi2::putSpy(TARGET, #ID, DATA)
template< TargetType K >
inline ReturnCode putSpy(const Target<K>& i_target,
const char* const i_spyId,
const variable_buffer& i_data);
template< TargetType K >
inline ReturnCode putSpy(const Target<K>& i_target,
const char* const i_spyId,
const char* i_enum);
#endif
/// @brief Writes spy data into a buffer holding ring data image
/// This API is used by L2/L3 repair to put column repair data
/// into a ring buffer image.
/// @tparam K template parameter, passed in target.
/// @param[in] TARGET Target to operate on.
/// @param[in] ID Id of the spy.
/// @param[in] DATA1 Buffer that holds spy data to write into ring
/// image.
/// @param[out] DATA2 Buffer that holds updated ring image.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
///
/// @note: The string version is only supported for cronus.
///
/// The fapi design to support both FSP and cronus use of get and
/// put spy functions is dependent on the SPY names being expanded
/// to resemble a valid C identifier. This design places some
/// restrictions on the SPY names which can be used.
///
/// See fapiPutSpy for details on spy id specifics.
///
#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN)
#define FAPI_PUT_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \
fapi2::putSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \
DATA1, DATA2)
template< TargetType K >
inline ReturnCode putSpyImage(const Target<K>& i_target,
const spyId_t i_spyId,
const variable_buffer& i_data,
variable_buffer& o_imageData);
#endif
#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN)
#define FAPI_PUT_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \
fapi2::putSpyImage(TARGET, #ID, DATA1,DATA2)
template< TargetType K >
inline ReturnCode putSpyImage(const Target<K>& i_target,
const char* const i_spyId,
const variable_buffer& i_data,
variable_buffer& o_imageData);
#endif
/// @brief Reads spy data from a ring image buffer
/// @param[in] TARGET Target to operate on
/// @param[in] ID The spy's id
/// @param[out] DATA1 Buffer that holds data read from ring image.
/// @param[in] DATA2 Buffer that holds ring image to read data
/// from.
/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code.
///
/// @note: The string version is only supported for cronus.
///
/// The fapi design to support both FSP and cronus use of get and
/// put spy functions is dependent on the SPY names being expanded
/// to resemble a valid C identifier. This design places some
/// restrictions on the SPY names which can be used.
///
/// See fapiPutSpy for details on spy id specifics.
///
#if defined(FAPI_SUPPORT_SPY_AS_ENUM) || defined(DOXYGEN)
#define FAPI_GET_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \
fapi2:getSpyImage(TARGET, FAPI_SPY_NAMES::ID.value, \
DATA1, DATA2)
template< TargetType K >
inline ReturnCode getSpyImage(const Target<K>& i_target,
const spyId_t i_spyId,
variable_buffer& o_data,
const variable_buffer& i_imageData);
#endif
#if defined(FAPI_SUPPORT_SPY_AS_STRING) || defined(DOXYGEN)
#define FAPI_GET_SPY_IMAGE(TARGET, ID, DATA1, DATA2) \
fapi2::getSpyImage(TARGET, #ID, DATA1,DATA2)
template< TargetType K >
inline ReturnCode getSpyImage(const Target<K>& i_target,
const char* const i_spyId,
variable_buffer& o_data,
const variable_buffer& i_imageData);
#endif
#endif // PPE
};
#endif // _FAPI2_HWACCESS_H_
|