summaryrefslogtreecommitdiffstats
path: root/src/include/usr/errl/errludlogregister.H
blob: b590fc3b0a7178f176e225fdbec1b30c2946ec4a (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
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
/*  IBM_PROLOG_BEGIN_TAG
 *  This is an automatically generated prolog.
 *
 *  $Source: src/include/usr/errl/errludlogregister.H $
 *
 *  IBM CONFIDENTIAL
 *
 *  COPYRIGHT International Business Machines Corp. 2012
 *
 *  p1
 *
 *  Object Code Only (OCO) source materials
 *  Licensed Internal Code Source Materials
 *  IBM HostBoot Licensed Internal Code
 *
 *  The source code for this program is not published or other-
 *  wise divested of its trade secrets, irrespective of what has
 *  been deposited with the U.S. Copyright Office.
 *
 *  Origin: 30
 *
 *  IBM_PROLOG_END_TAG
 */
#ifndef ERRL_UDLOGREGISTER_H
#define ERRL_UDLOGREGISTER_H

/**
 *  @file errludlogregister.H
 *
 *  Defines the following classes:
 *
 *  ErrlUserDetailsLogRegister: Adds register FFDC to an error log as
 *                                  user detail data
 *  ErrlUserDetailsParserLogRegister: Parses register FFDC user detail in
 *                                  an error log
*/

#include <errl/errluserdetails.H>
#include <stdarg.h>

#ifndef PARSER

// Forward reference
namespace TARGETING
{
    class Target;
}

#include <devicefw/userif.H>

namespace ERRORLOG
{

/**
 * @class ErrlUserDetailsLogRegister
 *
 * Adds LogRegister FFDC to an error log as user detail data
 */
class ErrlUserDetailsLogRegister : public ErrlUserDetails
{
public:
    /**
     *  @brief Constructor - target only
     *
     *  @param[in] i_pTarget - target of the register reads
     *
     *  Creates a LogRegister UserDetail, storing the HUID. User will
     *   next need to call addData() in order to get data into this object,
     *   and addToLog() in order to push the data to the error log.
     *
     */
    ErrlUserDetailsLogRegister(TARGETING::Target * i_pTarget);

    /**
     *  @brief Constructor - target and register type/address
     *
     *  @param[in] i_pTarget - target of the register reads
     *  @param[in] i_accessType - type of register access
     *  @param[in] ...      - these are generated by the devicefw/userif.H
     *                      macros (ie, DEVICE_SCOM_ADDRESS).
     *
     *  Creates a LogRegister UserDetail, storing the HUID, and perform
     *   the deviceOp() of the specified register type and address, storing
     *   that (type and address) as well as the result in this object.
     *
     *  Note that this can only be used for devicefw/userif.H register
     *   interface (DeviceFW::AccessType) types.
     *
     */
    ErrlUserDetailsLogRegister(TARGETING::Target * i_pTarget,
                                DeviceFW::AccessType i_accessType, ...);

    /**
     *  @brief Constructor - target, register type/address and data
     *
     *  @param[in] i_pTarget - target of the register reads
     *  @param[in] i_dataBuf - pointer to area with register data
     *  @param[in] i_dataSize - size of data pointed at by i_dataBuf
     *  @param[in] i_accessType - type of register access
     *  @param[in] ...      - these are generated by the devicefw/userif.H
     *                      macros (ie, DEVICE_SCOM_ADDRESS).
     *
     *  Creates a LogRegister UserDetail, storing the HUID, and stores
     *   the register type and address, as well as the passed-in result
     *   in this object. The deviceOp() operation is NOT performed UNLESS
     *   i_dataBuf is NULL.
     *
     *  Note that this can only be used for devicefw/userif.H register
     *   interface (DeviceFW::AccessType) types.
     */
    ErrlUserDetailsLogRegister(TARGETING::Target * i_pTarget,
                                void *i_dataBuf,
                                size_t i_dataSize,
                                DeviceFW::AccessType i_accessType, ...);

    /**
     *
     * @brief addData - do the register read and store the data
     *
     *  @param[in] i_accessType - type of register access
     *  @param[in] ...      - these are generated by the devicefw/userif.H
     *                      macros (ie, DEVICE_SCOM_ADDRESS).
     *
     *  Performs the deviceOp() of the specified register type and address,
     *   storing that (type and address) as well as the result in this object.
     *
     *  The template allows for userif.H AND deviceif.H register interfaces
     *   to be used. (ie, DeviceFW::AccessType_DriverOnly in addition to
     *   DeviceFW::AccessType).
     */
    template <typename ACCESS_TYPE>
    void addData(ACCESS_TYPE i_accessType, ...);

    /**
     *
     * @brief addDataBuffer - store the buffer of register data
     *
     *  @param[in] i_dataBuf - pointer to buffer with register data
     *  @param[in] i_dataSize - size of buffer pointed at by i_dataBuf
     *  @param[in] i_accessType - type of register access
     *  @param[in] ...      - these are generated by the devicefw/userif.H
     *                      macros (ie, DEVICE_SCOM_ADDRESS).
     *
     *  Stores the specified register type and address, as well as the
     *   passed-in result in this object. The deviceOp() operation is NOT
     *   performed UNLESS i_dataBuf is NULL.
     *
     *  The template allows for userif.H AND deviceif.H register interfaces
     *   to be used. (ie, DeviceFW::AccessType_DriverOnly in addition to
     *   DeviceFW::AccessType).
     */
    template <typename ACCESS_TYPE>
    void addDataBuffer(void *i_dataBuf, size_t i_dataSize,
            ACCESS_TYPE i_accessType, ...);

    /**
     *  @brief Destructor
     */
    virtual ~ErrlUserDetailsLogRegister() { };

private:
    // Disabled
    ErrlUserDetailsLogRegister(const ErrlUserDetailsLogRegister &);
    ErrlUserDetailsLogRegister & operator=(const ErrlUserDetailsLogRegister &);

    // internal functions:

    /**
     *
     * @brief setStateLogHUID - set state and log HUID.
     *
     * Worker function that will set the ErrlUserDetails instance variables
     *  and puts the HUID into the error log.
     */
    void setStateLogHUID();

    /**
     *
     * @brief writeRegisterData - write the register data to the log
     *
     *  @param[in] i_dataBuf - pointer to buffer with register data
     *  @param[in] i_dataSize - size of buffer pointed at by i_dataBuf
     *  @param[in] i_numAddressArgs - number of arguments in i_args va_list
     *  @param[in] i_accessType - type of register access
     *  @param[in] i_args - va_list of parameters of device access method
     *
     *  Worker function that will write the register data (access type and
     *   deviceOp() parameters, and contents of the register) to the error
     *   log.
     */
    void writeRegisterData(void *i_dataBuf, size_t i_dataSize,
            int32_t i_numAddressArgs,
            uint8_t i_accessType, va_list i_args);

    /**
     *
     * @brief readRegister - worker function to do and log the deviceOp()
     *
     *  @param[in] i_accessType - type of register access
     *  @param[in] i_args      - these are generated by the devicefw/userif.H
     *                      macros (ie, DEVICE_SCOM_ADDRESS).
     *
     *  Performs the deviceOp() of the specified register type and address,
     *   storing that (type and address) as well as the result in this object.
     *   This is called by the addData() and constructor that do not have
     *   passed-in register data.
     */
    void readRegister(uint8_t i_accessType, va_list i_args);

    /**
     *
     * @brief copyRegisterData - worker function to log the register data
     *
     *  @param[in] i_dataBuf - pointer to area with register data
     *  @param[in] i_dataSize - size of data pointed at by i_dataBuf
     *  @param[in] i_accessType - type of register access
     *  @param[in] i_args      - these are generated by the devicefw/userif.H
     *                      macros (ie, DEVICE_SCOM_ADDRESS).
     *
     *  Stores the specified register type and address, as well as the
     *   passed-in result in this object. The deviceOp() operation is NOT
     *   performed.
     *   This is called by the addDataBuffer() and constructor that have the
     *   passed-in register data.
     */
    void copyRegisterData(void *i_dataBuf, size_t i_dataSize,
            uint8_t i_accessType, va_list i_args);

    /**
     *
     * @brief __addData - do the register read and store the data
     *
     *  @param[in] i_accessType - type of register access
     *  @param[in] ...      - these are generated by the devicefw/userif.H
     *                      macros (ie, DEVICE_SCOM_ADDRESS).
     *
     *  Performs the deviceOp() of the specified register type and address,
     *   storing that (type and address) as well as the result in this object.
     *
     *  This is the actual function that does the work, where the AccessType
     *   and AccessType_DriverOnly enum is used as a generic uint8_t. The
     *   public addData() template functions are aliased to this function.
     */
    void __addData(uint8_t i_accessType, ...);

    /**
     *
     * @brief addDataBuffer - store the buffer of register data
     *
     *  @param[in] i_dataBuf - pointer to buffer with register data
     *  @param[in] i_dataSize - size of data pointed at by i_dataBuf
     *  @param[in] i_accessType - type of register access
     *  @param[in] ...      - these are generated by the devicefw/userif.H
     *                      macros (ie, DEVICE_SCOM_ADDRESS).
     *
     *  Stores the specified register type and address, as well as the
     *   passed-in result in this object. The deviceOp() operation is NOT
     *   performed.
     *
     *  This is the actual function that does the work, where the AccessType
     *   and AccessType_DriverOnly enum is used as a generic uint8_t. The
     *   public addDataBuffer() template functions are aliased to this function.
     */
    void __addDataBuffer(void *i_dataBuf, size_t i_dataSize,
            uint8_t i_accessType, ...);

    // allow for multiple calls to addData by user
    TARGETING::Target * iv_pTarget;
    uint32_t iv_dataSize;
};

}

#else // (if PARSER defined)

namespace ERRORLOG
{

/**
 * @class ErrlUserDetailsLogRegister
 *
 * Parses LogRegister user detail in an error log
*/
class ErrlUserDetailsParserLogRegister : public ErrlUserDetailsParser
{
public:
    /**
     *  @brief Constructor
     */
    ErrlUserDetailsParserLogRegister() {}

    /**
     *  @brief Destructor
     */
    virtual ~ErrlUserDetailsParserLogRegister() {}

    /**
     *  @brief Parses register user detail data from an error log
     *
     *  @param  i_version Version of the data
     *  @param  i_parse   ErrlUsrParser object for outputting information
     *  @param  i_pBuffer Pointer to buffer containing detail data
     *  @param  i_buflen  Length of the buffer
     */
    virtual void parse(errlver_t i_version,
                       ErrlUsrParser & i_parser,
                       void * i_pBuffer,
                       const uint32_t i_buflen) const
    {
        // TODO fix when parser if fix
        // RTC 41707
    }

private:
    // Disabled
    ErrlUserDetailsParserLogRegister(const ErrlUserDetailsParserLogRegister &);
    ErrlUserDetailsParserLogRegister & operator=(
        const ErrlUserDetailsParserLogRegister &);
};

}

#endif

#endif

OpenPOWER on IntegriCloud