summaryrefslogtreecommitdiffstats
path: root/src/usr/hwas/common/hwasCallout.C
blob: 6d90c3b6d954623c704aaecf6e9a80134c9c4925 (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
/*  IBM_PROLOG_BEGIN_TAG
 *  This is an automatically generated prolog.
 *
 *  $Source: src/usr/hwas/common/hwasCallout.C $
 *
 *  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
 */
/**
 *  @file hwasCallout.C
 *
 *  HardWare Availability Service Callout functions.
 *
 */


/******************************************************************************/
// Includes
/******************************************************************************/
#include <stdint.h>

#include <hwas/common/hwasCallout.H>
#include <hwas/common/hwasCommon.H>
#include <hwas/common/hwas_reasoncodes.H>
#include <hwas/deconfigGard.H>
#include <targeting/common/attributes.H>
#include <errl/errlmanager.H>

namespace HWAS
{

class RegisterHWASFunctions
{
    public:
    RegisterHWASFunctions()
    {
        // HWAS is awake - register our processCallout function
        HWAS_DBG("module load: calling errlog::setHwasProcessCalloutFn");
        ERRORLOG::ErrlManager::setHwasProcessCalloutFn((processCalloutFn)(&processCallout));
    }
};
// this causes the function to get run at module load.
RegisterHWASFunctions registerHWASFunctions;

void processCallout(const uint32_t i_errlPlid,
        uint8_t *i_pData,
        uint64_t i_Size)
{
    HWAS_INF("processCallout entry. plid 0x%x data %p %lld",
            i_errlPlid, i_pData, i_Size);

    callout_ud_t *pCalloutUD = (callout_ud_t *)i_pData;
    errlHndl_t errl = NULL;
    switch (pCalloutUD->type)
    {
        case (HW_CALLOUT):
        {
            TARGETING::Target *pTarget;
            // data after the pCalloutUD structure is either a token
            //  indicating it's the MASTER_PROCESSOR_CHIP_TARGET_SENTINEL
            //  or it's the EntityPath - getAttr<TARGETING::ATTR_PHYS_PATH>()
            if (*((uint8_t *)(pCalloutUD + 1)) == TARGET_IS_SENTINEL)
            {
                pTarget = TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL;
                // TODO RTC: 45780
                HWAS_INF("TARGET_SENTINEL - can't handle; exiting");
                break; // HWAS can't handle this right now... 
            }
            else
            {
                // convert the EntityPath to a Target pointer
                TARGETING::EntityPath ep;
                memcpy(&ep, (pCalloutUD + 1), sizeof(ep));
                pTarget = TARGETING::targetService().toTarget(ep);
            }

            if (pTarget == NULL)
            {   // should only happen if we have a corrupt errlog or targeting.
                HWAS_ERR("HW callout; pTarget was NULL!!!");

                /*@
                 * @errortype
                 * @moduleid     MOD_PROCESS_CALLOUT
                 * @reasoncode   INVALID_TARGET
                 * @devdesc      Invalid Target encountered into processCallout
                 */
                errl = new ERRORLOG::ErrlEntry(
                    ERRORLOG::ERRL_SEV_INFORMATIONAL,
                    MOD_PROCESS_CALLOUT,
                    RC_INVALID_TARGET);
                errlCommit(errl, HWAS_COMP_ID);
                break;
            }

            HWAS_INF("HW callout; pTarget %p", pTarget);
            const DeconfigEnum deconfigState = pCalloutUD->deconfigState;
            const GARD_ErrorType gardErrorType = pCalloutUD->gardErrorType;
            //const callOutPriority priority = pCalloutUD->priority;
            switch (gardErrorType)
            {
                case (GARD_NULL):
                {   // means no GARD operations
                    break;
                }
                default:
                {
                    // call HWAS common function
                    errl = HWAS::theDeconfigGard().createGardRecord(*pTarget,
                            i_errlPlid,
                            GARD_Fatal);
                    break;
                }
            } // switch gardErrorType
            switch (deconfigState)
            {
                case (NO_DECONFIG):
                {
                    break;
                }
                case (DECONFIG):
                {
                    // call HWAS common function
                    errl = HWAS::theDeconfigGard().deconfigureTarget(*pTarget,
                                i_errlPlid);
                    break;
                }
                case (DELAYED_DECONFIG):
                {
                    // call HWAS common function
                    // TODO RTC: 45781
                    //errl = HWAS::theDeconfigGard().registerDelayedDeconfigure(*pTarget,
                                //i_errlPlid);
                    break;
                }
            } // switch deconfigState
            break;
        }
        case (PROCEDURE_CALLOUT):
        {
            HWAS_INF("Procedure callout; proc 0x%x priority 0x%x",
                pCalloutUD->type, pCalloutUD->type);
            //const HWAS::epubProcedureID procedure = pCalloutUD->procedure;
            //const callOutPriority priority = pCalloutUD->priority;

            // TODO RTC: 35108
            // call HWAS common function
            //errl = HWAS::processCallout(procedure, priority, i_errlPlid);
            break;
        }
        default:
        {
            HWAS_ERR("bad data in Callout UD %x", pCalloutUD->type);
            break;
        }
    } // switch

    HWAS_INF("processCallout exit errl %p", errl);
} // processCallout

}; // end namespace
OpenPOWER on IntegriCloud