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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/targeting/attrrp.H $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* COPYRIGHT International Business Machines Corp. 2011,2012 */
/* */
/* p1 */
/* */
/* Object Code Only (OCO) source materials */
/* Licensed Internal Code Source Materials */
/* IBM HostBoot Licensed Internal Code */
/* */
/* The source code for this program is not published or otherwise */
/* divested of its trade secrets, irrespective of what has been */
/* deposited with the U.S. Copyright Office. */
/* */
/* Origin: 30 */
/* */
/* IBM_PROLOG_END_TAG */
#ifndef __TARGETING_ATTRRP_H
#define __TARGETING_ATTRRP_H
/**
* @file targeting/attrrp.H
*
* @brief Interface for the attribute resource provider, which manages the
* memory associated with targeting attributes and provides any
* translation, if necessary
*/
//******************************************************************************
// Includes
//******************************************************************************
#include <initservice/taskargs.H>
#include <sys/msg.h>
#include <targeting/adapters/types.H>
#include <targeting/common/targetservice.H>
#include <targeting/attrsync.H>
namespace TARGETING
{
// Forward declaration of attribute section parsed information structure.
struct AttrRP_Section;
/**
* @class AttrRP
*
* @brief Attribute Resource Provider daemon class.
*
* @par Detailed Description:
* Provides all the functionality to translate between PNOR and
* Attribute virtual memory spaces. Parses PNOR header for attribute
* sections, allocates virtual memory spaces with the kernel for each
* section, and handles virtual memory request messages from the
* kernel.
*/
class AttrRP
{
// add some friends for the attribute sync features
friend bool TargetService::writeSectionData(
const std::vector<sectionRefData>& i_pages );
friend void TargetService::readSectionData(
std::vector<sectionRefData>& o_pages,
const SECTION_TYPE i_sectionId);
public:
/**
* @brief Returns base address of the RO section containing the
* targets
*
* @return Base address of the RO section containing the targets as
* a void*
*/
void* getBaseAddress();
/**
* @brief Translates given address, according to the resource
* provider's translation algorithm
*
* @param[in] i_pAddress
* Address to translate
*
* @return void* Returns the translated address. Common attribute
* code has a static, compile time check that is used to
* determine whether to call this function, however the Hostboot
* compiler complains when this is not provided. Therefore
* while this method exists, Hostboot will never call it, and if
* it does it will always get a no-op translation.
*/
void* translateAddr(
void* i_pAddress)
{
return i_pAddress;
}
/**
* @brief Initializes and starts the AttrRP daemon.
*
* @param[in/out] io_taskRetErrl
* Error log handle; on input, a NULL error log handle; on
* output, a NULL error log handle on success, or !NULL handle
* on failure
*
* @note If any error occurs during initialization, it will be
* reported back through the TaskArgs structure to the init
* service.
*/
static void init(errlHndl_t& io_taskRetErrl);
protected:
/**
* @brief Initialize the attribute resource provider
*
* @par Detailed Description"
* Ensures member variables are initialized to sane values.
*/
AttrRP()
: iv_msgQ(NULL), iv_sections(NULL), iv_sectionCount(0)
{
};
/**
* @brief Destroy the attribute resource provider
*
* @par Detailed Description:
* Frees any memory allocated by the resource provider.
*
* @note This should never actually be used because the daemon
* thread and the vmm blocks are unable to be reclaimed.
* Function will assert if called due to leaky behavior.
*/
~AttrRP();
/**
* @brief Copies the section data buffer from the vector to the
* appropriate section offset with respect to the node target ptr
* and section id.
*
* @param[in] i_pages, vector of sectionRefData struct
*
* @return void
*/
void writeSectionData(
const std::vector <sectionRefData>& i_pages);
/**
* @brief Populates the output vector with the correct information
* for the data pages specified by the selected section
*
* @param[out] o_pages, vector of sectionRefData struct
*
* @return void
*/
void readSectionData(
std::vector <sectionRefData>& o_pages,
const SECTION_TYPE i_sectionType);
private:
/**
* @brief Performs the startup of the daemon instance.
*
* @par Detailed Description:
* init() is a static function that just calls
* Singleton<AttrRP>::instance().startup(). See init for
* behavior.
*
* @param[in/out] io_taskRetErrl
* Error log handle; on input, a NULL error log handle; on
* output, a NULL error log handle on success, or !NULL handle
* on failure
*/
void startup(errlHndl_t& io_taskRetErrl);
/**
* @brief Processes daemon messages
*
* @par Detailed Description:
* Performs a while(1) waiting for messages from the
* kernel/VMM and handles as appropriately. Reads / writes
* data from / to PNOR for the attribute sections.
*/
void msgServiceTask() const;
/**
* @brief Parses the attribute section header in PNOR.
*
* @par Detailed Description:
* Constructs the local attribute section data structures
* (iv_sections / iv_sectionCount).
*
* @return errlHndl_t
* Returns an error log handle that is NULL on success or !NULL
* on failure
*/
errlHndl_t parseAttrSectHeader();
/**
* @brief Allocates VMM sections for each Attribute section.
*
* @par Detailed Description:
* Calls to the kernel to create VMM blocks for each attribute
* and initializes permissions appropriately based on section
* type.
*
* @return errlHndl_t
* Returns an error log handle that is NULL on success or !NULL
* on failure
*/
errlHndl_t createVmmSections();
/**
* @brief Starts the attribute provider's message processor
*
* @par Detailed Description:
* This function, being static, can be called from task_create
* and is used to enter the daemon thread's msgServiceTask
* loop to process messages.
*
* @param[in] i_pInstance
* The AttrRP to call msgServiceTask on.
*/
static void* startMsgServiceTask(void* i_pInstance);
// Message Queue for VMM requests
msg_q_t iv_msgQ;
// Parsed structures of the attribute sections.
AttrRP_Section* iv_sections;
// Count of attribute sections.
size_t iv_sectionCount;
};
/**
* @brief Give callers access to the singleton
*/
TARG_DECLARE_SINGLETON(TARGETING::AttrRP,theAttrRP);
} // End namespace TARGETING
#endif // __TARGETING_ATTRRP_H
|