summaryrefslogtreecommitdiffstats
path: root/src/import/generic/memory/lib/utils/mcbist/gen_mss_mcbist_address.H
blob: b87cacba1cab639dbaa522d11300aef7b3d37b3c (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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/generic/memory/lib/utils/mcbist/gen_mss_mcbist_address.H $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 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                                                     */

///
/// @file gen_mss_mcbist_address.H
/// @brief Class for mcbist related addresses (addresses below the hash translation)
///
// *HWP HWP Owner: Stephen Glancy <sglancy@us.ibm.com>
// *HWP HWP Backup: Andre Marin <aamarin@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 3
// *HWP Consumed by: HB:FSP

#ifndef _GEN_MSS_MCBIST_ADDRESS_H_
#define _GEN_MSS_MCBIST_ADDRESS_H_

#include <fapi2.H>
#include <utility>


namespace mss
{

// Forward declaration

///
/// @class mcbistMCTraits
/// @tparam MC the mc type
/// @brief A MC to MC_TARGET_TYPE mapping
///
template< mss::mc_type MC >
class mcbistMCTraits;

///
/// @class mcbistTraits
/// @tparam MC the mc type of the T
/// @tparam T the fapi2::TargetType - derived
/// @brief a collection of traits associated with the MCBIST engine or hardware
///
template< mss::mc_type MC, fapi2::TargetType T >
class mcbistTraits;

namespace ecc
{

///
/// @class trap_address
/// @brief Converts trap address into mcbist::address
/// @tparam MC the mc type of the T
/// @tparam T fapi2 Target Type defaults to fapi2::TARGET_TYPE_MCA or TARGET_TYPE_MEM_PORT
/// @tparam TT traits type defaults to eccTraits<T>
///
// See declaration below
template< mss::mc_type MC = DEFAULT_MC_TYPE, fapi2::TargetType T = mss::mcbistMCTraits<MC>::FWMS_ADDR_TARGET_TYPE, typename TT = mss::eccTraits<T> >
class trap_address;

namespace fwms
{

///
/// @class address
/// @brief Converts Firmware Mark Store ADDRESS field into mcbist::address
/// @tparam MC the mc type of the T
/// @tparam T fapi2 Target Type defaults to fapi2::TARGET_TYPE_MCA or TARGET_TYPE_MEM_PORT
/// @tparam TT traits type defaults to eccTraits<T>
/// @note template argument defaults are in forward declaration in lib/mcbist/address.H
/// @note 12 = dimm
/// @note 13:14 = mrank
/// @note 15:17 = srank
/// @note 18:19 = bank group
/// @note 20:22 = bank
///
// See declaration below
template< mss::mc_type MC = DEFAULT_MC_TYPE, fapi2::TargetType T = mss::mcbistMCTraits<MC>::FWMS_ADDR_TARGET_TYPE, typename TT = mss::eccTraits<T> >
class address;

} // close namespace fwms
} // close namespace ecc

namespace mcbist
{

///
/// @class address
/// @brief Represents a physical address in memory
/// @note
/// 0:1   port select
/// 2     dimm select
/// 3:4   mrank(0 to 1)
/// 5:7   srank(0 to 2)
/// 8:25  row(0 to 17)
/// 26:32 col(3 to 9)
/// 33:35 bank(0 to 2)
/// 36:37 bank_group(0 to 1)
///
class address
{
    public:

        // How far over we shift to align the address in either the register or a buffer
        static constexpr uint64_t MAGIC_PAD = 26;

        // first is the start bit of the field, second is the length
        using field = std::pair<uint64_t, uint64_t>;

        constexpr static field PORT = {0, 2};
        constexpr static field DIMM = {2, 1};
        constexpr static field MRANK = {3, 2};
        constexpr static field SRANK = {5, 3};
        constexpr static field ROW = {8, 18};
        constexpr static field COL = {26, 7};
        constexpr static field BANK = {33, 3};
        constexpr static field BANK_GROUP = {36, 2};
        constexpr static field LAST_VALID = BANK_GROUP;

        ///
        /// @brief default ctor
        ///
        address() = default;

        // Used when accessing an integral value containing a port and DIMM combination
        static constexpr uint64_t DIMM_BIT = 63;
        static constexpr uint64_t PORT_START = 61;
        static constexpr uint64_t PORT_LEN = 2;

        ///
        /// @brief Construct an address from a uint64_t
        /// @param[in] i_value representing an address
        ///
        address( const uint64_t i_value ):
            iv_address(i_value << MAGIC_PAD)
        {
        }

        ///
        /// @brief Construct an address from an ecc::trap_address
        /// @tparam MC the mc type
        /// @param[in] i_address representing an address field from a trap address
        ///
        template< mss::mc_type MC = DEFAULT_MC_TYPE >
        address( const ecc::trap_address<MC>& i_address )
        {
            this->set_field<PORT      >(i_address.get_field<ecc::trap_address<MC>::PORT>());
            this->set_field<DIMM      >(i_address.get_field<ecc::trap_address<MC>::DIMM>());
            this->set_field<MRANK     >(i_address.get_field<ecc::trap_address<MC>::MRANK>());
            this->set_field<SRANK     >(i_address.get_field<ecc::trap_address<MC>::SRANK>());
            this->set_field<ROW       >(i_address.get_field<ecc::trap_address<MC>::ROW>());
            this->set_field<COL       >(i_address.get_field<ecc::trap_address<MC>::COL>());
            this->set_field<BANK      >(i_address.get_field<ecc::trap_address<MC>::BANK>());
            this->set_field<BANK_GROUP>(i_address.get_field<ecc::trap_address<MC>::BANK_GROUP>());
        }

        ///
        /// @brief Construct an address from an ecc::fwms::address
        /// @tparam MC the mc type
        /// @param[in] i_address representing an address field from a firmware mark store register
        ///
        template< mss::mc_type MC = DEFAULT_MC_TYPE >
        address( const ecc::fwms::address<MC>& i_address )
        {
            this->set_field<DIMM      >(i_address.get_field<ecc::fwms::address<MC>::DIMM>());
            this->set_field<MRANK     >(i_address.get_field<ecc::fwms::address<MC>::MRANK>());
            this->set_field<SRANK     >(i_address.get_field<ecc::fwms::address<MC>::SRANK>());
            this->set_field<BANK_GROUP>(i_address.get_field<ecc::fwms::address<MC>::BANK_GROUP>());
            this->set_field<BANK      >(i_address.get_field<ecc::fwms::address<MC>::BANK>());
        }

        ///
        /// @brief Conversion operator to uint64_t
        /// @warn Right-aligns the address
        ///
        inline operator uint64_t() const
        {
            return iv_address >> MAGIC_PAD;
        }

        ///
        /// @brief Set a field for an address
        /// @tparam F the field to set
        /// @param[in] i_value the value to set
        /// @return address& for method chaining
        ///
        template< const field& F >
        inline address& set_field( const uint64_t i_value )
        {
            iv_address.insertFromRight<F.first, F.second>(i_value);
            return *this;
        }

        ///
        /// @brief Get a field from an address
        /// @tparam F the field to get
        /// @return right-aligned uint64_t representing the value
        ///
        template< const field& F >
        inline uint64_t get_field() const
        {
            uint64_t l_value = 0;
            iv_address.extractToRight<F.first, F.second>(l_value);
            return l_value;
        }

        ///
        /// @brief Get a range of addresses.
        /// @tparam[in] F the left-most valid field. So, if the address was for master rank,
        /// the left-most valid field would be MRANK
        /// @param[out] o_end representing an address to end at
        /// @note this pointer is the start address
        ///
        template< const field& F >
        inline void get_range( address& o_end ) const
        {
            constexpr uint64_t START = F.first + F.second;
            constexpr uint64_t LEN = (LAST_VALID.first + LAST_VALID.second) - START;

            // All we need to do is fill in the bits to the right of the last valid field
            o_end.iv_address = iv_address;
            o_end.iv_address.setBit<START, LEN>();
        }


        ///
        /// @brief Get an end address for sim mode
        /// @param[out] o_end representing an address to end at
        /// @note this pointer is the start address
        ///
        inline void get_sim_end_address( address& o_end ) const
        {
            // This magic number represents a range of addresses which cover all
            // cache lines the training algorithms touch. By effecting 0 - this end
            // address you'll effect everything which has bad ECC in the sim.
            // TODO: this will have to change for explorer. it's algorithm dependent.
            //       we'll need to talk to the microchip about this
            constexpr uint64_t l_magic_sim_number = 0b1000000;

            get_range<COL>(o_end);
            o_end.set_column(l_magic_sim_number);
            return;
        }

        ///
        /// @brief Get a range of addresses given a master rank
        /// @param[in] i_start representing an address to start from
        /// @param[out] o_end representing an address to end at
        ///
        inline static void get_mrank_range( const address& i_start, address& o_end )
        {
            i_start.get_range<MRANK>(o_end);
        }

        ///
        /// @brief Get a range of addresses given a master rank
        /// @param[in] i_port representing the port for the starting address
        /// @param[in] i_dimm representing the dimm for the starting address
        /// @param[in] i_mrank representing the master rank for the starting address
        /// @param[out] o_start representing an address to start from
        /// @param[out] o_end representing an address to end at
        ///
        inline static void get_mrank_range( const uint64_t i_port,
                                            const uint64_t i_dimm,
                                            const uint64_t i_mrank,
                                            address& o_start,
                                            address& o_end )
        {
            o_start.set_port(i_port).set_dimm(i_dimm).set_master_rank(i_mrank);
            get_mrank_range(o_start, o_end);
        }

        ///
        /// @brief Get a range of addresses given a slave rank
        /// @param[in] i_start representing an address to start from
        /// @param[out] o_end representing an address to end at
        ///
        inline static void get_srank_range( const address& i_start, address& o_end )
        {
            i_start.get_range<SRANK>(o_end);
        }

        ///
        /// @brief Get a range of addresses given a slave rank
        /// @param[in] i_port representing the port for the starting address
        /// @param[in] i_dimm representing the dimm for the starting address
        /// @param[in] i_mrank representing the master rank for the starting address
        /// @param[in] i_srank representing the slave rank for the starting address
        /// @param[out] o_start representing an address to start from
        /// @param[out] o_end representing an address to end at
        ///
        inline static void get_srank_range( const uint64_t i_port, const uint64_t i_dimm,
                                            const uint64_t i_mrank, const uint64_t i_srank,
                                            address& o_start,
                                            address& o_end )
        {
            o_start.set_port(i_port).set_dimm(i_dimm).set_master_rank(i_mrank).set_slave_rank(i_srank);
            get_srank_range(o_start, o_end);
        }

        ///
        /// @brief Set the port value for an address
        /// @param[in] i_value the value to set
        /// @return address& for method chaining
        ///
        inline address& set_port( const uint64_t i_value )
        {
            return set_field<PORT>(i_value);
        }

        ///
        /// @brief Get the port value for an address
        /// @return right-aligned uint64_t representing the value
        ///
        inline uint64_t get_port() const
        {
            return get_field<PORT>();
        }

        ///
        /// @brief Set the DIMM value for an address
        /// @param[in] i_value the value to set
        /// @note 0 is the DIMM[0] != 0 is DIMM[1]
        /// @return address& for method chaining
        ///
        inline address& set_dimm( const uint64_t i_value )
        {
            return set_field<DIMM>(i_value);
        }

        ///
        /// @brief Get the DIMM value for an address
        /// @return right-aligned uint64_t representing the value
        ///
        inline uint64_t get_dimm() const
        {
            return get_field<DIMM>();
        }

        ///
        /// @brief Set the port and DIMM value for an address
        /// @param[in] i_value the value to set
        /// @return address& for method chaining
        /// @note Useful for indexing all ports/DIMM on a controller
        ///
        inline address& set_port_dimm( const fapi2::buffer<uint64_t> i_value )
        {
            uint64_t l_read_port = 0;

            i_value.extractToRight<PORT_START, PORT_LEN>(l_read_port);
            return set_dimm(i_value.getBit<DIMM_BIT>()).set_port(l_read_port);
        }

        ///
        /// @brief Get the port and DIMM value for an address
        /// @return right-aligned uint64_t representing the value
        /// @note Useful for indexing all ports/DIMM on a controller
        ///
        inline uint64_t get_port_dimm() const
        {
            fapi2::buffer<uint64_t> l_value;

            l_value.insertFromRight<PORT_START, PORT_LEN>(get_port());
            l_value.writeBit<DIMM_BIT>(get_dimm());

            return l_value;
        }

        ///
        /// @brief Set the master rank value for an address
        /// @param[in] i_value the value to set
        /// @return address& for method chaining
        ///
        inline address& set_master_rank( const uint64_t i_value )
        {
            return set_field<MRANK>(i_value);
        }

        ///
        /// @brief Get the master rank value for an address
        /// @return right-aligned uint64_t representing the value
        ///
        inline uint64_t get_master_rank() const
        {
            return get_field<MRANK>();
        }


        ///
        /// @brief Set the slave rank value for an address
        /// @param[in] i_value the value to set
        ///
        inline void set_slave_rank( const uint64_t i_value )
        {
            set_field<SRANK>(i_value);
        }

        ///
        /// @brief Get the slave rank value for an address
        /// @return right-aligned uint64_t representing the value
        ///
        inline uint64_t get_slave_rank() const
        {
            return get_field<SRANK>();
        }


        ///
        /// @brief Set the row value for an address
        /// @param[in] i_value the value to set
        /// @return address& for method chaining
        ///
        inline address& set_row( const uint64_t i_value )
        {
            return set_field<ROW>(i_value);
        }

        ///
        /// @brief Get the row value for an address
        /// @return right-aligned uint64_t representing the value
        ///
        inline uint64_t get_row() const
        {
            return get_field<ROW>();
        }


        ///
        /// @brief Set the column value for an address
        /// @param[in] i_value the value to set
        /// @return address& for method chaining
        ///
        inline address& set_column( const uint64_t i_value )
        {
            return set_field<COL>(i_value);
        }

        ///
        /// @brief Get the column value for an address
        /// @return right-aligned uint64_t representing the value
        ///
        inline uint64_t get_column() const
        {
            return get_field<COL>();
        }


        ///
        /// @brief Set the bank value for an address
        /// @param[in] i_value the value to set
        /// @return address& for method chaining
        ///
        inline address& set_bank( const uint64_t i_value )
        {
            return set_field<BANK>(i_value);
        }

        ///
        /// @brief Get the bank value for an address
        /// @return right-aligned uint64_t representing the value
        ///
        inline uint64_t get_bank() const
        {
            return get_field<BANK>();
        }

        ///
        /// @brief Set the bank group value for an address
        /// @param[in] i_value the value to set
        /// @return address& for method chaining
        ///
        inline address& set_bank_group( const uint64_t i_value )
        {
            return set_field<BANK_GROUP>(i_value);
        }

        ///
        /// @brief Get the bank group value for an address
        /// @return right-aligned uint64_t representing the value
        ///
        inline uint64_t get_bank_group() const
        {
            return get_field<BANK_GROUP>();
        }

    private:
        // We use a fapi2 buffer as it has static compile-time support
        fapi2::buffer<uint64_t> iv_address;
};

} // close namespace mcbist

// Documented above in its declaration.
template< mss::mc_type MC, fapi2::TargetType T , typename TT >
class ecc::fwms::address
{
    public:
        // first is the start bit of the field, second is the length
        using field = std::pair<uint64_t, uint64_t>;

        constexpr static field DIMM = {TT::FIRMWARE_MS_ADDRESS, 1};
        constexpr static field MRANK = {TT::FIRMWARE_MS_ADDRESS + 1, 2};
        constexpr static field SRANK = {TT::FIRMWARE_MS_ADDRESS + 3, 3};
        constexpr static field BANK_GROUP = {TT::FIRMWARE_MS_ADDRESS + 6, 2};
        constexpr static field BANK = {TT::FIRMWARE_MS_ADDRESS + 8, 3};

        address() = default;

        ///
        /// @brief Construct an address from a uint64_t (scom'ed value)
        /// @param[in] i_value representing raw value from FWMS register
        ///
        address( const uint64_t& i_value ):
            iv_value(i_value)
        {
        }

        ///
        /// @brief Construct an address from an mcbist::address
        /// @param[in] i_mcbist_address mcbist formatted address
        /// @note Construction of mcbist::address from ecc::fwms::address
        /// @note located in mcbist::address class
        ///
        address( const mcbist::address& i_mcbist_address )
        {
            iv_value.insertFromRight<DIMM.first, DIMM.second>(i_mcbist_address.get_field<mcbist::address::DIMM>());
            iv_value.insertFromRight<MRANK.first, MRANK.second>(i_mcbist_address.get_field<mcbist::address::MRANK>());
            iv_value.insertFromRight<SRANK.first, SRANK.second>(i_mcbist_address.get_field<mcbist::address::SRANK>());
            iv_value.insertFromRight<BANK_GROUP.first, BANK_GROUP.second>
            (i_mcbist_address.get_field<mcbist::address::BANK_GROUP>());
            iv_value.insertFromRight<BANK.first, BANK.second>(i_mcbist_address.get_field<mcbist::address::BANK>());
        }

        ///
        /// @brief Conversion operator to uint64_t
        ///
        inline operator uint64_t() const
        {
            uint64_t l_temp = 0;
            iv_value.extract<TT::FIRMWARE_MS_ADDRESS, TT::FIRMWARE_MS_ADDRESS_LEN, TT::FIRMWARE_MS_ADDRESS>(l_temp);
            return l_temp;
        }

        ///
        /// @brief Get a field from an address
        /// @tparam F the field to get
        /// @return right-aligned uint64_t representing the value
        ///
        template< const field& F >
        inline uint64_t get_field() const
        {
            uint64_t l_value = 0;
            iv_value.extractToRight<F.first, F.second>(l_value);
            return l_value;
        }

    private:
        fapi2::buffer<uint64_t> iv_value;

};

using field = std::pair<uint64_t, uint64_t>;
template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::fwms::address<MC, T, TT>::DIMM;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::fwms::address<MC, T, TT>::MRANK;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::fwms::address<MC, T, TT>::SRANK;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::fwms::address<MC, T, TT>::BANK_GROUP;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::fwms::address<MC, T, TT>::BANK;

// Documented above in its declaration.
template< mss::mc_type MC, fapi2::TargetType T , typename TT >
class ecc::trap_address
{
    public:
        // first is the start bit of the field, second is the length
        using field = std::pair<uint64_t, uint64_t>;

        constexpr static field PORT = {TT::TRAP_ADDRESS_PORT, TT::TRAP_ADDRESS_PORT_LEN};
        constexpr static field DIMM = {TT::TRAP_ADDRESS_DIMM, TT::TRAP_ADDRESS_DIMM_LEN};
        constexpr static field MRANK = {TT::TRAP_ADDRESS_MRANK, TT::TRAP_ADDRESS_MRANK_LEN};
        constexpr static field SRANK = {TT::TRAP_ADDRESS_SRANK, TT::TRAP_ADDRESS_SRANK_LEN};
        constexpr static field ROW = {TT::TRAP_ADDRESS_ROW, TT::TRAP_ADDRESS_ROW_LEN};
        constexpr static field COL = {TT::TRAP_ADDRESS_COL, TT::TRAP_ADDRESS_COL_LEN};
        constexpr static field BANK = {TT::TRAP_ADDRESS_BANK, TT::TRAP_ADDRESS_BANK_LEN};
        constexpr static field BANK_GROUP = {TT::TRAP_ADDRESS_BANK_GROUP, TT::TRAP_ADDRESS_BANK_GROUP_LEN};

        trap_address() = default;

        ///
        /// @brief Construct an address from a uint64_t (scom'ed value)
        /// @param[in] i_value representing raw value from FWMS register
        ///
        trap_address( const uint64_t& i_value ):
            iv_value(i_value)
        {
        }

        ///
        /// @brief Construct an address from an mcbist::address
        /// @param[in] i_mcbist_address mcbist formatted address
        /// @note Construction of mcbist::address from ecc::trap_address
        /// @note located in mcbist::address class
        ///
        trap_address( const mcbist::address& i_mcbist_address )
        {
            iv_value.insertFromRight<PORT.first, PORT.second>(i_mcbist_address.get_field<mcbist::address::PORT>());
            iv_value.insertFromRight<DIMM.first, DIMM.second>(i_mcbist_address.get_field<mcbist::address::DIMM>());
            iv_value.insertFromRight<MRANK.first, MRANK.second>(i_mcbist_address.get_field<mcbist::address::MRANK>());
            iv_value.insertFromRight<SRANK.first, SRANK.second>(i_mcbist_address.get_field<mcbist::address::SRANK>());
            iv_value.insertFromRight<ROW.first, ROW.second>(i_mcbist_address.get_field<mcbist::address::ROW>());
            iv_value.insertFromRight<COL.first, COL.second>(i_mcbist_address.get_field<mcbist::address::COL>());
            iv_value.insertFromRight<BANK.first, BANK.second>(i_mcbist_address.get_field<mcbist::address::BANK>());
            iv_value.insertFromRight<BANK_GROUP.first, BANK_GROUP.second>
            (i_mcbist_address.get_field<mcbist::address::BANK_GROUP>());
        }

        ///
        /// @brief Conversion operator to uint64_t
        ///
        inline operator uint64_t() const
        {
            uint64_t l_temp = 0;
            iv_value.extract<TT::TRAP_ADDRESS, TT::TRAP_ADDRESS_LEN, TT::TRAP_ADDRESS>(l_temp);
            return l_temp;
        }

        ///
        /// @brief Get a field from an address
        /// @tparam F the field to get
        /// @return right-aligned uint64_t representing the value
        ///
        template< const field& F >
        inline uint64_t get_field() const
        {
            uint64_t l_value = 0;
            iv_value.extractToRight<F.first, F.second>(l_value);
            return l_value;
        }

    private:
        fapi2::buffer<uint64_t> iv_value;
};

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::trap_address<MC, T, TT>::PORT;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::trap_address<MC, T, TT>::DIMM;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::trap_address<MC, T, TT>::MRANK;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::trap_address<MC, T, TT>::SRANK;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::trap_address<MC, T, TT>::ROW;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::trap_address<MC, T, TT>::COL;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::trap_address<MC, T, TT>::BANK;

template< mss::mc_type MC, fapi2::TargetType T , typename TT >
constexpr field ecc::trap_address<MC, T, TT>::BANK_GROUP;

} // close namespace mss

#endif
OpenPOWER on IntegriCloud