summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/register/prdfRegisterCache.H
blob: 648faee63cafeb87923e136b981c605c37989a98 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: prdfRegisterCache.H $                                         */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,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 REG_CACHE_H
#define REG_CACHE_H

/** @file prdfRegisterCache.H */

#include <map>
#include <iipbits.h>
#include <prdfGlobal.H>
#include <prdfScanFacility.H>
#include <prdfScomRegisterAccess.H>
#include <prdfTargetFwdRef.H>

class BIT_STRING_CLASS;

namespace PRDF
{
/**
 * @brief Caches the contents of registers used during analysis.
 *
 * It maintains the latest content of a register in a map. If contents of the
 * register remain unchanged, register read returns contents stored in
 * cache rather than reading from hardware. Hence it brings efficiency in read.
 * Whenever write to actual hardware takes place, it is expected that once write
 * to hardware succeeds, the user of cache shall call flush. It drops the
 * particular register from map. As a result, when read takes place from same
 * register next time, read from cache fails and actual access to hardware
 * takes place.
 */
class RegDataCache
{
  public:

    /**
     * @brief Constructor
     */
    RegDataCache()
    { }

    /**
     * @brief Destructor
     */
    ~RegDataCache();

    /**
     * @brief  Returns reference to singleton instance of the RegDataCache.
     * @return The singleton reference.
     */
     static RegDataCache & getCachedRegisters();

    /**
     * @brief Returns the data buffer for the given target and address.
     * @param i_chip The target associated with the register.
     * @param i_reg  Pointer to register to be read.
     * @return A reference to the data buffer associated with the register.
     */
    BIT_STRING_CLASS & read( ExtensibleChip * i_chip,
                             const SCAN_COMM_REGISTER_CLASS * i_reg );

    /**
     * @brief Flushes entire contents from cache.
     */
    void flush();

    /**
     * @brief Removes a single entry from the cache.
     * @param i_pChip       The rulechip  associated with the register.
     * @param i_pRegister   points to the register to be flushed from cache.
     */
    void flush( ExtensibleChip* i_pChip,
                const SCAN_COMM_REGISTER_CLASS * i_pRegister );
    /**
     * @brief Queries if a specific entry exist in cache.
     * @param i_pChip       The rulechip  associated with the register.
     * @param i_pRegister   base part of register entry to be queried in cache.
     * @return pointer to cache entry associated with a given register
     */
     BIT_STRING_CLASS * queryCache( ExtensibleChip* i_pChip,
                            const SCAN_COMM_REGISTER_CLASS * i_pRegister )const;
    /**
     * @brief Queries if a specific entry exist in cache.
     * @param i_scomAccessKey Reference to register to be queried.
     * @return pointer to cache entry associated with a given register
     */

    BIT_STRING_CLASS * queryCache(
                        const ScomRegisterAccess & i_scomAccessKey )const;
  private: // data

    typedef std::map<ScomRegisterAccess, BIT_STRING_CLASS *> CacheDump;
    CacheDump iv_cachedRead;

};

PRDF_DECLARE_SINGLETON(RegDataCache, ReadCache);

} // namespace PRDF

#endif // REG_CACHE_H

OpenPOWER on IntegriCloud