summaryrefslogtreecommitdiffstats
path: root/src/include/usr/hwpf/hwp/hwpisteperror.H
blob: b0f47e26c9927be4a532c556c1c3597054ff056c (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
/* 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,2013              */
/*                                                                        */
/* 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, all hwp error plids are added
 *              to the top level error.
 */

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


namespace ISTEP_ERROR
{
    /**
     * @class IStepError
     *
     * Inteface to the a top level error log returned to the ISTEP dispatcher
     * when an individual step fails due to an error in a hardware procedure.
     *
     * The class may be used to aggregate the errors returned from procedures
     * which may have been run in parallel.  The top level error log will
     * indicate the failed step and the module in which the error was created.
     * Callers should note that only the addErrorDetails call should be used
     * within a thread.
     *
     * NOTE: This class returns an allocated error log object which needs to
     *       deleted by the reciever.
     *       users must call getErrorHandle() to recieve the pointer which can
     *       be deleted.
     *
     */
    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 expected usage for this object is to agrigate
             *          errors which may have been generated by hardware
             *          procedures which are run in parallel.
             *
             *          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 funciton 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