summaryrefslogtreecommitdiffstats
path: root/src/hwpf/plat_target.H
blob: 51f326294ac4e6944f9e745341cc4332c33fd5f7 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/hwpf/plat_target.H $                                      */
/*                                                                        */
/* OpenPOWER sbe Project                                                  */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2015,2017                        */
/* [+] 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 plat_target.H
 * @brief platform definitions for fapi2 targets
 */

#ifndef __FAPI2_PLAT_TARGET__
#define __FAPI2_PLAT_TARGET__

#include <stdint.h>
#include <target_types.H>
#include <target_states.H>
#include <assert.h>
#include <plat_target_parms.H>
#include <vector>

static const uint8_t CORES_PER_QUAD = 4;
static const uint8_t EX_PER_QUAD = 2;
static const uint8_t CORES_PER_EX = 2;
static const uint8_t N2_CHIPLET = 4;
static const uint8_t N3_CHIPLET = 5;
static const uint8_t MCS_PER_MCBIST = 2;
static const uint8_t PCI0_CHIPLET = 0x0D;

//
// Define what a platform handle looks like. For Hostboot,
// for example, this might be a void*. For the SBE, this
// will be a uint32_t ...
//
namespace fapi2
{
    typedef enum plat_target_type
    {
        PPE_TARGET_TYPE_NONE              = 0x00,
        PPE_TARGET_TYPE_PROC_CHIP         = 0x01,
        PPE_TARGET_TYPE_MCS               = 0x02,
        PPE_TARGET_TYPE_CORE              = 0x04,
        PPE_TARGET_TYPE_EQ                = 0x08,
        PPE_TARGET_TYPE_EX                = 0x10,
        PPE_TARGET_TYPE_PERV              = 0x20,
        PPE_TARGET_TYPE_MCBIST            = 0x40,
        PPE_TARGET_TYPE_SYSTEM            = 0x80,
        PPE_TARGET_TYPE_PHB               = 0x100,
        PPE_TARGET_TYPE_ALL               = 0xFFF,
    } plat_target_type_t;

    typedef union plat_target_handle {
        uint32_t value;
        struct {
            uint32_t chiplet_num       : 8;
            uint32_t type_target_num   : 8;
            uint32_t present           : 1;
            uint32_t functional        : 1;
            uint32_t is_multicast      : 1;
            uint32_t valid             : 1;
            uint32_t type              : 12;
        } fields;
        ///
        /// @brief Plat target handle constructor
        ///
        /// @param  i_value Value to instantiate handle with
        ///
        explicit plat_target_handle(uint32_t i_value = 0):value(i_value) {}

        ///
        /// @brief Get the fapi2::TargetType for this target
        ///
        /// @par Converts the internal PPE type for this target to fapi2 enum
        ///
        /// @return The fapi2::TargetType for this target
        ///
        TargetType getFapiTargetType() const;

        ///
        /// @brief Get the scom address overlay for this target
        ///
        /// @return Address overlay
        ///
        uint32_t getAddressOverlay() const
        {
            return (value & 0xFF000000);
        }

        ///
        /// @brief Get the plat target type
        ///
        /// @return The plat target type as a fapi2::TargetType
        ///
        TargetType getTargetType() const
        {
            return static_cast<TargetType>(fields.type);
        }

        ///
        /// @brief Get the instance number for this target
        ///
        /// @return The instance number for this target
        ///
        uint32_t getTargetInstance() const
        {
            return fields.type_target_num;
        }

        ///
        /// @brief Returns whether this target is functional
        ///
        /// @return true if Target is functional
        ///
        bool getFunctional() const
        {
            return fields.functional;
        }

        ///
        /// @brief Set functional state of the Target
        ///
        /// @param [in] i_state Functional state to set
        ///
        void setFunctional(const bool &i_state)
        {
            fields.functional = i_state;
        }

        ///
        /// @brief Returns whether this target is present
        ///
        /// @return true if Target is present
        ///
        bool getPresent() const
        {
            return fields.present;
        }

        ///
        /// @brief Set Target as present
        ///
        void setPresent()
        {
            fields.present = true;
        }

        ///
        /// @brief Get this target's parent
        ///
        /// @param [in] The fapi2 type of the requested parent
        /// @return Plat target handle to the parent target
        ///
        plat_target_handle getParent(const TargetType i_parentType) const;

        ///
        /// @brief Get this target's children
        ///
        /// @param [in] i_parentType fapi2 type of the parent
        /// @param [in] i_childType  fapi2 type of the child
        /// @param [in] i_platType   Plat type of the parent
        /// @param [in] i_state      Required state of the children
        /// @param [out] o_children  A vector of child target handles
        ///
        void getChildren(const TargetType i_parentType,
                         const TargetType i_childType,
                         const plat_target_type_t i_platType,
                         const TargetState i_state,
                         std::vector<plat_target_handle> &o_children) const;

        ///
        /// @brief Get proc chip target's children - filtered
        ///
        /// @param [in] i_filter     Target filter
        /// @param [in] i_state      Required state of the children
        /// @param [out] o_children  A vector of child target handles
        ///
        void getChildren(const TargetFilter i_filter,
                         const TargetState i_state,
                         std::vector<plat_target_handle>& o_children) const;

        ///
        /// @brief Gets the plat target handle as a uint32
        ///
        /// @return Plat target handle as a uint32_t
        ///
        operator uint32_t() const {return value;}
    } plat_target_handle_t;

