summaryrefslogtreecommitdiffstats
path: root/src/include/usr/hwpf/hwp/hwpisteperror.H
blob: d5734d4fcb620d3a5f6e46e411c87fd2065c8dcd (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/hwpf/hwp/hwpisteperror.H $                    */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* 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 otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __ISTEPERROR_H
#define __ISTEPERROR_H
/**
 *  @file isteperror.H
 *
 *  Defines the following classes:
 *
 *  IStepError: Handles creation of a top level error to incidate that a
 *              particular ISTEP has failed
 */

#include <errl/errlentry.H>
#include <hwpf/istepreasoncodes.H>


namespace ISTEP_ERROR
{
    /**
     * @class IStepError
     *
     * Contains a top-level IStep failed error log.
     *
     * Isteps can perform operations on multiple components regardless of errors
     * in order to initilize as much hardware as possible. Each IStep creates an
     * IstepError object and for each sub-error, the addErrorDetails() function
     * is called before the caller commits the sub-error. At the end of an
     * IStep, the getErrorHandle() function is called to return the top-level
     * istep error (if any) to the IStep Dispatcher.
     *
     * The top-level IStep error and all sub-errors have the same PLID (matching
     * the EID of the first sub-error) so that the IStep error is linked to all
     * errors that caused the IStep failure.
     */
    class IStepError
    {
        public:
            /**
             *  @brief
             */
            IStepError()
             : iv_eHandle(NULL), iv_errorCount(0)
             {
                 mutex_init( &iv_mutex );
             };

            /**
             *  @brief Destructor
             *
             *  Will free internal storage if getErrorHandle is not called
             */
            ~IStepError()
            {
                 mutex_destroy( &iv_mutex );

                 if( iv_eHandle )
                 {
                     delete iv_eHandle;
                 }
            };

            /**
             *  @brief  Adds selected error details from the passed in
             *          error to the top level istep error log object
             *
             *          The first call will initialize the internal object
             *          pointer allocating a new errl object as needed.
             *          The iStep and subStep is retrieved from the
             *          istepdispatcher and added to the log.
             *          Subsequent calls to this function will result in a new
             *          user data section being added to the top level error
             *          log with additional error data from the error handle
             *          passed in.
             *
             *          NOTE: This function is thread safe.
             *
             *  @param  i_err     - error handle passed in, the internal code
             *                      will parse specific details from the log
             *                      passed in to include in the top level elog.
             */
            void addErrorDetails( errlHndl_t i_err );

            /**
             *  @brief  Return an errlHndl_t which points to the internal error
             *          log object.
             *
             *  Note:   Caller must delete the errlHndl_t after use.
             *          This function is not thread safe
             *
             *  @return  iv_eHandle - error handle of top level ISTEP error to
             *           be returned to the ISTEP dispatcher.
             *
             */
            errlHndl_t getErrorHandle();

            /**
             *  @brief  Utility function to determine if the internal error
             *          handle is null.
             *
             *  @return  boolean
             *                  true indicates errl handle is currently NULL;
             *                  false indicates error object has been
             *                  allocated;
             *
             *  Note: This funciton is not thread safe
             *
             */
            bool isNull() const { return ((iv_eHandle==NULL ) ? true : false);};

        private:

            // disable copy constructor
            IStepError(const IStepError&);

            // serialize access to the internal data area
            mutex_t     iv_mutex;

            // pointer to the top level ISTEP error log, this log will be
            // passed back to the istep dispatcher when a hardware proceudre
            // fails.
            errlHndl_t  iv_eHandle;

            // count placed in user data 3 of the error log to indicate how
            // many errors were captured in this top level elog
            uint32_t    iv_errorCount;

    };

    inline errlHndl_t IStepError::getErrorHandle()
    {
        errlHndl_t l_err = iv_eHandle;

        // storage will be freed by destructor if the pointer is non-null
        iv_eHandle = NULL;

        return l_err;
    };


};

#endif
OpenPOWER on IntegriCloud