summaryrefslogtreecommitdiffstats
path: root/src/include/usr/errl/errludlogregister.H
blob: 0ac769236706a9a67880e5cc229c2e03f7bf5eda (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/errl/errludlogregister.H $                    */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* 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 ERRL_UDLOGREGISTER_H
#define ERRL_UDLOGREGISTER_H

/**
 *  @file errludlogregister.H
 *
 *  Defines the ErrlUserDetailsLogRegister class that adds register FFDC to an
 *  error log as user detail data
 */

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

// Forward reference
namespace TARGETING
{
    class Target;
}

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(const 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(const 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(const 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
    const TARGETING::Target * iv_pTarget;
    uint32_t iv_dataSize;
};

}

#endif

OpenPOWER on IntegriCloud