summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfCenSymbol.C
blob: c75228e19321fde75a9664a415ac1cbc72378ff9 (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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfCenSymbol.C $       */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013,2014              */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

#include <prdfCenSymbol.H>

#include <prdfPlatServices.H>
#include <prdfTrace.H>
#include <prdfCenMemUtils.H>
#include <prdfParserUtils.H>

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;
using namespace CEN_SYMBOL;
using namespace PARSERUTILS;

static const uint8_t symbol2Galois[] =
{
    0x80, 0xa0, 0x90, 0xf0, 0x08, 0x0a, 0x09, 0x0f, // symbols  0- 7
    0x98, 0xda, 0xb9, 0x7f, 0x91, 0xd7, 0xb2, 0x78, // symbols  8-15
    0x28, 0xea, 0x49, 0x9f, 0x9a, 0xd4, 0xbd, 0x76, // symbols 16-23
    0x60, 0xb0, 0xc0, 0x20, 0x06, 0x0b, 0x0c, 0x02, // symbols 24-31
    0xc6, 0xfb, 0x1c, 0x42, 0xca, 0xf4, 0x1d, 0x46, // symbols 32-39
    0xd6, 0x8b, 0x3c, 0xc2, 0xcb, 0xf3, 0x1f, 0x4e, // symbols 40-47
    0xe0, 0x10, 0x50, 0xd0, 0x0e, 0x01, 0x05, 0x0d, // symbols 48-55
    0x5e, 0x21, 0xa5, 0x3d, 0x5b, 0x23, 0xaf, 0x3e, // symbols 56-63
    0xfe, 0x61, 0x75, 0x5d, 0x51, 0x27, 0xa2, 0x38, // symbols 64-71
};

//##############################################################################
//                           class CenSymbol
//##############################################################################

CenSymbol CenSymbol::fromSymbol( TargetHandle_t i_mba, const CenRank & i_rank,
                                 uint8_t i_symbol, uint8_t i_pins )
{
    #define PRDF_FUNC "[CenSymbol::fromSymbol] "

    CenSymbol o_symbol; // default contructor is invalid.

    do
    {
        if ( TYPE_MBA != getTargetType(i_mba) )
        {
            PRDF_ERR( PRDF_FUNC"i_mba is invalid: i_mba=0x%08x",
                      getHuid(i_mba) );
            break;
        }

        WiringType wiringType = WIRING_INVALID;
        int32_t l_rc = getWiringType( i_mba, i_rank, wiringType );
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC"getWiringType() failed" );
            break;
        }

        if ( BOTH_SYMBOL_DQS < i_pins )
        {
            PRDF_ERR( PRDF_FUNC"i_pins is invalid" );
            break;
        }

        o_symbol = CenSymbol ( i_mba, i_rank, wiringType, i_symbol, i_pins,
                               isDramWidthX4(i_mba) );

    } while (0);

    return o_symbol;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

CenSymbol CenSymbol::fromDimmDq( TargetHandle_t i_mba, const CenRank & i_rank,
                                 uint8_t i_dimmDq, uint8_t i_portSlct )
{
    #define PRDF_FUNC "[CenSymbol::fromDimmDq] "

    CenSymbol o_symbol; // default contructor is invalid.

    do
    {
        if ( TYPE_MBA != getTargetType(i_mba) )
        {
            PRDF_ERR( PRDF_FUNC"i_mba is invalid" );
            break;
        }

        WiringType wiringType = WIRING_INVALID;
        int32_t l_rc = getWiringType( i_mba, i_rank, wiringType );
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC"getWiringType() failed" );
            break;
        }

        uint8_t symbol;
        l_rc = getSymbol( i_rank, wiringType, i_dimmDq, i_portSlct, symbol );
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC"getSymbol() failed" );
            break;
        }

        uint8_t pins = (0 == (i_dimmDq & ODD_SYMBOL_DQ)) ? EVEN_SYMBOL_DQ :
                                                           ODD_SYMBOL_DQ;

        o_symbol = CenSymbol ( i_mba, i_rank, wiringType, symbol, pins,
                               isDramWidthX4(i_mba) );

    } while (0);

    return o_symbol;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

