summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/pm/p9_scan_ring_util.H
blob: f52832ff3d69bd0b20254149e868d1e344f03226 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/chips/p9/procedures/hwp/pm/p9_scan_ring_util.H $   */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,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                                                     */
#ifndef __P9_SCAN_RING_UTIL_H
#define __P9_SCAN_RING_UTIL_H

#include <fapi2.H>
#include "p9_ringId.H"
#include "p9_stop_util.H"
#include <map>

//#define __CRONUS_VER
///
/// @file   p9_scan_ring_util.H
/// @brief  utility classes and functions for scan ring debug.
///
/// *HWP HWP Owner:      Greg Still <stillgs@us.ibm.com>
/// *HWP FW Owner:       Prem S Jha <premjha2@in.ibm.com>
/// *HWP Team:           PM
/// *HWP Level:          2
/// *HWP Consumed by:    Hostboot:Phyp:Cro
//

namespace p9_hcodeImageBuild
{

/**
 * @brief   enumerates all the platforms associated with hcode image build.
 */
enum PlatId
{
    PLAT_SELF   =   0,
    PLAT_SGPE   =   1,
    PLAT_CME    =   2,
    PLAT_PGPE   =   3,
};

/**
 * @brief   constants associated with fake scan rings.
 */
enum FakeScanRing_t
{
    SCAN_RNG_START      =   0x5363616e20526e67,
    SCAN_RNG_END        =   0x52696e6720456e64,
    MAX_SCAN_RING_SIZE  =   120,
    MAX_FAKE_CMN_RING   =   0x14,
    MAX_FAKE_RING       =   0x1E,
};

/**
 * @brief   debug modes supported for scan rings.
 */
enum RingDebugMode_t
{
    SCAN_RING_NO_DEBUG          =   0x00,
    SCAN_RING_TRACE_DEBUG       =   0x01,
    SCAN_RING_TRACE_DEEP_DEBUG  =   0x02,
};
/**
 * @brief   models a fake ring for debug.
 */
struct FakeRing
{
    uint64_t iv_ringHeader;
    uint64_t iv_ringNumber;
    uint8_t  iv_ringPayload[MAX_SCAN_RING_SIZE];
    uint64_t iv_ringEnd;

#ifdef __CRONUS_VER
    FakeRing( uint8_t i_ringNumber ):
        iv_ringHeader( SWIZZLE_8_BYTE(SCAN_RNG_START) ),
        iv_ringEnd(SWIZZLE_8_BYTE(SCAN_RNG_END))
    {
        memset( &iv_ringPayload, 0xAA, MAX_SCAN_RING_SIZE );
        uint8_t temp1 = i_ringNumber / 100;
        temp1 = temp1 + 0x30;
        iv_ringNumber = temp1 << 16;
        temp1 = i_ringNumber % 100;
        iv_ringNumber |= (( temp1 / 10) + 0x30 ) << 8;
        iv_ringNumber |= ((temp1 % 10) + 0x30 );
        iv_ringNumber = SWIZZLE_8_BYTE(iv_ringNumber);
    }
#else
    FakeRing( uint8_t i_ringNumber ):
        iv_ringHeader( 0 ),
        iv_ringEnd( 0)
    {
        //dummy constructor to avoid compilation issue
        memset( &iv_ringPayload, 0xAA, MAX_SCAN_RING_SIZE );
    }
#endif
};

class RingName
{
    public:
        /**
         * @brief   constructor
         * @param   i_ringName      name associated with the a scan ring.
         * @param   i_debugMode     debug mode.
         */
        RingName( char* i_ringName );

        /**
         * @brief   constructor
         */
        RingName() {};

        /**
         * @brief   destructor
         */
        ~RingName() {};

        /**
         * @brief   returns string Name.
         */
        char* c_str();
    private:
        char iv_ringStr[40];
};

/**
 * @brief   models the profile of a scan ring for debug.
 */
struct RingProfile
{
    RingID iv_ringId;
    uint32_t iv_ringOffset;
    uint32_t iv_ringSize;
    uint32_t iv_chipletPos;

    RingProfile ( RingID i_ringId, uint16_t i_ringOffset, uint16_t i_ringSize ) :
        iv_ringId( i_ringId ),
        iv_ringOffset( i_ringOffset ),
        iv_ringSize( i_ringSize ),
        iv_chipletPos( 0 )
    { }

    RingProfile ( RingID i_ringId, uint8_t i_chipletPos ) :
        iv_ringId( i_ringId ),
        iv_ringOffset( 0 ),
        iv_ringSize( 0 ),
        iv_chipletPos( i_chipletPos )
    { }

    RingProfile():
        iv_ringId(eq_fure),
        iv_ringOffset(0),
        iv_ringSize(0)
    {}
};

/**
 * @brief   populates an input buffer with a fake scan ring.
 * @param   o_pRingBuffer   rings in which scan rings are copied.
 * @param   o_size          size of scan ring.
 * @param   i_ringId        scan ring id.
 * @param   i_plat          platform associated with scan ring.
 */
void getScanRing( void* o_pRingBuffer, uint32_t& o_size,
                  uint32_t i_ringId, PlatId i_plat );

/**
 * @brief   class to suppport debug of scan ring layout in P9 HOMER
 * @note    Intended platform is cronus.
 */
class RingBucket
{
    public:
        /**
         * @brief   constructor
         */
        RingBucket( PlatId i_plat, uint8_t* i_pRingStart, RingDebugMode_t i_debugMode );

