summaryrefslogtreecommitdiffstats
path: root/src/include/runtime/generic_hbrt_fsp_message.H
blob: 30566290df05b7fac03af2bd6b8d301c414e0180 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/runtime/generic_hbrt_fsp_message.H $              */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2013,2018                        */
/* [+] 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 __RUNTIME__GENERIC_HBRT_FSP_MESSAGE_H
#define __RUNTIME__GENERIC_HBRT_FSP_MESSAGE_H

#include <targeting/common/attributes.H>   // TARGETING::HwasState
#include <attributeenums.H>                // ATTRIBUTE_ID


/** @file generic_hbrt_fsp_message.H
 *  @brief A generic structure for passing data
 *
 *  This file has a generic struct to be used by the
 *  FSP/HWSV team to send and receive data.
 */

// Sentinel value for bad SCOM reads
#define DEADBEEF 0xDEADBEEF

/**
  * This generates a sequence ID that the GenericFspMboxMessage_t
  * consumes.
  */
struct SeqId_t
{
public:
  static uint16_t getNextSeqId();
  static uint16_t getCurrentSeqId();

private:
  static uint16_t SEQ_ID;
};


/**
  * A useful struct to pack/access the HUID and HWAS state
  * from the GenericFspMboxMessage_t.data.
  * The HUID will be in the first 4 bytes followed by the HWAS state.
  */
struct TargetDeconfigHbrtFspData_t
{
   uint32_t huid;
   TARGETING::HwasState hwasState;
} PACKED ;


/**
  * This struct contains the message-specific data for
  * MSG_SINGLE_SCOM_OP calls to the FSP.
  * It shows the format of GenericFspMboxMessage_t.data.
  */
struct SingleScomOpHbrtFspData_t
{
    uint8_t     scom_op;    // DeviceFW::READ, DeviceFW::WRITE
    uint32_t    huid;       // hardware target
    uint64_t    scom_addr;
    uint64_t    scom_data;  // SCOM value read by FSP, or
                            // SCOM value to be written by FSP
} PACKED;


/**
  * This struct contains the message-specific data for
  * MSG_MULTI_SCOM_OP calls to the FSP.
  * It shows the format of GenericFspMboxMessage_t.data.
  */
struct MultiScomReadHbrtFspData_t
{
    uint32_t    huid;       // hardware target
    uint8_t     scom_num;   // number of SCOMs to read
    uint64_t    scom_data;  // addresses of SCOMs to read, or
                            // values of SCOMs in FSP response
                            //
                            // ** if a SCOM cannot be read, its value **
                            // ** should be returned as DEADBEEF      **
                            //
                            // placeholder that can be cast to an array
                            // of SCOM addresses (or values)
                            // uint64_t* mydata =
                            //              (uint64_t*)&(l_generic_msg.data);
                            // more than 8 bytes of data is possible
} PACKED;


/**
  * A useful struct to access the PLID from GenericFspMboxMessage_t.data
  * in the case where the FSP is requesting Hostboot to restart a SBE
  */
struct SbeRetryReqData_t
{
   uint32_t huid;
   uint32_t plid;
} PACKED ;


/**
  * A useful struct to access the HUID, attribute ID and attribute data
  * from the GenericFspMboxMessage_t.data
  *
  * The HUID will be the first 4 bytes followed by a 4-byte attribute ID,
  * then a 4-byte size of attribute data, and finally the attribute's data
  *
  */
struct HbrtAttrSyncData_t
{
    // HUID of target on which we want to update the attribute
    uint32_t huid;

    // Attribute ID of attribute to update
    TARGETING::ATTRIBUTE_ID attrID;

    // size of attribute data in bytes
    uint32_t sizeOfAttrData;

    // first byte of <sizeOfAttrData> bytes of attribute data
    uint8_t attrDataStart;

} PACKED ;

/**
  * This struct sends/receives an MBox message to the FSP
  */
struct GenericFspMboxMessage_t
{

    /**
      * Value for the GenericFspMboxMessage_t::magic
      */
    static constexpr uint32_t MAGIC_NUMBER = 0x4746464D;  // `GFFM`
    static constexpr uint32_t FSP_HBRT_MESSAGEQ = 0x8000000F;

