summaryrefslogtreecommitdiffstats
path: root/src/usr/isteps/istep13/hbVddrMsg.C
blob: 0c253f9a5a8208b6449ffafb8a60bc26384a2275 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/isteps/istep13/hbVddrMsg.C $                          */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2012,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 <sys/task.h>
#include <stdlib.h>
#include <string.h>
#include <sys/msg.h>
#include <sys/mm.h>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <trace/interface.H>
#include <trace/trace.H>
#include <mbox/mbox_queues.H>
#include <mbox/mboxif.H>

#include "hbVddrMsg.H"
#include <initservice/initserviceif.H>
#include <pnor/pnorif.H>
#include "platform_vddr.H"


using namespace ERRORLOG;
using namespace TARGETING;

// Trace definition
trace_desc_t* g_trac_volt = NULL;
TRAC_INIT(&g_trac_volt, "HB_VDDR", 1024);

///////////////////////////////////////////////////////////////////////////////
// HBVddrMsg::HBVddrMsg()
///////////////////////////////////////////////////////////////////////////////
HBVddrMsg::HBVddrMsg()
{
    TRACDCOMP( g_trac_volt, ENTER_MRK "HBVddrMsg::HBVddrMsg()" );
    TRACDCOMP( g_trac_volt, EXIT_MRK "HBVddrMsg::HBVddrMsg()" );

};

///////////////////////////////////////////////////////////////////////////////
// HBVddrMsg::~HBVddrMsg()
///////////////////////////////////////////////////////////////////////////////
HBVddrMsg::~HBVddrMsg()
{
    TRACDCOMP( g_trac_volt, ENTER_MRK "HBVddrMsg::~HBVddrMsg()" );
    TRACDCOMP( g_trac_volt, EXIT_MRK "HBVddrMsg::~HBVddrMsg()" );
};


///////////////////////////////////////////////////////////////////////////////
// compareVids
///////////////////////////////////////////////////////////////////////////////

bool compareVids(
    HBVddrMsg::hwsvPowrMemVoltDomainRequest_t i_lhs,
    HBVddrMsg::hwsvPowrMemVoltDomainRequest_t i_rhs)
{
    bool lhsLogicallyBeforeRhs = (i_lhs.domain < i_rhs.domain);

    if (i_lhs.domain == i_rhs.domain)
    {
        lhsLogicallyBeforeRhs = (  static_cast<uint16_t>(i_lhs.domainId)
                                 < static_cast<uint16_t>(i_rhs.domainId) );
    }

    return lhsLogicallyBeforeRhs;
}

///////////////////////////////////////////////////////////////////////////////
// areVidsEqual
///////////////////////////////////////////////////////////////////////////////

bool areVidsEqual(
    HBVddrMsg::hwsvPowrMemVoltDomainRequest_t i_lhs,
    HBVddrMsg::hwsvPowrMemVoltDomainRequest_t i_rhs)
{
    return(   (   i_lhs.domain
               == i_rhs.domain)
           && (   static_cast<uint16_t>(i_lhs.domainId)
               == static_cast<uint16_t>(i_rhs.domainId)) );
}

///////////////////////////////////////////////////////////////////////////////
// isUnusedVoltageDomain
///////////////////////////////////////////////////////////////////////////////

bool isUnusedVoltageDomain(
    HBVddrMsg::hwsvPowrMemVoltDomainRequest_t i_vid)
{
    return (!i_vid.voltageMillivolts);
}

//******************************************************************************
// addMemoryVoltageDomains (templated)
//******************************************************************************

template<
    const ATTRIBUTE_ID OFFSET_DISABLEMENT_ATTR,
    const ATTRIBUTE_ID VOLTAGE_ATTR_WHEN_OFFSET_ENABLED,
    const ATTRIBUTE_ID VOLTAGE_ATTR_WHEN_OFFSET_DISABLED,
    const ATTRIBUTE_ID VOLTAGE_DOMAIN_ID_ATTR >
