summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/register/prdfScomRegister.C
blob: 6074be96e8d431d961da9cfbc7b4074522a1f5ad (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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: prdfScomRegister.C $                                          */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 1996,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                                                     */

// Module Description **************************************************
//
// Description: This module provides the implementation for the PRD Scan
//              Comm Register Chip class.
//
// End Module Description **********************************************

//----------------------------------------------------------------------
//  Includes
//----------------------------------------------------------------------

#include <iipchip.h>
#include <prdfScomRegister.H>
#include <iipconst.h>
#include <iipbits.h>
#include <prdfMain.H>
#include <prdf_ras_services.H>
#include <prdfRegisterCache.H>
#include <prdfHomRegisterAccess.H>
#include <prdfPlatServices.H>
#include <prdfExtensibleChip.H>

//----------------------------------------------------------------------
//  User Types
//----------------------------------------------------------------------

//----------------------------------------------------------------------
//  Constants
//----------------------------------------------------------------------

//----------------------------------------------------------------------
//  Macros
//----------------------------------------------------------------------

//----------------------------------------------------------------------
//  Internal Function Prototypes
//----------------------------------------------------------------------

//----------------------------------------------------------------------
//  Global Variables
//----------------------------------------------------------------------

//---------------------------------------------------------------------
// Member Function Specifications
//---------------------------------------------------------------------

// --------------------------------------------------------------------
namespace PRDF
{

// ---------------------------------------------------------------------

void ScomRegister::SetBitString( const BIT_STRING_CLASS *bs )
{
    BIT_STRING_CLASS & l_string  = AccessBitString();
    l_string.SetBits(*bs);
}


// ---------------------------------------------------------------------

const BIT_STRING_CLASS *ScomRegister::GetBitString( ATTENTION_TYPE i_type )const
{
    bool l_readStat = false;
    return &( readCache( l_readStat ) );
}
// ---------------------------------------------------------------------
BIT_STRING_CLASS & ScomRegister::AccessBitString( )
{
    bool l_readStat = false;
    return ( readCache( l_readStat ) );

}

//---------------------------------------------------------------------

uint32_t ScomRegister::Read( )
{
    int32_t rc = SUCCESS;
    bool l_readStat = false;
    readCache( l_readStat );
    if( false == l_readStat )
    {
        //updating cache by reading hardware .So that next read  need not access
        //hardware
        rc = ForceRead();
    }

    return(rc);
}

// ----------------------------------------------------------------------------
uint32_t ScomRegister::ForceRead()
{
    int32_t rc = SUCCESS;
    bool l_readStat = false;
    BIT_STRING_CLASS & bs = readCache( l_readStat );
    rc = Access( bs,MopRegisterAccess::READ );
    if( SUCCESS != rc )
    {
        ExtensibleChip* l_pChip = getChip( );
        flushCache( l_pChip );
    }

    return rc;
}
//------------------------------------------------------------------------------

uint32_t ScomRegister::Write()
{
    uint32_t rc = FAIL;
    bool l_entryBeforeWrite = false;
    BIT_STRING_CLASS & bs = readCache( l_entryBeforeWrite );
    PRDF_ASSERT( true == l_entryBeforeWrite );
    rc = Access( bs, MopRegisterAccess::WRITE );

    return(rc);
}
//------------------------------------------------------------------------------
uint32_t ScomRegister::Access( BIT_STRING_CLASS & bs,
                               MopRegisterAccess::Operation op ) const
{
    int32_t l_rc = SCR_ACCESS_FAILED;
    TARGETING::TargetHandle_t i_pchipTarget = getChip()->GetChipHandle();
    l_rc = getScomService().Access( i_pchipTarget,bs,iv_scomAddress,op );

    return(l_rc);
}
//-----------------------------------------------------------------------------
ExtensibleChip* ScomRegister::getChip( )const
{
    ExtensibleChip* l_pchip = NULL;
    l_pchip = ServiceDataCollector::getChipAnalyzed();
    TARGETING::TYPE l_type = PlatServices::getTargetType(
                                                l_pchip->GetChipHandle() );
    PRDF_ASSERT( iv_chipType == l_type )
    return l_pchip;
}
//-----------------------------------------------------------------------------
BIT_STRING_CLASS & ScomRegister::readCache( bool & o_existingEntry ) const
{
    ExtensibleChip* l_pChip = getChip( );
    RegDataCache & regDump = RegDataCache::getCachedRegisters();
    return  regDump.read( l_pChip,this,o_existingEntry );

}
//-----------------------------------------------------------------------------

void ScomRegister::flushCache( ExtensibleChip *i_pChip ) const
{
     RegDataCache & regDump = RegDataCache::getCachedRegisters();
    if( NULL == i_pChip )
    {
        regDump.flush();
    }
    else
    {
        regDump.flush( i_pChip ,this );
    }
}

//-----------------------------------------------------------------------------

bool ScomRegister::operator == ( const ScomRegister & i_rightRegister ) const
{
    if( iv_scomAddress == i_rightRegister.GetAddress() )
    {
        return ( iv_chipType == i_rightRegister.getChipType() );
    }
    else
    {
        return false ;
    }

}

//-----------------------------------------------------------------------------
bool ScomRegister::operator < ( const ScomRegister & i_rightRegister  ) const
{
    if( iv_scomAddress == i_rightRegister.GetAddress() )
    {
        return ( iv_chipType == i_rightRegister.getChipType() );
    }
    else
    {
        return( iv_scomAddress  < i_rightRegister.GetAddress() );
    }


}
//-----------------------------------------------------------------------------
bool ScomRegister::operator >= ( const ScomRegister & i_rightRegister  ) const
{
    return !( *this < i_rightRegister );
}
}//namespace PRDF ends
OpenPOWER on IntegriCloud