summaryrefslogtreecommitdiffstats
path: root/src/usr/vpd/ipvpd.H
blob: 4797cb3174a23b0d1fc6f788743c5402ae596c64 (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
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/vpd/ipvpd.H $                                         */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2013,2017                        */
/* [+] Google Inc.                                                        */
/* [+] 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 _VPD_IPVPD_H
#define _VPD_IPVPD_H


#include <list>
#include <pnor/pnorif.H>
#include <devicefw/driverif.H>
#include "vpd.H"

/** @file ipvpd.H
 *  @brief Provides base support for i/p-Series style IBM VPD
 */

/**
 *  @brief  Base class for i/p-Series VPD
 *
 */
class IpVpdFacade
{
  public:

    /**
     * @brief Miscellaneous IPVPD definitions
     */
    enum
    {
        RECORD_BYTE_SIZE        = 4,
        RECORD_ADDR_BYTE_SIZE   = 2,
        KEYWORD_BYTE_SIZE       = 2,
        KEYWORD_SIZE_BYTE_SIZE  = 1,
        RECORD_TOC_UNUSED       = 2,
        RT_SKIP_BYTES           = 3,
        VHDR_ECC_DATA_SIZE      = 11,
        VHDR_RESOURCE_ID_SIZE   = 1,
    };

    /**
     * @brief Structure representing the format of each record
     *      in the PT keyword of the VTOC or VHDR.
     */
    struct TocPtRecord {
        char record_name[4];
        // All uint16 fields are stored in little endian.
        uint16_t record_type;
        uint16_t record_offset;
        uint16_t record_length;
        uint16_t ecc_offset;
        uint16_t ecc_length;
    } PACKED;

    /**
     * @brief Structure for all VPD dd input parameter arguments
     */
    typedef struct
    {
        VPD::vpdRecord record;
        VPD::vpdKeyword keyword;
        VPD::vpdCmdTarget location;
    } input_args_t;

    /**
     * @brief Structure of information needed to access requested
     *      record/keyword combinations.
     */
    typedef struct
    {
        VPD::vpdRecord record;
        char recordName[RECORD_BYTE_SIZE+1];
    } recordInfo;

    /**
     */
    typedef struct
    {
        VPD::vpdKeyword keyword;
        char keywordName[KEYWORD_BYTE_SIZE+1];
    } keywordInfo;

    /**
     * @brief Structure defining where to read/write VPD data
     */
    typedef struct
    {
        bool vpdReadPNOR;
        bool vpdReadHW;
        bool vpdWritePNOR;
        bool vpdWriteHW;
    } configInfo;

    /**
     * @brief - Data Struct for TOC Entry
     */
    struct tocData
    {
        tocData()
        {
            bzero(asciiRec, sizeof(asciiRec));
            bzero(offset, sizeof(offset));
            bzero(unusedByte, sizeof(unusedByte));
        }

        uint8_t asciiRec[RECORD_BYTE_SIZE];
        uint8_t offset[RECORD_ADDR_BYTE_SIZE];
        uint8_t unusedByte[RECORD_ADDR_BYTE_SIZE];
    };

    /**
     * @brief  Constructor
     *
     * @param[in] i_vpdRecords -     Pointer to array of VPD Records to use
     *
     * @param[in] i_recSize -       size of i_vpdRecords array
     *
     * @param[in] i_vpdKeywords -    Pointer to array of VPD Keywords to use
     *
     * @param[in] i_keyCount -       size of i_vpdKeywords array
     *
     * @param[in] i_pnorSection -    PNOR Section containing VPD for current
     *                               chip
     *
     * @param[in] i_mutex -          Mutex to ensure instance variable updates
     *                               are thread safe
     *
     * @param[in] i_vpdMsgType -     Message type to use when sending write
     *                               data to FSP
     *
     */
    IpVpdFacade(const  recordInfo* i_vpdRecords,
                uint64_t i_recSize,
                const  keywordInfo* i_vpdKeywords,
                uint64_t i_keySize,
                PNOR::SectionId i_pnorSection,
                mutex_t i_mutex,
                VPD::VPD_MSG_TYPE i_vpdMsgType );


    /**
     * @brief This function will perform the steps required to do a read from
     *      the Hostboot I/P Series VPD data.
     *
     * @param[in] i_target -Target device
     *
     * @param [in/out] io_buffer - Pointer to the data that was read from
     *       the target device.  This parameter, when set to NULL, will return
     *       the keyword size value in io_buflen.
     *
     * @param [in/out] io_buflen - Length of the buffer to be read or written
     *       to/from the target.  This value should indicate the size of the
     *       io_buffer parameter that has been allocated.  Being returned it
     *       will indicate the number of valid bytes in the buffer being
     *       returned. This parameter will contain the size of a keyword when
     *       the io_buffer parameter is passed in NULL.
     *
     * @param [in] i_args - Records/Keyword struct
     *
     * @return errlHndl_t - NULL if successful, otherwise a pointer to the
     *       error log.
     */
    errlHndl_t read ( TARGETING::Target * i_target,
                      void* io_buffer,
                      size_t & io_buflen,
                      input_args_t i_args );

    /**
     * @brief This function will perform the steps required to do a write to
     *      the Hostboot I/P Series VPD data.
     *
     * @param[in] i_target -Target device
     *
     * @param [in/out] io_buffer - Pointer to the data that was read from
     *       the target device.  It will also be used to contain data to
     *       be written to the device.
     *
     * @param [in/out] io_buflen - Length of the buffer to be read or written
     *       to/from the target.  This value should indicate the size of the
     *       io_buffer parameter that has been allocated.  Being returned it
     *       willindicate the number of valid bytes in the buffer being
     *       returned.
     *
     * @param [in] i_args - Records/Keyword struct
     *
     * @return errlHndl_t - NULL if successful, otherwise a pointer to the
     *       error log.
     */
    errlHndl_t write ( TARGETING::Target * i_target,
                      void* io_buffer,
                      size_t & io_buflen,
                      input_args_t i_args );

    /**
     * @brief this function checks to see if the given target
     * is present.
     *
     * @param[in] i_target - target VPD to search for.
     *
     * @return - bool - true if vpd is present, false if it is not.
     */
    bool hasVpdPresent ( TARGETING::Target * i_target,
                         VPD::vpdRecord record,
                         VPD::vpdKeyword keyword );

    /**
     * @brief This function compares the specified record/keyword
     *      in PNOR/SEEPROM and returns the result.  A mismatch
     *      will not return an error.
     *
     * @param[in] i_target - Target device
     *
     * @param[in] i_record - Record to compare
     *
     * @param[in] i_keyword - Keyword to compare
     *
     * @param[out] o_match - Result of compare
     *
     * @return errlHndl_t - NULL if successful, otherwise a pointer to the
     *       error log.
     */
    errlHndl_t cmpPnorToSeeprom ( TARGETING::Target * i_target,
                                  VPD::vpdRecord i_record,
                                  VPD::vpdKeyword i_keyword,
                                  bool &o_match );

    /**
     * @brief This function compares the specified record/keyword
     *      in SEEPROM to zero and returns the result.  A mismatch
     *      will not return an error.
     *
     * @param[in] i_target - Target device
     *
     * @param[in] i_record - Record to compare
     *
     * @param[in] i_keyword - Keyword to compare
     *
     * @param[out] o_match - Result of compare
     *
     * @return errlHndl_t - NULL if successful, otherwise a pointer to the
     *       error log.
     */
    errlHndl_t cmpSeepromToZero ( TARGETING::Target * i_target,
                                  VPD::vpdRecord i_record,
                                  VPD::vpdKeyword i_keyword,
                                  bool &o_match );

    /**
     * @brief This function will perform the steps required to load the
     *      MVPD data from SEEPROM into the PNOR cache.
     *
     * @param[in] i_target - Target device
     *
     * @return errlHndl_t - NULL if successful, otherwise a pointer to the
     *       error log.
     */
    errlHndl_t loadPnor ( TARGETING::Target * i_target );

    /**
     * @brief This function will perform the steps required to invalidate
     *      the MVPD in the PNOR cache.
     *
     * @param[in] i_target - Target device
     *
     * @return errlHndl_t - NULL if successful, otherwise a pointer to the
     *       error log.
     */
    errlHndl_t invalidatePnor ( TARGETING::Target * i_target );

    /**
     * @brief This function sets the config flags to use HW and not PNOR
     */
    void setConfigFlagsHW ( );

  protected:

    /**
     * @brief This function will translate the enumeration for the VPD record
     *      into a char * variable to be used for comparing what was read from
     *      the VPD data.
     *
     * @param[in] i_record - The record enumeration.
     *
     * @param[out] o_record - The char representation of the record.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t translateRecord ( VPD::vpdRecord i_record,
                                 const char *& o_record );

    /**
     * @brief This function will translate the enumeration for the VPD keyword
     *      into a char * variable to be used for comparing what was read from
     *      the VPD data.
     *
     * @param[in] i_keyword - The keyword enumeration.
     *
     * @param[out] o_keyword - The char representation of the record.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t translateKeyword ( VPD::vpdKeyword i_keyword,
                                  const char *& o_keyword );

    /**
     * @brief This function calls the PNOR or EEPROM version of
     *      the findRecordOffset fuction based on the configInfo.
     *
     * @param[in] i_record - String value for the record to look for.
     *
     * @param[out] o_offset - The offset where the record is located.
     *
     * @param[in] i_rwPnorEnabled - Config value specifying
     *      whether PNOR reads/writes are enabled for this VPD type
     *
     * @param[in] i_rwHwEnabled - Config value specifying
     *      whether SEEPROM reads/writes are enabled for this VPD type
     *
     * @param[in] i_target - The target to retrieve the data for.
     *
     * @param[in] i_args - The input arguments.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t findRecordOffset ( const char * i_record,
                                  uint16_t & o_offset,
                                  bool i_rwPnorEnabled,
                                  bool i_rwHwEnabled,
                                  TARGETING::Target * i_target,
                                  input_args_t i_args );

    /**
     * @brief This function searches for the VPD record and returns
     * True if it is there, False otherwise. This function works similarly
     * to findRecordOffsetPnor except it does not create error logs if
     * the record was not found. This will replace some of the code in
     * findRecordOffsetPnor
     *
     * @param[in] i_record - String value for the record to look for.
     *
     * @param[out] offset - The offset where the record is located.
     *
     * @param[in] i_target - The target to retrieve the data for.
     *
     * @param[in] i_location - VPD location to fetch data from (PNOR/SEEPROM)
     *
     * @return bool - True if the record is found, False otherwise.
     */
    virtual bool recordPresent( const char * i_record,
                        uint16_t & offset,
                        TARGETING::Target * i_target,
                        VPD::vpdCmdTarget i_location );

    /**
     * @brief This function will read the VPD TOC to find the offset where the
     *      given record is located within the chunk of data.
     *
     * @param[in] i_record - String value for the record to look for.
     *
     * @param[out] o_offset - The offset where the record is located.
     *
     * @param[in] i_target - The target to retrieve the data for.
     *
     * @param[in] i_args - The input arguments.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t findRecordOffsetPnor ( const char * i_record,
                                      uint16_t & o_offset,
                                      TARGETING::Target * i_target,
                                      input_args_t i_args );

    /**
     * @brief This function will read the VPD VTOC to find the offset where the
     *      given record is located within the chunk of data.
     *
     * @param[in] i_record - String value for the record to look for.
     *
     * @param[out] o_offset - The offset where the record is located.
     *
     * @param[out] o_length - The length of the record.
     *
     * @param[in] i_target - The target to retrieve the data for.
     *
     * @param[in] i_args - The input arguments.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t findRecordOffsetSeeprom ( const char * i_record,
                                         uint16_t & o_offset,
                                         uint16_t & o_length,
                                         TARGETING::Target * i_target,
                                         input_args_t i_args );

    /**
     * @brief This function will scan the SEEPROM and return a list of VPD
     *      records for this target.
     *
     * @param[out] o_recList - The list of VPD records.
     *
     * @param[in] i_target - The target to retrieve the data for.
     *
     * @param[in] i_args - The input arguments.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t getRecordListSeeprom ( std::list<TocPtRecord> & o_recList,
                                      TARGETING::Target * i_target,
                                      input_args_t i_args );

    /**
     * @brief This function will read the required keyword from the VPD data.
     *
     * @param[in] i_keywordName - String representation of the keyword.
     *
     * @param[in] i_recordName - String representation of the record.
     *
     * @param[in] i_offset - The offset to start reading.
     *
     * @param[in] i_index - The index of the keyword to return if there are
     *       multiple instances of the same keyword.
     *
     * @param[in] i_target - The target to retrieve data for.
     *
     * @param[out] io_buffer - The buffer to place the data in.
     *
     * @param[in/out] io_buflen - Length of the buffer to be read or written
     *       to/from the target.  This value should indicate the size of the
     *       io_buffer parameter that has been allocated.  Being returned it
     *       will indicate the number of valid bytes in the buffer being
     *       returned.
     *
     * @param[in] i_args - The input arguments.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t retrieveKeyword ( const char * i_keywordName,
                                 const char * i_recordName,
                                 uint16_t i_offset,
                                 uint16_t i_index,
                                 TARGETING::Target * i_target,
                                 void * io_buffer,
                                 size_t & io_buflen,
                                 input_args_t i_args );

    /**
     * @brief This function will read the required record from the VPD data.
     *
     * @param[in] i_recordName - String representation of the record.
     *
     * @param[in] i_offset - The offset to start reading.
     *
     * @param[in] i_target - The target to retrieve data for.
     *
     * @param[out] io_buffer - The buffer to place the data in.
     *
     * @param[in/out] io_buflen - Length of the buffer to be read or written
     *       to/from the target.  This value should indicate the size of the
     *       io_buffer parameter that has been allocated.  Being returned it
     *       will indicate the number of valid bytes in the buffer being
     *       returned.
     *
     * @param[in] i_args - The input arguments.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t retrieveRecord ( const char * i_recordName,
                                 uint16_t i_offset,
                                 TARGETING::Target * i_target,
                                 void * io_buffer,
                                 size_t & io_buflen,
                                 input_args_t i_args );

    /**
     * @brief This function will write the required keyword into the VPD data.
     *
     * @param[in] i_keywordName - String representation of the keyword.
     *
     * @param[in] i_recordName - String representation of the record.
     *
     * @param[in] i_offset - The offset to start writing.
     *
     * @param[in] i_target - The target to write data for.
     *
     * @param[in] i_buffer - The buffer to pull the data from.
     *
     * @param[in] i_buflen - Length of the buffer to be written
     *       to the target's VPD area.  This value should indicate the
     *       size of the io_buffer parameter that has been allocated.
     *
     * @param[in] i_args - The input arguments.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t writeKeyword ( const char * i_keywordName,
                              const char * i_recordName,
                              uint16_t i_offset,
                              TARGETING::Target * i_target,
                              void * i_buffer,
                              size_t & i_buflen,
                              input_args_t i_args );

    /**
     * @brief This function will locate the byte address of a keyword
     *   within its VPD section.
     *
     * @param[in] i_keywordName - String representation of the keyword.
     *
     * @param[in] i_recordName - String representation of the record.
     *
     * @param[in] i_offset - The offset to start searching.
     *
     * @param[in] i_index - The index of the keyword to return if there are
     *    multiple instances of the same keyword.
     *
     * @param[in] i_target - The target to write data for.
     *
     * @param[out] o_keywordSize - Size of keyword in bytes.
     *
     * @param[out] o_byteAddr - Address of keyword, relative to this target's
     *    section.
     *
     * @param[in] i_args - The original input arguments.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t findKeywordAddr ( const char * i_keywordName,
                                 const char * i_recordName,
                                 uint16_t i_offset,
                                 uint16_t i_index,
                                 TARGETING::Target * i_target,
                                 size_t& o_keywordSize,
                                 uint64_t& o_byteAddr,
                                 input_args_t i_args );

    /**
     * @brief This function calls the PNOR or EEPROM version of
     *           the fetchData function based on the configInfo
     *
     * @param[in] i_byteAddr - The offset to be read.
     *
     * @param[in] i_numBytes - The number of bytes to read.
     *
     * @param[out] o_data - The data buffer where the data will be placed.
     *
     * @param[in] i_target - Target device.
     *
     * @param[in] i_location - VPD location to fetch data from (PNOR/SEEPROM)
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t fetchData ( uint64_t i_byteAddr,
                           size_t i_numBytes,
                           void * o_data,
                           TARGETING::Target * i_target,
                           VPD::vpdCmdTarget i_location );

    /**
     * @brief This function actually reads the data from PNOR
     *
     * @param[in] i_byteAddr - The offset to be read.
     *
     * @param[in] i_numBytes - The number of bytes to read.
     *
     * @param[out] o_data - The data buffer where the data will be placed.
     *
     * @param[in] i_target - Target device.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t fetchDataFromPnor ( uint64_t i_byteAddr,
                                   size_t i_numBytes,
                                   void * o_data,
                                   TARGETING::Target * i_target );

    /**
     * @brief This function actually reads the data from EEPROM
     *
     * @param[in] i_byteAddr - The offset to be read.
     *
     * @param[in] i_numBytes - The number of bytes to read.
     *
     * @param[out] o_data - The data buffer where the data will be placed.
     *
     * @param[in] i_target - Target device.
     *
     * @return errHndl_t - NULL if successful, otherwise a pointer to the
     *      error log.
     */
    errlHndl_t fetchDataFromEeprom ( uint64_t i_byteAddr,
                                     size_t i_numBytes,
                                     void * o_data,
                                     TARGETING::Target * i_target );


    /**
     * @brief This function compares 2 ipvpd record values.  Used for binary
     *       search to find a match.
     *
     * @param[in] e1 - Entry 1 to be compared.
     *
     * @param[in] e2 - Entry 2 to be compared.
     *
     * @return bool - Whether or not the e2 value is larger than the e1 value.
     */
    static bool compareKeywords ( const keywordInfo e1,
                                  const keywordInfo e2 );

    /**
     * @brief This function compares 2 vpd keyword values.  Used for binary
     *       search to find a match.
     *
     * @param[in] e1 - Entry 1 to be compared.
     *
     * @param[in] e2 - Entry 2 to be compared.
     *
     * @return bool - Whether or not the e2 value is larger than the e1 value.
     */
    static bool compareRecords ( const recordInfo e1,
                                 const recordInfo e2 );

    /**
     * @brief This function compares sizes to be sure buffers are large enough
     *      to handle the data to be put in them.  If it is not, it will return
     *      an error.
     *
     * @param[in] i_bufferSize - The size of the buffer to check.
     *
     * @param[in] i_expectedSize - The minimum size the buffer should be.
     *
     * @param[in] i_target - Target device. (Only used for error callout)
     *
     * @return errlHndl_t - An error log will be returned if the buffer is not
     *      large enough.
     */
    errlHndl_t checkBufferSize( size_t i_bufferSize,
                                size_t i_expectedSize,
                                TARGETING::Target * i_target );
    /**
     * @brief This function returns a primary and an alternate list of records
     *       that should be copied to pnor. The Alternate list is optional.
     *
     * @param[out] o_primaryVpdRecords - Pointer to array of VPD Records to use
     *
     * @param[out] o_primaryRecSize -    Size of o_primaryVpdRecords array
     *
     * @param[out] o_altVpdRecords -     Pointer to array of VPD Records to use
     *
     * @param[out] o_altRecSize -        Size of o_altVpdRecords array
     *
     */
    virtual void getRecordLists(
                const  recordInfo* & o_primaryVpdRecords,
                uint64_t           & o_primaryRecSize,
                const  recordInfo* & o_altVpdRecords,
                uint64_t           & o_altRecSize);

  protected: // Variables

    /**
     * @brief Indicates allocated space for each chip's VPD
     *        data in PNOR.
     */
    uint64_t iv_vpdSectionSize;

    /**
     * @brief Indicates number of VPD sections in PNOR for
     *        current type of chip
     */
    uint64_t iv_vpdMaxSections;


  public: // Variables
    /**
     * @brief Pointer to array of VPD Record information
     *
     */
    const recordInfo* iv_vpdRecords;

    /**
     * @brief Returns the cached pnor address
     *
     */
    inline static uint64_t getPnorAddr(const IpVpdFacade& x)
    {
        return x.iv_cachePnorAddr;
    }

    /**
     * @brief Set the cached pnor address to the given value
     *
     */
    inline void setPnorAddr(uint64_t i_pnorAddr)
    {
        this->iv_cachePnorAddr = i_pnorAddr;
    }

    /**
     * @brief Number of VPD Records for current chip
     *
     */
    uint64_t iv_recSize;

  protected: // Variables
    /**
     * @brief Pointer to array of VPD Keyword information
     *
     */
    const keywordInfo* iv_vpdKeywords;

    /**
     * @brief Number of VPD Keywords for current chip
     *
     */
    uint64_t iv_keySize;

    /**
     * @brief PNOR section enum for vpd type
     *
     */
    PNOR::SectionId iv_pnorSection;

    /**
     * @brief VPD Operation Mutex
     *
     */
    mutex_t iv_mutex;

    /**
     * @brief cached PNOR offset for VPD
     *
     */
    uint64_t iv_cachePnorAddr;

    /**
     * @brief cached PNOR offset for VPD
     *
     */
    VPD::VPD_MSG_TYPE iv_vpdMsgType;

    /**
     * @brief Config defining where to read/write
     *          VPD data
     */
    configInfo iv_configInfo;

    /**
     * @brief Boolean variable to denote if the pnor section was
     *        accessed for the MEMD section
     */
    bool iv_memdAccessed;

};



#endif /* _VPD_IPVPD_H */
OpenPOWER on IntegriCloud