summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/plat/fapiPlatHwpInvoker.C
blob: 7a31ca6103b5b2989aae85e50fc278a57f554cfc (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
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/hwpf/plat/fapiPlatHwpInvoker.C $
//
//  IBM CONFIDENTIAL
//
//  COPYRIGHT International Business Machines Corp. 2011
//
//  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
/**
 *  @file fapiPlatHwpInvoker.C
 *
 *  @brief Implements the fapiRcToErrl function.
 */

#include <fapiTarget.H>
#include <fapiReturnCode.H>
#include <fapiPlatTrace.H>
#include <fapiErrorInfo.H>
#include <fapiPlatReasonCodes.H>
#include <errl/errlentry.H>

namespace fapi
{

//******************************************************************************
// processEIFfdcs.
// Processes any FFDC in the ReturnCode Error Information
//******************************************************************************
void processEIFfdcs(const ErrorInfo & i_errInfo,
                    errlHndl_t io_pError)
{
    // Iterate through the FFDCs, adding each to the error log
    // TODO Should all of the FFDC sections be added as a single blob? There is
    // overhead to adding lots of different sections.
    uint32_t l_size;
    const void * l_pFfdc;

    for (ErrorInfo::ErrorInfoFfdcCItr_t l_itr = i_errInfo.iv_ffdcs.begin();
         l_itr != i_errInfo.iv_ffdcs.end(); ++l_itr)
    {
        l_pFfdc = (*l_itr)->getData(l_size);

        FAPI_ERR("processEIFfdcs: Adding %d bytes of FFDC to errlog",
                 l_size);

        // TODO Which comp id and section numbers should be used and how will
        // FFDC be parsed?
        io_pError->addFFDC(HWPF_COMP_ID, l_pFfdc, l_size);
    }
}

//******************************************************************************
// processEICallouts
// Processes any Callout requests in the ReturnCode Error Information
//******************************************************************************
void processEICallouts(const ErrorInfo & i_errInfo,
                          errlHndl_t io_pError)
{
    // Iterate through the callout requestss, adding each  to the error log
    for (ErrorInfo::ErrorInfoCalloutCItr_t l_itr =
             i_errInfo.iv_callouts.begin();
         l_itr != i_errInfo.iv_callouts.end(); ++l_itr)
    {
        // TODO Add callout to error log
        FAPI_ERR("processEICallouts: Adding target callout to errlog (TODO). Type: 0x%x. Pri: 0x%x",
                 (*l_itr)->iv_target.getType(), (*l_itr)->iv_priority);
    }
}

//******************************************************************************
// processEIDeconfigs
// Processes any Deconfig requests in the ReturnCode Error Information
//******************************************************************************
void processEIDeconfigs(const ErrorInfo & i_errInfo,
                           errlHndl_t io_pError)
{
    // Iterate through the deconfigure requests, deconfiguring each target
    for (ErrorInfo::ErrorInfoDeconfigCItr_t l_itr =
             i_errInfo.iv_deconfigs.begin();
         l_itr != i_errInfo.iv_deconfigs.end(); ++l_itr)
    {
        // TODO Deconfigure target
        FAPI_ERR("processEIDeconfigs: Deconfiguring target (TODO). Type: 0x%x",
                 (*l_itr)->iv_target.getType());
    }
}


//******************************************************************************
// processEiGards
// Processes any Gard requests in the ReturnCode Error Information
//******************************************************************************
void processEiGards(const ErrorInfo & i_errInfo,
                       errlHndl_t io_pError)
{
    // Iterate through gard requests, creating a GARD record for each target
    for (ErrorInfo::ErrorInfoGardCItr_t l_itr = i_errInfo.iv_gards.begin();
         l_itr != i_errInfo.iv_gards.end(); ++l_itr)
    {
        // TODO Create GARD record for target
        FAPI_ERR("processEIGards: Garding target (TODO). Type: 0x%x",
                 (*l_itr)->iv_target.getType());
    }
}

//******************************************************************************
// fapiRcToErrl function. Converts a fapi::ReturnCode to an error log
//******************************************************************************
errlHndl_t fapiRcToErrl(ReturnCode & io_rc)
{
    errlHndl_t l_pError = NULL;

    if (io_rc)
    {
        // ReturnCode contains an error. Find out which component of the HWPF
        // created the error
        ReturnCode::returnCodeCreator l_creator = io_rc.getCreator();

        if (l_creator == ReturnCode::CREATOR_PLAT)
        {
            // PLAT error. Release the errlHndl_t
            FAPI_ERR("fapiRcToErrl: PLAT error: 0x%x",
                     static_cast<uint32_t>(io_rc));
            l_pError = reinterpret_cast<errlHndl_t> (io_rc.releasePlatData());
        }
        else if (l_creator == ReturnCode::CREATOR_HWP)
        {
            // HWP Error. Create an error log
            FAPI_ERR("fapiRcToErrl: HWP error: 0x%x",
                     static_cast<uint32_t>(io_rc));

            // TODO What should the severity be? Should it be in the error info?

            // The errlog reason code is the HWPF compID and the rcValue LSB
            uint32_t l_rcValue = static_cast<uint32_t>(io_rc);
            uint16_t l_reasonCode = l_rcValue;
            l_reasonCode &= 0xff;
            l_reasonCode |= HWPF_COMP_ID;

            // HostBoot errlog tags for HWP errors are in generated file
            // fapiHwpReasonCodes.H
            l_pError = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                               MOD_HWP_RC_TO_ERRL,
                                               l_reasonCode);

            // Get the Error Information Pointer
            const ErrorInfo * l_pErrorInfo = io_rc.getErrorInfo();

            if (l_pErrorInfo)
            {
                // There is error information associated with the ReturnCode
                processEIFfdcs(*l_pErrorInfo, l_pError);
                processEICallouts(*l_pErrorInfo, l_pError);
                processEIDeconfigs(*l_pErrorInfo, l_pError);
                processEiGards(*l_pErrorInfo, l_pError);
            }
            else
            {
                FAPI_ERR("fapiRcToErrl: No Error Information");
            }
        }
        else
        {
            // FAPI error. Create an error log
            FAPI_ERR("fapiRcToErrl: FAPI error: 0x%x",
                     static_cast<uint32_t>(io_rc));

            // The errlog reason code is the HWPF compID and the rcValue LSB
            uint32_t l_rcValue = static_cast<uint32_t>(io_rc);
            uint16_t l_reasonCode = l_rcValue;
            l_reasonCode &= 0xff;
            l_reasonCode |= HWPF_COMP_ID;

            // HostBoot errlog tags for FAPI errors are in fapiPlatReasonCodes.H
            l_pError = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                               MOD_FAPI_RC_TO_ERRL,
                                               l_reasonCode);

            // FAPI may have added FFDC Error Information.
            // Get the Error Information Pointer
            const ErrorInfo * l_pErrorInfo = io_rc.getErrorInfo();

            if (l_pErrorInfo)
            {
                processEIFfdcs(*l_pErrorInfo, l_pError);
            }
        }

        // Set the ReturnCode to success, this will delete any ErrorInfo or PLAT
        // DATA associated with the ReturnCode
        io_rc = FAPI_RC_SUCCESS;
    }

    return l_pError;
}

} // End namespace
OpenPOWER on IntegriCloud