/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/import/chips/p9/procedures/hwp/memory/lib/dimm/rcd_load.H $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ /* Contributors Listed Below - COPYRIGHT 2015,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ /* You may obtain a copy of the License at */ /* */ /* http://www.apache.org/licenses/LICENSE-2.0 */ /* */ /* Unless required by applicable law or agreed to in writing, software */ /* distributed under the License is distributed on an "AS IS" BASIS, */ /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ /* implied. See the License for the specific language governing */ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ /// /// @file rcd_load.H /// @brief Code to support rcd_loads /// // *HWP HWP Owner: Jacob Harvey // *HWP HWP Backup: Andre Marin // *HWP Team: Memory // *HWP Level: 3 // *HWP Consumed by: HB:FSP #ifndef _MSS_RCD_LOAD_H_ #define _MSS_RCD_LOAD_H_ #include #include #include #include namespace mss { /// /// @brief Perform the rcd_load operations /// @tparam T, the fapi2::TargetType of i_target /// @param[in] i_target, a fapi2::Target /// @return FAPI2_RC_SUCCESS if and only if ok /// template< fapi2::TargetType T > fapi2::ReturnCode rcd_load( const fapi2::Target& i_target ); // // Implement the polymorphism for rcd_load // // -# Register the API. /// -# Define the template parameters for the overloaded function /// @note the first argument is the api name, and the rest are the api's template parameters. /// @note this creates __api_name##_overload template< mss::kind_t K > struct perform_rcd_load_overload { static const bool available = false; }; /// -# Register the specific overloads. The first parameter is the name /// of the api, the second is the kind of the element which is being /// overloaded - an RDIMM, an LRDIMM, etc. The remaining parameters /// indicate the specialization of the api itself. /// @note You need to define the "DEFAULT_KIND" here as an overload. This /// allows the mechanism to find the "base" implementation for things which /// have no specific overload. template<> struct perform_rcd_load_overload< DEFAULT_KIND > { static const bool available = true; }; template<> struct perform_rcd_load_overload< KIND_RDIMM_DDR4 > { static const bool available = true; }; template<> struct perform_rcd_load_overload< KIND_LRDIMM_DDR4 > { static const bool available = true; }; /// /// -# Define the default case for overloaded calls. enable_if states that /// if there is a DEFAULT_KIND overload for this TargetType, then this /// entry point will be defined. Note the general case below is enabled if /// there is no overload defined for this TargetType /// /// /// @brief Perform the rcd_load operations /// @tparam K, the kind of DIMM we're operating on (derived) /// @param[in] i_target, a fapi2::Target /// @param[in] a vector of CCS instructions we should add to /// @return FAPI2_RC_SUCCESS if and only if ok /// template< mss::kind_t K = FORCE_DISPATCH > typename std::enable_if< perform_rcd_load_overload::available, fapi2::ReturnCode>::type perform_rcd_load( const fapi2::Target& i_target, std::vector< ccs::instruction_t >& i_inst); // // We know we registered overloads for perform_rcd_load, so we need the entry point to // the dispatcher. Add a set of these for all TargetTypes which get overloads // for this API // template<> fapi2::ReturnCode perform_rcd_load( const fapi2::Target& i_target, std::vector< ccs::instruction_t >& i_inst); template<> fapi2::ReturnCode perform_rcd_load( const fapi2::Target& i_target, std::vector< ccs::instruction_t >& i_inst); /// /// @brief Start the rcd_load_dispatch boilerplate -- specialization for recursion dispatcher /// @param[in] i_kind the dimm kind struct for i_target /// @param[in] i_target a fapi2::Target /// @param[in] i_inst a vector of CCS instructions we should add to /// @return FAPI2_RC_SUCCESS if and only if ok /// template< kind_t K, bool B = perform_rcd_load_overload::available > inline fapi2::ReturnCode perform_rcd_load_dispatch( const kind_t& i_kind, const fapi2::Target& i_target, std::vector< ccs::instruction_t >& i_inst) { // We dispatch to another kind if: // We don't have an overload defined (B == false) // Or, if we do have an overload (B == true) and this is not out kind. if ((B == false) || ((B == true) && (K != i_kind))) { return perform_rcd_load_dispatch < (kind_t)(K - 1) > (i_kind, i_target, i_inst); } // Otherwise, we call the overload. return perform_rcd_load(i_target, i_inst); } /// /// @brief Start the rcd_load_dispatch boilerplate -- specialization for recursion root /// @param[in] i_kind the dimm kind struct for i_target /// @param[in] i_target a fapi2::Target /// @param[in] i_inst a vector of CCS instructions we should add to /// @return FAPI2_RC_SUCCESS if and only if ok /// @note DEFAULT_KIND is 0 so this is the end of the recursion /// template<> inline fapi2::ReturnCode perform_rcd_load_dispatch(const kind_t&, const fapi2::Target& i_target, std::vector< ccs::instruction_t >& i_inst) { return perform_rcd_load(i_target, i_inst); } } #endif