void HBVddrMsg::addMemoryVoltageDomains(
    const TARGETING::Target* const     i_pMembuf,
          HBVddrMsg::RequestContainer& io_domains) const
{
    assert(
        (i_pMembuf != NULL),
        "HBVddrMsg::addMemoryVoltageDomains: Code bug!  Caller passed NULL "
        "memory buffer target handle.");

    assert(
        (    (   i_pMembuf->getAttr<TARGETING::ATTR_CLASS>()
              == TARGETING::CLASS_CHIP)
          && (   i_pMembuf->getAttr<TARGETING::ATTR_TYPE>()
              == TARGETING::TYPE_MEMBUF)),
        "HBVddrMsg::addMemoryVoltageDomains: Code bug!  Caller passed non-"
        "memory buffer target handle of class = 0x%08X and type of 0x%08X.",
        i_pMembuf->getAttr<TARGETING::ATTR_CLASS>(),
        i_pMembuf->getAttr<TARGETING::ATTR_TYPE>());

    TARGETING::Target* pSysTarget = NULL;
    TARGETING::targetService().getTopLevelTarget(pSysTarget);

    assert(
        (pSysTarget != NULL),
        "HBVddrMsg::addMemoryVoltageDomains: Code bug!  System target was "
        "NULL.");

    typename AttributeTraits< OFFSET_DISABLEMENT_ATTR >::Type
        disableOffsetVoltage =
            pSysTarget->getAttr< OFFSET_DISABLEMENT_ATTR >();

    assert(
        (disableOffsetVoltage <= true),
        "HBVddrMsg::addMemoryVoltageDomains: Code Bug!  Unsupported "
        "value of 0x%02X for attribute ID of 0x%08X.",
        disableOffsetVoltage,
        OFFSET_DISABLEMENT_ATTR);

    // Initialized by constructor to invalid defaults
    HBVddrMsg::hwsvPowrMemVoltDomainRequest_t entry;

    switch(VOLTAGE_DOMAIN_ID_ATTR)
    {
        case TARGETING::ATTR_VMEM_ID:
            entry.domain = MEM_VOLTAGE_DOMAIN_VDDR;
            break;
        case TARGETING::ATTR_VCS_ID:
            entry.domain = MEM_VOLTAGE_DOMAIN_VCS;
            break;
        case TARGETING::ATTR_VPP_ID:
            entry.domain = MEM_VOLTAGE_DOMAIN_VPP;
            break;
        case TARGETING::ATTR_AVDD_ID:
            entry.domain = MEM_VOLTAGE_DOMAIN_AVDD;
            break;
        case TARGETING::ATTR_VDD_ID:
            entry.domain = MEM_VOLTAGE_DOMAIN_VDD;
            break;
        default:
            assert(
                0,
                "HBVddrMsg::addMemoryVoltageDomains: Code Bug!  Unsupported "
                "voltage domain of 0x%08X.",
                VOLTAGE_DOMAIN_ID_ATTR);
            break;
    }

    // There is no reasonable check to validate if a voltage ID we're reading
    // is valid so it has to be assumed good
    entry.domainId = i_pMembuf->getAttr< VOLTAGE_DOMAIN_ID_ATTR >();

    // There is no reasonable check to validate if a voltage we're
    // reading is valid so it has to be assumed good for the cases below
    if(!disableOffsetVoltage)
    {
        typename
        TARGETING::AttributeTraits< VOLTAGE_ATTR_WHEN_OFFSET_ENABLED >::Type
            voltageMillivolts
                = i_pMembuf->getAttr< VOLTAGE_ATTR_WHEN_OFFSET_ENABLED >();

        entry.voltageMillivolts = static_cast<uint32_t>(voltageMillivolts);
        io_domains.push_back(entry);
    }
    else if(   VOLTAGE_ATTR_WHEN_OFFSET_DISABLED
            != VOLTAGE_ATTR_WHEN_OFFSET_ENABLED)
    {
        typename
        TARGETING::AttributeTraits< VOLTAGE_ATTR_WHEN_OFFSET_DISABLED >::Type
            voltageMillivolts
                = i_pMembuf->getAttr< VOLTAGE_ATTR_WHEN_OFFSET_DISABLED >();

        entry.voltageMillivolts = static_cast<uint32_t>(voltageMillivolts);
        io_domains.push_back(entry);
    }
}

