summaryrefslogtreecommitdiffstats
path: root/src/import/generic/memory/lib/ecc/fw_mark_store.H
blob: 3e840c4d0a10ac2521a11be9b0296acb198e4670 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/generic/memory/lib/ecc/fw_mark_store.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 fw_mark_store.H
/// @brief Subroutines for the MC firmware mark store registers
///
// *HWP HWP Owner: Matthew Hickman <Matthew.Hickman@ibm.com>
// *HWP HWP Backup: Stephen Glancy <sglancy@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 3
// *HWP Consumed by: FSP:HB

#ifndef _MSS_FW_MARK_STORE_H_
#define _MSS_FW_MARK_STORE_H_

#include <fapi2.H>
#include <generic/memory/lib/utils/mcbist/gen_mss_mcbist_fwms_address.H>
#include <generic/memory/lib/utils/scom.H>
#include <generic/memory/lib/ecc/ecc_traits.H>

namespace mss
{

namespace ecc
{

namespace fwms
{

///
/// @brief chip mark type enums
///
enum mark_type
{
    SYMBOL = 1,
    CHIP = 0
};

///
/// @brief Chip Mark Region. Used for region field values in the FWMS regs
///
enum mark_region
{
    DISABLED = 0b000,
    RESERVED = 0b001,
    BANK = 0b010,
    BANKGROUP = 0b011,
    SRANK = 0b100,
    MRANK = 0b101,
    DIMM = 0b110,
    UNIVERSAL = 0b111
};

///
/// @brief Read Firmware Mark Store (FWMS) register
/// @tparam R master rank number
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< uint64_t R, fapi2::TargetType T, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline fapi2::ReturnCode read_rank( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    static_assert((R < TT::ECC_MAX_MRANK_PER_PORT), "Master rank index failed range check");
    FAPI_TRY( mss::getScom(i_target, (TT::FIRMWARE_MS0_REG + R), o_data) );
    FAPI_INF("read_rank<%d>: 0x%016lx", R, o_data);
fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Read Firmware Mark Store (FWMS) rank 0 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read_rank0( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    return ( read_rank<0>(i_target, o_data) );
}

///
/// @brief Read Firmware Mark Store (FWMS) rank 1 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read_rank1( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    return ( read_rank<1>(i_target, o_data) );
}

///
/// @brief Read Firmware Mark Store (FWMS) rank 2 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read_rank2( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    return ( read_rank<2>(i_target, o_data) );
}

///
/// @brief Read Firmware Mark Store (FWMS) rank 3 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read_rank3( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    return ( read_rank<3>(i_target, o_data) );
}

///
/// @brief Read Firmware Mark Store (FWMS) rank 4 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read_rank4( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    return ( read_rank<4>(i_target, o_data) );
}

///
/// @brief Read Firmware Mark Store (FWMS) rank 5 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read_rank5( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    return ( read_rank<5>(i_target, o_data) );
}

///
/// @brief Read Firmware Mark Store (FWMS) rank 6 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read_rank6( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    return ( read_rank<6>(i_target, o_data) );
}

///
/// @brief Read Firmware Mark Store (FWMS) rank 7 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read_rank7( const fapi2::Target<T>& i_target, fapi2::buffer<uint64_t>& o_data )
{
    return ( read_rank<7>(i_target, o_data) );
}

///
/// @brief Read Firmware Mark Store (FWMS) register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_rank the master rank index
/// @param[out] o_data the value of the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode read( const fapi2::Target<T>& i_target,
                               const uint64_t i_rank,
                               fapi2::buffer<uint64_t>& o_data )
{
    switch (i_rank)
    {
        case(0):
            return ( read_rank0(i_target, o_data) );

        case(1):
            return ( read_rank1(i_target, o_data) );

        case(2):
            return ( read_rank2(i_target, o_data) );

        case(3):
            return ( read_rank3(i_target, o_data) );

        case(4):
            return ( read_rank4(i_target, o_data) );

        case(5):
            return ( read_rank5(i_target, o_data) );

        case(6):
            return ( read_rank6(i_target, o_data) );

        case(7):
            return ( read_rank7(i_target, o_data) );

        default:
            FAPI_ASSERT( false,
                         fapi2::MSS_INVALID_RANK_PASSED()
                         .set_RANK(i_rank)
                         .set_TARGET(i_target)
                         .set_FUNCTION(FWMS_READ),
                         "%s Invalid rank passed to fwms::ecc::read (%d)",
                         mss::c_str(i_target),
                         i_rank);
    }

    return fapi2::FAPI2_RC_SUCCESS;
fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Write Firmware Mark Store (FWMS) register
/// @tparam R master rank number
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< uint64_t R, fapi2::TargetType T, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline fapi2::ReturnCode write_rank( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    static_assert((R < TT::ECC_MAX_MRANK_PER_PORT), "Master rank index failed range check");
    FAPI_TRY( mss::putScom(i_target, (TT::FIRMWARE_MS0_REG + R), i_data) );
    FAPI_DBG("write_rank<%d>: 0x%016lx", R, i_data);
fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief Write Firmware Mark Store (FWMS) rank 0 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write_rank0( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    return ( write_rank<0>(i_target, i_data) );
}

///
/// @brief Write Firmware Mark Store (FWMS) rank 1 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write_rank1( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    return ( write_rank<1>(i_target, i_data) );
}

///
/// @brief Write Firmware Mark Store (FWMS) rank 2 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write_rank2( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    return ( write_rank<2>(i_target, i_data) );
}

