blob: b1702bb53e14994ac90cfff65bd7e786f6a5f513 [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//----------------------------------------------------------------------
Zane Shelley52cb1a92019-08-21 14:38:31 -050033
34#include <hei_includes.hpp>
35#include <util/hei_bit_string.hpp>
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050036
37#include <prdfHomRegisterAccess.H>
38#include <prdf_service_codes.H>
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050039#include <prdfMain.H>
40#include <prdfPlatServices.H>
41#include <prdfGlobal.H>
42#include <prdfErrlUtil.H>
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050043
44#ifdef __HOSTBOOT_RUNTIME
45#include <pm_common_ext.H>
46#include <p9_stop_api.H>
47#endif
48
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050049using namespace TARGETING;
50
Zane Shelleyfd275a22019-09-05 23:13:59 -050051namespace libhei
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050052{
53
54//----------------------------------------------------------------------
55// User Types
56//----------------------------------------------------------------------
57
58//----------------------------------------------------------------------
59// Constants
60//----------------------------------------------------------------------
61
62//----------------------------------------------------------------------
63// Macros
64//----------------------------------------------------------------------
65
66//----------------------------------------------------------------------
67// Internal Function Prototypes
68//----------------------------------------------------------------------
69
70//----------------------------------------------------------------------
71// Global Variables
72//----------------------------------------------------------------------
73
74//------------------------------------------------------------------------------
75// Member Function Specifications
76//------------------------------------------------------------------------------
77
78ScomService& getScomService()
79{
80 return PRDF_GET_SINGLETON(theScomService);
81}
82
83ScomService::ScomService() :
Zane Shelley05bac982019-09-02 20:57:42 -050084 iv_ScomAccessor(nullptr)
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050085{
86 PRDF_DTRAC("ScomService() initializing default iv_ScomAccessor");
87 iv_ScomAccessor = new ScomAccessor();
88}
89
90ScomService::~ScomService()
91{
Zane Shelley05bac982019-09-02 20:57:42 -050092 if(nullptr != iv_ScomAccessor)
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050093 {
94 PRDF_DTRAC("~ScomService() deleting iv_ScomAccessor");
95 delete iv_ScomAccessor;
Zane Shelley05bac982019-09-02 20:57:42 -050096 iv_ScomAccessor = nullptr;
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -050097 }
98}
99
100void ScomService::setScomAccessor(ScomAccessor & i_ScomAccessor)
101{
102 PRDF_DTRAC("ScomService::setScomAccessor() setting new scom accessor");
103
Zane Shelley05bac982019-09-02 20:57:42 -0500104 if(nullptr != iv_ScomAccessor)
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500105 {
106 PRDF_TRAC("ScomService::setScomAccessor() deleting old iv_ScomAccessor");
107 delete iv_ScomAccessor;
Zane Shelley05bac982019-09-02 20:57:42 -0500108 iv_ScomAccessor = nullptr;
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500109 }
110
111 iv_ScomAccessor = &i_ScomAccessor;
112}
113
114uint32_t ScomService::Access(TargetHandle_t i_target,
115 BitString & bs,
116 uint64_t registerId,
Zane Shelleyea1a1ac2019-08-08 16:27:20 -0500117 RegisterAccess::Operation operation) const
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500118{
119 PRDF_DENTER("ScomService::Access()");
120 uint32_t rc = SUCCESS;
121
122 rc = iv_ScomAccessor->Access( i_target,
123 bs,
124 registerId,
125 operation);
126
127 PRDF_DEXIT("ScomService::Access(): rc=%d", rc);
128
129 return rc;
130}
131
132
133uint32_t ScomAccessor::Access(TargetHandle_t i_target,
134 BitString & bs,
135 uint64_t registerId,
Zane Shelleyea1a1ac2019-08-08 16:27:20 -0500136 RegisterAccess::Operation operation) const
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500137{
138 PRDF_DENTER("ScomAccessor::Access()");
139
140 uint32_t rc = SUCCESS;
141
Zane Shelley05bac982019-09-02 20:57:42 -0500142 if(i_target != nullptr)
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500143 {
144 switch (operation)
145 {
Zane Shelleyea1a1ac2019-08-08 16:27:20 -0500146 case RegisterAccess::WRITE:
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500147 {
148 rc = PRDF::PlatServices::putScom(i_target, bs, registerId);
149
150 #ifdef __HOSTBOOT_RUNTIME
151 using namespace stopImageSection;
152
153 // Update CORE/EQ/EX Fir masks in HCODE image
154 TARGETING::TYPE type = PlatServices::getTargetType(i_target);
155 if( TYPE_EX == type || TYPE_EQ == type || TYPE_CORE == type )
156 {
157 uint32_t l_MaskReg[7] = {
158 0x2004000f, // EC_LFIR_MASK_OR
159 0x20010a45, // EC_COREFIR_MASK_OR
160 0x1004000f, // EQ_LOCAL_FIR_MASK_OR
161 0x10010805, // EX_L2FIR_MASK_OR
162 0x10011005, // EX_NCUFIR_MASK_OR
163 0x10011805, // EX_L3FIR_MASK_OR
164 0x10012005 }; // EX_CMEFIR_MASK_OR
165
166 for(uint32_t l_count = 0; l_count < 7; l_count++)
167 {
168 if( l_MaskReg[l_count] == registerId )
169 {
170 errlHndl_t err = nullptr;
171 uint32_t sec = (TYPE_CORE == type) ?
172 P9_STOP_SECTION_CORE_SCOM :
173 P9_STOP_SECTION_EQ_SCOM;
174
175 uint64_t scomVal =
176 (((uint64_t)bs.getFieldJustify(0, 32)) << 32) |
177 ((uint64_t)bs.getFieldJustify(32, 32));
178
179 err = RTPM::hcode_update(sec,
180 P9_STOP_SCOM_OR_APPEND,
181 i_target,
182 registerId,
183 scomVal);
184 if( nullptr != err)
185 {
Zane Shelley5d432bf2019-09-02 20:58:51 -0500186 HEI_ERR("[ScomAccessor::Access()] Error in"
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500187 " hcode_update");
188 PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT );
189 }
190 break;
191 }
192 }
193 }
194 #endif
195 break;
196 }
197
Zane Shelleyea1a1ac2019-08-08 16:27:20 -0500198 case RegisterAccess::READ:
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500199 bs.clearAll(); // clear all bits
200
201 rc = PRDF::PlatServices::getScom(i_target, bs, registerId);
202
203 break;
204
205 default:
Zane Shelley5d432bf2019-09-02 20:58:51 -0500206 HEI_ERR("ScomAccessor::Access() unsuppported scom op: 0x%08X",
Zane Shelleyfd3f9cc2019-07-29 15:02:24 -0500207 operation);
208 break;
209
210 } // end switch operation
211
212 }
213 else // Invalid target
214 {
215 rc = PRD_SCANCOM_FAILURE;
216 }
217
218 PRDF_DEXIT("ScomAccessor::Access()");
219
220 return rc;
221}
222
Zane Shelleyfd275a22019-09-05 23:13:59 -0500223} // end namespace libhei
224