///////////////////////////////////////////////////////////////////////////////
// HBVddrMsg::createVddrData
///////////////////////////////////////////////////////////////////////////////

void HBVddrMsg::createVddrData(
          VDDR_MSG_TYPE     i_requestType,
          RequestContainer& io_request) const
{
    TRACFCOMP( g_trac_volt, ENTER_MRK "HBVddrMsg::createVddrData" );

    // Go through all the memory buffers and gather their domains, domain
    // specific IDs, and domain specific voltages
    io_request.clear();

    do{

        TARGETING::TargetHandleList membufTargetList;
        //When request is a disable command, disable all present Centaurs
        // in case we go through a reconfigure loop
        if(i_requestType == HB_VDDR_DISABLE)
        {
            getChipResources( membufTargetList, TYPE_MEMBUF,
                              UTIL_FILTER_PRESENT );
        }
        //When the request is an enable command, enable only functional
        // centaurs.
        else
        {
            getAllChips(membufTargetList, TYPE_MEMBUF);
        }

        TARGETING::Target* pMembuf =NULL;
        for (TARGETING::TargetHandleList::const_iterator
                ppMembuf = membufTargetList.begin();
             ppMembuf != membufTargetList.end();
             ++ppMembuf)
        {
            pMembuf = *ppMembuf;

            if(i_requestType == HB_VDDR_ENABLE)
            {
                (void)addMemoryVoltageDomains<
                    TARGETING::ATTR_MSS_CENT_VDD_OFFSET_DISABLE,
                    TARGETING::ATTR_MEM_VDD_OFFSET_MILLIVOLTS,
                    TARGETING::ATTR_MEM_VDD_OFFSET_MILLIVOLTS,
                    TARGETING::ATTR_VDD_ID>(
                        pMembuf,
                        io_request);

                (void)addMemoryVoltageDomains<
                    TARGETING::ATTR_MSS_CENT_AVDD_OFFSET_DISABLE,
                    TARGETING::ATTR_MEM_AVDD_OFFSET_MILLIVOLTS,
                    TARGETING::ATTR_MEM_AVDD_OFFSET_MILLIVOLTS,
                    TARGETING::ATTR_AVDD_ID>(
                        pMembuf,
                        io_request);

                (void)addMemoryVoltageDomains<
                    TARGETING::ATTR_MSS_CENT_VCS_OFFSET_DISABLE,
                    TARGETING::ATTR_MEM_VCS_OFFSET_MILLIVOLTS,
                    TARGETING::ATTR_MEM_VCS_OFFSET_MILLIVOLTS,
                    TARGETING::ATTR_VCS_ID>(
                        pMembuf,
                        io_request);

                (void)addMemoryVoltageDomains<
                    TARGETING::ATTR_MSS_VOLT_VPP_OFFSET_DISABLE,
                    TARGETING::ATTR_MEM_VPP_OFFSET_MILLIVOLTS,
                    TARGETING::ATTR_VPP_BASE,
                    TARGETING::ATTR_VPP_ID>(
                        pMembuf,
                        io_request);
            }

            (void)addMemoryVoltageDomains<
                TARGETING::ATTR_MSS_VOLT_VDDR_OFFSET_DISABLE,
                TARGETING::ATTR_MEM_VDDR_OFFSET_MILLIVOLTS,
                TARGETING::ATTR_MSS_VOLT,
                TARGETING::ATTR_VMEM_ID>(
                    pMembuf,
                    io_request);
        }

        if (membufTargetList.size() > 1)
        {
            // Take out the duplicate records in io_request by first
            // sorting and then removing the duplicates
            std::sort(io_request.begin(), io_request.end(), compareVids);
            std::vector<hwsvPowrMemVoltDomainRequest_t>::iterator
                pInvalidEntries = std::unique(
                    io_request.begin(),
                    io_request.end(),
                    areVidsEqual);
            io_request.erase(pInvalidEntries,io_request.end());
        }

        if( ( (i_requestType == HB_VDDR_ENABLE) ||
              (i_requestType == HB_VDDR_POST_DRAM_INIT_ENABLE) )
           && (!membufTargetList.empty())      )
        {
            // Inhibit sending any request to turn on a domain with no voltage.
            // When disabling we don't need to do this because the voltage is
            // ignored.
            io_request.erase(
                std::remove_if(io_request.begin(), io_request.end(),
                    isUnusedVoltageDomain),io_request.end());
        }

    } while(0);

    TRACFCOMP( g_trac_volt, EXIT_MRK "HBVddrMsg::createVddrData" );
    return;
}

