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/prdfScanFacility.H $ */ |
| 5 | /* */ |
| 6 | /* OpenPOWER HostBoot Project */ |
| 7 | /* */ |
| 8 | /* Contributors Listed Below - COPYRIGHT 2012,2018 */ |
| 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 | #ifndef PRDFSCANFACILITY_H |
| 27 | #define PRDFSCANFACILITY_H |
| 28 | /** |
| 29 | @file prdfScanFacility.H |
| 30 | @brief Description |
| 31 | */ |
| 32 | |
| 33 | |
| 34 | //-------------------------------------------------------------------- |
| 35 | // Includes |
| 36 | //-------------------------------------------------------------------- |
| 37 | |
Zane Shelley | 52cb1a9 | 2019-08-21 14:38:31 -0500 | [diff] [blame] | 38 | #include <register/hei_hardware_register.hpp> |
| 39 | #include <register/hei_operator_register.hpp> |
| 40 | |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 41 | #include <prdfFlyWeight.H> |
| 42 | #include <prdfFlyWeightS.H> |
| 43 | #include <vector> |
| 44 | #include <prdfHomRegisterAccess.H> |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 45 | #include <prdfScomRegisterAccess.H> |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 46 | #include <prdfPlatServices.H> |
| 47 | |
| 48 | namespace PRDF |
| 49 | { |
| 50 | |
| 51 | |
| 52 | /** |
| 53 | PRD Scan Facility |
| 54 | @author Doug Gilbert |
| 55 | @par The Scan facility is used by PRD to access Scan and Scan Comm |
| 56 | @ functions.It attempts to reduce duplicate objects and their |
| 57 | @ aggragates as must as possible. |
| 58 | */ |
| 59 | class ScanFacility |
| 60 | { |
| 61 | public: |
| 62 | /** |
| 63 | The Scan Facility is a singleton - this function provides access to it. |
| 64 | */ |
| 65 | static ScanFacility & Access(void); |
| 66 | |
| 67 | /** |
Zane Shelley | cd36f43 | 2019-08-30 21:22:07 -0500 | [diff] [blame] | 68 | * @brief Returns reference to flyweight object of type HardwareRegister. |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 69 | * An object of given address is first searched in flyweight. |
| 70 | * If object exist, reference to existing object is returned |
| 71 | * else a new one is created. |
| 72 | * @param i_address address of the register |
| 73 | * @param i_scomLength length of the bit string |
| 74 | * @param i_type type of target associated with register |
| 75 | * @param i_regOp operations supported for given register |
| 76 | * @return returns reference to flyweight object from factory |
| 77 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 78 | Register & GetScanCommRegister( uint64_t address, |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 79 | uint32_t i_scomLength, TARGETING::TYPE i_type, |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 80 | Register::AccessLevel i_regOp ); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * @brief Get a register that bitwise inverts the bitstring of a register |
| 84 | * when read or written to |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 85 | * @param Register source |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 86 | * @post Only one instance of the register with this SCR parameter will |
| 87 | * exist |
| 88 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 89 | Register & GetNotRegister(Register & i_arg); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * @brief Get a register that bitwise left shift the bitstring of a register |
| 93 | * when read or written to |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 94 | * @param Register source |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 95 | * @post Only one instance of the register with this SCR parameter and |
| 96 | * amount will exist |
| 97 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 98 | Register & GetLeftShiftRegister( |
| 99 | Register & i_arg, uint16_t i_amount); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * @brief Get a register that bitwise right shift the bitstring of a register |
| 103 | * when read or written to |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 104 | * @param Register source |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 105 | * @post Only one instance of the register with this SCR parameter and amount |
| 106 | * @ will exist |
| 107 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 108 | Register & GetRightShiftRegister( |
| 109 | Register & i_arg, uint16_t i_amount); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * @brief Get a register for the summary construct |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 113 | * @param Register source |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 114 | * @param uint16_t i_bit bit to set if any attentions found in i_arg |
| 115 | * @post Only one instance of the register with this SCR parameter and |
| 116 | * amount will exist |
| 117 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 118 | Register & GetSummaryRegister( |
| 119 | Register & i_arg, uint16_t i_bit); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 120 | |
| 121 | /** |
| 122 | * @brief Get a register that bit-wise ANDs the bitstring of two register |
| 123 | * when read or written to |
| 124 | * @param The 2 SCR 's to AND |
| 125 | * @posrt Only one instance of the register with these SCRs will exist |
| 126 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 127 | Register & GetAndRegister(Register & i_left, |
| 128 | Register & i_right); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * @brief Get a register that bitwise ORs the bitstrings of two register when |
| 132 | * read or written |
| 133 | * @param the 2 SCR's to OR |
| 134 | * @post Only one instance of the register with these SCR's will exist |
| 135 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 136 | Register & GetOrRegister(Register & i_left, |
| 137 | Register & i_right); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 138 | |
| 139 | /** |
| 140 | * @brief Get a AttnTypeRegister |
| 141 | * @params 5 pointers to scr Registers |
| 142 | * @post only one instance of the register with these SCR's will exist |
| 143 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 144 | Register & GetAttnTypeRegister( |
| 145 | Register * i_check, |
| 146 | Register * i_recov, |
| 147 | Register * i_special, |
| 148 | Register * i_proccs, |
| 149 | Register * i_hostattn ); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 150 | |
| 151 | /** |
| 152 | * @brief Get a PrdfConstantRegister |
| 153 | * @param BitString - the bit string constant to use. |
| 154 | * @post only one instance of the register with this BIT_STRING value will |
| 155 | * exist. |
| 156 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 157 | Register & GetConstantRegister(const BitStringBuffer & i_val); |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 158 | /** |
| 159 | * @brief Get a plugin register |
| 160 | * @param Reference to target less flyweight object |
| 161 | * @param RuleChip associatd with register |
| 162 | * @post only one instance of the register with this BIT_STRING value will |
| 163 | * exist. |
| 164 | */ |
Zane Shelley | 23244cb | 2019-08-30 21:12:12 -0500 | [diff] [blame] | 165 | Register & GetPluginRegister( |
| 166 | Register & i_flyweight, |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 167 | ExtensibleChip & i_RuleChip ); |
| 168 | /** |
| 169 | * @brief Delete all the plugin register |
| 170 | * @param None |
| 171 | * @post all the ScomRegisterAccess register flyweight object created for |
| 172 | * plugin shall be deleted |
| 173 | * exist. |
| 174 | */ |
| 175 | void ResetPluginRegister(); |
| 176 | |
| 177 | /** |
| 178 | * @brief Intended to reset all the flyweights if PRD is uninitialized due to |
| 179 | * a reIPL, reset/reload, or failover. This free up the memory and |
| 180 | * avoids memory leaks in the flyweights. |
| 181 | */ |
| 182 | void reset(); |
| 183 | |
| 184 | #ifdef FLYWEIGHT_PROFILING |
| 185 | /** |
| 186 | * @brief prints memory allocated for object residing on flyweight |
| 187 | */ |
| 188 | void printStats(); |
| 189 | #endif |
| 190 | |
| 191 | /** |
| 192 | Destructor |
| 193 | */ |
| 194 | // ~ScanFacility(); |
| 195 | private: // functions |
| 196 | /** |
| 197 | Constructor |
| 198 | * @param |
| 199 | * @returns |
| 200 | * @pre |
| 201 | * @post |
| 202 | * @see |
| 203 | * @note |
| 204 | */ |
| 205 | ScanFacility() {} |
| 206 | |
| 207 | |
| 208 | private: // Data |
Zane Shelley | cd36f43 | 2019-08-30 21:22:07 -0500 | [diff] [blame] | 209 | typedef FlyWeightS<HardwareRegister,50> ScanCommRegisters; |
Zane Shelley | fd3f9cc | 2019-07-29 15:02:24 -0500 | [diff] [blame] | 210 | //FIXME RTC 64345 Investigate benefit of changing below from FlyWeight to |
| 211 | //FlyWeightS |
| 212 | typedef FlyWeight<AttnTypeRegister,50> AttnTypeRegisters; |
| 213 | typedef FlyWeightS<AndRegister,50> AndRegisters; |
| 214 | typedef FlyWeightS<OrRegister,10> OrRegisters; |
| 215 | typedef FlyWeightS<NotRegister,50> NotRegisters; |
| 216 | typedef FlyWeightS<LeftShiftRegister,10> LeftShiftRegisters; |
| 217 | typedef FlyWeightS<RightShiftRegister, 10> RightShiftRegisters; |
| 218 | typedef FlyWeightS<SummaryRegister,10> SummaryRegisters; |
| 219 | typedef FlyWeight<ConstantRegister, 10> ConstantRegisters; |
| 220 | typedef FlyWeightS<ScomRegisterAccess, 10> PluginRegisters; |
| 221 | |
| 222 | ScanCommRegisters iv_scomRegFw; |
| 223 | AttnTypeRegisters iv_attnRegFw; |
| 224 | AndRegisters iv_andRegFw; |
| 225 | OrRegisters iv_orRegFw; |
| 226 | NotRegisters iv_notRegFw; |
| 227 | LeftShiftRegisters iv_leftRegFw; |
| 228 | SummaryRegisters iv_sumRegFw; |
| 229 | RightShiftRegisters iv_rightRegFw; |
| 230 | ConstantRegisters iv_constRegFw; |
| 231 | PluginRegisters iv_pluginRegFw; |
| 232 | |
| 233 | }; |
| 234 | |
| 235 | } // end namespace PRDF |
| 236 | |
| 237 | #endif /* PRDFSCANFACILITY_H */ |