summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfCenSymbol.C
blob: fe28589bad78f6e0a0e91c70daea768989a6260c (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfCenSymbol.C $       */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013                   */
/*                                                                        */
/* 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                                                     */

#include <prdfCenSymbol.H>

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

using namespace TARGETING;

namespace PRDF
{

using namespace PlatServices;

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

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

    int32_t o_rc = SUCCESS;

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

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

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

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

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

    } while (0);

    if ( SUCCESS != o_rc )
    {
        PRDF_ERR( PRDF_FUNC"Failed: i_mba=0x%08x i_rank=%d i_symbol=%d "
                  "i_pins=%d", getHuid(i_mba), i_rank.flatten(), i_symbol,
                  i_pins );
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

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

    int32_t o_rc = SUCCESS;

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

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

        uint8_t symbol;
        o_rc = getSymbol( i_rank, wiringType, i_dimmDq, i_portSlct, symbol );
        if ( SUCCESS != o_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 );

    } while (0);

    if ( SUCCESS != o_rc )
    {
        PRDF_ERR( PRDF_FUNC"Failed: i_mba=0x%08x i_rank=%d i_dimmDq=%d "
                  "i_portSlct=%d", getHuid(i_mba), i_rank.flatten(), i_dimmDq,
                  i_portSlct );
    }

    return o_rc;

    #undef PRDF_FUNC
}

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

int32_t CenSymbol::getWiringType( TARGETING::TargetHandle_t i_mba,
                                        const CenRank & i_rank,
                                        WiringType & o_type )
{
    int32_t o_rc = SUCCESS;

    // TODO: RTC 67376 Add support for wiring type.
    o_type = WIRING_INVALID;

    return o_rc;
}

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

uint8_t CenSymbol::cenDq2Symbol( uint8_t i_cenDq, uint8_t i_ps )
{
    uint8_t sym = SYMBOLS_PER_RANK;

    if ( DQS_PER_DIMM > i_cenDq && PORT_SLCT_PER_MBA > i_ps )
    {
        if ( i_cenDq >= 64 )
            sym = ( (3 - ((i_cenDq - 64) / 2)) + ((0 == i_ps) ? 4 : 0) );
        else
            sym = ( ((63 - i_cenDq) / 2) + ((0 == i_ps) ? 32 : 0) + 8 );
    }

    return sym;
}

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

uint8_t CenSymbol::symbol2CenDq( uint8_t i_symbol )
{
    uint8_t cenDq = DQS_PER_DIMM;

    if ( SYMBOLS_PER_RANK > i_symbol )
    {
        if ( 8 > i_symbol )
            cenDq = ( ((3 - (i_symbol % 4)) * 2) + 64 );
        else
            cenDq = ( (31 - (((i_symbol - 8) % 32))) * 2 );
    }

    return cenDq;
}

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

uint8_t CenSymbol::symbol2PortSlct( uint8_t i_symbol )
{
    uint8_t portSlct = PORT_SLCT_PER_MBA;

    if ( SYMBOLS_PER_RANK > i_symbol )
    {
        portSlct = ( ((i_symbol <= 3) || ((8 <= i_symbol) && (i_symbol <= 39)))
                     ? 1 : 0 );
    }

    return portSlct;
}

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

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::fromDq] "

    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=%d i_wiringType=%d i_dimmDq=%d "
                  "i_portSlct=%d", i_rank.flatten(), i_wiringType, i_dimmDq,
                  i_portSlct );
    }

    return o_rc;

    #undef PRDF_FUNC
}

} // end namespace PRDF
OpenPOWER on IntegriCloud