summaryrefslogtreecommitdiffstats
path: root/src/import/generic/memory/lib/spd/spd_traits.H
blob: b05f2c4473cc21cbeccd8d1042e7ac13b0647428 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/import/generic/memory/lib/spd/spd_traits.H $              */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2018                             */
/* [+] 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 spd_traits.H
/// @brief Declaration for assocated traits to reading SPD
///

// *HWP HWP Owner: Andre Marin <aamarin@us.ibm.com>
// *HWP HWP Backup: Stephen Glancy <sglancy@us.ibm.com>
// *HWP Team: Memory
// *HWP Level: 2
// *HWP Consumed by: HB:FSP

#ifndef _MSS_SPD_READER_TRAITS_H_
#define _MSS_SPD_READER_TRAITS_H_

#include <cstdint>
#include <functional>
#include <generic/memory/lib/spd/spd_field.H>

namespace mss
{
namespace spd
{

///
/// @brief Checks SPD input field against a custom conditional
/// @tparam T SPD field input type
/// @tparam F Callable object type
/// @param[in] i_spd_field Extracted SPD field
/// @param[in] i_comparison_val value we are comparing against
/// @param[in] i_op comparison operator function object
/// @return boolean true or false
///
template < typename T, typename F >
bool conditional(const T i_spd_field,
                 const size_t i_comparison_val,
                 const F i_op)
{
    return i_op(i_spd_field, i_comparison_val);
}

///
/// @class readerTraits
/// @brief trait structure to hold static SPD information
/// @tparam F holds SPD field info
/// @tparam R the revision of the SPD field
///
template< const field_t& F, rev R >
class readerTraits;

///
/// @class readerTraits
/// @brief trait structure to hold static SPD information
/// @tparam R the revision of the SPD field
/// @note REVISION field specialization
/// @note valid for all revs
///
template< rev R >
class readerTraits < init_fields::REVISION, R >
{
    public:

        static constexpr size_t COMPARISON_VAL = 0xFF;
        static constexpr const char* FIELD_STR = "SPD Revision";

        template <typename T>
        using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class readerTraits
/// @brief trait structure to hold static SPD information
/// @tparam R the revision of the SPD field
/// @note DEVICE_TYPE field specialization
/// @note valid for all revs
///
template< rev R >
class readerTraits< init_fields::DEVICE_TYPE, R >
{
    public:

        static constexpr size_t COMPARISON_VAL = 0x11; ///< Largest valid SPD encoding
        static constexpr const char* FIELD_STR = "DRAM Device Type";

        template <typename T>
        using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class readerTraits
/// @brief trait structure to hold static SPD information
/// @tparam R the revision of the SPD field
/// @note BASE_MODULE field specialization
/// @note valid for all revs
///
template< rev R >
class readerTraits < init_fields::BASE_MODULE, R >
{
    public:

        static constexpr size_t COMPARISON_VAL = 0b1101;
        static constexpr const char* FIELD_STR = "Base Module";

        template <typename T>
        using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class readerTraits
/// @brief trait structure to hold static SPD information
/// @note HYBRID field specialization
/// @note valid for all revs
///
template< rev R >
class readerTraits< init_fields::HYBRID, R >
{
    public:

        static constexpr size_t COMPARISON_VAL = 1;
        static constexpr const char* FIELD_STR = "Hybrid";

        template <typename T>
        using COMPARISON_OP = std::less_equal<T>;
};

///
/// @class readerTraits
/// @brief trait structure to hold static SPD information
/// @note HYBRID_MEDIA field specialization
/// @note valid for all revs
///
template< rev R >
class readerTraits< init_fields::HYBRID_MEDIA, R >
{
    public:

        static constexpr size_t COMPARISON_VAL = 1;
        static constexpr const char* FIELD_STR = "Hybrid Media";

        template <typename T>
        using COMPARISON_OP = std::less_equal<T>;
};

/// @class readerTraits
/// @brief trait structure to hold static SPD information
/// @note REF_RAW_CARD field specialization
/// @note valid for all revs
///
template< rev R >
class readerTraits< init_fields::REF_RAW_CARD, R >
{
    public:

        static constexpr size_t COMPARISON_VAL = 1;
        static constexpr const char* FIELD_STR = "Reference Raw Card";

        template <typename T>
        using COMPARISON_OP = std::less_equal<T>;
};

}// spd
}// mss

#endif //_MSS_SPD_READER_TRAITS_H_
OpenPOWER on IntegriCloud