///////////////////////////////////////////////////////////////////////////////
// HBVddrMsg::sendMsg
///////////////////////////////////////////////////////////////////////////////
errlHndl_t HBVddrMsg::sendMsg(VDDR_MSG_TYPE i_msgType) const
{
    errlHndl_t l_err = NULL;

    TRACFCOMP(g_trac_volt, ENTER_MRK
              "hbVddrMsg::sendMsg msg_type =0x%08X",i_msgType);

    do
    {
        RequestContainer l_request;

        if ( ! ( (i_msgType == HB_VDDR_ENABLE) ||
                 (i_msgType == HB_VDDR_DISABLE) ||
                 (i_msgType == HB_VDDR_POST_DRAM_INIT_ENABLE) ) )
        {
            TRACFCOMP(g_trac_volt, ERR_MRK "hbVddrMsg::send msg with non-"
                      "valid msg type%08X",i_msgType);
            /*@
             *   @errortype
             *   @moduleid      fapi::MOD_VDDR_SEND_MSG
             *   @reasoncode    fapi::RC_INCORRECT_MSG_TYPE
             *   @userdata1     i_msgType
             *   @userdata2     0
             *
             *   @devdesc       HB got an incorrect type message.  HB did not
             *                  provide the correct message type in the istep.
             *                  Userdata1 shows the message type passed in
             */
            createErrLog(l_err, fapi::MOD_VDDR_SEND_MSG,
                         fapi::RC_INCORRECT_MSG_TYPE, i_msgType);
            break;
        }
        createVddrData(i_msgType, l_request);


        size_t l_dataCount = l_request.size();

        // Only send a message if there is data to send
        if (l_dataCount)
        {
            uint32_t l_msgSize = l_dataCount *
                sizeof(hwsvPowrMemVoltDomainRequest_t);

            // Create the message to send to HWSV
            msg_t* l_msg = msg_allocate();
            l_msg->type = i_msgType;
            l_msg->data[0] = 0;
            l_msg->data[1] = l_msgSize;

            TRACFCOMP(g_trac_volt, INFO_MRK "hbVddrMsg::l_dataCount=%d, "
                      "l_msgSize=%d",
                      l_dataCount, l_msgSize);
            void* l_data = malloc(l_msgSize);

            hwsvPowrMemVoltDomainRequest_t* l_ptr =
                reinterpret_cast<hwsvPowrMemVoltDomainRequest_t*>(l_data);

            for (size_t j =0; j<l_dataCount; ++j)
            {
                l_ptr->domain=l_request.at(j).domain;
                l_ptr->domainId=l_request.at(j).domainId;
                l_ptr->voltageMillivolts=l_request.at(j).voltageMillivolts;

                TRACFCOMP(g_trac_volt, ENTER_MRK "hbVddrMsg::sendMsg "
                          "Voltage domain type = 0x%08X, "
                          "Voltage domain ID = 0x%04X, "
                          "Voltage (mV) = %d, index = %d",
                          l_ptr->domain,
                          l_ptr->domainId, l_ptr->voltageMillivolts,j);
                l_ptr++;
            }

            l_msg->extra_data = l_data;

            TRACFBIN(g_trac_volt, "l_data", l_data, l_msgSize);
            l_err = MBOX::sendrecv( MBOX::FSP_VDDR_MSGQ, l_msg );
            if (l_err)
            {
                TRACFCOMP(g_trac_volt,
                          ERR_MRK "Failed sending VDDR message to FSP");
            }
            else
            {
                l_err=processMsg(l_msg);
            }

            // If sendrecv returns error then it may not have freed the
            // extra_data, else need to free the response message extra_data
            free(l_msg->extra_data);
            l_msg->extra_data = NULL;

            msg_free(l_msg);
            l_msg = NULL;
        }
    } while(0);

    TRACFCOMP(g_trac_volt, EXIT_MRK "hbEnableVddr::sendMsg");
    return l_err;
}


