blob: 8b6f811e96cbcd5d75b20916e1ea4aedb7d58a8f [file] [log] [blame]
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -05001/* IBM_PROLOG_BEGIN_TAG */
2/* This is an automatically generated prolog. */
3/* */
4/* $Source: src/usr/diag/prdf/common/framework/register/prdfHomRegisterAccess.C $ */
5/* */
6/* OpenPOWER HostBoot Project */
7/* */
8/* Contributors Listed Below - COPYRIGHT 2012,2017 */
9/* [+] International Business Machines Corp. */
10/* */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
21/* implied. See the License for the specific language governing */
22/* permissions and limitations under the License. */
23/* */
24/* IBM_PROLOG_END_TAG */
25
26/**
27 @file prdfHomRegisterAccess.C
28 @brief definition of HomRegisterAccess
29*/
30//----------------------------------------------------------------------
31// Includes
32//----------------------------------------------------------------------
33#define prdfHomRegisterAccess_C
34
35#include <prdfHomRegisterAccess.H>
36#include <prdf_service_codes.H>
37#include <iipbits.h>
38#include <prdfMain.H>
39#include <prdfPlatServices.H>
40#include <prdfGlobal.H>
41#include <prdfErrlUtil.H>
42#include <prdfTrace.H>
43
44#ifdef __HOSTBOOT_RUNTIME
45#include <pm_common_ext.H>
46#include <p9_stop_api.H>
47#endif
48
49#undef prdfHomRegisterAccess_C
50
51
52using namespace TARGETING;
53
54namespace PRDF
55{
56
57//----------------------------------------------------------------------
58// User Types
59//----------------------------------------------------------------------
60
61//----------------------------------------------------------------------
62// Constants
63//----------------------------------------------------------------------
64
65//----------------------------------------------------------------------
66// Macros
67//----------------------------------------------------------------------
68
69//----------------------------------------------------------------------
70// Internal Function Prototypes
71//----------------------------------------------------------------------
72
73//----------------------------------------------------------------------
74// Global Variables
75//----------------------------------------------------------------------
76
77//------------------------------------------------------------------------------
78// Member Function Specifications
79//------------------------------------------------------------------------------
80
81ScomService& getScomService()
82{
83 return PRDF_GET_SINGLETON(theScomService);
84}
85
86ScomService::ScomService() :
87 iv_ScomAccessor(NULL)
88{
89 PRDF_DTRAC("ScomService() initializing default iv_ScomAccessor");
90 iv_ScomAccessor = new ScomAccessor();
91}
92
93ScomService::~ScomService()
94{
95 if(NULL != iv_ScomAccessor)
96 {
97 PRDF_DTRAC("~ScomService() deleting iv_ScomAccessor");
98 delete iv_ScomAccessor;
99 iv_ScomAccessor = NULL;
100 }
101}
102
103void ScomService::setScomAccessor(ScomAccessor & i_ScomAccessor)
104{
105 PRDF_DTRAC("ScomService::setScomAccessor() setting new scom accessor");
106
107 if(NULL != iv_ScomAccessor)
108 {
109 PRDF_TRAC("ScomService::setScomAccessor() deleting old iv_ScomAccessor");
110 delete iv_ScomAccessor;
111 iv_ScomAccessor = NULL;
112 }
113
114 iv_ScomAccessor = &i_ScomAccessor;
115}
116
117uint32_t ScomService::Access(TargetHandle_t i_target,
118 BitString & bs,
119 uint64_t registerId,
Zane Shelleyea1a1ac2019-08-08 16:27:20 -0500120 RegisterAccess::Operation operation) const
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500121{
122 PRDF_DENTER("ScomService::Access()");
123 uint32_t rc = SUCCESS;
124
125 rc = iv_ScomAccessor->Access( i_target,
126 bs,
127 registerId,
128 operation);
129
130 PRDF_DEXIT("ScomService::Access(): rc=%d", rc);
131
132 return rc;
133}
134
135
136uint32_t ScomAccessor::Access(TargetHandle_t i_target,
137 BitString & bs,
138 uint64_t registerId,
Zane Shelleyea1a1ac2019-08-08 16:27:20 -0500139 RegisterAccess::Operation operation) const
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500140{
141 PRDF_DENTER("ScomAccessor::Access()");
142
143 uint32_t rc = SUCCESS;
144
145 if(i_target != NULL)
146 {
147 switch (operation)
148 {
Zane Shelleyea1a1ac2019-08-08 16:27:20 -0500149 case RegisterAccess::WRITE:
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500150 {
151 rc = PRDF::PlatServices::putScom(i_target, bs, registerId);
152
153 #ifdef __HOSTBOOT_RUNTIME
154 using namespace stopImageSection;
155
156 // Update CORE/EQ/EX Fir masks in HCODE image
157 TARGETING::TYPE type = PlatServices::getTargetType(i_target);
158 if( TYPE_EX == type || TYPE_EQ == type || TYPE_CORE == type )
159 {
160 uint32_t l_MaskReg[7] = {
161 0x2004000f, // EC_LFIR_MASK_OR
162 0x20010a45, // EC_COREFIR_MASK_OR
163 0x1004000f, // EQ_LOCAL_FIR_MASK_OR
164 0x10010805, // EX_L2FIR_MASK_OR
165 0x10011005, // EX_NCUFIR_MASK_OR
166 0x10011805, // EX_L3FIR_MASK_OR
167 0x10012005 }; // EX_CMEFIR_MASK_OR
168
169 for(uint32_t l_count = 0; l_count < 7; l_count++)
170 {
171 if( l_MaskReg[l_count] == registerId )
172 {
173 errlHndl_t err = nullptr;
174 uint32_t sec = (TYPE_CORE == type) ?
175 P9_STOP_SECTION_CORE_SCOM :
176 P9_STOP_SECTION_EQ_SCOM;
177
178 uint64_t scomVal =
179 (((uint64_t)bs.getFieldJustify(0, 32)) << 32) |
180 ((uint64_t)bs.getFieldJustify(32, 32));
181
182 err = RTPM::hcode_update(sec,
183 P9_STOP_SCOM_OR_APPEND,
184 i_target,
185 registerId,
186 scomVal);
187 if( nullptr != err)
188 {
189 PRDF_ERR("[ScomAccessor::Access()] Error in"
190 " hcode_update");
191 PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
192 }
193 break;
194 }
195 }
196 }
197 #endif
198 break;
199 }
200
Zane Shelleyea1a1ac2019-08-08 16:27:20 -0500201 case RegisterAccess::READ:
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500202 bs.clearAll(); // clear all bits
203
204 rc = PRDF::PlatServices::getScom(i_target, bs, registerId);
205
206 break;
207
208 default:
209 PRDF_ERR("ScomAccessor::Access() unsuppported scom op: 0x%08X",
210 operation);
211 break;
212
213 } // end switch operation
214
215 }
216 else // Invalid target
217 {
218 rc = PRD_SCANCOM_FAILURE;
219 }
220
221 PRDF_DEXIT("ScomAccessor::Access()");
222
223 return rc;
224}
225
226} // End namespace PRDF