summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/prdfGlobal.H
blob: 0994f2bc74f2294bf42d968c2888468e49d716e0 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/prdfGlobal.H $                              */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2002,2014              */
/*                                                                        */
/* 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 PRDF_GLOBAL_HB_H
#define PRDF_GLOBAL_HB_H

/**
 * @file  prdfGlobal.H
 * @brief PRD global code specific to hostboot.
 *
 * This file contains the Processor Runtime Diagnostics global variable
 * and type declarations specific to hostboot.
 */

/*--------------------------------------------------------------------*/
/*  Includes                                                          */
/*--------------------------------------------------------------------*/
#include <prdfGlobal_common.H>
#include <util/singleton.H>
#include <sys/sync.h> // for mutex support

/*--------------------------------------------------------------------*/
/*  Singleton macros common to both FSP and Hostboot                  */
/*--------------------------------------------------------------------*/
/**
 *  @brief common singleton declaration to specific platform
 *
 *  @param[in] __T__
 *      Type of singleton, fully namespaced
 *
 *  @param[in] __NAME__
 *      Symbol name for singleton
 */

/**
 *  @brief common singleton "getter" to the specific platform
 *
 *  @param[in] __TYPE__
 *      Typedef for singleton, as created above
 *
 *  @return Singleton reference for the given singleton
 */

#define PRDF_DECLARE_SINGLETON(__T__,__NAME__) \
    typedef Singleton<__T__> __NAME__


#define PRDF_GET_SINGLETON(__TYPE__) \
    __TYPE__::instance()

// end Singleton macros

/**
 * @brief Interface to deconfig target at Runtime (Not valid in Hostboot)
 */
// FIXME:RTC: 65609 will address this issue.
// need to implement in Hostboot
#define PRDF_RUNTIME_DECONFIG( i_pTarget, i_errl, i_dmp ) \
  SUCCESS

/**
 * @brief   defined dump content to get through hostboot compilation.
 *          hwTableContent is a FSP specific enum originally defined in dump.
 */
typedef uint32_t hwTableContent;

/**
 * @brief   defined dump content type to get through hostboot compilation.
 *          CONTENT_HW is a FSP specific enum val originally defined in dump.
 */
const uint32_t CONTENT_HW = 0x40000000;

/**
 * @brief   This class provides general purpose mutual
 *          exclusion (mutex) class for locking static or
 *          member data to ensure thread safety.
 */
class prdfMutex
{
public:

    /**
     * Constructor
     */
    prdfMutex();

    /**
     * Destructor
     */
    ~prdfMutex();

    /**
     * Lock this mutex
     */
    void lock();

    /**
     * Unlock this mutex
     */
    void unlock();

private:
    mutex_t ivMutex;

    // No copies or assignments allowed
    prdfMutex(prdfMutex& r);
    prdfMutex& operator=(prdfMutex& r);
};

inline prdfMutex::prdfMutex()
{
    mutex_init(&ivMutex);
}

inline prdfMutex::~prdfMutex()
{
    mutex_destroy(&ivMutex);
}

inline void prdfMutex::lock()
{
    mutex_lock( &ivMutex );
}

inline void prdfMutex::unlock()
{
    mutex_unlock( &ivMutex );
}

/**
 * @brief   This class provides interfaces to
 *          acquire a scope mutex
 */
class prdfScopeMutex
{
public:
    /**
     * Constructor (locks the specified mutex)
     *
     * @param i_mutex the mutex to be locked
     *        for the scope of this function
     */
    prdfScopeMutex(prdfMutex& i_mutex);

    /**
     * Destructor
     */
    ~prdfScopeMutex();

private:
    prdfMutex* ivMutex;

    // No copies or assignments allowed
    prdfScopeMutex(prdfScopeMutex& r);
    prdfScopeMutex& operator=(prdfScopeMutex& r);
};

inline prdfScopeMutex::prdfScopeMutex(prdfMutex& i_mutex)
: ivMutex(&i_mutex)
{
    ivMutex->lock();
}

inline prdfScopeMutex::~prdfScopeMutex()
{
    ivMutex->unlock();
}

extern prdfMutex g_prdMutex;

/**
 * @brief macro to acquire global scope mutex
 */
#define PRDF_SYSTEM_SCOPELOCK         \
    prdfScopeMutex dataLock(g_prdMutex);

#endif // PRDF_GLOBAL_HB_H
OpenPOWER on IntegriCloud