///////////////////////////////////////////////////////////////////////////////
// HBVddrMsg::processVDDRmsg
///////////////////////////////////////////////////////////////////////////////
errlHndl_t  HBVddrMsg::processVDDRmsg(msg_t* i_recvMsg) const
{
    TRACFCOMP(g_trac_volt, ENTER_MRK "HBVddrMsg::processVDDRmsg");
    errlHndl_t l_errLog = NULL;
    //check to see if an error occurred from the powr Enable/Disable functions
    //and is inside the message

    uint32_t l_msgSize = i_recvMsg->data[1];
    uint16_t l_elementCount = l_msgSize/sizeof(hwsvPowrMemVoltDomainReply_t);
    const uint8_t* l_extraData = NULL;
    l_extraData=static_cast<uint8_t*>(i_recvMsg->extra_data);

    do{
        if (l_extraData==NULL)
        {
            //an error occred in obtaining the extra data from the response msg
            TRACFCOMP( g_trac_volt, ERR_MRK
                       "HBVddrMsg::processVDDRmsg: l_extraData = NULL");
            //create an errorlog
            /*@
            *   @errortype
            *   @moduleid      fapi::MOD_VDDR_PROC_VDDR_MSG
            *   @reasoncode    fapi::RC_VDDR_EMPTY_MSG
            *   @userdata1     0
            *   @userdata2     0
            *
            *   @devdesc       The hwsv returned a message where the extra data
            *                  was null.  This should not happen so need to
            *                  tell HostBoot to stop the ipl
            */
            createErrLog(l_errLog, fapi::MOD_VDDR_PROC_VDDR_MSG,
                         fapi::RC_VDDR_EMPTY_MSG);
            break;
        }

        MEM_VOLTAGE_DOMAIN domain = MEM_VOLTAGE_DOMAIN_UNKNOWN;
        TARGETING::ATTR_VMEM_ID_type l_domainId =0x0;
        uint32_t l_errPlid =0x0;

        TRACFCOMP( g_trac_volt, INFO_MRK "HBVddrMsg::processVDDRmsg: "
                    "l_elementCount=%d, l_msgSize =%d",
                    l_elementCount, l_msgSize);
        const hwsvPowrMemVoltDomainReply_t* l_ptr=
            reinterpret_cast<const hwsvPowrMemVoltDomainReply_t*>(l_extraData);

        for (size_t i=0; i<l_elementCount; ++i)
        {
            domain = l_ptr->domain;
            l_domainId = l_ptr->domainId;
            l_errPlid = l_ptr->plid;

            TRACFCOMP( g_trac_volt, INFO_MRK "HBVddrMsg::processVDDRmsg: "
                      "domain = 0x%08X, l_domainId=0x%08X, l_errPlid=0x%08X",
                      domain,l_domainId,l_errPlid);
            if (l_errPlid ==0x0)
            {
                TRACFCOMP( g_trac_volt, INFO_MRK "HBVddrMsg::processVDDRmsg: "
                          "no plid error found for domain = 0x%08X, "
                          "l_domainId=0x%08X", domain, l_domainId);
            }
            else
            {
                //error occured so break out of the loop and indicate
                //an error was present
                TRACFCOMP( g_trac_volt, ERR_MRK
                           "HBVddrMsg::processVDDRmsg: error occured "
                           "on the powr function called in hwsv");
                //create an errorlog
                /*@
                *   @errortype
                *   @moduleid      fapi::MOD_VDDR_PROC_VDDR_MSG
                *   @reasoncode    fapi::RC_VDDR_POWR_ERR
                *   @userdata1     l_errPlid
                *   @userdata2     0
                *
                *   @devdesc       The hwsv returned a message where there was
                *                  an error when the powr function was called.
                *                  userdata1 contains the errorlog plid from
                *                  hwsv generated by the powr function
                */
                createErrLog(l_errLog, fapi::MOD_VDDR_PROC_VDDR_MSG,
                             fapi::RC_VDDR_POWR_ERR, l_errPlid);
                l_errLog->plid(l_errPlid);
                break;
            }

            l_ptr++;
        }
    }while(0);
    TRACFCOMP(g_trac_volt, EXIT_MRK "HBVddrMsg::processVDDRmsg");
    return l_errLog;
}

