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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
|
// IBM_PROLOG_BEGIN_TAG
// This is an automatically generated prolog.
//
// $Source: src/usr/initservice/istepdispatcher/splesscommon.H $
//
// IBM CONFIDENTIAL
//
// COPYRIGHT International Business Machines Corp. 2011
//
// 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 other-
// wise divested of its trade secrets, irrespective of what has
// been deposited with the U.S. Copyright Office.
//
// Origin: 30
//
// IBM_PROLOG_END
#ifndef __ISTEPDISP_SPLESS_COMMON_H
#define __ISTEPDISP_SPLESS_COMMON_H
/**
* @file splesscommon.H
*
* Prototypes for routines to access SPLESS Command and
* and SPLESS Status interfaces
*
* Currently SPLess only supports the one command 0x00, this rewrite will
* allow support of other SPLess commands.
*
*/
/******************************************************************************/
// Includes
/******************************************************************************/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
// undefine this before checking in....
// #define SPLESS_DEBUG 1
#ifdef SPLESS_DEBUG
#include <kernel/console.H> // printk DEBUG
#endif
#include <sys/mmio.h> // mmio_scratch_read()
// external reference
namespace INITSERVICE
{
extern trace_desc_t *g_trac_initsvc;
} // end namespace INITSERVICE
/******************************************************************************/
// SPLESS Command and Status Prototypes
/******************************************************************************/
/**
* @namespace SPLESSCMD
*
* Contains functions to manipulate the SPLESS Command Register
*
*/
namespace SPLESS
{
/**
* @note Since ISTEP_MODE attribute is nonvolatile (persists across boots),
* we must have a way to turn the attribute both ON and OFF - we
* cannot depend on the FSP to do it since we may not have a FSP.
*/
const uint64_t ISTEP_MODE_ON_SIGNATURE = 0x4057b0074057b007;
const uint64_t ISTEP_MODE_OFF_SIGNATURE = 0x700b7504700b7504;
/**
* @enum
* SPLess Task return codes
*
* task return codes for SPless single step
* @note future errors will be passed from task_create() and task_exec()
* and should be documented in errno.h
*
*/
enum {
SPLESS_TASKRC_INVALID_ISTEP = -3, // invalid istep or substep
SPLESS_TASKRC_LAUNCH_FAIL = -4, // failed to launch the task
SPLESS_TASKRC_RETURNED_ERRLOG = -5, // istep returned an errorlog
SPLESS_TASKRC_TERMINATED = -6, // terminated the polling loop
SPLESS_TASKRC_FAIL_LOADMODULE = -7, // failed to load module
SPLESS_INVALID_COMMAND = 10, // invalid command from user console
SPLESS_AT_BREAK_POINT = 11, // at breakpoint
SPLESS_NOT_AT_BREAK_POINT = 12, // resume command w/o breakpoint
SPLESS_SHUTTING_DOWN = 13, // shutdown command issued
};
/**
* @note declare global regs to implement SPLess.
* These replace the SCOM regs that are accessed by mmio; the reason we
* are changing this is that there is no support at present for read/writing
* SCOM in the Debug Framework.
* This will have to be modified again when we get to Secure Boot
*
* @todo An review issue came up about when and how these are updated -
* While hostboot is running in SIMICS or VBU, the user console (i.e. a
* perl script, see src/build/vpo/hb_istep) will stop the instruction clock,
* write a command to g_SPLess_Command_Reg, and then restart the clock.
*
* Q1) In non-VPO mode (real FSP) are we always going to stop instructions
* to the processor to modify these variables?
* A: Yes, at this writing. If this changes, we should revisit this
* implementation.
*
* Q1a) Do these memory locations need to be accessed atomically (i.e. using
* __sync_add_and_fetch() and/or isync()/sync() )?
* A: No, not at this writing.
*
* Q2) When we stop instructions to the processor is the instruction pipeline
* and load/store queues flushed?
*
* A: No. The stop commands used in the simulator user console should
* quiesce the processor; this should guarantee that there are no
* outstanding loads or stores.
*/
extern uint64_t g_SPLess_Command_Reg;
extern uint64_t g_SPLess_Status_Reg;
extern uint64_t g_SPLess_IStepMode_Reg;
/**
* @note SPLess commands, and masks for the status.
*
*/
const uint8_t SPLESS_SINGLE_ISTEP_CMD = 0x00;
const uint8_t SPLESS_RESUME_ISTEP_CMD = 0x01;
const uint8_t SPLESS_CLEAR_TRACE_CMD = 0x02;
const uint8_t SPLESS_SHUTDOWN_CMD = 0x03;
const uint64_t SPLESS_SINGLE_STEP_STS_MASK = 0x00000000ffffffff;
/**
* @brief init ISTEP_MODE attribute
*
* @return nothing
*
*/
inline void initIStepMode( )
{
using namespace TARGETING;
uint64_t l_readData = 0;
Target *l_pTopLevel = NULL;
TargetService& l_targetService = targetService();
(void) l_targetService.getTopLevelTarget(l_pTopLevel);
if (l_pTopLevel == NULL)
{
TRACFCOMP( INITSERVICE::g_trac_initsvc, "Top level handle was NULL" );
// drop through, default of attribute is is false
}
else
{
// got a pointer to Targeting, complete setting the flag
// $$ save l_readData = mmio_scratch_read( MMIO_SCRATCH_IPLSTEP_CONFIG );
l_readData = g_SPLess_IStepMode_Reg;
#ifdef SPLESS_DEBUG
printk( "IStepMode Reg = 0x%p, 0x%lx\n", &g_SPLess_IStepMode_Reg, l_readData );
printk( "Status Reg = 0x%p\n", &g_SPLess_Status_Reg );
printk( "Command Reg = 0x%p\n", &g_SPLess_Command_Reg );
#endif
TRACDCOMP( INITSERVICE::g_trac_initsvc,
"IStepMode Reg = 0x%llx",
l_readData );
// check for IStep Mode signature(s)
if ( l_readData == ISTEP_MODE_ON_SIGNATURE )
{
l_pTopLevel->setAttr<ATTR_ISTEP_MODE> (true );
TRACDCOMP( INITSERVICE::g_trac_initsvc,
"ISTEP_MODE attribute set to TRUE." );
}
else
{
// make sure it's set to one or the other after istepdispatcher starts.
// This makes it easier for hb-istep to find HostBoot's state.
l_readData = ISTEP_MODE_OFF_SIGNATURE;
// $$ save mmio_scratch_write( MMIO_SCRATCH_IPLSTEP_CONFIG, l_readData );
l_pTopLevel->setAttr<ATTR_ISTEP_MODE> ( false );
TRACDCOMP( INITSERVICE::g_trac_initsvc,
"ISTEP_MODE attribute set to FALSE." );
}
}
}
/**
* @struct CommandHdr
*
* Command Header for all SPless commands. 2 bytes long.
* Bit numbers are in ppc notation, where bit 0 is the most significant bit.
* Go Bit : bit 0 (ppc notation, msbit)
* - set to 1 by the user to start the IStep
* - cleared to 0 by HostBoot
* Reserved: bit 1: always 0
* Sequence #: bits 2-7
* Command Number: bits 8:15
*
*
*/
struct CommandHdr
{
bool gobit:1;
uint8_t reserved0:1;
uint8_t seqnum:6;
uint8_t cmdnum;
} __attribute__((packed));
/**
* @union SPLessCmd
*
* 64-bit "template" struct for the SPLess command.
* This will be read in and used to extract the header info, then "cast"
* to the correct command.
*/
union SPLessCmd
{
uint64_t val64;
struct
{
CommandHdr hdr;
uint16_t reserved1;
uint32_t reserved2;
} __attribute__((packed));
// init struct to 0
SPLessCmd() : val64(0) {};
} ;
/**
* @union SPLessSingleIStepCmd
*
* Implement Command 0x00, run Istep/Substep
*
* Send IStep and SubStep number(s) to run.
*
*/
union SPLessSingleIStepCmd
{
uint64_t val64;
struct
{
CommandHdr hdr;
uint8_t istep;
uint8_t substep;
uint32_t reserved;
} __attribute__((packed));
SPLessSingleIStepCmd() : val64(0) {};
SPLessSingleIStepCmd( const SPLessCmd &i_cmd )
: val64(i_cmd.val64) { };
private:
// disable assignment constructor
SPLessSingleIStepCmd& operator=(const SPLessSingleIStepCmd& i_right);
} ;
/**
* @brief Read the command register and return a filled-in SPLessCmd struct
*
* @param[in,out] io_rcmd - reference to a SPLessCmd struct
*
* @return none
*/
inline void readCmd( SPLessCmd &io_rcmd )
{
// $$ save io_rcmd.val64 = mmio_scratch_read(MMIO_SCRATCH_IPLSTEP_COMMAND);
io_rcmd.val64 = g_SPLess_Command_Reg;
#ifdef SPLESS_DEBUG
printk( "readCmd 0x%lx\n", g_SPLess_Command_Reg );
#endif
}
/**
* @brief Write a filled-in command struct to the command reg.
*
* Normally the user writes the command reg; this is only used to
* init the command reg at the beginning
*
* @param[in] i_rcmd - reference to a filled-in SPLessCmd reg
*
* @return none
*/
inline void writeCmd( SPLessCmd &io_rcmd )
{
// $$ save mmio_scratch_write( MMIO_SCRATCH_IPLSTEP_COMMAND, io_rcmd.val64 );
g_SPLess_Command_Reg = io_rcmd.val64;
#ifdef SPLESS_DEBUG
printk( "writeCmd 0x%lx\n", g_SPLess_Command_Reg );
#endif
}
/******************************************************************************/
// SPLESS Status Prototypes
/******************************************************************************/
/**
* @struct StatusHdr
*
* header for the Status Reg returned by all SPLess Commands.
*
* Bit numbers are in ppc notation, where bit 0 is the most significant bit.
* * Running bit, bit 0 (ppc notation, msbit):
* = 1 when IStep is running
* = 0 when IStep is finished
* Ready bit, bit 1:
* = 1 when IStep Dispatcher is ready to run individual ISteps
* = 0 if IStep Dispatcher is not ready:
* - System has not loaded the IStep Dispatcher yet
* - IStep Mode Flag = 0
* Sequence # : bits 2-7 - echoes the sequence number in the associated
* command frame.
* Status : returned status for the command, from IStepDisp.
* For example:
* -EINVAL IStep number is invalid
* -ENOENT, -ENOEXEC (return code from kernel) IStep could not
* be launched as a task or as a function within a task
*/
struct StatusHdr
{
bool runningbit:1;
bool readybit:1;
uint8_t seqnum:6;
int8_t status;
} __attribute__((packed));
union SPLessSingleIStepSts;
/**
* @union SPLessSts
*
* Send HostBoot Status to the user console
*
*/
union SPLessSts {
uint64_t val64;
struct {
StatusHdr hdr;
uint16_t reserved1;
uint32_t reserved2;
} __attribute__((packed));
// init struct to 0
SPLessSts() : val64(0) {};
SPLessSts & operator=(const SPLessSingleIStepSts & i_right);
} ;
/**
* @union SPLessSts0x00
*
* Return Status from IStep/Substep
*
*/
union SPLessSingleIStepSts {
uint64_t val64;
struct {
StatusHdr hdr;
uint8_t istep;
uint8_t substep;
uint32_t istepStatus;
} __attribute__((packed));
SPLessSingleIStepSts() : val64(0) {};
SPLessSingleIStepSts(const SPLessSts & i_sts ) : val64(i_sts.val64) {};
SPLessSingleIStepSts & operator=(const SPLessSts & i_right)
{
this->val64 = i_right.val64;
return *this;
}
} ;
SPLessSts & SPLessSts::operator=(const SPLessSingleIStepSts & i_right)
{
this->val64 = i_right.val64;
return *this;
}
/**
* @brief Read the SPLess Status reg and return a filled in struct.
*
* @param[in,out] io_rsts - ref SPLessSts struct
*
* @return none.
*/
inline void readSts( SPLessSts &io_rsts )
{
// $$ save io_rsts.val64 = mmio_scratch_read(MMIO_SCRATCH_IPLSTEP_STATUS);
io_rsts.val64 = g_SPLess_Status_Reg;
#ifdef SPLESS_DEBUG
printk( "readSts 0x%lx\n", g_SPLess_Status_Reg );
#endif
}
/**
* @brief Write a filled in SPLessSts struct to the SPLess Status Reg
*
* @param[in,out] io_rsts
*
* @return none
*/
inline void writeSts( SPLessSts &io_rsts )
{
// $$ save mmio_scratch_write( MMIO_SCRATCH_IPLSTEP_STATUS, io_rsts.val64 );
g_SPLess_Status_Reg = io_rsts.val64;
#ifdef SPLESS_DEBUG
printk( "writeSts 0x%lx\n", g_SPLess_Status_Reg );
#endif
}
} // namespace
#endif
|