summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfMemoryMru.C
blob: 134b1b39ce19bd8c08dbd4d34969ce92a3cf0b53 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfMemoryMru.C $       */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2008,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                                                     */

/** @file prdfMemoryMru.C */

#include <prdfMemoryMru.H>

#include <prdfCalloutUtil.H>
#include <prdfTrace.H>
#include <prdfCenMemUtils.H>

using namespace TARGETING;

namespace PRDF
{

using namespace MemoryMruData;
using namespace PlatServices;
using namespace CEN_SYMBOL;

MemoryMru::MemoryMru() :
    iv_mbaTarget(NULL), iv_rank(), iv_special(NO_SPECIAL_CALLOUT)
{
    iv_memMruMeld.u = 0;
}

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

MemoryMru::MemoryMru( uint32_t i_memMru ) :
    iv_mbaTarget(NULL), iv_rank(), iv_special(NO_SPECIAL_CALLOUT)
{
    #define PRDF_FUNC "[MemoryMru::MemoryMru] "

    iv_memMruMeld.u = i_memMru;

    iv_memMruMeld.s.valid = 0; // initially invalidated

    do
    {
        // Get MBA target using node, proc, membuff and mba position
        TargetHandle_t system = getSystemTarget();

        if ( NULL == system )
        {
            PRDF_ERR( PRDF_FUNC"Could not find system target" );
            break;
        }

        TargetHandle_t node = getConnectedChild( system, TYPE_NODE,
                                                 iv_memMruMeld.s.nodePos );
        if ( NULL == node )
        {
            PRDF_ERR( PRDF_FUNC"Could not find functional node attached to "
                      "system at pos: %u", iv_memMruMeld.s.nodePos );
            break;
        }

        TargetHandle_t proc = getConnectedChild( node, TYPE_PROC,
                                                 iv_memMruMeld.s.procPos );
        if ( NULL == proc )
        {
            PRDF_ERR( PRDF_FUNC"Could not find functional  proc attached to "
                      "node 0x%08X at pos: %u", getHuid( node ),
                       iv_memMruMeld.s.procPos );
            break;
        }

        TargetHandle_t membuff = getConnectedChild( proc, TYPE_MEMBUF,
                                                   iv_memMruMeld.s.cenPos );
        if ( NULL == membuff )
        {
            PRDF_ERR( PRDF_FUNC"Could not find functional  membuff attached to "
                      "proc 0x%08X at pos: %u", getHuid( proc ),
                       iv_memMruMeld.s.cenPos );
            break;
        }

        iv_mbaTarget = getConnectedChild( membuff, TYPE_MBA,
                                          iv_memMruMeld.s.mbaPos );
        if ( NULL == iv_mbaTarget )
        {
            PRDF_ERR( PRDF_FUNC"Could not find functional MBA attached to "
                      "membuff 0x%08X at pos: %u", getHuid( membuff ),
                       iv_memMruMeld.s.mbaPos );
            break;
        }


        // Get the rank
        iv_rank = (0 == iv_memMruMeld.s.srankValid)
                    ? CenRank( iv_memMruMeld.s.mrank )
                    : CenRank( iv_memMruMeld.s.mrank, iv_memMruMeld.s.srank );

        // Get the symbol or special callout
        if ( (FIRST_SPECIAL_CALLOUT <= iv_memMruMeld.s.symbol) &&
             (iv_memMruMeld.s.symbol <= LAST_SPECIAL_CALLOUT) )
        {
            iv_special = (MemoryMruData::Callout)iv_memMruMeld.s.symbol;
        }
        else
        {
            if ( SYMBOLS_PER_RANK <= iv_memMruMeld.s.symbol )
            {
                PRDF_ERR( PRDF_FUNC"Invalid symbol value :%u",
                                    iv_memMruMeld.s.symbol );
                break;
            }

            iv_symbol = CenSymbol::fromSymbol( iv_mbaTarget, iv_rank,
                                               iv_memMruMeld.s.symbol,
                                               iv_memMruMeld.s.pins );
            if ( !iv_symbol.isValid() )
            {
                PRDF_ERR( PRDF_FUNC"fromSymbol() failed" );
                break;
            }

            if ( iv_memMruMeld.s.dramSpared ) iv_symbol.setDramSpared();
            if ( iv_memMruMeld.s.eccSpared  ) iv_symbol.setEccSpared();

            // Validation checks
            CEN_SYMBOL::WiringType type = iv_symbol.getWiringType();

            if ( type != CEN_SYMBOL::WiringType (iv_memMruMeld.s.wiringType))
            {
                PRDF_ERR( PRDF_FUNC"Wiring Type does not match type:%u "
                                    "iv_memMruMeld.s.wiringType :%u",
                                    type, iv_memMruMeld.s.wiringType);
                break;
            }

        }

        // If the code gets to this point the MemoryMru is valid.
        iv_memMruMeld.s.valid = 1;

    } while (0);

    #undef PRDF_FUNC
}

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

MemoryMru::MemoryMru( TARGETING::TargetHandle_t i_mbaTarget,
                      const CenRank & i_rank, const CenSymbol & i_symbol ) :
    iv_mbaTarget(i_mbaTarget), iv_rank(i_rank),
    iv_special(NO_SPECIAL_CALLOUT), iv_symbol( i_symbol )
{
    #define PRDF_FUNC "[MemoryMru::MemoryMru] "

    iv_memMruMeld.u = 0;

    do
    {
        TargetHandle_t node = getConnectedParent( iv_mbaTarget, TYPE_NODE );
        if ( NULL == node )
        {
            PRDF_ERR( PRDF_FUNC"Could not find node attached to MBA 0x%08x",
                      getHuid(iv_mbaTarget) );
            break;
        }

        TargetHandle_t proc = getConnectedParent( iv_mbaTarget, TYPE_PROC );
        if ( NULL == proc )
        {
            PRDF_ERR( PRDF_FUNC"Could not find proc attached to MBA 0x%08x",
                      getHuid(iv_mbaTarget) );
            break;
        }

        TargetHandle_t memBuff = getConnectedParent( iv_mbaTarget,
                                                     TYPE_MEMBUF );
        if ( NULL == memBuff )
        {
            PRDF_ERR( PRDF_FUNC"Could not find memBuff attached to MBA 0x%08x",
                      getHuid(iv_mbaTarget) );
            break;
        }

        iv_memMruMeld.s.nodePos    = getTargetPosition( node );
        iv_memMruMeld.s.procPos    = getTargetPosition( proc );
        iv_memMruMeld.s.cenPos     = getTargetPosition( memBuff );
        iv_memMruMeld.s.mbaPos     = getTargetPosition( iv_mbaTarget );
        iv_memMruMeld.s.mrank      = iv_rank.getMaster();
        iv_memMruMeld.s.srank      = iv_rank.getSlave();
        iv_memMruMeld.s.srankValid = iv_rank.isSlaveValid();
        iv_memMruMeld.s.symbol     = iv_symbol.getSymbol();
        iv_memMruMeld.s.pins       = iv_symbol.getPins();
        iv_memMruMeld.s.dramSpared = iv_symbol.isDramSpared() ? 1 : 0;
        iv_memMruMeld.s.eccSpared  = iv_symbol.isEccSpared()  ? 1 : 0;
        iv_memMruMeld.s.wiringType = iv_symbol.getWiringType();
        // If the code gets to this point the MemoryMru is valid.
        iv_memMruMeld.s.valid = 1;

    } while (0);

    #undef PRDF_FUNC
}

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

MemoryMru::MemoryMru( TARGETING::TargetHandle_t i_mbaTarget,
                      const CenRank & i_rank,
                      MemoryMruData::Callout i_specialCallout ) :
    iv_mbaTarget(i_mbaTarget), iv_rank(i_rank), iv_special(i_specialCallout)
{
    #define PRDF_FUNC "[MemoryMru::MemoryMru] "

    iv_memMruMeld.u = 0;

    do
    {
        TargetHandle_t node = getConnectedParent( iv_mbaTarget, TYPE_NODE );
        if ( NULL == node )
        {
            PRDF_ERR( PRDF_FUNC"Could not find node attached to MBA 0x%08x",
                      getHuid(iv_mbaTarget) );
            break;
        }

        TargetHandle_t proc = getConnectedParent( iv_mbaTarget, TYPE_PROC );
        if ( NULL == proc )
        {
            PRDF_ERR( PRDF_FUNC"Could not find proc attached to MBA 0x%08x",
                      getHuid(iv_mbaTarget) );
            break;
        }

        TargetHandle_t memBuff = getConnectedParent( iv_mbaTarget,
                                                     TYPE_MEMBUF );
        if ( NULL == memBuff )
        {
            PRDF_ERR( PRDF_FUNC"Could not find memBuff attached to MBA 0x%08x",
                      getHuid(iv_mbaTarget) );
            break;
        }

        iv_memMruMeld.s.nodePos    = getTargetPosition( node );
        iv_memMruMeld.s.procPos    = getTargetPosition( proc );
        iv_memMruMeld.s.cenPos     = getTargetPosition( memBuff );
        iv_memMruMeld.s.mbaPos     = getTargetPosition( iv_mbaTarget );
        iv_memMruMeld.s.mrank      = iv_rank.getMaster();
        iv_memMruMeld.s.srank      = iv_rank.getSlave();
        iv_memMruMeld.s.srankValid = iv_rank.isSlaveValid();
        iv_memMruMeld.s.symbol     = iv_special;

        // If the code gets to this point the MemoryMru is valid.
        iv_memMruMeld.s.valid = 1;

    } while (0);

    #undef PRDF_FUNC
}

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

TargetHandleList MemoryMru::getCalloutList() const
{
    #define PRDF_FUNC "[MemoryMru::getCalloutList] "

    TargetHandleList o_list;

    if ( 0 == iv_memMruMeld.s.valid )
    {
        PRDF_ERR( PRDF_FUNC"MemoryMru 0x%08x not valid.", iv_memMruMeld.u );
    }
    else
    {
        if ( NO_SPECIAL_CALLOUT != iv_special )
        {
            switch ( iv_special )
            {
                case CALLOUT_RANK:
                    o_list = CalloutUtil::getConnectedDimms( iv_mbaTarget,
                                                             iv_rank );
                    break;
                case CALLOUT_RANK_AND_MBA:
                    o_list = CalloutUtil::getConnectedDimms( iv_mbaTarget,
                                                             iv_rank );
                    o_list.push_back( iv_mbaTarget );
                    break;
                case CALLOUT_ALL_MEM:
                    o_list = CalloutUtil::getConnectedDimms( iv_mbaTarget );
                    break;
                default:
                    PRDF_ERR( PRDF_FUNC"MemoryMruData::Callout 0x%02x not "
                              "supported", iv_special );
            }
        }
        else
        {
            // Add DIMM represented by symbol
            uint8_t ps = iv_symbol.getPortSlct();
            if ( iv_memMruMeld.s.eccSpared ) ps = 1; // Adjust for ECC spare
            o_list = CalloutUtil::getConnectedDimms( iv_mbaTarget,
                                                     iv_rank, ps );
        }
    }

    return o_list;

    #undef PRDF_FUNC
}

} // end namespace PRDF

OpenPOWER on IntegriCloud