///////////////////////////////////////////////////////////////////////////////
// HBVddrMsg::processMsg
///////////////////////////////////////////////////////////////////////////////
errlHndl_t HBVddrMsg::processMsg(msg_t* i_Msg) const
{
    TRACFCOMP(g_trac_volt, ENTER_MRK "HBVddrMsg::processMsg");
    errlHndl_t l_errLog = NULL;

    do
    {
        //check to see if the data[0] =0 or contains a value.
        //A value of 0 means its a response to a request and a value not equal
        //to zero  means that its an error coming back

        uint16_t l_value1=i_Msg->data[0];
        if (l_value1 ==0)
        {
            //process a response to a request

            uint32_t l_msgType =i_Msg->type;
            TRACFCOMP( g_trac_volt, INFO_MRK
                       "HBVddrMsg::processMsg l_msgType=x%08X",l_msgType );
            if ( (l_msgType == HB_VDDR_ENABLE) ||
                 (l_msgType == HB_VDDR_DISABLE)||
                 (l_msgType == HB_VDDR_POST_DRAM_INIT_ENABLE) )
            {
                //process a VDDR message
                l_errLog=processVDDRmsg(i_Msg);
                if (l_errLog)
                {
                    break;
                }

            }
            else
            {
                TRACFCOMP( g_trac_volt, ERR_MRK
                           "HBVddrMsg::processMsg recv'd a non valid type");
                //generate errorLog;
                /*@
                 *   @errortype
                 *   @moduleid      fapi::MOD_VDDR_PROC_MSG
                 *   @reasoncode    fapi::RC_INCORRECT_MSG_TYPE
                 *   @userdata1     0
                 *   @userdata2     0
                 *
                 *   @devdesc       HB got an incorrect type message.
                 *                  HWSV did not populate the message correctly
                 *                  or mbox corrupted the message
                 */
                createErrLog(l_errLog, fapi::MOD_VDDR_PROC_MSG,
                             fapi::RC_INCORRECT_MSG_TYPE);
            }
        }
        else
        {
            //an error occurred so should stop the IPL
            TRACFCOMP( g_trac_volt, ERR_MRK
                       "HBVddrMsg::RecvMsgHndlr recv'd an error message" );
            //generate an errorlog
            /*@
             *   @errortype
             *   @moduleid      fapi::MOD_VDDR_PROC_MSG
             *   @reasoncode    fapi::RC_VDDR_ERROR_MSG
             *   @userdata1     error PLID from hwsv
             *   @userdata2     0
             *
             *   @devdesc       The hwsv found an error while processing the
             *                  message so it sent an error message back to
             *                  indicate to HostBoot to stop the IPL.
             *                  Userdata1 will have the error PLID from hwsv's
             *                  errorlog
             */
            createErrLog(l_errLog, fapi::MOD_VDDR_PROC_MSG,
                         fapi::RC_VDDR_ERROR_MSG, i_Msg->data[1]);
            l_errLog->plid(i_Msg->data[1]);
        }

    }while(0);

    TRACFCOMP(g_trac_volt, EXIT_MRK "HBVddrMsg::processMsg");
    return l_errLog;
}