        /**
         * @brief   destructor
         */
        ~RingBucket();
        /**
         * @brief   returns the id of common ring from storage index.
         * @param   i_ringPos   storage position of ring.
         * @return  scan ring id.
         */
        RingID getCommonRingId( uint16_t i_ringPos );

        /**
         * @brief   returns the id of chiplet instance specific ring from storage index.
         * @param   i_ringPos   storage position of ring.
         * @return  scan ring id.
         */
        RingID getInstRingId  ( uint16_t  i_ringPos );

        /**
         * @brief   returns the offset associated with scan ring of given id.
         * @param   i_ringId    Id associated with a scan ring.
         * @param   SUCCESS for successful operation erro code otherwise.
         * @return  offset associated with a given ring.
         */
        uint16_t getRingOffset( RingID i_ringId, uint8_t i_chipletPos = 0 );

        /**
         * @brief   sets the offset associated with scan ring of given id.
         * @param   i_pRingPtr  points to start of scan ring.
         * @param   i_ringId    Id associated with a scan ring.
         * @param   SUCCESS for successful operation, error code otherwise.
         */
        void setRingOffset( uint8_t* i_pRingPtr, RingID i_ringId, uint8_t i_chipletPos = 0 );

        /**
         * @brief   sets base of a ring associated with a given platform.
         * @param   i_ringPos   points to start of ring index of CME/SGPE
         */
        void initRingBase( uint8_t* i_pRingStart );

        /**
         * @brief   sets size of a given scan ring.
         * @param   i_ringId    Id associated with a given scan ring.
         * @param   i_ringSize  size of scan ring.
         */
        void setRingSize( RingID i_ringId, uint16_t i_ringSize, uint8_t i_chipletPos = 0 );

        /**
         * @brief   returns size of a given scan ring.
         * @param   i_ringId    Id associated with a given scan ring.
         * @return  size of a given scan ring.
         */
        uint16_t getRingSize( RingID i_ringId, uint8_t i_chipletPos = 0 );

        /**
         * @brief   returns name of scan ring associated with given id.
         * @param   i_ringId    Id associated with a given scan ring.
         * @return  size of a given scan ring.
         */
        const char* getRingName( RingID i_ringId );

        /**
         * @brief   generates a report on layout of CME/SGPE scan rings in HOMER.
         */
        void dumpRings( );

        /**
         * @brief   generates a report on layout of CME/SGPE scan ring overrides in HOMER.
         */
        void dumpOverrideRings();

        /**
         * @brief   prints a given ring for content debug
         * @param   i_ptr       points to a work buffer containing ring.
         * @param   i_ringSize  size of a ring.
         * @param   i_ringId    ring id
         */
        void extractRing( void* i_ptr, uint32_t i_ringSize, uint32_t i_ringId );
    private:
        std::map<uint16_t, RingProfile> iv_cmnRingMap;
        std::map<uint16_t, RingProfile> iv_instRingMap;
        uint8_t* iv_pRingStart;
        uint16_t iv_ringSize;
        PlatId iv_plat;
        RingDebugMode_t iv_debugMode;

        std::map<RingID, RingName> iv_ringName;
};

class P9FuncModel
{
    public:
        /**
         * @brief   constructor
         */
        P9FuncModel( const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP >& i_procTgt );
        /**
         * brief    destructor
         */
        ~P9FuncModel( );

        /**
         * @brief   returns functional state of a given core.
         */
        bool isCoreFunctional( uint32_t i_corePos ) const;

        /**
         * @brief   returns functional state of a given ex.
         */
        bool isExFunctional( uint32_t i_exPos )     const;

        /**
         * @brief   returns functional state of a given quad.
         */
        bool isQuadFunctional( uint32_t i_quadPos ) const;

        /**
         * @brief   returns dd level associated with a processor.
         */
        uint8_t getChipLevel()  const;

        /**
         * uint8_t returns an ID pertaining to chip name.
         */

        uint8_t getChipName() const;

        /**
         * reutrns true if SMF is enabled else false.
         */
        bool isSmfEnabled() const;

        /**
         * @brief   constructor
         */
        P9FuncModel(  );

    private:
        P9FuncModel( const P9FuncModel& );              //Disallow copy constructor
        P9FuncModel& operator = ( const P9FuncModel&); // Disallow assignment operator
        uint32_t iv_funcCores;
        uint16_t iv_funcExes;
        uint8_t  iv_funcQuads;
        uint8_t  iv_ddLevel;
        uint8_t  iv_chipName;
        uint8_t  iv_smfEn;
        uint8_t  iv_reserve[2];
};

}// namesapce p9_hcodeImageBuild ends

#endif //__P9_SCAN_RING_UTIL_H
OpenPOWER on IntegriCloud