summaryrefslogtreecommitdiffstats
path: root/src/include/usr/targeting/attrsync.H
blob: f7614a9922fa1fc035ca35dbd1dded1ac83841ca (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/targeting/attrsync.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 __ATTRSYNC_H_
#define __ATTRSYNC_H_
/**
 *  @file targeting/attsync.H
 *
 *  @brief  Interface to support syncing the targeting attributes between the
 *          FSP and Hostboot. Sync operations can be either direction, HB->FSP
 *          or FSP->HB however for sprint 7.12 only HB->FSP support will be
 *          added.
 */
//******************************************************************************
// Includes
//******************************************************************************
#include <mbox/mbox_queues.H>
#include <mbox/mboxif.H>
#include <errl/errlentry.H>
#include <sys/msg.h>
#include <pnortargeting.H>
#include <stddef.h>
#include <targeting/common/targetservice.H>
#include <targeting/common/attrsyncdefs.H>


namespace   TARGETING
{

    /**
     *  @class AttributeSync
     *
     *  @brief Targeting attribute sync class
     *
     *  @par Detailed Description:
     *      Provides all the functionality to synchronize the targetting
     *      attributes from the Hostboot area down to the FSP
     */
    class AttributeSync
    {

        public:

            /**
             *  @brief Initialize the attribute synchronization object
             *
             *  @par Detailed Description
             *      Ensures member variables are initialized to sane values.
             */
            AttributeSync();

            /**
             *  @brief Destroy the attribute sync object resources
             *
             *  @par Detailed Description:
             *      Frees any memory allocated by the attribute sync object
             *
             */
            ~AttributeSync();

            /**
             *  @brief  Setup the internal variables to point to the correct
             *          attribute section.
             *
             *  @par Detailed Description:
             *          This function will call into the AttRP:: to have the
             *          correct attribute section paged into accessable memory.
             *          this function may be called multiple times with different
             *          section names.
             *
             *  @pre None:
             *
             *  @post   The entire section from the HB attribute section
             *          passed in has been synchronized to the FSP memory area.
             *
             *  @param[in]  i_section_to_sync
             *                  TARGETING::SECTION_TYPE is passed in to
             *                  identify the section to be synced to the
             *                  FSP.
             *
             *  @return     errlHndl_t
             *                  return errl ==  NULL  -> success
             *                  return errl !=  NULL  -> failure
             *
             */
            errlHndl_t  syncSectionToFsp( 
                                    TARGETING::SECTION_TYPE i_section_to_sync );

            /**
             *  @brief  Sends a request to the FSP to sync its data to Hostboot
             *          for a specific attribute section.  Write the data
             *          received from the FSP to the attribute section.
             *
             *  @par Detailed Description:
             *          This function will call into the AttRP:: to have the
             *          correct attribute section updated.  This function may be
             *          called multiple times with different section names.
             *
             *  @pre None:
             *
             *  @post   The entire section from the FSP attribute section
             *          passed in has been synchronized to the HB memory area.
             *
             *  @param[in]  i_section_to_sync
             *                  TARGETING::SECTION_TYPE is passed in to
             *                  identify the section to be synced from the
             *                  FSP.
             *              i_msgQ
             *                  the message queue which FSP will use to send
             *                  the attribute data
             *
             *  @return     errlHndl_t
             *                  return errl ==  NULL  -> success
             *                  return errl !=  NULL  -> failure
             *
             */
            errlHndl_t  syncSectionFromFsp(
                                    TARGETING::SECTION_TYPE i_section_to_sync,
                                    msg_q_t i_pMsgQ );

        private:

            /**
             * @enum TARGETING::MBOX_MSG_TYPE
             *
             * @brief  Message enum to determine if msg should be sent
             *         asynchronously or if the call should be synchronous
             *
             */
            enum MBOX_MSG_TYPE
            {
                ASYNCHRONOUS,
                SYNCHRONOUS
            };

            /**
             *  @brief  Setup the internal variables to point to the correct
             *          attribute section.
             *
             *  @par Detailed Description:
             *      This function will call into the AttRP:: to have the
             *      correct attribute section paged into accessable memory
             *
             */
            void        getSectionData();

            /**
             *  @brief  Write the attribute data received from the FSP to
             *          the attribute section.
             *
             *  @par Detailed Description:
             *      This function will call into the AttRP:: to have the
             *      correct attribute section written
             *
             *  @return     ATTR_SYNC_SUCCESS -> success
             *              ATTR_SYNC_FAILURE -> failure
             *
             */
            ATTR_SYNC_RC updateSectionData() const;

            /**
             *  @brief  Uses the internal mailbox to send a message to the FSP
             *
             *
             *  @par Detailed Description:
             *          This funciton will call into mailboxsp code using the
             *          FSP_ATTR_SYNC_MSGQ as a target message queue..
             *
             *  @param[in] i_type
             *           TARGETING::MBOX_MSG_TYPE passed in to define the
             *           message sending policy.
             *
             *  @param[in/out] i_msg 
             *                    This parameter is used as both input and an
             *                    output parameter. If the message is sent
             *                    synchronusly the response will be populated
             *                    in an object pointed to by this pointer. If
             *                    the message is asynchronus the object
             *                    pointed to by this paramter will be sent to
             *                    the fsp.
             *
             *  @return     errlHndl_t
             *                  return errl ==  NULL  -> success
             *                  return errl !=  NULL  -> failure
             */
            errlHndl_t  sendMboxMessage( MBOX_MSG_TYPE i_type, msg_t * i_msg  );

            /**
             *  @brief  Sends the sync complete message to the FSP indicating
             *          the operation has completed.
             *
             *  @return     errlHndl_t
             *                  return errl ==  NULL  -> success
             *                  return errl !=  NULL  -> failure
             */
            errlHndl_t  sendSyncCompleteMessage();

            /**
             *  @brief  Sends the sync to HB request message to the FSP
             *          requesting the FSP to sync it's attribute data
             *          to Hostboot.
             *
             *  @return     errlHndl_t
             *                  return errl ==  NULL  -> success
             *                  return errl !=  NULL  -> failure
             */
            errlHndl_t  sendSyncToHBRequestMessage();

        private:

            // id of the section being updated
            TARGETING::SECTION_TYPE iv_section_to_sync;


            // count of total pages, calculated from data supplied by the
            // attribute resource provider code;
            uint16_t    iv_total_pages;

            // maintiains the current page number being sync'ed.
            uint16_t    iv_current_page;

            // vector of structures to hold the location info for each section
            // we would like to sync.  Data is filled in by the attrrp code
            // when we call AttRP::readSectionData(...
            std::vector <TARGETING::sectionRefData>iv_pages;

    };

    /**
     *  @brief  Handles synchronization of all RW targeting attributes from
     *          hostboot to the fsp; the following sections are
     *          synchronized.
     * 
     *           1). SECTION_TYPE_PNOR_RW
     *           2). SECTION_TYPE_HEAP_PNOR_INIT
     *           3). SECTION_TYPE_HEAP_PNOR_ZERO_INIT
     *
     *
     *  @return     errlHndl_t
     *                  return errl ==  NULL  -> success
     *                  return errl !=  NULL  -> failure
     */
    errlHndl_t syncAllAttributesToFsp();

    /**
     *  @brief  Handles synchronization of all RW targeting attributes from
     *          the fsp to hostboot; the following sections are
     *          synchronized.
     * 
     *           1). SECTION_TYPE_PNOR_RW
     *           2). SECTION_TYPE_HEAP_PNOR_INIT
     *           3). SECTION_TYPE_HEAP_PNOR_ZERO_INIT
     *
     *
     *  @return     errlHndl_t
     *                  return errl ==  NULL  -> success
     *                  return errl !=  NULL  -> failure
     */
    errlHndl_t syncAllAttributesFromFsp();

} // namespace
#endif
OpenPOWER on IntegriCloud