///
/// @brief Write Firmware Mark Store (FWMS) rank 3 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write_rank3( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    return ( write_rank<3>(i_target, i_data) );
}

///
/// @brief Write Firmware Mark Store (FWMS) rank 4 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write_rank4( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    return ( write_rank<4>(i_target, i_data) );
}

///
/// @brief Write Firmware Mark Store (FWMS) rank 5 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write_rank5( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    return ( write_rank<5>(i_target, i_data) );
}

///
/// @brief Write Firmware Mark Store (FWMS) rank 6 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write_rank6( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    return ( write_rank<6>(i_target, i_data) );
}

///
/// @brief Write Firmware Mark Store (FWMS) rank 7 register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write_rank7( const fapi2::Target<T>& i_target, const fapi2::buffer<uint64_t>& i_data )
{
    return ( write_rank<7>(i_target, i_data) );
}

///
/// @brief Write Firmware Mark Store (FWMS) register
/// @tparam T fapi2 Target Type - derived from i_target's type
/// @param[in] i_target the fapi2 target of the mc
/// @param[in] i_rank the master rank index
/// @param[in] i_data the value to write to the register
/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS if ok
///
template< fapi2::TargetType T >
inline fapi2::ReturnCode write( const fapi2::Target<T>& i_target,
                                const uint64_t i_rank,
                                const fapi2::buffer<uint64_t>& i_data )
{
    switch (i_rank)
    {
        case(0):
            return ( write_rank0(i_target, i_data) );

        case(1):
            return ( write_rank1(i_target, i_data) );

        case(2):
            return ( write_rank2(i_target, i_data) );

        case(3):
            return ( write_rank3(i_target, i_data) );

        case(4):
            return ( write_rank4(i_target, i_data) );

        case(5):
            return ( write_rank5(i_target, i_data) );

        case(6):
            return ( write_rank6(i_target, i_data) );

        case(7):
            return ( write_rank7(i_target, i_data) );

        default:
            FAPI_ASSERT( false,
                         fapi2::MSS_INVALID_RANK_PASSED()
                         .set_RANK(i_rank)
                         .set_TARGET(i_target)
                         .set_FUNCTION(FWMS_WRITE),
                         "%s Invalid rank passed to fwms::ecc::write (%d)",
                         mss::c_str(i_target),
                         i_rank);
    }

    return fapi2::FAPI2_RC_SUCCESS;
fapi_try_exit:
    return fapi2::current_err;
}

///
/// @brief set_mark
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in, out] io_data the register value
/// @param[in] i_value the value of the field
/// @note FWMS0_MARK: mark (Galois field code)
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void set_mark( fapi2::buffer<uint64_t>& io_data, const uint64_t i_value )
{
    io_data.insertFromRight<TT::FIRMWARE_MS_MARK, TT::FIRMWARE_MS_MARK_LEN>(i_value);
    FAPI_DBG("set_mark: 0x%02lx", i_value);
}

///
/// @brief get_mark
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_data the register value
/// @param[out] o_value the value of the field
/// @note FWMS0_MARK: mark (Galois field code)
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void get_mark( const fapi2::buffer<uint64_t>& i_data, uint64_t& o_value )
{
    i_data.extractToRight<TT::FIRMWARE_MS_MARK, TT::FIRMWARE_MS_MARK_LEN>(o_value);
    FAPI_INF("get_mark: 0x%02lx", o_value);
}

///
/// @brief set_type
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in, out] io_data the register value
/// @param[in] i_value the value of the field
/// @note FWMS0_TYPE: mark type
/// @note Dial enums:
/// @note SYMBOL=>0b1
/// @note CHIP=>0b0
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void set_type( fapi2::buffer<uint64_t>& io_data, const mark_type i_value )
{
    io_data.writeBit<TT::FIRMWARE_MS_TYPE>(i_value);
    FAPI_INF("set_type: 0x%01lx", i_value);
}