   /**
    * GenericFspMboxMessage_t Version info
    *
    */
    enum GENERIC_FSP_MBOX_MESSAGE_VERSION
    {
       STRUCT_VERSION_FIRST = 0x1,
       STRUCT_VERSION_LATEST = STRUCT_VERSION_FIRST,
    };

    /**
      * Values for the GenericFspMboxMessage_t::__req flag
      */
    enum GENERIC_FSP_MBOX_MESSAGE_FLOW
    {
        RESPONSE = 0,
        REQUEST  = 1,
    };

    /**
      * Values for the GenericFspMboxMessage_t::__onlyError flag
      */
    enum GENERIC_FSP_MBOX_MESSAGE_ERROR_FLAG
    {
        NOT_ERROR_ONLY = 0,
        ERROR_ONLY     = 1,
    };

    /**
      * The different message types for the GenericFspMboxMessage_t
      */
    enum GENERIC_FSP_MBOX_MESSAGE_MSG_TYPE
    {
        MSG_TOD_BACKUP_RESET             = 0x0001,
        MSG_TOD_BACKUP_RESET_INFORM_PHYP = 0x0002,
        MSG_TOD_TOPOLOGY_DATA            = 0x0003,
        MSG_DECONFIG_TARGET              = 0x0004,
        MSG_SINGLE_SCOM_OP               = 0x0005,
        MSG_MULTI_SCOM_OP                = 0x0006,
        MSG_ATTR_SYNC_REQUEST            = 0x000000A5,
        MSG_SBE_ERROR                    = 0x000000D4,
        MSG_SBE_RECOVERY_SUCCESS         = 0x000000D5,
        MSG_SBE_RECOVERY_FAILED          = 0x000000D6,
    };

    /**
      * GenericFspMboxMessage_t data members
      */
    uint32_t magic;     // ='GFMM'
    uint32_t dataSize;  // total number of bytes in the entire message,
                        // includes structure plus data buffer,
                        // minimum is sizeof(GenericFspMboxMessage_t)
    uint8_t structVer;  // =1, allow for future modifications
    uint8_t reserved;   // unused, just for alignment and expansion
    uint16_t seqnum;    // incremented for each new request, bit0=1 indicates
                        // the request came from the FSP, i.e. 0x0000->0x7FFF
                        // are from HBRT, 0x8000->0xFFFF are from HWSV.
    uint32_t msgq;      // Example: MBOX::FSP_VPD_MSGQ
    uint32_t msgType;   // Example: VPD_MSG_TYPE:VPD_WRITE_PROC
    struct  // flags
    {
        uint32_t __req:1;    // 1=this is a request, 0=this is a response
        uint32_t __async:1;  // =0 for now, future async req/resp support
        uint32_t __onlyError:1; // 1=this is a response that only contains a
                                // single 32-bit plid in the first 4 bytes of
                                // the data payload
        uint32_t __unused:29;   // reserved for future
    };
    uint64_t data;  // generic member that can be used
                    // to do casting to other types:
                    // MyDataType_t* mydatatype =
                    //              (MyDataType_t*)&(l_generic_msg.data);
                    // more than 8 bytes of data is possible

    // A method to set the local vars to a default state
    void initialize()
    {
        magic = MAGIC_NUMBER;
        dataSize = sizeof(GenericFspMboxMessage_t);
        structVer = STRUCT_VERSION_LATEST;
        reserved = 0;
        seqnum = SeqId_t::getNextSeqId();
        msgq = 0;
        msgType = 0;
        __req = RESPONSE;
        __async = 0;
        __onlyError = NOT_ERROR_ONLY;
        __unused = 0;
        data = 0;
    };
} PACKED ;

// Handy macro that computes the size of the message minus the data portion
#define GENERIC_FSP_MBOX_MESSAGE_BASE_SIZE \
   (sizeof(GenericFspMboxMessage_t)-sizeof(GenericFspMboxMessage_t::data))

#endif // __RUNTIME__GENERIC_HBRT_FSP_MESSAGE_H
OpenPOWER on IntegriCloud