summaryrefslogtreecommitdiffstats
path: root/src/usr/pnor/pnor_common.C
blob: c14e41b6ca4be9f36f1b27f252b4bfa1eb729d4d (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/pnor/pnor_common.C $                                  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,2015                        */
/* [+] 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                                                     */

#include "pnor_common.H"
#include <pnor/pnor_reasoncodes.H>

#include "ffs.h"           //Common header file with BuildingBlock.
#include "common/ffs_hb.H" //Hostboot def of user data in ffs_entry struct
#include <sys/mm.h>

#include <initservice/initserviceif.H>
#include <util/align.H>
#include <errl/errlmanager.H>

// Trace definition
trace_desc_t* g_trac_pnor = NULL;
TRAC_INIT(&g_trac_pnor, PNOR_COMP_NAME, 4*KILOBYTE, TRACE::BUFFER_SLOW); //4K

// Easy macro replace for unit testing
//#define TRACUCOMP(args...)  TRACFCOMP(args)
#define TRACUCOMP(args...)

/**
 * Eyecatcher strings for PNOR TOC entries
 */
const char* cv_EYECATCHER[] = {
    "part",      /**< PNOR::TOC            : Table of Contents */
    "HBI",       /**< PNOR::HB_EXT_CODE    : Hostboot Extended Image */
    "GLOBAL",    /**< PNOR::GLOBAL_DATA    : Global Data */
    "HBB",       /**< PNOR::HB_BASE_CODE   : Hostboot Base Image */
    "SBEC",      /**< PNOR::CENTAUR_SBE    : Centaur Self-Boot Engine image */
    "SBE",       /**< PNOR::SBE_IPL        : Self-Boot Enginer IPL image */
    "WINK",      /**< PNOR::WINK           : Sleep Winkle Reference image */
    "PAYLOAD",   /**< PNOR::PAYLOAD        : HAL/OPAL */
    "HBRT",      /**< PNOR::HB_RUNTIME     : Hostboot Runtime (for Sapphire) */
    "HBD",       /**< PNOR::HB_DATA        : Hostboot Data */
    "GUARD",     /**< PNOR::GUARD_DATA     : Hostboot Data */
    "HBEL",      /**< PNOR::HB_ERRLOGS     : Hostboot Error log Repository */
    "DJVPD",     /**< PNOR::DIMM_JEDEC_VPD : Dimm JEDEC VPD */
    "MVPD",      /**< PNOR::MODULE_VPD     : Module VPD */
    "CVPD",      /**< PNOR::CENTAUR_VPD    : Centaur VPD */
    "NVRAM",     /**< PNOR::NVRAM          : OPAL Storage */
    "OCC",       /**< PNOR::OCC            : OCC LID */
    "FIRDATA",   /**< PNOR::FIRDATA        : FIRDATA */
    "ATTR_TMP",  /**< PNOR::ATTR_TMP       : Temporary Attribute Overrides */
    "ATTR_PERM", /**< PNOR::ATTR_PERM      : Permanent Attribute Overrides */
    "CAPP",      /**< PNOR::CAPP           : CAPP LID */
    "VERSION",   /**< PNOR::VERSION        : PNOR Version string */
    "TEST",      /**< PNOR::TEST           : Test space for PNOR*/
    "TESTRO",    /**< PNOR::TESTRO         : ReadOnly Test space for PNOR */
    //Not currently used
//    "XXX",    /**< NUM_SECTIONS       : Used as invalid entry */
};

/**
 * @brief calculates the checksum on data(ffs header/entry) and will return
 *    0 if the checksums match
 */
uint32_t PNOR::pnor_ffs_checksum(void* data, size_t size)
{
    uint32_t checksum = 0;

    for (size_t i = 0; i < (size/4); i++)
    {
        checksum ^= ((uint32_t*)data)[i];
    }

    checksum = htobe32(checksum);
    return checksum;
}

/*
 * @brief determine the physical offset of the ffs entry
 *        (to be used before readTOC is called)
 */
void PNOR::findPhysicalOffset(ffs_hdr* i_tocAddress,
                                const char* i_entryName,
                                uint64_t & o_offset)
{
    for(uint32_t i = 0; i < i_tocAddress->entry_count; i++)
    {
        ffs_entry* l_curEntry = (&i_tocAddress->entries[i]);
        if(strcmp(i_entryName,l_curEntry->name) == 0)
        {
            o_offset = ((uint64_t)l_curEntry->base)*PAGESIZE;
            break;
        }
    }
}

/*
 * @brief used to translate mmio offset stored in mbox scratch 2
 *        to physical offset of HBB Image
 */
errlHndl_t  PNOR::mmioToPhysicalOffset(uint64_t& o_hbbAddress)
{
    errlHndl_t l_err = NULL;
    do
    {
        uint64_t l_hbbMMIO = 0;
        size_t l_size = sizeof(uint64_t);
        TARGETING::Target* l_masterProc =
            TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL;

        //MBOX_SCRATCH_REG2 = 0x5003A
        l_err = DeviceFW::deviceRead(l_masterProc, &l_hbbMMIO,l_size,
                DEVICE_SCOM_ADDRESS(SPLESS::MBOX_SCRATCH_REG2));
        if (l_err)
        {
            TRACFCOMP(g_trac_pnor,"PNOR::mmioToPhysicalOffset: Failed to read"
                    " HB MMIO offset");
            break;
        }
        //All SCOMS are 64-bit, HB MMIO is stored in higher 32-bits.
        //ANDing with TOP_OF_FLASH to maskout anything in the higher bits
        l_hbbMMIO    = (l_hbbMMIO >> 32) & PNOR::LPC_TOP_OF_FLASH_OFFSET;
        o_hbbAddress = ((9*l_hbbMMIO) - (9*PNOR::LPC_SFC_MMIO_OFFSET)
                                 - PNOR::PNOR_SIZE) /8;
    } while (0);
    return l_err;
}

/*
 * @brief used to translate HBB Address to MMIO offset
 */
void  PNOR::physicalToMmioOffset(uint64_t  i_hbbAddress,
                                 uint64_t& o_mmioOffset)
{
    //Left shifting 32-bits because SCOMS store a 64-bit value
    //and HBB Offset is stored in the higher 32-bits
    o_mmioOffset = ((PNOR::LPC_SFC_MMIO_OFFSET + i_hbbAddress +
                   ((PNOR::PNOR_SIZE - i_hbbAddress)/9)) |
                   PNOR::LPC_FW_SPACE) << 32;
}

/*
 *  @brief: parse the TOCs read from memory and store section information
 *          from one of the verified TOCs
 */
errlHndl_t PNOR::parseTOC(uint8_t* i_toc0Buffer, uint8_t* i_toc1Buffer,
           TOCS & o_TOC_used, SectionData_t * o_TOC, uint64_t i_baseVAddr)
{
    TRACUCOMP(g_trac_pnor,"PNOR::parseTOC>");
    errlHndl_t l_errhdl = NULL;

    bool TOC_0_failed = false;

    do{
        o_TOC_used = TOC_0;

        for (TOCS cur_TOC = TOC_0; cur_TOC < NUM_TOCS;
            cur_TOC = (TOCS)(cur_TOC+1))
        {
            TRACFCOMP(g_trac_pnor, "PNOR::parseTOC verifying TOC: %d",cur_TOC);
            uint64_t nextVAddr = i_baseVAddr;

            // Zero out my table
            for( size_t id = PNOR::FIRST_SECTION;
                 id <= PNOR::NUM_SECTIONS; //include extra entry for error paths
                 ++id )
            {
                o_TOC[id].id = (PNOR::SectionId)id;
                //everything else should default to zero
            }
            // Read TOC information from TOC 0 and then TOC 1
            ffs_hdr* l_ffs_hdr;
            if (cur_TOC == 0)
            {
                l_ffs_hdr = (ffs_hdr*) i_toc0Buffer;
            }
            else if (cur_TOC == 1)
            {
                l_ffs_hdr = (ffs_hdr*) i_toc1Buffer;
            }

            // ffs entry check, 0 if checksums match
            if( PNOR::pnor_ffs_checksum(l_ffs_hdr, FFS_HDR_SIZE) != 0)
            {
                //@TODO - RTC:90780 - May need to handle this differently
                // in SP-less config
                TRACFCOMP(g_trac_pnor,"PNOR::parseTOC pnor_ffs_checksum header"
                        " checksums do not match.");
                if (cur_TOC == 0)
                {
                    TRACFCOMP(g_trac_pnor, "PNOR::parseTOC TOC 0 failed header checksum");
                    TOC_0_failed = true;
                    o_TOC_used = TOC_1;
                    continue;
                }
                else if (cur_TOC == TOC_1 && TOC_0_failed)
                {
                    // Both TOC's failed
                    TRACFCOMP(g_trac_pnor, "PNOR::parseTOC both TOCs are corrupted");
                    /*@
                     * @errortype
                     * @moduleid   PNOR::MOD_PNORCOMMON_PARSETOC
                     * @reasoncode PNOR::RC_CORRUPTED_TOCS
                     * @devdesc    Both TOCs are corruputed
                     */
                    //@todo Add PNOR callout RTC:116145
                    l_errhdl = new ERRORLOG::ErrlEntry
                               (ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                PNOR::MOD_PNORCOMMON_PARSETOC,
                                PNOR::RC_CORRUPTED_TOCS,
                                0, 0, true);
                    break;
                }
                else
                {
                    // TOC 1 failed
                    TRACFCOMP(g_trac_pnor, "PNOR::parseTOC TOC 1 failed header checksum");
                    break;
                }
            }

            // Only check header if on first TOC or the first TOC failed
            if (cur_TOC == TOC_0 || TOC_0_failed)
            {
                TRACFCOMP(g_trac_pnor, "PNOR::parseTOC: FFS Block size=0x%.8X,"
                 " Partition Table Size = 0x%.8x, entry_count=%d",
                 l_ffs_hdr->block_size,l_ffs_hdr->size,l_ffs_hdr->entry_count);

                uint64_t spaceUsed = (sizeof(ffs_entry))*l_ffs_hdr->entry_count;

                /* Checking FFS Header to make sure it looks valid */
                bool header_good = true;
                if(l_ffs_hdr->magic != FFS_MAGIC)
                {
                    TRACFCOMP(g_trac_pnor, "E>PNOR::parseTOC: Invalid magic"
                            " number in FFS header: 0x%.4X",l_ffs_hdr->magic);
                    header_good = false;
                }
                else if(l_ffs_hdr->version != SUPPORTED_FFS_VERSION)
                {
                    TRACFCOMP(g_trac_pnor, "E>PNOR::parseTOC:Unsupported FFS"
                            " Header version: 0x%.4X", l_ffs_hdr->version);
                    header_good = false;
                }
                else if(l_ffs_hdr->entry_size != sizeof(ffs_entry))
                {
                    TRACFCOMP(g_trac_pnor, "E>PNOR::parseTOC: Unexpected"
                            " entry_size(0x%.8x) in FFS header: 0x%.4X",
                            l_ffs_hdr->entry_size);
                    header_good = false;
                }
                else if(l_ffs_hdr->entries == NULL)
                {
                    TRACFCOMP(g_trac_pnor, "E>PNOR::parseTOC:"
                            "  FFS Header pointer to entries is NULL.");
                    header_good = false;
                }
                else if(l_ffs_hdr->block_size != PAGESIZE)
                {
                    TRACFCOMP(g_trac_pnor, "E>PNOR::parseTOC:  Unsupported"
                            " Block Size(0x%.4X). PNOR Blocks must be 4k",
                              l_ffs_hdr->block_size);
                    header_good = false;
                }
                else if(l_ffs_hdr->block_count == 0)
                {
                    TRACFCOMP(g_trac_pnor, "E>PNOR::parseTOC:  Unsupported"
                            " Block COunt(0x%.4X). Device cannot be zero"
                            " blocks in length.",l_ffs_hdr->block_count);
                    header_good = false;
                }
                //Make sure all the entries fit in specified partition
                //table size
                else if(spaceUsed >
                    ((l_ffs_hdr->block_size*l_ffs_hdr->size)-sizeof(ffs_hdr)))
                {
                    TRACFCOMP(g_trac_pnor, "E>PNOR::parseTOC:  FFS Entries"
                            " (0x%.16X) go past end of FFS Table.",spaceUsed);
                    header_good = false;
                }

                if(!header_good)
                {
                    //Shutdown if we detected a partition table issue
                    //for any reason
                    if (TOC_0_failed)
                    {
                       /*@
                        * @errortype
                        * @moduleid   PNOR::MOD_PNORCOMMON_PARSETOC
                        * @reasoncode PNOR::RC_BAD_TOC_HEADER
                        * @devdesc    TOC 0 doesn't have a good header
                        */
                        l_errhdl = new ERRORLOG::ErrlEntry
                                             (ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                              PNOR::MOD_PNORCOMMON_PARSETOC,
                                              PNOR::RC_BAD_TOC_HEADER,
                                              0, 0, true);
                        break;
                    }
                    else
                    {
                        TOC_0_failed = true;
                    }
                    //Try TOC1
                    continue;
                }
            }

            ffs_hb_user_t* ffsUserData = NULL;

            //Walk through all the entries in the table and parse the data.
            for(uint32_t i=0; i<l_ffs_hdr->entry_count; i++)
            {
                ffs_entry* cur_entry = (&l_ffs_hdr->entries[i]);

                TRACUCOMP(g_trac_pnor, "PNOR::parseTOC:  Entry %d, name=%s, "
                        "pointer=0x%X",i,cur_entry->name, (uint64_t)cur_entry);

                uint32_t secId = PNOR::INVALID_SECTION;

                // ffs entry check, 0 if checksums match
                if( PNOR::pnor_ffs_checksum(cur_entry, FFS_ENTRY_SIZE) != 0)
                {
                    //@TODO - RTC:90780 - May need to handle this differently
                    // in SP-less config
                    TRACFCOMP(g_trac_pnor, "PNOR::parseTOC pnor_ffs_checksum"
                            " entry checksums do not match");
                    if (cur_TOC == TOC_0)
                    {
                        TRACFCOMP(g_trac_pnor,"PNOR::parseTOC TOC 0 entry"
                                " checksum failed");
                        TOC_0_failed = true;
                        o_TOC_used = TOC_1;
                        break;
                    }
                    else if (cur_TOC == TOC_1 && TOC_0_failed)
                    {
                        // Both TOC's failed
                        TRACFCOMP(g_trac_pnor, "PNOR::parseTOC both TOC's are"
                                  " corrupted");
                       /*@
                        * @errortype
                        * @moduleid   PNOR::MOD_PNORCOMMON_PARSETOC
                        * @reasoncode PNOR::RC_PARTITION_TABLE_INVALID
                        * @devdesc    Both TOCs are corrupted
                        */
                        l_errhdl = new ERRORLOG::ErrlEntry
                                             (ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                              PNOR::MOD_PNORCOMMON_PARSETOC,
                                              PNOR::RC_PARTITION_TABLE_INVALID,
                                              0, 0, true);
                        break;
                    }
                    else
                    {
                        // TOC 1 failed
                        TRACFCOMP(g_trac_pnor, "PNOR::parseTOC TOC 1 entry"
                                " checksum failed");
                        break;
                    }
                }

                // Only set data if on first TOC or the first TOC failed
                if (cur_TOC == TOC_0 || TOC_0_failed)
                {
                    //Figure out section enum
                    for(uint32_t eyeIndex=PNOR::TOC;eyeIndex<PNOR::NUM_SECTIONS;
                                     eyeIndex++)
                    {
                        if(strcmp(cv_EYECATCHER[eyeIndex],cur_entry->name) == 0)
                        {
                            secId = eyeIndex;
                            TRACUCOMP(g_trac_pnor, "PNOR::parseTOC: sectionId=%d", secId);
                            break;
                        }
                    }

                    if(secId == PNOR::INVALID_SECTION)
                    {
                        TRACFCOMP(g_trac_pnor, "PNOR::parseTOC:  Unrecognized"
                                " Section name(%s), skipping",cur_entry->name);
                        continue;
                    }

                    ffsUserData = (ffs_hb_user_t*)&(cur_entry->user);

                    //size
                    o_TOC[secId].size = ((uint64_t)cur_entry->size)*PAGESIZE;

                    //virtAddr
                    o_TOC[secId].virtAddr = nextVAddr;
                    nextVAddr += o_TOC[secId].size;

                    //flashAddr
                    o_TOC[secId].flashAddr=((uint64_t)cur_entry->base)*PAGESIZE;

                    //chipSelect
                    o_TOC[secId].chip = ffsUserData->chip;

                    //user data
                    o_TOC[secId].integrity = ffsUserData->dataInteg;
                    o_TOC[secId].version = ffsUserData->verCheck;
                    o_TOC[secId].misc = ffsUserData->miscFlags;

                    TRACFCOMP(g_trac_pnor,"PNOR::parseTOC: User Data %s",
                            cur_entry->name);

                    if (o_TOC[secId].integrity == FFS_INTEG_ECC_PROTECT)
                    {
                        TRACFCOMP(g_trac_pnor, "PNOR::TOC: ECC enabled for %s",
                                cur_entry->name);
                        o_TOC[secId].size = ALIGN_PAGE_DOWN
                                            ((o_TOC[secId].size * 8 ) / 9);
                    }

                    // TODO RTC:96009 handle version header w/secureboot
                    if (o_TOC[secId].version == FFS_VERS_SHA512)
                    {
                        TRACFCOMP(g_trac_pnor, "PNOR::parseTOC: Incrementing"
                                " Flash Address for SHA Header");
                        if (o_TOC[secId].integrity == FFS_INTEG_ECC_PROTECT)
                        {
                            o_TOC[secId].flashAddr += PAGESIZE_PLUS_ECC;
                        }
                        else
                        {
                            o_TOC[secId].flashAddr += PAGESIZE;
                        }
                    }

                    if((o_TOC[secId].flashAddr + o_TOC[secId].size) >
                            (l_ffs_hdr->block_count*PAGESIZE))
                    {
                        TRACFCOMP(g_trac_pnor, "E>PNOR::parseTOC:Partition(%s)"
                                " at base address (0x%.8x) extends past end of"
                                " flash device",cur_entry->name,
                                o_TOC[secId].flashAddr);
                       /*@
                        * @errortype
                        * @moduleid   PNOR::MOD_PNORCOMMON_PARSETOC
                        * @reasoncode PNOR::RC_SECTION_SIZE_IS_BIG
                        * @devdesc    Invalid partition table
                        */
                        l_errhdl = new ERRORLOG::ErrlEntry
                                             (ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                              PNOR::MOD_PNORCOMMON_PARSETOC,
                                              PNOR::RC_SECTION_SIZE_IS_BIG,
                                              0, 0, true);
                        break;
                    }

#ifndef __HOSTBOOT_RUNTIME
                    // Handle section permissions
                    if (o_TOC[secId].misc & FFS_MISC_READ_ONLY)
                    {
                        // Need to set permissions to allow writing to virtual
                        // addresses, but prevents the kernel from ejecting
                        // dirty pages (no WRITE_TRACKED).
                        int rc = mm_set_permission(
                                                (void*)o_TOC[secId].virtAddr,
                                                o_TOC[secId].size,
                                                WRITABLE);
                        if (rc)
                        {
                            TRACFCOMP(g_trac_pnor, "E>PnorRP::readTOC: Failed to set block permissions to WRITABLE for section %s.",
                                      cv_EYECATCHER[secId]);
                            /*@
                            * @errortype
                            * @moduleid PNOR::MOD_PNORRP_READTOC
                            * @reasoncode PNOR::RC_WRITABLE_PERM_FAIL
                            * @userdata1 PNOR section id
                            * @userdata2 PNOR section vaddr
                            * @devdesc Could not set permissions of the
                            * given PNOR section to WRITABLE
                            * @custdesc A problem occurred while reading PNOR partition table
                            */
                            l_errhdl = new ERRORLOG::ErrlEntry(
                                            ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                            PNOR::MOD_PNORRP_READTOC,
                                            PNOR::RC_WRITABLE_PERM_FAIL,
                                            secId,
                                            o_TOC[secId].virtAddr,
                                            true /*Add HB SW Callout*/);
                            l_errhdl->collectTrace(PNOR_COMP_NAME);
                        }
                    }
                    else
                    {
                        // Need to set permissions to R/W
                        int rc = mm_set_permission(
                                            (void*)o_TOC[secId].virtAddr,
                                            o_TOC[secId].size,
                                            WRITABLE | WRITE_TRACKED);
                        if (rc)
                        {
                            TRACFCOMP(g_trac_pnor, "E>PnorRP::readTOC: Failed to set block permissions to WRITABLE/WRITE_TRACKED for section %s.",
                                      cv_EYECATCHER[secId]);
                            /*@
                            * @errortype
                            * @moduleid PNOR::MOD_PNORRP_READTOC
                            * @reasoncode PNOR::RC_WRITE_TRACKED_PERM_FAIL
                            * @userdata1 PNOR section id
                            * @userdata2 PNOR section vaddr
                            * @devdesc Could not set permissions of the
                            * given PNOR section to
                            * WRITABLE/WRITE_TRACKED
                            * @custdesc A problem occurred while reading
                            * PNOR partition table
                            */
                            l_errhdl = new ERRORLOG::ErrlEntry(
                                            ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                                            PNOR::MOD_PNORRP_READTOC,
                                            PNOR::RC_WRITE_TRACKED_PERM_FAIL,
                                            secId,
                                            o_TOC[secId].virtAddr,
                                            true /*Add HB SW Callout*/);
                            l_errhdl->collectTrace(PNOR_COMP_NAME);
                        }
                    }
#endif
                    if( l_errhdl )
                    {
                        // If both toc0 and toc1 fail break and return the error
                        if ( (cur_TOC == TOC_1) && (TOC_0_failed) )
                        {
                            TRACFCOMP(g_trac_pnor, "PNOR::parseTOC readFromDevice Failed on both TOCs");
                            break;
                        }

                        // Toc 1 has not been read yet or Toc 0 was read
                        // successfully
                        // Commit error and break to continue checking the next
                        // TOC
                        else
                        {
                            TRACFCOMP(g_trac_pnor, "PNOR::parseTOC readFromDevice Failed on TOC %d, commit error",
                                      cur_TOC);
                            errlCommit(l_errhdl,PNOR_COMP_ID);
                            l_errhdl = NULL;
                            break;
                        }
                    }
                }
            } // For TOC Entries
            if (l_errhdl)
            {
                break;
            }
            if (!TOC_0_failed)
            {
                //if we find a working TOC we don't need to loop again.
                //In runtime case, OPAL returns a working TOC.
                //So, we don't want to look at the second one.
                break;
            }
        } // For TOC's
        if (l_errhdl)
        {
            break;
        }
    } while(0);

    for(PNOR::SectionId tmpId = PNOR::FIRST_SECTION;
        tmpId < PNOR::NUM_SECTIONS;
        tmpId = (PNOR::SectionId) (tmpId + 1) )
    {
        TRACFCOMP(g_trac_pnor, "%s:    size=0x%.8X  flash=0x%.8X  "
               "virt=0x%.16X", cv_EYECATCHER[tmpId], o_TOC[tmpId].size,
               o_TOC[tmpId].flashAddr, o_TOC[tmpId].virtAddr );
    }

    TRACUCOMP(g_trac_pnor, "< PNOR::parseTOC" );
    return l_errhdl;
}

OpenPOWER on IntegriCloud