summaryrefslogtreecommitdiffstats
path: root/src/usr/hdat/hdatmsarea.C
blob: 78c3633e8b8d4b253fd219f18a6f141d2d5f68f6 (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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hdat/hdatmsarea.C $                                   */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,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                                                     */
/**
 * @file hdatmsarea.C
 *
 *  @brief This file contains the implementation of the HdatMsArea class.
 *
 */


/*----------------------------------------------------------------------------*/
/* Includes                                                                   */
/*----------------------------------------------------------------------------*/
#include <stdlib.h>         // malloc & free
#include <hdat/hdat.H>           // debug compile control variables
#include "hdatmsarea.H"     // HdatMsArea class definition
#include "hdatutil.H"       // utility functions
#include "hdatmsvpd.H"

#include <stdio.h>

namespace HDAT
{
/*----------------------------------------------------------------------------*/
/* Global variables                                                           */
/*----------------------------------------------------------------------------*/
uint32_t HdatMsArea::cv_actualCnt;

static vpdData cvpdData[] =
{
    { MVPD::VINI, MVPD::DR },
    { MVPD::VINI, MVPD::FN },
    { MVPD::VINI, MVPD::PN },
    { MVPD::VINI, MVPD::SN },
    { MVPD::VINI, MVPD::CC },
//    { MVPD::VINI, MVPD::PR },
    //{ MVPD::VINI, MVPD::SZ },
    { MVPD::VINI, MVPD::HE },
    { MVPD::VINI, MVPD::CT },
    { MVPD::VINI, MVPD::HW },
 //   { MVPD::VINI, MVPD::B3 },
 //   { MVPD::VINI, MVPD::B4 },
 //   { MVPD::VINI, MVPD::B7 },
};

const HdatKeywordInfo l_cvpdKeywords[] =
{
    { CVPD::DR,  "DR" },
    { CVPD::FN,  "FN" },
    { CVPD::PN,  "PN" },
    { CVPD::SN,  "SN" },
    { CVPD::CC,  "CC" },
    { CVPD::HE,  "HE" },
    { CVPD::CT,  "CT" },
    { CVPD::HW,  "HW" },
    { CVPD::PF,  "PF" },
};



/** @brief See the prologue in hdatmsarea.H
 */
HdatMsArea::HdatMsArea(errlHndl_t &o_errlHndl,
                       TARGETING::Target * i_target,
                            uint16_t i_msAreaId,
                            uint32_t i_ramCnt,
                            uint32_t i_chipEcCnt,
                            uint32_t i_addrRngCnt,
                            uint32_t i_resourceId,
                            uint32_t i_slcaIdx,
                            uint32_t i_kwdSize,
                            char *&i_kwd)

: HdatHdif(o_errlHndl,HDAT_MSAREA_STRUCT_NAME,HDAT_MS_AREA_LAST,cv_actualCnt++,
    HDAT_MS_AREA_CHILD_LAST,HDAT_MS_AREA_VERSION), 
  iv_kwdSize(i_kwdSize),
  iv_maxAddrRngCnt(HDAT_MAX_ADDR_RNG_ENTRIES), iv_maxEcCnt(HDAT_MAX_EC_ENTRIES),
  iv_maxRamCnt(i_ramCnt), iv_actRamCnt(0), iv_maxRamObjSize(0), iv_kwd(NULL),
  iv_ramPadReq(false),iv_addrRange(NULL), iv_ecLvl(NULL), iv_ramPtrs(NULL)
{
    HDAT_ENTER( );

    uint32_t l_slcaIdx = 0;
    iv_msaHostI2cCnt = 0;
    iv_msaHostI2cSize = 0;
    iv_msaI2cDataPtr = NULL;

    o_errlHndl = NULL;
    iv_fru.hdatResourceId = i_resourceId;

    memset(&iv_msId, 0x00, sizeof(hdatMsAreaId_t));
    memset(&iv_msSize, 0x00, sizeof(hdatMsAreaSize_t));
    memset(&iv_aff, 0x00, sizeof(hdatMsAreaAffinity_t));

    iv_msId.hdatMsAreaId = i_msAreaId;

    //TODO : RTC Story 161864
    //For Nimbus based systems, FSI device path length is always zero so hard
    //coding the values
    //But for Cumulus/Centaur based systems, we need to get the actual data
    iv_msId.hdatFsiDevicePathLen = 0;
    memset(iv_msId.hdatFsiDevicePath, 0x00, 64);
  
    iv_addrRngArrayHdr.hdatOffset    = sizeof(hdatHDIFDataArray_t);
    iv_addrRngArrayHdr.hdatArrayCnt  = 0;
    iv_addrRngArrayHdr.hdatAllocSize = sizeof(hdatMsAreaAddrRange_t);
    iv_addrRngArrayHdr.hdatActSize   = sizeof(hdatMsAreaAddrRange_t);

    iv_ecArrayHdr.hdatOffset    = sizeof(hdatHDIFDataArray_t);
    iv_ecArrayHdr.hdatArrayCnt  = 0;
    iv_ecArrayHdr.hdatAllocSize = sizeof(hdatEcLvl_t);
    iv_ecArrayHdr.hdatActSize   = sizeof(hdatEcLvl_t);
    l_slcaIdx = i_slcaIdx;


    // If the ASCII keyword data and related info has been passed to us as a
    // parm, use it and avoid calling into svpd.  This is an IPL performance
    // improvement since all mainstore areas for an MCM will have the same
    // resource id and thus the same keyword VPD.
    if (i_kwdSize > 0)
    {
        l_slcaIdx = i_slcaIdx;
        iv_kwd = new char[i_kwdSize];
        memcpy(iv_kwd, i_kwd, i_kwdSize);
    }
    else
    {
        // Get the SLCA index and ASCII keyword for this resource id
        uint32_t l_num = sizeof(cvpdData)/sizeof(cvpdData[0]);
        size_t theSize[l_num];
        hdatGetAsciiKwdForMvpd(i_target,iv_kwdSize,iv_kwd,cvpdData,
                                    l_num,theSize);
        do
        {
            char *o_fmtKwd;
            uint32_t o_fmtkwdSize;
            o_errlHndl = hdatformatAsciiKwd(cvpdData , l_num , theSize, iv_kwd,
                iv_kwdSize, o_fmtKwd, o_fmtkwdSize, l_cvpdKeywords);
            if( o_fmtKwd != NULL )
            {
                delete[] iv_kwd;
                //padding extra 8 bytes to keep data sync as FSP
                iv_kwd = new char [o_fmtkwdSize + 8];
                memcpy(iv_kwd,o_fmtKwd,o_fmtkwdSize);
                iv_kwdSize = o_fmtkwdSize + 8;
                delete[] o_fmtKwd;
            }
        }while(0);
    }

    // Allocate space for the address range array
    if (NULL == o_errlHndl)
    {
        iv_addrRange = new hdatMsAreaAddrRange_t[iv_maxAddrRngCnt];
        memset(iv_addrRange,0,
                (sizeof(hdatMsAreaAddrRange_t) * iv_maxAddrRngCnt));
    }

    // Allocate space for the EC level array
    if (NULL == o_errlHndl)
    {
        iv_fru.hdatSlcaIdx = l_slcaIdx;
        iv_ecLvl = new hdatEcLvl_t[iv_maxEcCnt];
    }
    // Allocate space for the RAM entries
    if (NULL == o_errlHndl)
    {
        iv_ramPtrs = new HdatRam*[i_ramCnt];
    }

    HDAT_EXIT();
    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
HdatMsArea::~HdatMsArea()
{
    HDAT_ENTER( );

    uint32_t l_cnt;
    HdatRam *l_ramObj, **l_curPtr;

    // Delete RAM Objects
    l_curPtr = iv_ramPtrs;
    for (l_cnt = 0; l_cnt < iv_actRamCnt; l_cnt++)
    {
        l_ramObj = *l_curPtr;
        delete l_ramObj;
        l_curPtr = reinterpret_cast<HdatRam **>(reinterpret_cast<char*>(l_curPtr)
                    + sizeof(HdatRam *));
    }
    
    delete[] iv_msaI2cDataPtr;
    delete[] iv_kwd;
    delete[] iv_addrRange;
    delete[] iv_ecLvl;
    delete [] iv_ramPtrs;

    HDAT_EXIT();
    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::setParentType(uint16_t i_type)
{
    iv_msId.hdatMsAreaParentType = i_type;
    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::setStatus(uint16_t i_status)
{
    iv_msId.hdatMsAreaStatus = i_status;

    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::setInterleavedId(uint16_t i_id)
{
    iv_msId.hdatInterleavedId = i_id;

    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::setSize(uint32_t i_size)
{
    iv_msSize.hdatReserved1 = 0;
    iv_msSize.hdatMsAreaSize = i_size;

    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::setModuleId(uint32_t i_moduleId)
{
    iv_aff.hdatMsAreaModuleId = i_moduleId;

    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::setAffinityDomain(uint32_t i_affinityDomain)
{
    iv_aff.hdatMsAffinityDomain = i_affinityDomain;

    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::getKwdInfo(uint32_t &o_resourceId,
                                 uint32_t &o_slcaIdx,
                                 uint32_t &o_kwdSize,
                                 char *&o_kwd)
{
    o_resourceId = iv_fru.hdatResourceId;
    o_slcaIdx    = iv_fru.hdatSlcaIdx;
    o_kwdSize    = iv_kwdSize;
    o_kwd        = iv_kwd;

    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
errlHndl_t HdatMsArea::addAddrRange(hdatMsAddr_t &i_start,
                                    hdatMsAddr_t &i_end,
                                    uint32_t i_procChipId,
                                    bool i_rangeIsMirrorable,
                                    uint8_t i_mirroringAlgorithm,
                                    hdatMsAddr_t &i_startMirrAddr,
                                    uint32_t  i_memcntlrId)
{
    HDAT_ENTER();
    errlHndl_t l_errlHndl = NULL;
    hdatMsAreaAddrRange_t *l_addr;

    if (iv_addrRngArrayHdr.hdatArrayCnt < iv_maxAddrRngCnt)
    {
        l_addr = reinterpret_cast<hdatMsAreaAddrRange_t*>(
        reinterpret_cast<char*>(iv_addrRange) + iv_addrRngArrayHdr.hdatArrayCnt*
        sizeof(hdatMsAreaAddrRange_t));

        l_addr->hdatMsAreaStrAddr = i_start;
        l_addr->hdatMsAreaEndAddr = i_end;
        l_addr->hatMsAreaProcChipId = i_procChipId;
        l_addr->hdatSMMAttributes.hdatRangeIsMirrorable = 
                i_rangeIsMirrorable ? 1 : 0; 
        l_addr->hdatSMMAttributes.hdatMirroringAlgorithm = i_mirroringAlgorithm;
        l_addr->hdatStartMirrAddr = i_startMirrAddr;
        l_addr->hdatMsAreaMemCntId = i_memcntlrId;
        iv_addrRngArrayHdr.hdatArrayCnt++;
    }
    else
    {
        /*@
         * @errortype
         * @refcode LIC_REFCODE
         * @subsys EPUB_FIRMWARE_SP
         * @reasoncode RC_ERC_MAX_EXCEEDED
         * @moduleid MOD_ADD_ADDR_RANGE
         * @userdata1 current number of array entries
         * @userdata2 maximum number of array entries
         * @userdata3 ID number of mainstore area
         * @userdata4 none
         * @devdesc Failed trying to add another entry to a mainstore area 
         *          address range array
         */
        hdatBldErrLog(l_errlHndl,
                      MOD_ADD_ADDR_RANGE,         // SRC module ID
                      RC_ERC_MAX_EXCEEDED,        // SRC extended reference code
                      iv_addrRngArrayHdr.hdatArrayCnt, // SRC hex word 1
                      iv_maxAddrRngCnt,           // SRC hex word 2
                      iv_msId.hdatMsAreaId);      // SRC hex word 3
    }
    HDAT_EXIT();
    return l_errlHndl;
}


/** @brief See the prologue in hdatmsarea.H
 */
errlHndl_t HdatMsArea::addEcEntry(uint32_t i_manfId,
                                       uint32_t i_ecLvl)
{
    HDAT_ENTER();
    errlHndl_t l_errlHndl = NULL;
    hdatEcLvl_t *l_ec;


    if (iv_ecArrayHdr.hdatArrayCnt < iv_maxEcCnt)
    {
        l_ec = reinterpret_cast<hdatEcLvl_t*>(reinterpret_cast<char*>
        (iv_ecLvl) + iv_ecArrayHdr.hdatArrayCnt * sizeof(hdatEcLvl_t));
        l_ec->hdatChipManfId = i_manfId;
        l_ec->hdatChipEcLvl  = i_ecLvl;
        iv_ecArrayHdr.hdatArrayCnt++;
    }

    HDAT_EXIT();
    return l_errlHndl;
}

/** @brief See the prologue in hdatmsarea.H
 */ 
void HdatMsArea::setMsaI2cInfo(
    std::vector<hdatI2cData_t> &i_I2cDevEntries )
{
    HDAT_ENTER();
    // this is just header of 5 words. arrays start at 0x0014
    iv_msaI2cHdr.hdatOffset = sizeof(iv_msaI2cHdr);
    iv_msaI2cHdr.hdatArrayCnt = i_I2cDevEntries.size();
    iv_msaI2cHdr.hdatAllocSize = sizeof(hdatI2cData_t);
    iv_msaI2cHdr.hdatActSize = sizeof(hdatI2cData_t);
    iv_msaI2cHdr.hdatVersion = HOST_I2C_DEV_INFO_VERSION::V2;
    iv_msaHostI2cCnt = i_I2cDevEntries.size();
    iv_msaHostI2cSize = sizeof(iv_msaI2cHdr) +
        (sizeof(hdatI2cData_t) * iv_msaHostI2cCnt);
    HDAT_INF("iv_msaHostI2cCnt=%d, iv_msaHostI2cSize=%d",
        iv_msaHostI2cCnt, iv_msaHostI2cSize);
    if ( i_I2cDevEntries.size() != 0 )
    {
        iv_msaI2cDataPtr = new uint8_t[sizeof(hdatI2cData_t) * iv_msaHostI2cCnt];
        memcpy(iv_msaI2cDataPtr , i_I2cDevEntries.begin() ,
                    (sizeof(hdatI2cData_t) * iv_msaHostI2cCnt));  

    }
    else
    {
        HDAT_INF("Empty Host I2C device info vector : Ms Area Id=%d, Size=%d",
            iv_msId.hdatMsAreaId, i_I2cDevEntries.size());
    } 
    HDAT_EXIT();
}

/** @brief See the prologue in hdatmsarea.H
 */
errlHndl_t HdatMsArea::addRam(HdatRam &i_ram)
{
    HDAT_ENTER();
    errlHndl_t l_errlHndl = NULL;
    HdatRam **l_arrayEntry;
    uint32_t l_ramSize;

    if (iv_actRamCnt < iv_maxRamCnt)
    {
        l_arrayEntry =  reinterpret_cast<HdatRam**>(reinterpret_cast<char*>
        (iv_ramPtrs) + iv_actRamCnt * sizeof(HdatRam *));

        *l_arrayEntry = &i_ram;

        //Determine if the size of this RAM is larger than any other RAM objects
        // associated with this mainstore area
        l_ramSize = i_ram.size();
        if (l_ramSize != iv_maxRamObjSize)
        {
            // If not the first RAM object, then we have to pad some shorter
            // RAM object(s)
            if (iv_maxRamObjSize != 0)
            {
                iv_ramPadReq = true;
            }
            if (l_ramSize > iv_maxRamObjSize)
            {
                iv_maxRamObjSize = l_ramSize;
            }
        }

        iv_actRamCnt++;
    }
    else
    {
        /*@
         * @errortype
         * @refcode LIC_REFCODE
         * @subsys EPUB_FIRMWARE_SP
         * @reasoncode RC_ERC_MAX_EXCEEDED
         * @moduleid MOD_ADD_RAM
         * @userdata1 current number of array entries
         * @userdata2 maximum number of array entries
         * @userdata3 ID number of mainstore area
         * @userdata4 none
         * @devdesc Failed trying to add another entry to a mainstore area
         *          RAM array
         */

        HDAT_INF("Failed trying to add another entry to a mainstore area RAM "
                  "array %d",iv_actRamCnt);

        hdatBldErrLog(l_errlHndl,
                  MOD_ADD_RAM,           // SRC module ID
                  RC_ERC_MAX_EXCEEDED,  // SRC extended reference code
                  iv_actRamCnt,           // SRC hex word 1
                  iv_maxRamCnt,           // SRC hex word 2
                  iv_msId.hdatMsAreaId);  // SRC hex word 3 
    }
    HDAT_EXIT();
    return l_errlHndl;
}


/** @brief See the prologue in hdatmsarea.H
 */
uint32_t HdatMsArea::ramObjSizes()
{
    HDAT_ENTER();
    uint32_t l_size, l_cnt;
    HdatRam *l_ramObj;

    l_size = 0;

    // Process the RAM objects
    for (l_cnt = 0; l_cnt < iv_actRamCnt; l_cnt++)
    {
        l_ramObj = *(reinterpret_cast<HdatRam **>(reinterpret_cast<char*>
            (iv_ramPtrs) + l_cnt * sizeof(HdatRam *)));
        l_size += l_ramObj->size();
    }

    HDAT_EXIT();
    return l_size;
}


/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::finalizeObjSize()
{
    HDAT_ENTER();
    uint32_t l_idx;
    HdatRam **l_ramEntry;

    // Update the base class internal data pointers
    // When the data is written to the file by commit(), it must be done in the
    // same order as these addData() calls
    this->addData(HDAT_MS_AREA_FRU_ID, sizeof(hdatFruId_t));
    this->addData(HDAT_MS_AREA_KWD, iv_kwdSize);
    this->addData(HDAT_MS_AREA_ID, sizeof(hdatMsAreaId_t));
    this->addData(HDAT_MS_AREA_SIZE, sizeof(hdatMsAreaSize_t));
    this->addData(HDAT_MS_AREA_ADDR_RNG, sizeof(hdatHDIFDataArray_t) +
                  iv_maxAddrRngCnt * sizeof(hdatMsAreaAddrRange_t));

    this->addData(HDAT_MS_AREA_AFF, sizeof(hdatMsAreaAffinity_t));
    this->addData(HDAT_MS_AREA_EC_ARRAY, sizeof(hdatHDIFDataArray_t) +
                    iv_maxEcCnt * sizeof(hdatEcLvl_t));
    this->addData(HDAT_MS_AREA_HOST_I2C, iv_msaHostI2cSize);

    this->align();

    // If we have RAM objects of different sizes, the smaller ones have to be
    // padded to the size of the largest one so that PHYP can traverse through
    // the RAM objects as elements of an array.
    if (iv_ramPadReq)
    {
        for (l_idx = 0; l_idx < iv_actRamCnt; l_idx++)
        {
            l_ramEntry = (reinterpret_cast<HdatRam **>(reinterpret_cast<char*>
            (iv_ramPtrs) + l_idx * sizeof(HdatRam *)));

            if (iv_maxRamObjSize > (*l_ramEntry)->size())
	        {
                (*l_ramEntry)->maxSiblingSize(iv_maxRamObjSize);
	        }
	    }
    }

    // Update the base class for children that have been added
    for (l_idx = 0; l_idx < iv_actRamCnt; l_idx++)
    {
        l_ramEntry = (reinterpret_cast<HdatRam **>(reinterpret_cast<char*>
            (iv_ramPtrs) + l_idx * sizeof(HdatRam *)));
        this->addChild(HDAT_MS_AREA_RAM_AREAS, (*l_ramEntry)->size(), 1);
                                                    // 1st parm is 0 based
    }

    HDAT_EXIT();
    return;
}


/** @brief See the prologue in hdatmsarea.H
 */
uint32_t  HdatMsArea::getMsAreaSize()
{
    uint32_t l_size = 0;

    // Start committing the base class data
    l_size += this->getSize();

    // Write the various pieces of data from this derived class
    l_size += sizeof(hdatFruId_t);

    if ( iv_kwdSize > 0)
    {
        l_size += iv_kwdSize;
    }

    l_size += sizeof(hdatMsAreaId_t);

    l_size += sizeof(hdatMsAreaSize_t);

    l_size += sizeof(hdatHDIFDataArray_t);

    l_size += (iv_maxAddrRngCnt * sizeof(hdatMsAreaAddrRange_t));

    l_size += sizeof(hdatMsAreaAffinity_t);

    l_size += sizeof(hdatHDIFDataArray_t);

    l_size += (iv_maxEcCnt * sizeof(hdatEcLvl_t));

    l_size += sizeof(iv_msaI2cHdr);

    l_size += (sizeof(hdatI2cData_t) * iv_msaHostI2cCnt);

    l_size += this->endCommitSize();
    return l_size;
}


/** @brief See the prologue in hdatmsarea.H
 */
uint32_t HdatMsArea::getRamAreaSize()
{
    uint32_t l_size = 0, l_cnt = 0;
    HdatRam *l_ramObj;

    // Write the RAM structures
    if (iv_actRamCnt > 0)
    {
        l_cnt = 0;
        while (l_cnt < iv_actRamCnt)
        {
            l_ramObj = *(reinterpret_cast<HdatRam **>(reinterpret_cast<char*>
            (iv_ramPtrs) + l_cnt * sizeof(HdatRam *)));

            l_size += l_ramObj->getRamSize();
            l_cnt++;

        }
    }

    return l_size;
}
/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::commit(UtilMem &i_data)
{

    // Start committing the base class data
    this->startCommit(i_data);


    i_data.write(&iv_fru,sizeof(hdatFruId_t));

    if (iv_kwdSize > 0)
    {
        i_data.write(iv_kwd,iv_kwdSize);
    }


    i_data.write(&iv_msId,sizeof(hdatMsAreaId_t));


    i_data.write(&iv_msSize, sizeof(hdatMsAreaSize_t));

    i_data.write(&iv_addrRngArrayHdr,sizeof(hdatHDIFDataArray_t));

    i_data.write(iv_addrRange,iv_maxAddrRngCnt * sizeof(hdatMsAreaAddrRange_t));

    i_data.write(&iv_aff, sizeof(hdatMsAreaAffinity_t));

    i_data.write(&iv_ecArrayHdr, sizeof(hdatHDIFDataArray_t));

    i_data.write(iv_ecLvl,iv_maxEcCnt * sizeof(hdatEcLvl_t));

    i_data.write(&iv_msaI2cHdr, sizeof(iv_msaI2cHdr));

    if (NULL != iv_msaI2cDataPtr)
    {
        i_data.write(iv_msaI2cDataPtr,
            (iv_msaHostI2cSize - sizeof(iv_msaI2cHdr)));
    }

    this->endCommit(i_data);
}
/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::commitRamAreas(UtilMem &i_data)
{

    uint32_t l_cnt;
    HdatRam *l_ramObj;

    // Write the RAM structures
    if (iv_actRamCnt > 0)
    {      
        l_cnt = 0; 
        while (l_cnt < iv_actRamCnt)
        {
            l_ramObj = *(reinterpret_cast<HdatRam **>(reinterpret_cast<char*>
            (iv_ramPtrs) + l_cnt * sizeof(HdatRam *)));

            l_ramObj->commit(i_data);
            l_cnt++;

        }
    }
}



/** @brief See the prologue in hdatmsarea.H
 */
void HdatMsArea::prt()
{
    uint32_t l_cnt;
    hdatEcLvl_t *l_ec;
    hdatMsAreaAddrRange_t *l_addr;
    HdatRam *l_ramObj;

    HDAT_INF("  **** HdatMsArea start ****");
    HDAT_INF("      cv_actualCnt = %u", cv_actualCnt);
    HDAT_INF("      iv_kwdSize = %u", iv_kwdSize);
    HDAT_INF("      iv_maxAddrRngCnt = %u", iv_maxAddrRngCnt);
    HDAT_INF("      iv_maxEcCnt = %u", iv_maxEcCnt);
    HDAT_INF("      iv_maxRamCnt = %u", iv_maxRamCnt);
    HDAT_INF("      iv_actRamCnt = %u", iv_actRamCnt);
    this->print();
    //hdatPrintFruId(&iv_fru);
    hdatPrintKwd(iv_kwd, iv_kwdSize);

    HDAT_INF("  **hdatMsAreaId_t**");
    HDAT_INF("      hdatMsAreaId = %u", iv_msId.hdatMsAreaId);
    HDAT_INF("      hdatMsAreaParentType = %u", iv_msId.hdatMsAreaParentType);
    HDAT_INF("      hdatMsAreaStatus %u", iv_msId.hdatMsAreaStatus);

    HDAT_INF("  **hdatMsAreaSize_t**");
    HDAT_INF("      hdatMsAreaSize = %u", iv_msSize.hdatMsAreaSize);

    HDAT_INF("  **hdatMsAreaAddrRange_t**");
    hdatPrintHdrs(NULL, NULL, &iv_addrRngArrayHdr, NULL);
    l_addr = iv_addrRange;
    for (l_cnt = 0; l_cnt < iv_ecArrayHdr.hdatArrayCnt; l_cnt++)
    {
        HDAT_INF("      hdatMsAreaStrAddr = 0X %08X %08X ",
               l_addr->hdatMsAreaStrAddr.hi,
               l_addr->hdatMsAreaStrAddr.lo);
        HDAT_INF("      hdatMsAreaEndAddr = 0X %08X %08X ",
               l_addr->hdatMsAreaEndAddr.hi,
               l_addr->hdatMsAreaEndAddr.lo);
        HDAT_INF("      hatMsAreaProcChipId = %u", l_addr->hatMsAreaProcChipId);
        HDAT_INF("      hdatSMMAttributes.hdatRangeIsMirrorable = %u",
                    l_addr->hdatSMMAttributes.hdatRangeIsMirrorable);
        HDAT_INF("      hdatSMMAttributes.hdatMirroringAlgorithm = %u",
                    l_addr->hdatSMMAttributes.hdatMirroringAlgorithm);
        HDAT_INF("      hdatStartMirrAddr = 0X %08X %08X ",
                    l_addr->hdatStartMirrAddr.hi, l_addr->hdatStartMirrAddr.lo);
        l_addr++;
        l_cnt++;
    }
    HDAT_INF("");


    HDAT_INF("  **hdatMsAreaAffinity_t**");
    HDAT_INF("      hdatMsAreaModuleId = %u", iv_aff.hdatMsAreaModuleId);
    HDAT_INF("      hdatMsAffinityDomain = %u", iv_aff.hdatMsAffinityDomain);

    HDAT_INF("  **hdatEcLvl_t**");
    hdatPrintHdrs(NULL, NULL, &iv_ecArrayHdr, NULL);
    l_ec = iv_ecLvl;
    for (l_cnt = 0; l_cnt < iv_ecArrayHdr.hdatArrayCnt; l_cnt++)
    {
        HDAT_INF("      hdatChipManfId = %u", l_ec->hdatChipManfId);
        HDAT_INF("      hdatChipEcLvl = %u", l_ec->hdatChipEcLvl);
        l_ec++;
    }

    HDAT_INF("  **** HdatMsArea end ****");

    // Write the RAM structures
    if (iv_actRamCnt > 0)
    {
        HDAT_INF("  **associated RAM objects**");
        for(l_cnt = 0; l_cnt < iv_actRamCnt; l_cnt++)
        {
            l_ramObj = *(HdatRam **)((char *)iv_ramPtrs + l_cnt
            * sizeof(HdatRam *));
            l_ramObj->prt();
        }
    }

    return;
}
}
OpenPOWER on IntegriCloud