Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 1 | /* 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 Shelley | 52cb1a9 | 2019-08-21 14:38:31 -0500 | [diff] [blame] | 33 | |
| 34 | #include <hei_includes.hpp> |
| 35 | #include <util/hei_bit_string.hpp> |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 36 | |
| 37 | #include <prdfHomRegisterAccess.H> |
| 38 | #include <prdf_service_codes.H> |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 39 | #include <prdfMain.H> |
| 40 | #include <prdfPlatServices.H> |
| 41 | #include <prdfGlobal.H> |
| 42 | #include <prdfErrlUtil.H> |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 43 | |
| 44 | #ifdef __HOSTBOOT_RUNTIME |
| 45 | #include <pm_common_ext.H> |
| 46 | #include <p9_stop_api.H> |
| 47 | #endif |
| 48 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 49 | using namespace TARGETING; |
| 50 | |
| 51 | namespace PRDF |
| 52 | { |
| 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 | |
| 78 | ScomService& getScomService() |
| 79 | { |
| 80 | return PRDF_GET_SINGLETON(theScomService); |
| 81 | } |
| 82 | |
| 83 | ScomService::ScomService() : |
| 84 | iv_ScomAccessor(NULL) |
| 85 | { |
| 86 | PRDF_DTRAC("ScomService() initializing default iv_ScomAccessor"); |
| 87 | iv_ScomAccessor = new ScomAccessor(); |
| 88 | } |
| 89 | |
| 90 | ScomService::~ScomService() |
| 91 | { |
| 92 | if(NULL != iv_ScomAccessor) |
| 93 | { |
| 94 | PRDF_DTRAC("~ScomService() deleting iv_ScomAccessor"); |
| 95 | delete iv_ScomAccessor; |
| 96 | iv_ScomAccessor = NULL; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | void ScomService::setScomAccessor(ScomAccessor & i_ScomAccessor) |
| 101 | { |
| 102 | PRDF_DTRAC("ScomService::setScomAccessor() setting new scom accessor"); |
| 103 | |
| 104 | if(NULL != iv_ScomAccessor) |
| 105 | { |
| 106 | PRDF_TRAC("ScomService::setScomAccessor() deleting old iv_ScomAccessor"); |
| 107 | delete iv_ScomAccessor; |
| 108 | iv_ScomAccessor = NULL; |
| 109 | } |
| 110 | |
| 111 | iv_ScomAccessor = &i_ScomAccessor; |
| 112 | } |
| 113 | |
| 114 | uint32_t ScomService::Access(TargetHandle_t i_target, |
| 115 | BitString & bs, |
| 116 | uint64_t registerId, |
Zane Shelley | ea1a1ac | 2019-08-08 16:27:20 -0500 | [diff] [blame] | 117 | RegisterAccess::Operation operation) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 118 | { |
| 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 | |
| 133 | uint32_t ScomAccessor::Access(TargetHandle_t i_target, |
| 134 | BitString & bs, |
| 135 | uint64_t registerId, |
Zane Shelley | ea1a1ac | 2019-08-08 16:27:20 -0500 | [diff] [blame] | 136 | RegisterAccess::Operation operation) const |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 137 | { |
| 138 | PRDF_DENTER("ScomAccessor::Access()"); |
| 139 | |
| 140 | uint32_t rc = SUCCESS; |
| 141 | |
| 142 | if(i_target != NULL) |
| 143 | { |
| 144 | switch (operation) |
| 145 | { |
Zane Shelley | ea1a1ac | 2019-08-08 16:27:20 -0500 | [diff] [blame] | 146 | case RegisterAccess::WRITE: |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 147 | { |
| 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 | { |
| 186 | PRDF_ERR("[ScomAccessor::Access()] Error in" |
| 187 | " hcode_update"); |
| 188 | PRDF_COMMIT_ERRL( err, ERRL_ACTION_REPORT ); |
| 189 | } |
| 190 | break; |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | #endif |
| 195 | break; |
| 196 | } |
| 197 | |
Zane Shelley | ea1a1ac | 2019-08-08 16:27:20 -0500 | [diff] [blame] | 198 | case RegisterAccess::READ: |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 199 | bs.clearAll(); // clear all bits |
| 200 | |
| 201 | rc = PRDF::PlatServices::getScom(i_target, bs, registerId); |
| 202 | |
| 203 | break; |
| 204 | |
| 205 | default: |
| 206 | PRDF_ERR("ScomAccessor::Access() unsuppported scom op: 0x%08X", |
| 207 | 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 | |
| 223 | } // End namespace PRDF |