summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/attn/test/attnfaketarget.H
blob: de03d891f2190d9273f4bf97b624532c323a3069 (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
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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/attn/test/attnfaketarget.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 __TEST_ATTNFAKETARGET_H
#define __TEST_ATTNFAKETARGET_H

/**
 * @file attnfaketarget.H
 *
 * @brief HBATTN fake targeting class definitions.
 */

#include "attntest.H"
#include "../attntarget.H"

namespace ATTN
{

/**
 * @brief FakeProcTargetService
 *
 * A fake service for supporting processor only configurations.
 */
class FakeProcTargetService : public TargetServiceImpl
{
    public:

        /**
         * @brief getProc
         *
         * @param[in] i_pos
         *
         * @return
         */
        TARGETING::TargetHandle_t getProcFromPos(uint64_t i_pos);

        /**
         * @brief getProcPos
         *
         * @param[in] i_proc
         *
         * @return
         */
        uint64_t getProcFromTarget(TARGETING::TargetHandle_t i_proc);

        /**
         * @brief getAllChips Get a list of chips.
         *
         * @param[out] o_list The populated list of chips.
         * @param[in] i_type The type of chip for which a list
         *              should be obtained.
         * @param[in] i_functional functional chip filter.
         */
        virtual void getAllChips(
                TARGETING::TargetHandleList & o_list,
                TARGETING::TYPE i_type,
                bool i_functional = true);

        /**
         * @brief getMcsList Obtain the list of MCS unit targets
         *           for the given proc chip target.
         *
         * Not implemented for processor only configurations.
         *
         * @param[in] i_proc The proc chip target for which a
         *              list of MCS unit targets should be obtained.
         * @param[out] o_list The populated list of MCS unit targets.
         */
        virtual void getMcsList(
                TARGETING::TargetHandle_t i_proc,
                TARGETING::TargetHandleList & o_list)
        {

        }

        /**
         * @brief getProc Find the requested membuf chip
         *           target parent proc chip target.
         *
         * @param[in] i_membuf The membuf chip target
         *             for which the parent proc chip target
         *             should be found.
         *
         * Not implemented for processor only configurations.
         *
         * @retval[0] Did not find any associated proc chip target.
         * @retval[!0] Associated proc chip parent target.
         */
        virtual TARGETING::TargetHandle_t getProc(
                TARGETING::TargetHandle_t i_membuf)
        {
            return 0;
        }

        /**
         * @brief getMcs Find the requested membuf chip
         *           target parent MCS unit target.
         *
         * @param[in] i_membuf The membuf chip target
         *             for which the parent MCS unit target
         *             should be found.
         *
         * Not implemented for processor only configurations.
         *
         * @retval[0] Did not find any associated MCS unit target.
         * @retval[!0] Associated MCS unit parent target.
         */
        virtual TARGETING::TargetHandle_t getMcs(
                TARGETING::TargetHandle_t i_membuf)
        {
            return 0;
        }

        /**
         * @brief getMcs Find the MCS unit target given
         *           the proc chip parent target and MCS position.
         *
         * @param[in] i_proc The proc chip target for which the
         *                MCS unit target should be found.
         * @param[in] i_pos The MCS unit position for which the MCS
         *                unit target should be found.
         *
         * Not implemented for processor only configurations.
         *
         * @retval[0] Did not find any associated MCS unit target.
         * @retval[!0] Associated MCS unit target.
         */
        virtual TARGETING::TargetHandle_t getMcs(
                TARGETING::TargetHandle_t i_proc,
                uint64_t i_pos)
        {
            return 0;
        }

        /**
         * @brief getMcsPos Find the MCS unit position given
         *           the MCS unit target.
         *
         * Not implemented for processor only configurations.
         *
         * @param[in] i_mcs The MCS unit target for which the
         *                MCS unit position should be found.
         * @param[out] o_pos The MCS unit position.
         */
        virtual void getMcsPos(
                TARGETING::TargetHandle_t i_mcs,
                uint64_t & o_pos)
        {

        }

        /**
         * @brief getMembuf Find the requested MCS unit target
         *           child membuf chip target.
         *
         * @param[in] i_mcs The MCS unit target
         *             for which the child membuf chip target
         *             should be found.
         *
         * Not implemented for processor only configurations.
         *
         * @retval[0] Did not find any associated membuf chip target.
         * @retval[!0] Associated membuf chip target.
         */
        virtual TARGETING::TargetHandle_t getMembuf(
                TARGETING::TargetHandle_t i_mcs)
        {
            return 0;
        }

        /**
         * @brief getType Obtain the type of the provided target.
         *
         * Returns Hardcoded to TYPE_PROC for anything passed in.
         *
         * @param[in] i_target The target for which the type
         *                should be obtained.
         *
         * @return The type of the provided target.
         */
        virtual TARGETING::TYPE getType(TARGETING::TargetHandle_t i_target)
        {
            return TARGETING::TYPE_PROC;
        }

        virtual bool getAttribute(
                TARGETING::ATTRIBUTE_ID i_attribute,
                TARGETING::TargetHandle_t i_target,
                uint64_t & o_val);

        /**
         * @brief dtor
         */
        virtual ~FakeProcTargetService() {}

        /**
         * @brief ctor
         *
         * @param[in] i_count The number of processor targets.
         */
        explicit FakeProcTargetService(uint64_t i_count);

    private:

        /**
         * @brief iv_procs The fake processor targets.
         */
        TARGETING::TargetHandleList iv_procs;
};

/**
 * @brief FakeProcTargetService
 *
 * A fake service for supporting processor and membuf configurations.
 * Provides a hardcoded number of fake membuf targets, and a mapping
 * between them and an externally provided array of processor targets.
 */
class FakeMemTargetService : public FakeProcTargetService
{
    public:

        /**
         * @brief getAllChips Get a list of chips.
         *
         * @param[out] o_list The populated list of chips.
         * @param[in] i_type The type of chip for which a list
         *              should be obtained.
         * @param[in] i_functional functional chip filter.
         */
        void getAllChips(
                TARGETING::TargetHandleList & o_list,
                TARGETING::TYPE i_type,
                bool i_functional = true);

        /**
         * @brief getMcsList Obtain the list of MCS unit targets
         *           for the given proc chip target.
         *
         * @param[in] i_proc The proc chip target for which a
         *              list of MCS unit targets should be obtained.
         * @param[out] o_list The populated list of MCS unit targets.
         */
        void getMcsList(
                TARGETING::TargetHandle_t i_proc,
                TARGETING::TargetHandleList & o_list);

        /**
         * @brief getProc Find the requested membuf chip
         *           target parent proc chip target.
         *
         * @param[in] i_membuf The membuf chip target
         *             for which the parent proc chip target
         *             should be found.
         *
         * @retval[0] Did not find any associated proc chip target.
         * @retval[!0] Associated proc chip parent target.
         */
        TARGETING::TargetHandle_t getProc(
                TARGETING::TargetHandle_t i_membuf);

        /**
         * @brief getMcs Find the requested membuf chip
         *           target parent MCS unit target.
         *
         * @param[in] i_membuf The membuf chip target
         *             for which the parent MCS unit target
         *             should be found.
         *
         * @retval[0] Did not find any associated MCS unit target.
         * @retval[!0] Associated MCS unit parent target.
         */
        TARGETING::TargetHandle_t getMcs(
                TARGETING::TargetHandle_t i_membuf);

        /**
         * @brief getMcs Find the MCS unit target given
         *           the proc chip parent target and MCS position.
         *
         * @param[in] i_proc The proc chip target for which the
         *                MCS unit target should be found.
         * @param[in] i_pos The MCS unit position for which the MCS
         *                unit target should be found.
         *
         * @retval[0] Did not find any associated MCS unit target.
         * @retval[!0] Associated MCS unit target.
         */
        TARGETING::TargetHandle_t getMcs(
                TARGETING::TargetHandle_t i_proc,
                uint64_t i_pos);

        /**
         * @brief getMcsPos Find the MCS unit position given
         *           the MCS unit target.
         *
         * @param[in] i_mcs The MCS unit target for which the
         *                MCS unit position should be found.
         * @param[out] o_pos The MCS unit position.
         */
        void getMcsPos(
                TARGETING::TargetHandle_t i_mcs,
                uint64_t & o_pos);

        /**
         * @brief getMembuf Find the requested MCS unit target
         *           child membuf chip target.
         *
         * @param[in] i_mcs The MCS unit target
         *             for which the child membuf chip target
         *             should be found.
         *
         * @retval[0] Did not find any associated membuf chip target.
         * @retval[!0] Associated membuf chip target.
         */
        TARGETING::TargetHandle_t getMembuf(
                TARGETING::TargetHandle_t i_mcs);

        /**
         * @brief getType Obtain the type of the provided target.
         *
         * @param[in] i_target The target for which the type
         *                should be obtained.
         *
         * @return The type of the provided target.
         */
        TARGETING::TYPE getType(
                TARGETING::TargetHandle_t i_target);

        /**
         * @brief dump print configuration to trace.
         */
        void dump();

        /**
         * @brief dtor
         */
        ~FakeMemTargetService();

        /**
         * @brief ctor
         *
         * @param[in] i_firstProc The first proc target for
         *                which to generate membuf mappings.
         * @param[in] i_lastProc Past the last proc target for which
         *                to generate membuf mappings.
         */
        explicit FakeMemTargetService(uint64_t i_count);

    private:

        TARGETING::TargetHandleList iv_mcses;
        TARGETING::TargetHandleList iv_membufs;

        /**
         * @brief iv_first The first proc target for which to
         *           generate mappings.
         */
        TARGETING::TargetHandle_t iv_first;

        /**
         * @brief iv_firstMcs The first mcs target for
         *              which to generate mappings.
         */
        TARGETING::TargetHandle_t iv_firstMcs;

        /**
         * @brief iv_firstMcs The first membuf target for
         *              which to generate mappings.
         */
        TARGETING::TargetHandle_t iv_firstMembuf;

        /**
         * @brief cv_membufsPerProc The number of membuf targets
         *            per proc target for which mappings should
         *            be generated.
         */
        static const uint64_t cv_membufsPerProc = 8;
};
}
#endif
OpenPOWER on IntegriCloud