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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/initservice/baseinitsvc/initservice.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2015 */
/* [+] 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 __BASEINITSVC_INITSERVICE_H
#define __BASEINITSVC_INITSERVICE_H
/**
* @file initservice.H
*
* Base image Initialization Service
* - Manage high-level host boot IPL flow
* - Perform can-continue processing
* - Perform automatic and manual Istep execution
* - Handle flow errors as appropriate.
*
*/
/******************************************************************************/
// Includes
/******************************************************************************/
#include <stdint.h>
#include <util/singleton.H>
#include <sys/vfs.h> // VFS_MODULE_NAME_MAX
#include <sys/msg.h>
#include <trace/interface.H>
#include <errl/errlentry.H> // errlHndl_t
#include <errl/errlmanager.H> // errlCommit()
#include <initservice/initsvcreasoncodes.H>
#include <initservice/initsvcstructs.H>
#include <vmmconst.h>
#include <initservice/initserviceif.H>
namespace INITSERVICE
{
/******************************************************************************/
// Globals/Constants
/******************************************************************************/
/******************************************************************************/
// Typedef/Enumerations
/******************************************************************************/
/******************************************************************************/
// InitService Class
/******************************************************************************/
/**
* @class InitService
*
* Singleton Class
* This class is launched by _start() (see initservicetaskentry.C),
* which is launched by the kernel (init_main.C).
*
* Once started, it handles the rest of HostBoot Initialization.
*
*/
class InitService
{
public:
friend class InitServiceTest;
/**
* @brief Message queue structure.
*
*/
struct regMsgQ_t
{
msg_q_t msgQ;
uint32_t msgType;
uint32_t msgPriority;
/**
* @brief Constructor
*/
regMsgQ_t(msg_q_t i_msgQ,
uint32_t i_msgType,
EventPriority_t i_priority) :
msgQ(i_msgQ), msgType(i_msgType),
msgPriority((uint32_t)i_priority) {}
// allow us to sort the queue based on priority
bool operator < (const regMsgQ_t &msg ) const
{
return ( msgPriority < msg.msgPriority);
}
};
/**
* @brief Get singleton instance of this class.
*
* @return the (one and only) instance of InitService
*/
static InitService& getTheInstance();
/**
* @brief Provide an entry function into the class, called from _start()
*
* @param[in] i_args pointer to any arguments passed in from
* _start() and by extension the kernel,
* currently this is always NULL .
*
* @return nothing
*
*/
void init( void *i_args);
/**
* @brief Start a task using the taskname string in the TaskInfo struct.
*
* taskname string will be something like "libtargeting.so", which
* is the name of the compiled and linked targeting module.
* The module is expected to have implemented a extern "C"
* function called "void _start(void *args)" which is considered
* to be the "task entry point". *
*
* @param[in] i_ptask pointer to a TaskInfo struct
* @param[in,out] io_pargs pointer to any args. This is usually NULL.
*
* @return pointer to errorlog
* @retval NULL if success, filled in errorlog handle for failure
*/
errlHndl_t startTask( const TaskInfo *i_ptask,
void *io_pargs ) const;
/**
* @brief Execute an function
*
* @param[in] i_ptask - pointer to an TaskInfo struct
* @param[in,out] i_pargs - pointer to any args. This is usually NULL.
*
* @return pointer to errorlog
* @retval NULL if success, filled out errorlog if failure
*/
errlHndl_t executeFn( const TaskInfo *i_ptask,
void *i_pargs ) const;
/**
* @brief dispatch Task depending on what type of task it is,
* etc.
*
* @param[in] i_ptask - pointer to a TaskInfo struct, which should
* contain all the info to run the task.
* @param[in,out] io_pargs - pointer to any args. This is usually NULL.
*
* @return pointer to errlog
* @retval returns NULL, or a pointer to a filled out errorlog
*/
errlHndl_t dispatchTask( const TaskInfo *i_ptask,
void *io_pargs ) const;
/**
* @brief Registry a block/range of vitual memory to be handled during a
* shutdown.
*
* @param[in] i_vaddr - Base virtual address
* @param[in] i_size - Size of virtual memory from base address
* @param[in] i_priority - Order to handle given block(0-Lowest Priority)
*
* @return Nothing
*/
void registerBlock(void* i_vaddr, uint64_t i_size, BlockPriority i_priority);
/**
* @brief Register a service to be notified during shutdown
*
* @param[in] i_msgQ, A message queue to send a message to on shutdown
* @param[in] i_msgType, The message type to send.
* @param[in] i_priority, @See src/include/usr/initservice/initserviceif.H
*
* @return true - i_msgQ registered
* false - i_msgQ already registered.- not registered again.
*/
bool registerShutdownEvent(msg_q_t i_msgQ,
uint32_t i_msgType,
EventPriority_t i_priority);
/**
* @brief Un register a service for a Shutdown event
*
* @param[in] i_msgQ, The message queue to be removed.
*
* @return true - i_msgQ was removed from the event notification list. |
* false - i_msgQ was not registered in the event notification list.
*/
bool unregisterShutdownEvent(msg_q_t i_msgQ);
/**
* @brief Perform necessary shut down steps.
*
* @param[in] i_status - Shutdown status to be passed along on shutdown
* @param[in] i_payload_base - The base address (target HRMOR) of the
* payload.
* @param[in] i_payload_entry - The offset from base address of the
* payload entry-point.
* @param[in] i_payload_entry - HRMOR adjusted address of any payload data
* placed in r3
* @param[in] i_masterHBInstance - master hostboot instance number (node)
* Needed when starting payload on a
* multi-node system.
*
* @return Nothing
* @note This calls registered services to notify them of shutdown and it
* flushes the virtual memory.
*/
void doShutdown ( uint64_t i_status,
uint64_t i_payload_base = 0,
uint64_t i_payload_entry = 0,
uint64_t i_payload_data = 0,
uint64_t i_masterHBInstance = 0xffffffffffffffffull);
protected:
/**
* @brief Constructor for the InitService object.
*/
InitService();
/**
* @brief Destructor for the InitService object.
*/
~InitService();
private:
/**
* Disable copy constructor and assignment operator
*/
InitService(const InitService& i_right);
InitService& operator=(const InitService& i_right);
/**
* Check and load module associated with this task or function
* if necessary.
*
* @param[in] i_ptask - pointer to a TaskInfo struct, which should
* contain all the info to run the task.
* @return pointer to errorlog
* @retval NULL if success, filled out errorlog if failure
*/
errlHndl_t checkNLoadModule( const TaskInfo *i_ptask ) const;
/**
* @struct regBlock_t
* @brief Attributes stored for virtual memory ranges that must be handled
* during a shutdown.
*/
struct regBlock_t
{
//Base virtual address
void* vaddr;
//Size of virtual memory from base address
uint64_t size;
//Priority order in which to handle the given block
uint64_t priority;
/**
* @brief Constructor to initialize a registered block object
*/
regBlock_t(void* i_vaddr, uint64_t i_size, uint64_t i_priority) :
vaddr(i_vaddr), size(i_size), priority(i_priority) {}
};
//Store a list of registered blocks
std::vector<regBlock_t*> iv_regBlock;
typedef std::vector<regMsgQ_t> EventRegistry_t;
// List of Services to notify on shutdown
EventRegistry_t iv_regMsgQ;
mutex_t iv_registryMutex;
bool iv_shutdownInProgress;
}; // class InitService
} // namespace INITSERVICE
#endif
|