summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plugins/prdfParserUtils.C
blob: 2f9bdb458a41008d59a4d1101094d760d35f7755 (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
342
343
344
345
346
347
348
349
350
351
352
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plugins/prdfParserUtils.C $          */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,2019                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* 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 <prdfParserUtils.H>
#include <prdfParserEnums.H>

namespace PRDF
{

#if defined(PRDF_HOSTBOOT_ERRL_PLUGIN)
namespace HOSTBOOT
{
#elif defined(PRDF_FSP_ERRL_PLUGIN)
namespace FSP
{
#endif

namespace PARSERUTILS
{

template<>
uint8_t symbol2Dq<TARGETING::TYPE_MBA>( uint8_t i_symbol )
{
    uint8_t dq = DQS_PER_DIMM;

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

    return dq;
}

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

template<>
uint8_t symbol2Dq<TARGETING::TYPE_MCA>( uint8_t i_symbol )
{
    uint8_t dq = DQS_PER_DIMM;

    static const uint8_t symbol2dq[] =
    {
        71, 70, 69, 68, 67, 66, 65, 64, // symbols  0- 7
        63, 62, 61, 60, 55, 54, 53, 52, // symbols  8-15
        47, 46, 45, 44, 39, 38, 37, 36, // symbols 16-23
        31, 30, 29, 28, 23, 22, 21, 20, // symbols 24-31
        15, 14, 13, 12,  7,  6,  5,  4, // symbols 32-39
        59, 58, 57, 56, 51, 50, 49, 48, // symbols 40-47
        43, 42, 41, 40, 35, 34, 33, 32, // symbols 48-55
        27, 26, 25, 24, 19, 18, 17, 16, // symbols 56-63
        11, 10,  9,  8,  3,  2,  1,  0, // symbols 64-71
    };

    if ( SYMBOLS_PER_RANK > i_symbol )
    {
        dq = symbol2dq[i_symbol];
    }

    return dq;
}

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

template<>
uint8_t symbol2Dq<TARGETING::TYPE_OCMB_CHIP>( uint8_t i_symbol )
{
    // OCMB_CHIP case is identical to MCA
    return symbol2Dq<TARGETING::TYPE_MCA>(i_symbol);
}

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

template<>
uint8_t symbol2PortSlct<TARGETING::TYPE_MBA>( uint8_t i_symbol )
{
    uint8_t portSlct = MAX_PORT_PER_MBA;

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

    return portSlct;
}

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

template<>
uint8_t symbol2PortSlct<TARGETING::TYPE_MCA>( uint8_t i_symbol )
{
    // Port select does not exist on MCA. Always return 0 so that code will
    // continue to work.
    return 0;
}

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

template<>
uint8_t symbol2PortSlct<TARGETING::TYPE_OCMB_CHIP>( uint8_t i_symbol )
{
    // TODO RTC 210072 - Explorer only has one port, as such we can just
    // return 0. However, multiple ports will be supported in the future,
    // We'll need to figure out how to convert the symbol to a port select for
    // OCMB at that time.
    return 0;
}

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

template<>
uint8_t dq2Symbol<TARGETING::TYPE_MBA>( uint8_t i_dq, uint8_t i_ps )
{
    uint8_t sym = SYMBOLS_PER_RANK;

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

    return sym;
}

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

template<TARGETING::TYPE T>
uint8_t dq2Symbol( uint8_t i_dq, uint8_t i_ps )
{
    uint8_t symbol = SYMBOLS_PER_RANK;

    static const uint8_t dq2symbol[] =
    {
        71, 70, 69, 68, 39, 38, 37, 36, // dqs 0- 7
        67, 66, 65, 64, 35, 34, 33, 32, // dqs 8-15
        63, 62, 61, 60, 31, 30, 29, 28, // dqs 16-23
        59, 58, 57, 56, 27, 26, 25, 24, // dqs 24-31
        55, 54, 53, 52, 23, 22, 21, 20, // dqs 32-39
        51, 50, 49, 48, 19, 18, 17, 16, // dqs 40-47
        47, 46, 45, 44, 15, 14, 13, 12, // dqs 48-55
        43, 42, 41, 40, 11, 10,  9,  8, // dqs 56-63
         7,  6,  5,  4,  3,  2,  1,  0, // dqs 64-71
    };

    if ( DQS_PER_DIMM > i_dq )
    {
        symbol = dq2symbol[i_dq];
    }

    return symbol;
}

template
uint8_t dq2Symbol<TARGETING::TYPE_MCA>( uint8_t i_dq, uint8_t i_ps );
template
uint8_t dq2Symbol<TARGETING::TYPE_MEM_PORT>( uint8_t i_dq, uint8_t i_ps );
template
uint8_t dq2Symbol<TARGETING::TYPE_OCMB_CHIP>( uint8_t i_dq, uint8_t i_ps );

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

template<>
uint8_t nibble2Symbol<TARGETING::TYPE_MBA>( uint8_t i_x4Dram )
{
    return (MBA_NIBBLES_PER_RANK >i_x4Dram) ? (i_x4Dram *MBA_SYMBOLS_PER_NIBBLE)
                                            : SYMBOLS_PER_RANK;
}

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

template<>
uint8_t nibble2Symbol<TARGETING::TYPE_MCA>( uint8_t i_x4Dram )
{
    uint8_t symbol = SYMBOLS_PER_RANK;

    static const uint8_t nibble2symbol[] =
    {
        68, 36, 64, 32, 60, 28, // nibbles  0- 5
        56, 24, 52, 20, 48, 16, // nibbles  6-11
        44, 12, 40,  8,  4,  0, // nibbles 12-17
    };

    if ( NIBBLES_PER_DIMM > i_x4Dram )
    {
        symbol = nibble2symbol[i_x4Dram];
    }

    return symbol;
}

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

template<>
uint8_t nibble2Symbol<TARGETING::TYPE_OCMB_CHIP>( uint8_t i_x4Dram )
{
    // OCMB_CHIP case is identical to MCA
    return nibble2Symbol<TARGETING::TYPE_MCA>(i_x4Dram);
}

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

template<>
uint8_t byte2Symbol<TARGETING::TYPE_MBA>( uint8_t i_x8Dram )
{
    return (MBA_BYTES_PER_RANK > i_x8Dram) ? (i_x8Dram * MBA_SYMBOLS_PER_BYTE)
                                           : SYMBOLS_PER_RANK;
}

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

template<>
uint8_t byte2Symbol<TARGETING::TYPE_MCA>( uint8_t i_x8Dram )
{
    uint8_t symbol = SYMBOLS_PER_RANK;

    static const uint8_t byte2symbol[] =
    {
        36, 32, 28, // bytes 0-2
        24, 20, 16, // bytes 3-5
        12,  8,  0, // bytes 6-8
    };

    if ( BYTES_PER_DIMM > i_x8Dram )
    {
        symbol = byte2symbol[i_x8Dram];
    }

    return symbol;
}

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

template<>
uint8_t byte2Symbol<TARGETING::TYPE_OCMB_CHIP>( uint8_t i_x8Dram )
{
    // OCMB_CHIP case is identical to MCA
    return byte2Symbol<TARGETING::TYPE_MCA>(i_x8Dram);
}

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

template<>
uint8_t symbol2Nibble<TARGETING::TYPE_MBA>( uint8_t i_symbol )
{
    return (SYMBOLS_PER_RANK > i_symbol) ? (i_symbol / MBA_SYMBOLS_PER_NIBBLE)
                                         : MBA_NIBBLES_PER_RANK;
}

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

template<>
uint8_t symbol2Nibble<TARGETING::TYPE_MCA>( uint8_t i_symbol )
{
    return (SYMBOLS_PER_RANK > i_symbol)
            ? (symbol2Dq<TARGETING::TYPE_MCA>(i_symbol)/4)
            : MEM_NIBBLES_PER_RANK;
}

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

template<>
uint8_t symbol2Nibble<TARGETING::TYPE_OCMB_CHIP>( uint8_t i_symbol )
{
    // OCMB_CHIP case is identical to MCA
    return symbol2Nibble<TARGETING::TYPE_MCA>(i_symbol);
}

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

template<>
uint8_t symbol2Byte<TARGETING::TYPE_MBA>( uint8_t i_symbol )
{
    return (SYMBOLS_PER_RANK > i_symbol) ? (i_symbol / MBA_SYMBOLS_PER_BYTE)
                                         : MBA_BYTES_PER_RANK;
}

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

template<>
uint8_t symbol2Byte<TARGETING::TYPE_MCA>( uint8_t i_symbol )
{
    return (SYMBOLS_PER_RANK > i_symbol)
            ? (symbol2Dq<TARGETING::TYPE_MCA>(i_symbol)/8)
            : MEM_BYTES_PER_RANK;
}

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

template<>
uint8_t symbol2Byte<TARGETING::TYPE_OCMB_CHIP>( uint8_t i_symbol )
{
    // OCMB_CHIP case is identical to MCA
    return symbol2Byte<TARGETING::TYPE_MCA>(i_symbol);
}

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

/**
 * @brief Find the first symbol of the given DRAM index
 * @param i_dram     The Dram
 * @param i_isX4Dram TRUE if DRAM is x4
 * @return The Symbol
 */
template<>
uint8_t dram2Symbol<TARGETING::TYPE_MBA>( uint8_t i_dram, bool i_isX4Dram )
{
    const uint8_t dramsPerRank   = i_isX4Dram ? MBA_NIBBLES_PER_RANK
                                              : MBA_BYTES_PER_RANK;

    const uint8_t symbolsPerDram = i_isX4Dram ? MBA_SYMBOLS_PER_NIBBLE
                                              : MBA_SYMBOLS_PER_BYTE;

    return (dramsPerRank > i_dram) ? (i_dram * symbolsPerDram)
                                   : SYMBOLS_PER_RANK;
}



} // namespace PARSERUTILS

#if defined(PRDF_HOSTBOOT_ERRL_PLUGIN) || defined(PRDF_FSP_ERRL_PLUGIN)
} // end namespace FSP/HOSTBOOT
#endif

} // End of namespace PRDF
OpenPOWER on IntegriCloud