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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/hwpf/plat/fapiPlatAttrOverrideSync.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2014 */
/* [+] 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 */
/**
* @file fapiPlatAttrOverrideSync.H
*
* @brief Defines the AttrOverrideSync class that contains functions for
* Attribute Override and Sync
*/
#ifndef FAPIPLATATTROVERRIDESYNC_H_
#define FAPIPLATATTROVERRIDESYNC_H_
//******************************************************************************
// Includes
//******************************************************************************
#include <stdint.h>
#include <errl/errlentry.H>
#include <mbox/mboxif.H>
#include <fapiAttributeIds.H>
#include <targeting/common/attributeTank.H>
#include <pnor/pnorif.H>
//******************************************************************************
// Interface
//******************************************************************************
namespace TARGETING
{
errlHndl_t getAttrOverrides(PNOR::SectionInfo_t &i_sectionInfo,
AttributeTank* io_tanks[AttributeTank::TANK_LAYER_LAST]);
}
namespace fapi
{
// Forward references
class AttrOverrideSync;
class Target;
/**
* @brief Return the AttrOverrideSync Singleton. Other modules must call this
* rather than using Singleton<>
*
* @return Reference to the AttrOverrideSync Singleton
*/
AttrOverrideSync & theAttrOverrideSync();
/**
* @class AttrOverrideSync
*
* This class contains the FAPI Attribute Override and Sync tanks. It provides
* functions to:
* - Monitor for incoming attribute override/sync messages from the FSP
* - Send attribute override/syncs to the FSP
* - Return any attribute override on an attribute get
* - Cancel any non-const attribute override and save the attribute in the sync
* tank on an attribute set
*/
class AttrOverrideSync
{
public:
/**
* @brief Allow a debug tool to directly access the override tank
*/
friend void directOverride();
/**
* @brief Allow a attribute override to directly access the override tank
*/
friend errlHndl_t TARGETING::getAttrOverrides(
PNOR::SectionInfo_t &i_sectionInfo,
TARGETING::AttributeTank*
io_tanks[TARGETING::AttributeTank::TANK_LAYER_LAST]);
/**
* @brief Maximum size of a direct attribute override
*/
static const size_t MAX_DIRECT_OVERRIDE_ATTR_SIZE_BYTES = 64;
/**
* @brief Attribute Override/Sync Mailbox Message Type Constants
* These must be kept in sync with FSP firmware
*/
enum MAILBOX_MSG_TYPE
{
MSG_SET_OVERRIDES = MBOX::FIRST_UNSECURE_MSG + 0x10, // FSP<->Hb
MSG_CLEAR_ALL_OVERRIDES = MBOX::FIRST_UNSECURE_MSG + 0x11, // FSP<->Hb
MSG_SET_SYNC_ATTS = MBOX::FIRST_UNSECURE_MSG + 0x12, // FSP<--Hb
MSG_GET_OVERRIDES = MBOX::FIRST_UNSECURE_MSG + 0x13, // FSP<--Hb
};
/**
* @brief Default constructor
*/
AttrOverrideSync();
/**
* @brief Destructor
*/
~AttrOverrideSync();
/**
* @brief Monitors for incoming attribute override messages from the FSP.
* This function never returns and must be called by a task
* specifically started to monitor for these messages
*/
void monitorForFspMessages();
/**
* @brief Sends Attribute Overrides and Syncs to the FSP
*
* This is called at the end of an IStep. For both FAPI/TARG tanks it:
* - Clears the FSP Attribute Overrides
* - Sends the Hostboot Attribute Overrides to the FSP
* - Sends the Hostboot Attribute Syncs to the FSP
*/
void sendAttrOverridesAndSyncsToFsp();
/**
* @brief Gets Attribute Overrides and Syncs from the FSP
*
* This is called at the start of a normal (non-istep) IPL if an attribute
* is set indicating that the FSP has attribute overrides in place
*/
void getAttrOverridesFromFsp();
/**
* @brief This function gets any Attribute Override on an attribute get
*
* This is called for those FAPI Attributes that do not map to Targeting
* attributes - their overrides live in the FAPI Attribute tanks.
*
* @param[in] i_attrId FAPI Attribute ID
* @param[in] i_pTarget Pointer to FAPI Target
* @param[in] o_pVal Pointer to attribute value
*
* @return true if an override exists and was written to o_pVal
*/
bool getAttrOverride(const fapi::AttributeId i_attrId,
const fapi::Target * const i_pTarget,
void * o_pVal) const;
/**
* @brief This function gets any Attribute Override on an attribute get
*
* This is a wrapper that calls getAttrOverride on the AttrOverrideSync
* singleton, it should be called by external modules to avoid the
* performance penalty of calling theAttrOverrideSync() then getAttrOverride
*
* @param[in] i_attrId FAPI Attribute ID
* @param[in] i_pTarget Pointer to FAPI Target
* @param[in] o_pVal Pointer to attribute value
*
* @return true if an override exists and was written to o_pVal
*/
static bool getAttrOverrideFunc(const fapi::AttributeId i_attrId,
const fapi::Target * const i_pTarget,
void * o_pVal);
/**
* @brief This function performs the actions required on an attribute set
*
* This is called for those FAPI Attributes that do not map to Targeting
* attributes - their overrides/syncs live in the FAPI Attribute tanks.
*
* - Any non-const attribute override is cleared
* - The attribute is saved to be synced to Cronus (if Cronus Sync enabled)
*
* @param[in] i_attrId FAPI Attribute ID
* @param[in] i_pTarget Pointer to FAPI Target
* @param[in] i_size Size of attribute value
* @param[in] i_pVal Pointer to attribute value
*/
void setAttrActions(const fapi::AttributeId i_attrId,
const fapi::Target * const i_pTarget,
const uint32_t i_size,
const void * i_pVal);
/**
* @brief This function performs the actions required on an attribute set
*
* This is a wrapper that calls setAttrActions on the AttrOverrideSync
* singleton, it should be called by external modules to avoid the
* performance penalty of calling theAttrOverrideSync() then setAttrActions
*
* @param[in] i_attrId FAPI Attribute ID
* @param[in] i_pTarget Pointer to FAPI Target
* @param[in] i_size Size of attribute value
* @param[in] i_pVal Pointer to attribute value
*/
static void setAttrActionsFunc(const fapi::AttributeId i_attrId,
const fapi::Target * const i_pTarget,
const uint32_t i_size,
const void * i_pVal);
private:
/**
* @brief Utility function that sends attributes to the FSP
*
* This function frees the allocated memory in the input vector of chunks
* and empties the vector
*
* @param[in] i_msgType Message type (ID) to send
* @param[in] i_tankLayer Tank Layer to send attribute to
* @param[io] io_attributes Attributes to send.
*
* @return error log handle
*/
static errlHndl_t sendAttrsToFsp(
const MAILBOX_MSG_TYPE i_msgType,
const TARGETING::AttributeTank::TankLayer i_tankLayer,
std::vector<TARGETING::AttributeTank::AttributeSerializedChunk> &
io_attributes);
/**
* @brief Utility function that gets the target type of a FAPI Target as
* used in an attribute tank
*
* @param[in] i_pTarget Pointer to FAPI Target (NULL = system)
*
* @return Target Type
*/
static uint32_t getTargetType(const fapi::Target * const i_pTarget);
// The FAPI Attribute Tanks
TARGETING::AttributeTank iv_overrideTank;
TARGETING::AttributeTank iv_syncTank;
};
} // namespace fapi
#endif // FAPIPLATATTROVERRIDESYNC_H_
|