    typedef plat_target_handle_t plat_target_argument_t;

    template<TargetType K, bool MULTICAST = false>
    plat_target_handle_t createPlatTargetHandle(const uint32_t i_plat_argument)
    {
        static_assert((MULTICAST != true) || (K == TARGET_TYPE_PROC_CHIP),
                "Only PROC_CHIP types can be multicast");
        plat_target_handle_t l_handle;

        if(MULTICAST == true)
        {
            // Simply set the is multicast flag
            l_handle.fields.is_multicast = 1;
        }
        else if(K & TARGET_TYPE_PROC_CHIP)
        {
            l_handle.fields.chiplet_num = 0;
            l_handle.fields.type = PPE_TARGET_TYPE_PROC_CHIP;
            l_handle.fields.type_target_num = 0;
        }
        else if(K & TARGET_TYPE_PERV)
        {
            l_handle.fields.chiplet_num = i_plat_argument + NEST_GROUP1_CHIPLET_OFFSET;
            l_handle.fields.type = PPE_TARGET_TYPE_PERV;
            l_handle.fields.type_target_num = i_plat_argument;
        }
        else if(K & TARGET_TYPE_CORE)
        {
            l_handle.fields.chiplet_num = i_plat_argument + CORE_CHIPLET_OFFSET;
            l_handle.fields.type = PPE_TARGET_TYPE_CORE | PPE_TARGET_TYPE_PERV;
            l_handle.fields.type_target_num = i_plat_argument;
        }
        else if(K & TARGET_TYPE_EQ)
        {
            l_handle.fields.chiplet_num = i_plat_argument + EQ_CHIPLET_OFFSET;
            l_handle.fields.type = PPE_TARGET_TYPE_EQ | PPE_TARGET_TYPE_PERV;
            l_handle.fields.type_target_num = i_plat_argument;
        }
        else if(K & TARGET_TYPE_EX)
        {
            l_handle.fields.chiplet_num = (i_plat_argument / 2) + EX_CHIPLET_OFFSET;
            l_handle.fields.type = PPE_TARGET_TYPE_EX;
            l_handle.fields.type_target_num = i_plat_argument;
        }
        else if(K & TARGET_TYPE_MCBIST)
        {
            l_handle.fields.chiplet_num = i_plat_argument + MCBIST_CHIPLET_OFFSET;
            l_handle.fields.type = PPE_TARGET_TYPE_MCBIST | PPE_TARGET_TYPE_PERV;
            l_handle.fields.type_target_num = i_plat_argument;
        }
        else if(K & TARGET_TYPE_MCS)
        {
            l_handle.fields.chiplet_num = N3_CHIPLET - (MCS_PER_MCBIST * (i_plat_argument / MCS_PER_MCBIST));
            l_handle.fields.type = PPE_TARGET_TYPE_MCS;
            l_handle.fields.type_target_num = i_plat_argument;
        }
        else if(K & TARGET_TYPE_PHB)
        {
            l_handle.fields.chiplet_num = (0 == i_plat_argument) ? PCI0_CHIPLET :
                                           (((i_plat_argument / 3) + 1) + PCI0_CHIPLET);
            l_handle.fields.type = PPE_TARGET_TYPE_PHB;
            l_handle.fields.type_target_num = i_plat_argument;
        }
        else if(K == TARGET_TYPE_ALL)
        {
            l_handle.fields.chiplet_num = i_plat_argument;
            l_handle.fields.type = PPE_TARGET_TYPE_ALL;
        }

        l_handle.fields.valid = 1;
        return l_handle;
    }

};

#endif
OpenPOWER on IntegriCloud