summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfCenMbaUeTable.H
blob: 148b28fcf4140312e0694732d6da46b40931ac60 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfCenMbaUeTable.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 __prdfCenMbaUeTable_H
#define __prdfCenMbaUeTable_H

/** @file prdfCenMbaUeTable.H */

// Framwork includes
#include <iipCaptureData.h>
#include <prdfParserEnums.H>
#include <prdfPlatServices.H>

// Pegasus includes
#include <prdfCenAddress.H>

// Other includes
#include <list>

namespace PRDF
{

/**
 * @brief A table of memory UEs.
 * @note  Only one of these tables will exists per MBA.
 * @note  So far, this table is used only for FFDC.
 */
class CenMbaUeTable
{

  private: // constants, enums

    /** @brief Table size limits. */
    enum TableTHs
    {
        MAX_ENTRY_COUNT = 255, ///< Entry count threshold
    };

  public: // functions

    /**
     * @brief Will attempt to add a new entry to the table.
     * @note  If an entry already exists, the entry's count is incremented and
     *        moved to the end of the queue.
     * @param i_type See enum UE_TABLE::Type.
     * @param i_addr The address in which the UE occured.
     */
    void addEntry( UE_TABLE::Type i_type, const CenAddr & i_addr );

    /**
     * @brief Gathers all table data to be stored in capture data.
     * @param i_mbaTrgt  An MBA target.
     * @param io_cd      Capture data struct.
     */
    void addCapData( TARGETING::TargetHandle_t i_mbaTrgt, CaptureData & io_cd );

  private: // structs, typedefs

    /** @brief Individual entries of iv_table. */
    struct UeTableData
    {
        UE_TABLE::Type  type;  ///< See enum UE_TABLE::Type
        CenAddr         addr;  ///< The address in which the UE occured
        uint8_t         count; ///< Number of times the entry is detected

        /** @brief Default constructor. */
        UeTableData() {}

        /**
         * @brief Constructor from components.
         * @param i_type See enum UE_TABLE::Type.
         * @param i_addr The address in which the UE occured.
         */
        UeTableData( UE_TABLE::Type i_type, const CenAddr & i_addr ) :
            type(i_type), addr(i_addr), count(1)
        {}

        /** An entry is equivalent if the type and address match. */
        bool operator==( const UeTableData & i_data ) const
        {
            return ( this->type == i_data.type && this->addr == i_data.addr );
        }
    };

    typedef std::list<UeTableData> UeTable;

  private: // instance variables

    /** A FIFO that stores the latest memory UE addresses and their types. This
     *  is not a pure FIFO, because if a new entry matches an existing entry,
     *  the existing entries count is incremented and it is moved to the end of
     *  the queue. However, if a new entry does not match an existing entry and
     *  the table is full, the oldest entry will be removed to make room for
     *  the new entry. */
    UeTable iv_table;
};

} // end namespace PRDF

#endif // __prdfCenMbaUeTable_H

OpenPOWER on IntegriCloud