CenSymbol CenSymbol::fromGalois( TargetHandle_t i_mba, const CenRank & i_rank,
                                 uint8_t i_galois, uint8_t i_mask )
{
    #define PRDF_FUNC "[CenSymbol::fromGalois] "

    CenSymbol o_symbol; // default contructor is invalid.

    do
    {
        if ( TYPE_MBA != getTargetType(i_mba) )
        {
            PRDF_ERR( PRDF_FUNC"i_mba=0x%08x is invalid", getHuid(i_mba) );
            break;
        }

        WiringType wiringType = WIRING_INVALID;
        int32_t l_rc = getWiringType( i_mba, i_rank, wiringType );
        if ( SUCCESS != l_rc )
        {
            PRDF_ERR( PRDF_FUNC"getWiringType() failed" );
            break;
        }

        // Get symbol from Galois field.
        uint8_t symbol = SYMBOLS_PER_RANK;
        for ( uint32_t i = 0; i < SYMBOLS_PER_RANK; i++ )
        {
            if ( symbol2Galois[i] == i_galois )
            {
                symbol = i;
                break;
            }
        }

        // Get pins from mask.
        uint8_t pins = NO_SYMBOL_DQS;
        if ( 0 != (i_mask & 0xaa) ) pins |= EVEN_SYMBOL_DQ;
        if ( 0 != (i_mask & 0x55) ) pins |= ODD_SYMBOL_DQ;

        // Create symbol object.
        o_symbol = CenSymbol ( i_mba, i_rank, wiringType, symbol, pins,
                               isDramWidthX4(i_mba) );

    } while (0);

    return o_symbol;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenSymbol::getWiringType( TargetHandle_t i_mba, const CenRank & i_rank,
                                  WiringType & o_type )
{
    #define  PRDF_FUNC "CenSymbol::getWiringType "

    int32_t o_rc = SUCCESS;
    o_type = WIRING_INVALID;

    do
    {
        bool isCenDimm = false;
        o_rc = isMembufOnDimm( i_mba, isCenDimm );

        if( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC" isMembufOnDimm() Failed " );
            break;
        }

        if( isCenDimm )
        {
            //It is a centaur DIMM. Let us find out card type
            o_rc = MemUtils::getRawCardType( i_mba, o_type );

            if( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC"getRawCardType returned error" );
                o_type = WIRING_INVALID;
                break;
            }
        }
        //else it is a IS DIMM
    }while(0);

    return o_rc;

    #undef  PRDF_FUNC
}

//------------------------------------------------------------------------------

uint8_t CenSymbol::getDramPins() const
{
    uint32_t spd = iv_x4Dram ? SYMBOLS_PER_X4DRAM : SYMBOLS_PER_X8DRAM;

    return iv_pins << (((spd - 1) - (iv_symbol % spd)) * DQS_PER_SYMBOL);
}

//------------------------------------------------------------------------------

int32_t CenSymbol::getSymbol( const CenRank & i_rank, WiringType i_wiringType,
                              uint8_t i_dimmDq, uint8_t i_portSlct,
                              uint8_t & o_symbol )
{
    #define PRDF_FUNC "[CenSymbol::getSymbol] "

    int32_t o_rc = SUCCESS;

    do
    {
        if ( DQS_PER_DIMM <= i_dimmDq )
        {
            PRDF_ERR( PRDF_FUNC"i_dimmDq is invalid" );
            o_rc = FAIL; break;
        }

        if ( PORT_SLCT_PER_MBA <= i_portSlct )
        {
            PRDF_ERR( PRDF_FUNC"i_portSlct is invalid" );
            o_rc = FAIL; break;
        }

        // Get the Centaur DQ.
        uint8_t cenDq = i_dimmDq;

        // TODO: RTC 67376 Add wiring type support for IS DIMMs to convert from
        //       i_dimmDq to cenDq.

        o_symbol = cenDq2Symbol( cenDq, i_portSlct );

    } while(0);

    if ( SUCCESS != o_rc )
    {
        PRDF_ERR( PRDF_FUNC"Failed: i_rank=M%dS%d i_wiringType=%d i_dimmDq=%d "
                  "i_portSlct=%d", i_rank.getMaster(), i_rank.getSlave(),
                  i_wiringType, i_dimmDq, i_portSlct );
    }

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenSymbol::setPins( uint8_t i_pins )
{
    #define PRDF_FUNC "[CenSymbol::setPins] "
    int32_t o_rc = SUCCESS;

    do
    {
        if ( BOTH_SYMBOL_DQS < i_pins )
        {
            PRDF_ERR( PRDF_FUNC"i_pins %u is invalid", i_pins );
            o_rc = FAIL;
            break;
        }

        iv_pins = i_pins;

    } while (0);

    return o_rc;
    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

uint8_t CenSymbol::getEvenDq() const
{
    return symbol2CenDq( iv_symbol );
}

//------------------------------------------------------------------------------

uint8_t CenSymbol::getPortSlct() const
{
    return symbol2PortSlct( iv_symbol );
}

//------------------------------------------------------------------------------

uint8_t CenSymbol::getDramSymbol() const
{
    return dram2Symbol( symbol2Dram(iv_symbol, iv_x4Dram), iv_x4Dram);
}

uint8_t CenSymbol::getDram() const
{
    return symbol2Dram( iv_symbol, iv_x4Dram );
}

} // end namespace PRDF
OpenPOWER on IntegriCloud