summaryrefslogtreecommitdiffstats
path: root/src/usr/hwas/testHWP.C
blob: 82bef62307140f4c710cf5842f4e02e6223d78e8 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwas/testHWP.C $                                      */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2011,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 otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/**
 *  @file testHWP.C
 *
 *  testHWP -this is the last substep of IStep4 (HWAS)
 *
 */


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

#include    <sys/task.h>

#include    <trace/interface.H>         //  trace support
#include    <errl/errlentry.H>          //  errlHndl_t
#include    <errl/errlmanager.H>
#include    <initservice/taskargs.H>       //  task args

//  pull in stuff to run HW procedure -
//  NOTE:  there are extra include paths in the makefile to find the fapi
//          includes:
//      EXTRAINCDIR += ${ROOTPATH}/src/include/usr/ecmddatabuffer
//      EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi
//      EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat
//      EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp
//

#include <fapiTarget.H>
#include <fapiPlatHwpInvoker.H>
#include <targeting/common/targetservice.H>
#include <vector>

using namespace fapi;

/******************************************************************************/
// Globals/Constants
/******************************************************************************/
namespace HWAS
{

extern HWAS_TD_t g_trac_imp_hwas;

void*    testHWP( void * io_pArgs )
{
    errlHndl_t l_err = NULL;
    std::vector<fapi::Target> l_target;

    // Get the master processor chip
    TARGETING::Target* l_pTarget = NULL;
    TARGETING::targetService().masterProcChipTargetHandle(l_pTarget);

    // Create the FAPI Targets and invoke the hwpInitialTest HWP
    fapi::Target l_fapiTarget(TARGET_TYPE_PROC_CHIP,
                              reinterpret_cast<void *> (l_pTarget));

    l_target.push_back(l_fapiTarget);

    // Get the target for the MBA chiplets of the first MEMBUF chip
    TARGETING::PredicateCTM l_membufChip(TARGETING::CLASS_CHIP,
                                         TARGETING::TYPE_MEMBUF);

    TARGETING::TargetRangeFilter l_filter(
        TARGETING::targetService().begin(),
        TARGETING::targetService().end(),
        &l_membufChip);

    PredicateCTM l_mba(CLASS_UNIT,TYPE_MBA);

    // Just look at the first MEMBUF chip
    if (l_filter)
    {
        TargetHandleList l_list;
        (void) targetService().getAssociated(
            l_list,
            *l_filter,
            TARGETING::TargetService::CHILD,
            TARGETING::TargetService::ALL,
            &l_mba);

        if (2 == l_list.size())
        {
            for (size_t i = 0; i < l_list.size(); i++)
            {
                //Set the associated targets
                fapi::Target l_fapiTargetAssoc(fapi::TARGET_TYPE_MBA_CHIPLET,
                    reinterpret_cast<void *>(l_list.at(i)));
                l_target.push_back(l_fapiTargetAssoc);
            }

            FAPI_INVOKE_HWP(l_err, hwpInitialTest, l_target);
        }
        else
        {
            HWAS_ERR("testHWP: Incorrect # of MBAs found: %u",
                l_list.size());

            size_t l_ffdc = l_list.size();
            size_t & FFDC_IF_TEST_NUM_MBAS_FOUND = l_ffdc;
            FAPI_SET_HWP_ERROR(l_rc,
                RC_HWP_EXEC_INITFILE_TEST_INCORRECT_NUM_MBAS_FOUND);
            l_err = fapiRcToErrl(l_rc);
        }
    }
    else
    {
        HWAS_ERR("testHWP: No MEMBUFs found");
        FAPI_SET_HWP_ERROR(l_rc, RC_HWP_EXEC_INITFILE_TEST_NO_MEMBUF_FOUND);
        l_err = fapiRcToErrl(l_rc);
    }

    if (l_err)
    {
        TRACFCOMP( g_trac_hwas, "testHWP failed. ");
    }

    return  l_err ;
}


} // namespace
OpenPOWER on IntegriCloud