summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plugins/prdfParserUtils.C
blob: 42b39cdc1b2008820da3e0d9a132e86366f1bee9 (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
/* 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,2017                        */
/* [+] 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>

namespace PRDF
{

#ifdef PRDF_HOSTBOOT_ERRL_PLUGIN
namespace HOSTBOOT
{
#endif

#ifdef 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 symbol2PortSlct<TARGETING::TYPE_MBA>( uint8_t i_symbol )
{
    uint8_t portSlct = MBA_DIMMS_PER_RANK;

    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 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 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 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)
            : MCA_NIBBLES_PER_RANK;
}

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

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)
            : MCA_NIBBLES_PER_RANK;
}

} // namespace PARSERUTILS

#ifdef PRDF_HOSTBOOT_ERRL_PLUGIN
} // end namespace HOSTBOOT
#endif

#ifdef PRDF_FSP_ERRL_PLUGIN
} // end namespace FSP
#endif

} // End of namespace PRDF
OpenPOWER on IntegriCloud