///////////////////////////////////////////////////////////////////////////////
// HBVddrMsg::createErrLog
///////////////////////////////////////////////////////////////////////////////
void HBVddrMsg::createErrLog(errlHndl_t& io_err,
                             fapi::hwpfModuleId i_mod,
                             fapi::hwpfReasonCode i_rc,
                             uint32_t i_userData1) const
{
    if (io_err == NULL)
    {
        io_err = new ErrlEntry(ERRL_SEV_UNRECOVERABLE,
                                i_mod,
                                i_rc,
                                i_userData1,
                                0);

    }
    return;
}

// External interfaces

errlHndl_t platform_enable_vspd()
{
    // noop on FSP based system
    return NULL;
}

errlHndl_t platform_enable_vddr()
{
    errlHndl_t l_err = NULL;
    if(INITSERVICE::spBaseServicesEnabled())
    {
        HBVddrMsg l_hbVddr;

        l_err = l_hbVddr.sendMsg(HBVddrMsg::HB_VDDR_ENABLE);
        if (l_err)
        {
            TRACFCOMP(g_trac_volt,
                      "ERROR 0x%.8X: call_host_enable_vddr to sendMsg"
                      " returns error",
                      l_err->reasonCode());
        }
        else
        {
            TRACFCOMP( g_trac_volt,
                       "SUCCESS :  host_enable_vddr()" );
        }
    }
    else // no FSP/mbox services available
    {
        TRACFCOMP(g_trac_volt,"call_host_enable_vddr"
                "no-op because mbox not available");
    }

    return l_err;
}

errlHndl_t platform_disable_vddr()
{
    errlHndl_t l_err = NULL;
    if(INITSERVICE::spBaseServicesEnabled())
    {
        HBVddrMsg l_hbVddr;

        l_err = l_hbVddr.sendMsg(HBVddrMsg::HB_VDDR_DISABLE);
        if (l_err)
        {
            TRACFCOMP(g_trac_volt,
                      "ERROR 0x%.8X: call_host_disable_vddr to sendMsg"
                      " returns error",
                      l_err->reasonCode());
        }
        else
        {
            TRACFCOMP( g_trac_volt,
                       "SUCCESS :  host_disable_vddr()" );
        }
    }
    else  // no FSP/mbox services available
    {
        TRACFCOMP(g_trac_volt,"call_host_disable_vddr"
                "no-op because mbox not available");
    }

    return l_err;
}

errlHndl_t platform_adjust_vddr_post_dram_init()
{
    errlHndl_t l_err = NULL;
    if(INITSERVICE::spBaseServicesEnabled())
    {
        HBVddrMsg l_hbVddr;

        l_err = l_hbVddr.sendMsg(HBVddrMsg::HB_VDDR_POST_DRAM_INIT_ENABLE);
        if (l_err)
        {
            TRACFCOMP(g_trac_volt,
                      "ERROR 0x%.8X: call_host_adjust_vddr_post_dram_init to "
                      "sendMsg returns error",
                      l_err->reasonCode());
        }
        else
        {
            TRACFCOMP( g_trac_volt,
                       "SUCCESS :  host_adjust_vddr_post_dram_init()" );
        }
    }
    else  // no FSP/mbox services available
    {
        TRACFCOMP(g_trac_volt,"call_host_adjust_vddr_post_dram_init()"
                "no-op because mbox not available");
    }

    return l_err;
}

OpenPOWER on IntegriCloud