summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/dram_training/hbVddrMsg.H
blob: 4d71237cf7ee05f57b19dbfe3f7f54255b49ba72 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/dram_training/hbVddrMsg.H $                  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2014              */
/*                                                                        */
/* 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 __HB_VDDR_MSG_H
#define __HB_VDDR_MSG_H

/*****************************************************************************/
// I n c l u d e s
/*****************************************************************************/
#include <sys/task.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mm.h>
#include <sys/msg.h>
#include <sys/sync.h>
#include <stdint.h>

#include <util/singleton.H>
#include <errl/errlentry.H>
#include <kernel/timemgr.H>
#include <hbotcompid.H>
#include <hwas/common/hwasCallout.H>
#include <mbox/mbox_queues.H>
#include <mbox/mboxif.H>
#include <targeting/common/targetservice.H>
#include <targeting/common/utilFilter.H>
#include <hwpf/hwpf_reasoncodes.H>

/*****************************************************************************/
// Forward class declarations
/*****************************************************************************/
class HBVddrMsg;

/**
 *  @brief  HBVddrMsg
 *  This class provides interfaces to send and process messages to and from
 *  hwsv with respect to powr.  It also indicates when to stop the IPL via
 *  errorlogs
 */
class HBVddrMsg
{

public:
    /**
     * @struct hwsvPowrVmemRequest_t
     *
     * @brief structure to contain the Vmem Voltage rail ID and 
     *        its corresponding voltage
     *
     */
    struct hwsvPowrVmemRequest_t
    {
        TARGETING::ATTR_VMEM_ID_type VmemId;
        TARGETING::ATTR_MSS_VOLT_type Voltage;
        
        hwsvPowrVmemRequest_t()
        {
            VmemId=0x0;
            Voltage=0;
        }
    }__attribute__ ((packed));

    /**
     * @struct hwsvPowrVmemReply_t
     *
     * @brief structure to contain the Vmem Voltage rail ID and 
     *        its corresponding errorlog plid from the powr function
     *        call
     *
     */
    struct hwsvPowrVmemReply_t
    {
        TARGETING::ATTR_VMEM_ID_type VmemId;
        uint32_t plid;
    
        hwsvPowrVmemReply_t()
        {
            VmemId=0x0;
            plid=0x0;
        }
    }__attribute__ ((packed));

    /**
     * @enum VDDR_MSG_TYPE
     *
     * @brief  Message enum to determine how the msg should be processed
     *
     */
    enum VDDR_MSG_TYPE
    {
        HB_VDDR_ENABLE = 0x40000041,
        HB_VDDR_DISABLE = 0x40000042,
    };

    /** 
     * @brief typedefs for containers for structures
     */
    typedef std::vector<hwsvPowrVmemReply_t> ResponseContainer;
    typedef std::vector<hwsvPowrVmemRequest_t> RequestContainer;

    /**
     * @brief Default constructor
     */
    HBVddrMsg();
    
    /**
     * @brief   Destructor
     *
     * Releases all resources owned by the handle.  
     *
     * @return  None
     *
     */
    ~HBVddrMsg();


    /**
      *  @brief  Uses the internal mailbox to send a message to the FSP
      *
      *
      *  @par Detailed Description:
      *          This funciton will create the request message by 
      *          going through the attributes and correlating the 
      *          VID and Voltage into the final message for all the 
      *          VIDs in the system
      *
      *  @param[in/out] io_request
      *             Contains the voltage and VID pairs to be passed
      *             to hwsvd on the FSP. 
      *
      *  @return     None
    */  
    void createVddrData(RequestContainer& io_request)const;

    /**
      *  @brief  Uses the internal mailbox to send a message to the FSP
      *
      *
      *  @par Detailed Description:
      *          This function will call into mailbox FSP code using the
      *          FSP_VDDR_MSGQ as the message queue..
      *
      *  @param[in] i_msgType
      *             HBVddrMsg::VDDR_MSG_TYPE passed in to define the
      *             message policy.
      *
      *  @return     errlHndl_t
      *              return errl ==  NULL  -> success
      *              return errl !=  NULL  -> failure
     */
    errlHndl_t sendMsg(uint32_t i_msgType) const;


protected:


     /**
     * @brief function to process a generic message recieved from the FSP
     *
     * @param[in] i_recvMsg The message from the message queue.  
     *               It contains the response data from the FSP
     *
     * @return     errlHndl_t
     *              return errl ==  NULL  -> success
     *              return errl !=  NULL  -> failure
     */
    errlHndl_t processMsg(msg_t* i_recvMsg) const;

     /**
     * @brief function to process a power Vmem message recieved from the FSP
     *
     * @param[in] i_recvMsg The message from the message queue.  
     *               It contains the response data from the FSP
     *
     * @param[out] i_passed indicates if powr function succeeded or failed on the
     *               FSP.
     *
     * @return     errlHndl_t
     *              return errl ==  NULL  -> success
     *              return errl !=  NULL  -> failure
     */
    errlHndl_t processVDDRmsg(msg_t* i_recvMsg)const;

     /**
     * @brief function to create error logs for errors that occured in FSP side
     *
     * @param[in/out] io_err.  Error log to generate indicating that an error has
     *                    has occured on HB or in the powr messages.  This error
     *                    should stop the IPL from processing further.
     *
     * @param[in] i_mod. The module where the error occured
     *
     * @param[in] i_rc. The return code for the error that occured
     *
     * @return     None
     */
    void createErrLog(errlHndl_t& io_err,
                      fapi::hwpfModuleId i_mod,
                      fapi::hwpfReasonCode i_rc,
                      uint32_t i_userData1=0x0) const;

};


#endif
OpenPOWER on IntegriCloud