summaryrefslogtreecommitdiffstats
path: root/src/usr/hwas/hwas.C
blob: acbb005040002a27953db7d0fb9650b9799e3efc (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
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/hwas/hwas.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 hwas.C
 *
 *  HardWare Availability Service functions.
 *  See hwas.H for doxygen documentation tags.
 *
 */


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

#include    <kernel/console.H>
#include    <trace/interface.H>
#include    <initservice/taskargs.H>
#include    <errl/errlentry.H>
#include    <targeting/targetservice.H>
#include    <fsi/fsiif.H>
#include    <hwas/hwas.H>
#include    <hwas/deconfigGard.H>

namespace   HWAS
{
trace_desc_t *g_trac_hwas = NULL;
TRAC_INIT(&g_trac_hwas, "HWAS", 2048 );

using   namespace   TARGETING;


void    init_target_states( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "init_target_states entry: set default HWAS state:" );

    //  loop through all the targets and set HWAS_STATE to a known default
    TARGETING::TargetIterator l_pTarget = TARGETING::targetService().begin();
    for(    ;
            l_pTarget != TARGETING::targetService().end();
            ++l_pTarget
            )
    {
        // HWAS_STATE attribute definition in the attribute_types.xml file
        //  gets translated into TARGETING::HwasState .
        //  fetch it from targeting - this is not strictly necessary (right now)
        //  but makes debug easier later.
        TARGETING::HwasState l_hwasState =
            l_pTarget->getAttr<ATTR_HWAS_STATE>();

        l_hwasState.poweredOn             =   false;
        l_hwasState.present               =   false;
        l_hwasState.functional            =   false;
        l_hwasState.changedSinceLastIPL   =   false;
        l_hwasState.gardLevel             =   0;

        //  Now write the modified value back to Targeting.
        l_pTarget->setAttr<ATTR_HWAS_STATE>( l_hwasState );
    }


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}


void    init_fsi( void *io_pArgs )
{
    errlHndl_t  l_errl      =   NULL;
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "init_fsi entry" );

    //@todo
    //@VBU workaround - Disable init_fsi
    //Temporarily disable the FSI initialization in VBU because of
    //an MFSI/CFSI XSCOM hardware bug.
    TARGETING::EntityPath syspath(TARGETING::EntityPath::PATH_PHYSICAL);
    syspath.addLast(TARGETING::TYPE_SYS,0);
    TARGETING::Target* sys = TARGETING::targetService().toTarget(syspath);
    uint8_t vpo_mode = 0;
    if( sys
            && sys->tryGetAttr<TARGETING::ATTR_VPO_MODE>(vpo_mode)
            && (vpo_mode == 1) )
    {
        //  wait here on the barrier, then end the task.
        pTaskArgs->waitChildSync();
        task_end();
        TRACFCOMP( g_trac_hwas, "HWBUG Workaround - No FSI initialization");
        return;
    }

    l_errl  =   FSI::initializeHardware( );
    if ( l_errl )
    {
        TRACFCOMP( g_trac_hwas, "ERROR: failed to init FSI hardware" );
        pTaskArgs->postErrorLog( l_errl );
    }

    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_fsi_info( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_fsi_info entry" );


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_dd_presence( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_dd_presence entry" );


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_pr_keyword_data( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_pr_keyword_data" );


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_partial_bad( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_partial_bad entry" );


    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}

void    apply_gard( void *io_pArgs )
{
    INITSERVICE::TaskArgs *pTaskArgs =
            static_cast<INITSERVICE::TaskArgs *>( io_pArgs );

    TRACDCOMP( g_trac_hwas, "apply_gard entry" );

    errlHndl_t l_errl = theDeconfigGard().clearGardRecordsForReplacedTargets();

    if (l_errl)
    {
        TRACFCOMP(g_trac_hwas, "ERROR: apply_gard failed to clear GARD Records for replaced Targets");
        pTaskArgs->postErrorLog(l_errl);
    }
    else
    {
        l_errl = theDeconfigGard().deconfigureTargetsFromGardRecordsForIpl();

        if (l_errl)
        {
            TRACFCOMP(g_trac_hwas, "ERROR: apply_gard failed to deconfigure Targets from GARD Records for IPL");
            pTaskArgs->postErrorLog(l_errl);
        }
        else
        {
            TRACFCOMP(g_trac_hwas, "apply_gard completed successfully");
        }
    }

    //  wait here on the barrier, then end the task.
    pTaskArgs->waitChildSync();
    task_end();
}


};   // end namespace

OpenPOWER on IntegriCloud