summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/mnfgtools/prdfMfgThresholdFile_common.H
blob: 226a2e4c85b7fd70785d9998f9ea8d6604822ced (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/mnfgtools/prdfMfgThresholdFile_common.H $ */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013                   */
/*                                                                        */
/* 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 otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

#ifndef __PRDFMFGTHRESHOLDFILECOMMON
#define __PRDFMFGTHRESHOLDFILECOMMON

#include <stdint.h>
#include <map>

#ifdef __HOSTBOOT_MODULE

  // FIXME: RTC 73204 was opened to add support for these in hostboot. They will
  //        need to be removed once the issue has been resolved.
  #ifndef htonl
    #define htonl(foo) (foo)
  #endif

  #ifndef ntohl
    #define ntohl(foo) (foo)
  #endif

#else

  #include <netinet/in.h>

#endif


namespace PRDF
{

class MfgThresholdFileCommon
{
    public:

        /**
         *  @brief Structure of threshold to sync
        */
        struct SyncThreshold_t
        {
            uint32_t hash;
            uint8_t  value;
            SyncThreshold_t()
            {
                hash  = 0;
                value = 0;
            }
        }__attribute__ ((packed));

        /**
         *  @brief threshold map
        */
        typedef std::map<uint32_t, uint8_t> Threshold_t;

        /**
         * @brief Infinite threshold enum
        */
        enum { INFINITE_LIMIT_THR = 0xff };

        /**
         *  @brief constructor
        */
        MfgThresholdFileCommon() {};

        /**
         *  @brief destructor
        */
        virtual ~MfgThresholdFileCommon() {};

        /**
         *  @brief configure MfgThresholdFile
        */
        virtual void setup() = 0;

        /**
         * @brief get threshold value from name
         * @param[in] i_thrName - threshold name
         *
         * @return corresponding threshold value
         */
        uint8_t getThreshold(uint32_t i_thrName);

        /**
         * @brief set threshold name/value
         * @param[in] i_thrName - threshold name
         * @param[in] i_value - threshold value
         */
        void setThreshold(uint32_t i_thrName, uint8_t i_value);

        /**
         * @brief clear all thresholds
         *
         */
        void clearThresholds();

        /**
         * @brief get number of thresholds
         *
         * @return number of predefined thresholds
         */
        inline uint32_t getThresholdSize()
        {
            return iv_thresholds.size() * sizeof(SyncThreshold_t);
        }

        /**
         * @brief serialize threshold data into data buffer
         * @param[in/out] o_buffer - data buffer
         * @param[in] i_sizeOfBuf - size of buffer
         */
        virtual void packThresholdDataIntoBuffer(
                                        uint8_t* & o_buffer,
                                        uint32_t i_sizeOfBuf) = 0;

        /**
         * @brief deserialize data buffer into threshold data
         * @param[in/out] o_buffer - data buffer
         * @param[in] i_sizeOfBuf - size of buffer
         */
        virtual void unpackThresholdDataFromBuffer(
                                        uint8_t* & o_buffer,
                                        uint32_t i_sizeOfBuf);

    protected:

        Threshold_t iv_thresholds;

};

} // end namespace PRDF

#endif
OpenPOWER on IntegriCloud