///
/// @brief get_type
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_data the register value
/// @param[out] o_value the value of the field
/// @note FWMS0_TYPE: mark type
/// @note Dial enums:
/// @note SYMBOL=>0b1
/// @note CHIP=>0b0
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void get_type( const fapi2::buffer<uint64_t>& i_data, mark_type& o_value )
{
    o_value = mark_type(i_data.getBit<TT::FIRMWARE_MS_TYPE>());
    FAPI_INF("get_type: 0x%01lx", o_value);
}

///
/// @brief set_region
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in, out] io_data the register value
/// @param[in] i_value the value of the field
/// @note FWMS0_REGION: Selects mark region (address range to which mark applies)
/// @note Dial enums:
/// @note DISABLED=>0b000
/// @note RESERVED=>0b001
/// @note BANK=>0b010
/// @note BANKGROUP=>0b011
/// @note SRANK=>0b100
/// @note MRANK=>0b101
/// @note DIMM=>0b110
/// @note UNIVERSAL=>0b111
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void set_region( fapi2::buffer<uint64_t>& io_data, const mark_region i_value )
{
    io_data.insertFromRight<TT::FIRMWARE_MS_REGION, TT::FIRMWARE_MS_REGION_LEN>(i_value);
    FAPI_INF("set_region: 0x%02lx", i_value);
}

///
/// @brief get_region
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<T>
/// @param[in] i_data the register value
/// @param[out] o_value the value of the field
/// @note FWMS0_REGION: Selects mark region (address range to which mark applies)
/// @note Dial enums:
/// @note DISABLED=>0b000
/// @note RESERVED=>0b001
/// @note BANK=>0b010
/// @note BANKGROUP=>0b011
/// @note SRANK=>0b100
/// @note MRANK=>0b101
/// @note DIMM=>0b110
/// @note UNIVERSAL=>0b111
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void get_region( const fapi2::buffer<uint64_t>& i_data, mark_region& o_value )
{
    uint64_t l_temp = 0;
    i_data.extractToRight<TT::FIRMWARE_MS_REGION, TT::FIRMWARE_MS_REGION_LEN>(l_temp);
    o_value = mark_region(l_temp);
    FAPI_INF("get_region: 0x%02lx", o_value);
}

///
/// @brief set_address
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in, out] io_data the register value
/// @param[in] i_address mcbist::address form of address field
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void set_address( fapi2::buffer<uint64_t>& io_data, const mcbist::address& i_address)
{
    // construct fwms::address from mcbist::address
    const auto l_addr = address<>(i_address);
    io_data.insert<TT::FIRMWARE_MS_ADDRESS, TT::FIRMWARE_MS_ADDRESS_LEN, TT::FIRMWARE_MS_ADDRESS>(l_addr);
    FAPI_INF("set_address: 0x%016lx", uint64_t(l_addr));
}

///
/// @brief get_address
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_data the register value
/// @param[out] o_address mcbist::address form of address field
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void get_address( const fapi2::buffer<uint64_t>& i_data, mcbist::address& o_address )
{
    // construct fwms::address from i_data
    const auto l_addr = mss::ecc::fwms::address<>(uint64_t(i_data));
    // construct mcbist::address from fwms::address
    o_address = l_addr.operator mss::mcbist::address();
    FAPI_INF("get_address: 0x%016lx", uint64_t(l_addr));
}

///
/// @brief set_exit_1
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in, out] io_data the register value
/// @param[in] i_state mss::YES or mss::NO - desired state
/// @note FWMS0_EXIT_1: When set, bypass-enabled reads using this mark will use exit 1
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void set_exit_1( fapi2::buffer<uint64_t>& io_data, const mss::states i_state )
{
    io_data.writeBit<TT::FIRMWARE_MS_EXIT1>(i_state);
    FAPI_INF("set_exit_1: 0x%01lx", i_state);
}

///
/// @brief get_exit_1
/// @tparam T fapi2 Target Type defaults to defaulted port in mc const
/// @tparam TT traits type defaults to eccTraits<DEFAULT_MC_TYPE, T>
/// @param[in] i_data the register value
/// @param[out] o_state mss::YES or mss::NO - representing the state of the field
/// @note FWMS0_EXIT_1: When set, bypass-enabled reads using this mark will use exit 1
///
template< fapi2::TargetType T = DEFAULT_MEM_PORT_TARGET, typename TT = eccTraits<DEFAULT_MC_TYPE, T> >
inline void get_exit_1( const fapi2::buffer<uint64_t>& i_data, mss::states& o_state )
{
    o_state = (i_data.getBit<TT::FIRMWARE_MS_EXIT1>() == false) ? mss::NO : mss::YES;
    FAPI_INF("get_exit_1: 0x%01lx", o_state);
}

} // close namespace fwms

} // close namespace ecc

} // close namespace mss

#endif
OpenPOWER on IntegriCloud