summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/fapiTestHwp.C
blob: 347c1829178ab7be1f8f03d16efd696b909f8176 (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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
//  IBM_PROLOG_BEGIN_TAG
//  This is an automatically generated prolog.
//
//  $Source: src/usr/hwpf/hwp/fapiTestHwp.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 fapiTestHwp.C
 *
 *  @brief Implements a simple test Hardware Procedure
 */

/*
 * Change Log ******************************************************************
 * Flag     Defect/Feature  User        Date        Description
 * ------   --------------  ----------  ----------- ----------------------------
 *                          mjjones     04/21/2011  Created.
 *                          mjjones     06/02/2011  Use ecmdDataBufferBase
 *                          mjjones     06/28/2011  Removed attribute tests
 *                          andrewg     07/07/2011  Added test for hw team to fill in
 *                          mjjones     08/10/2011  Removed clock HWP
 *                          mjjones     09/01/2011  Call toString in InitialTest
 *                          mjjones     09/14/2011  Update to scom function name
 *
 */

#include <fapiTestHwp.H>
#include <fapiHwAccess.H>
extern "C"
{

//******************************************************************************
// hwpInitialTest function - Override with whatever you want here
//******************************************************************************
fapi::ReturnCode hwpInitialTest(const fapi::Target & i_chip)
{
    FAPI_INF("Performing HWP: hwpInitialTest");

    // Print the ecmd string of the chip
    char l_string[fapi::MAX_ECMD_STRING_LEN] = {0};
    i_chip.toString(l_string);
    FAPI_INF("hwpInitialTest: Chip: %s", l_string);
    fapi::ReturnCode l_rc;
    uint32_t l_ecmdRc = ECMD_DBUF_SUCCESS;

    do
    {
        // Use this SCOM register for testing
        const uint64_t l_addr = 0x13010002;
        ecmdDataBufferBase l_ScomData(64);
        uint64_t l_originalScomData = 0;

        // --------------------------------------------------------
        // 1. fapiGetScom test
        // --------------------------------------------------------
        l_rc = fapiGetScom(i_chip, l_addr, l_ScomData);
        if (l_rc != fapi::FAPI_RC_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: Error from fapiGetScom");
            break;
        }
        else
        {
            // Save the original data so we can restore it later
            l_originalScomData = l_ScomData.getDoubleWord(0);
            FAPI_INF("hwpInitialTest: GetScom data 0x%.16llX", l_originalScomData);
        }

        // --------------------------------------------------------
        // 2. fapiPutScom test
        // --------------------------------------------------------
        uint64_t l_scomWriteValue = 0x9000000000000000;

        l_ecmdRc = l_ScomData.setDoubleWord(0, l_scomWriteValue);
        if (l_ecmdRc != ECMD_DBUF_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: fapiPutScom test, error from ecmdDataBuffer setDoubleWord() - rc 0x%.8X", l_ecmdRc);
            l_rc = fapi::FAPI_RC_ECMD_MASK;
            break;
        }

        l_rc = fapiPutScom(i_chip, l_addr, l_ScomData);
        if (l_rc != fapi::FAPI_RC_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: Error from fapiPutScom");
            break;
        }
        else
        {
            FAPI_INF("hwpInitialTest: PutScom data 0x%.16llX", l_scomWriteValue);
        }

        // --------------------------------------------------------
        // 3. fapiPutScomUnderMask test
        // --------------------------------------------------------
        l_scomWriteValue = 0xA000000000000000;
        uint64_t l_mask  = 0x3000000000000000;
        ecmdDataBufferBase l_maskData(64);

        l_ecmdRc = l_ScomData.setDoubleWord(0, l_scomWriteValue);
        l_ecmdRc |= l_maskData.setDoubleWord(0, l_mask);
        if (l_ecmdRc != ECMD_DBUF_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: fapiPutScomUnderMask test, error from ecmdDataBuffer setDoubleWord() - rc 0x%.8X", l_ecmdRc);
            l_rc = fapi::FAPI_RC_ECMD_MASK;
            break;
        }


        l_rc = fapiPutScomUnderMask(i_chip, l_addr, l_ScomData, l_maskData);
        if (l_rc != fapi::FAPI_RC_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: Error from fapiPutScomUnderMask");
            break;
        }
        else
        {
            FAPI_INF("hwpInitialTest: fapiPutScomUnderMask data 0x%.16llX, mask 0x%.16llX",
                     l_scomWriteValue, l_mask);
        }

        // --------------------------------------------------------
        // 4. fapiPutScom to restore original value
        // --------------------------------------------------------
        l_ecmdRc = l_ScomData.setDoubleWord(0, l_originalScomData);
        if (l_ecmdRc != ECMD_DBUF_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: fapiPutScom to restore, error from ecmdDataBuffer setDoubleWord() - rc 0x%.8X", l_ecmdRc);
            l_rc = fapi::FAPI_RC_ECMD_MASK;
            break;
        }

        l_rc = fapiPutScom(i_chip, l_addr, l_ScomData);
        if (l_rc != fapi::FAPI_RC_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: Error from fapiPutScom");
            break;
        }
        else
        {
            FAPI_INF("hwpInitialTest: PutScom data 0x%.16llX", l_originalScomData);
        }

#if 0
// @todo
// Per Dean, there's no access to the CFAM engines on the master processor, therefore,
// we *should not* allow access to them on any processor in any position
// from a FAPI standpoint.
// This means that get/put/modifyCfamRegister can't not be called on any of the processors.
// These functions, therefore, can only be called on the Centaur, which is not available
// at this time.
// When Centaur is supported:
//  - Don't use i_chip (a processor) as a target. Set the target as one of the Centaurs.
//  - Enable this block of code and test the cfam access functions on the Centaur.

        // --------------------------------------------------------
        // 5. fapiGetCfamRegister test
        // --------------------------------------------------------
        ecmdDataBufferBase l_cfamData(32); // 32-bit cfam data holder
        uint32_t l_originalCfamData = 0;
        const uint32_t l_cfamAddr = 0x100A; // ChipID register
        l_rc = fapiGetCfamRegister(i_chip, l_cfamAddr, l_cfamData);
        if (l_rc != fapi::FAPI_RC_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: Error from fapiGetCfamRegister");
            break;
        }
        else
        {
            l_originalCfamData = l_cfamData.getWord(0);
            FAPI_INF("hwpInitialTest: fapiGetCfamRegister data 0x%.8X",
                    l_originalCfamData);
        }

        // --------------------------------------------------------
        // 6. fapiPutCfamRegister test
        // --------------------------------------------------------
        uint32_t l_cfamWriteValue = 0x90000000;
        l_ecmdRc = l_cfamData.setWord(0, l_cfamWriteValue);
        if (l_ecmdRc != ECMD_DBUF_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: fapiPutCfamRegister test, error from ecmdDataBuffer setWord() - rc 0x%.8X", l_ecmdRc);
            l_rc = fapi::FAPI_RC_ECMD_MASK;
            break;
        }


        l_rc = fapiPutCfamRegister(i_chip, l_cfamAddr, l_cfamData);
        if (l_rc != fapi::FAPI_RC_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: Error from fapiPutCfamRegister");
            break;
        }
        else
        {
            FAPI_INF("hwpInitialTest: fapiPutCfamRegister data 0x%.8X",
                    l_cfamData.getWord(0));
        }

        // --------------------------------------------------------
        // 7. fapiModifyCfamRegister test
        // --------------------------------------------------------
        l_cfamWriteValue = 0xA0000000;
        l_ecmdRc = l_cfamData.setWord(0, l_cfamWriteValue);
        if (l_ecmdRc != ECMD_DBUF_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: fapiModifyCfamRegister test, error from ecmdDataBuffer setWord() - rc 0x%.8X", l_ecmdRc);
            l_rc = fapi::FAPI_RC_ECMD_MASK;
            break;
        }

        l_rc = fapiModifyCfamRegister(i_chip, l_cfamAddr,
                l_cfamData, fapi::CHIP_OP_MODIFY_MODE_AND);
        if (l_rc != fapi::FAPI_RC_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: Error from fapiPutCfamRegister");
            break;
        }
        else
        {
            FAPI_INF("hwpInitialTest: fapiPutCfamRegister data 0x%.8X",
                    l_cfamData.getWord(0));
        }

        // --------------------------------------------------------
        // 8. fapiPutCfamRegister to restore original CFAM value
        // --------------------------------------------------------
        l_ecmdRc = l_cfamData.setWord(0, l_originalCfamData);
        if (l_ecmdRc != ECMD_DBUF_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: fapiPutCfamRegister to restore, error from ecmdDataBuffer setWord() - rc 0x%.8X", l_ecmdRc);
            l_rc = fapi::FAPI_RC_ECMD_MASK;
            break;
        }

        l_rc = fapiPutCfamRegister(i_chip, l_cfamAddr, l_cfamData);
        if (l_rc != fapi::FAPI_RC_SUCCESS)
        {
            FAPI_ERR("hwpInitialTest: Error from fapiPutCfamRegister to restore");
            break;
        }
        else
        {
            FAPI_INF("hwpInitialTest: fapiPutCfamRegister data 0x%.8X",
                    l_cfamData.getWord(0));
        }

#endif

    } while (0);

    return l_rc;
}

} // extern "C"
OpenPOWER on IntegriCloud