/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/import/chips/p9/procedures/hwp/pm/p9_pm_recovery_ffdc_base.H $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ /* Contributors Listed Below - COPYRIGHT 2015,2018 */ /* [+] 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 */ #ifndef __P9_PM_RECOVERY_FFDC_BASE_ #define __P9_PM_RECOVERY_FFDC_BASE_ /// /// @file p9_pm_recovery_ffdc_base.H /// @brief Models generic platform for the FFDC collection of PM complex /// /// *HWP HWP Owner: Greg Still /// *HWP FW Owner: Prem S Jha /// *HWP Team: PM /// *HWP Level: 2 /// *HWP Consumed by: Hostboot:Phyp // // *INDENT-OFF* //-------------------------------------------------------------------------- // Includes //-------------------------------------------------------------------------- #include #include #include #include namespace p9_stop_recov_ffdc { class PlatPmComplex { public: /// @brief constructor /// @param[in] i_procChipTgt fapi2 target for P9 chip /// @param[in] i_plat platform id /// @param[in] i_imageHdrBaseAddr sram address of start of image header /// @param[in] i_traceBufBaseAddress address of pointer to trace buffer and size /// @param[in] i_globalBaseAddr sram address of start of global variables PlatPmComplex( const fapi2::Target< fapi2::TARGET_TYPE_PROC_CHIP > i_procChipTgt, PmComplexPlatId i_plat = PLAT_INIT, uint32_t i_imageHdrBaseAddr = 0, uint32_t i_traceBufBaseAddress = 0, uint32_t i_globalBaseAddr = 0 ); /// @brief destructor virtual ~PlatPmComplex() { }; /// @brief Initializes the PM FFDC Section Header in HOMER /// @param[in] i_pHomerBuf pointer to base of P9 HOMER. // @return fapi2 return code virtual fapi2::ReturnCode init ( void* i_pHomerBuf ); /// @brief Collects specified FFDC to PM FFDC section of HOMER /// @param[in] i_pHomerBuf points to base of P9 HOMER. /// @param[in] i_ffdcType indicates the content type to collect // @return fapi2 return code. virtual fapi2::ReturnCode collectFfdc( void* i_pHomerBuf, uint8_t i_ffdcType = ALL ); /// @brief returns proc chip target associated with platform fapi2::Target< fapi2::TARGET_TYPE_PROC_CHIP > getProcChip() const { return iv_procChip; } /// @brief collects FFDC pertaining to a given target. /// @param[in] i_pBuf points to base of FFDC buffer. /// @param[in] i_dataType indicates the content type to collect /// @param[in] i_exTgt ex target /// @param[in] o_ffdcLength length of FFDC in bytes /// @return fapi2 return code. /// @note function intends to copy FFDC pertaining to CME and SGPE to /// an error log. virtual fapi2::ReturnCode collectPartialFfdc( void * i_pBuf, FfdcDataType i_dataType, fapi2::Target& i_exTgt, uint32_t & o_ffdcLength ); /// @brief collects FFDC pertaining to a given target. /// @param[in] i_pBuf points to base of FFDC buffer. /// @param[in] i_dataType indicates the content type to collect /// @param[in] o_ffdcLength length of FFDC in bytes /// @return fapi2 return code. /// @note function intends to copy FFDC pertaining to CME and SGPE to /// an error log. virtual fapi2::ReturnCode collectPartialFfdc( void * i_pBuf, FfdcDataType i_dataType, uint32_t & o_ffdcLength ); /// @brief sets start address of platform's trace buffer. void setTraceBufAddr (uint32_t i_addr) { iv_traceBufBaseAddress = i_addr; } ///@brief returns trace buffer/ptr address uint32_t getTraceBufAddr() { return iv_traceBufBaseAddress; }; ///@brief returns instance id. PmComplexPlatId getPlatId() { return iv_plat ; } /// @brief generates summary of FFDC pertaining to a given platform. /// @param[in] i_pHomer points to Homer base. /// @return fapi2 return code virtual fapi2::ReturnCode generateSummary( void * i_pHomer ); ///@brief initializes a list of register for generation of FFDC summary. void initRegList(); ///@brief logs the current PM Reset Phase in the PmFfdcHeader ///@param[in] i_pHomerBuf Base address of PM FFDC in HOMER ///@return N.A. void logPmResetPhase ( const void* i_pHomerBuf ); protected: /// @brief parses a region of HOMER to extract PPE registers /// @param[in] i_pHomerBuf points to HOMER base /// @param[in] i_regionLimit size of memory region in which register is to be looked up. /// @param[in] o_ffdcSummary location in the FFDC summary region /// @return SUCCESS on success else an error code uint32_t extractPpeSummaryReg( uint8_t * i_pHomerBuf, const uint32_t i_regionLimit, uint8_t * o_ffdcSummary ); /// @brief parses a region of HOMER to extract SCOM registers /// @param[in] i_pHomerBuf points to HOMER base /// @param[in] i_regionLimit size of memory region in which register is to be looked up. /// @param[in] o_ffdcSummary location in the FFDC summary region /// @return SUCCESS on success else an error code uint32_t extractScomSummaryReg( uint8_t * i_pHomerBuf, const uint32_t i_regionLimit, uint8_t * o_ffdcSummary ); ///@brief sets the validity of a section in the PmFfdcHeader ///@param[in] i_pHomerBuf Base address of PM FFDC in HOMER ///@param[in] i_pmFfdcSectionState See PmFfdcSectionState ///@param[in] i_valid true: sets the section valid /// false: sets the section invalid ///@return N.A. void setPmFfdcSectionValid ( void* i_pHomerBuf, uint16_t i_pmFfdcSectionState, bool i_valid = true ); ///@brief reads the PPE Halt State from XSR, w/o halting the PPE ///@param[in] i_xirBaseAddress XCR SCOM Address of the PPE ///@param[in] i_pHomerOffset PPE section base address in HOMER ///@return fapi2 return code fapi2::ReturnCode readPpeHaltState ( const uint64_t i_xirBaseAddress, const uint8_t* i_pHomerOffset ); ///@brief collects PPE State (XIRs, SPRs, GPRs) to a loc in HOMER ///@param[in] i_xirBaseAddress XCR SCOM Address of the PPE ///@param[in] i_pHomerOffset PPE section base address in HOMER ///@param[in] i_mode PPE_DUMP_MODE, defaults to HALT ///@return fapi2 return code fapi2::ReturnCode collectPpeState ( const uint64_t i_xirBaseAddress, const uint8_t* i_pHomerOffset, const PPE_DUMP_MODE i_mode = FORCE_HALT ); ///@brief collects FFDC from CME/OCC SRAM ///@param[in] i_chipletTarget fapi2 target for EX or Proc ///@param[in] i_pSramData points to HOMER location containing SRAM contents ///@param[in] i_dataType type of FFDC data ///@param[in] i_sramLength length of SRAM FFDC in bytes ///@return fapi2 return code fapi2::ReturnCode collectSramInfo( const fapi2::Target< fapi2::TARGET_TYPE_EX >& i_exTgt, uint8_t * i_pSramData, FfdcDataType i_dataType, uint32_t i_sramLength ); fapi2::ReturnCode collectSramInfo( const fapi2::Target< fapi2::TARGET_TYPE_PROC_CHIP > & i_procChip, uint8_t * i_pSramData, FfdcDataType i_dataType, uint32_t i_sramLength ); ///@brief updates parts of PPE FFDC Header common for all platforms. ///param[in] i_pFfdcHdr points to the PPE FFDC header ///param[in] i_sectionsValid bit vector summarizing FFDC validity fapi2::ReturnCode updatePpeFfdcHeader( PpeFfdcHeader * i_pFfdcHdr, uint16_t i_sectionsValid ); ///@brief update header for the FIR FFDC section ///param[in] i_pFfdcHdr pointer to FIR FFDC header in HOMER ///param[in] i_pos chiplet position ///param[in] i_ffdcValid true if valid, false otherwise ///@return fapi2 return code fapi2::ReturnCode updateFirFfdcHeader( uint8_t* i_pFfdcHdr, uint8_t i_pos, bool i_ffdcValid); ///@brief Collects register data ///param[in] i_chipletTarget Chip/chilpet target ///param[out] o_pHomerBuf Homer base address to fill register // data // param[in] i_ffdcId Hwp ffdc id to know register // collection type ///@return fapi2 return code template fapi2::ReturnCode collectRegisterData( const fapi2::Target& i_chipletTarget, uint8_t* o_pHomerBuf, fapi2::HwpFfdcId i_ffdcId); ///@brief reads info from OCC SRAM. ///@param[in] i_procChip fapi2 target for proc chip ///@param[in] i_pSramAddress start address for reading SRAM ///@param[in] i_pSramData pointer to data to be read from SRAM ///@param[in] i_sramLen length of data read from SRAM. ///@param[in] o_doubleWordRead number of double word actually read from SRAM. ///@return fapi2 return code fapi2::ReturnCode readSramInfo( const fapi2::Target< fapi2::TARGET_TYPE_PROC_CHIP >& i_procChip, uint32_t i_sramAddress, uint8_t * i_pSramData, uint32_t i_sramLen, uint32_t &o_doubleWordRead ); ///@brief reads info from CME SRAM. ///@param[in] i_exTgt fapi2 target for ex Chiplet ///@param[in] i_pSramAddress start address for reading SRAM ///@param[in] i_pSramData pointer to data read from SRAM ///@param[in] i_sramLen length of data to be read from SRAM. ///@param[in] o_doubleWordRead number of double word actually read from SRAM. ///@return fapi2 return code fapi2::ReturnCode readSramInfo( const fapi2::Target< fapi2::TARGET_TYPE_EX >& i_exTgt, uint32_t i_sramAddress, uint8_t * i_pSramData, uint32_t i_sramLen, uint32_t &o_doubleWordRead ); ///@brief overrides the list of register addresses used for summary generation. ///@brief i_regAddrList[in] new list of register addresses for summary. void updateSummaryList( const std::vector & i_regAddrList ) { iv_summaryReg = i_regAddrList; } #ifndef __HOSTBOOT_MODULE ///@brief to debug FFDC contents collected from SRAM. ///param[in] i_pSram points to location of SRAM info in HOMER. ///param[in] i_len length of info. ///@return fapi2 return code fapi2::ReturnCode debugSramInfo( uint8_t * i_pSram, uint32_t i_len ); #endif private: fapi2::Target< fapi2::TARGET_TYPE_PROC_CHIP > iv_procChip; // processor chip target uint32_t iv_imageHeaderBaseAddress; // base address of platform's image header uint32_t iv_traceBufBaseAddress; // base address of platforms's trace buffer uint32_t iv_globalBaseAddress; // base address of platform's global variables PmComplexPlatId iv_plat; std::vector iv_summaryReg; }; //--------------------------------------------------------------------------------------------- template fapi2::ReturnCode PlatPmComplex::collectRegisterData ( const fapi2::Target& i_chipletTarget, uint8_t *o_pHomerBuf, fapi2::HwpFfdcId i_ffdcId ) { FAPI_DBG(">> collectRegisterData"); std::vector l_cfamAddresses; std::vector l_scomAddresses; uint32_t l_ffdcRegReadSize = 0; uint32_t l_offset = 0; fapi2::ScomReader l_scomReader(i_chipletTarget); fapi2::getAddressData(i_ffdcId, l_scomAddresses, l_cfamAddresses, l_ffdcRegReadSize); FAPI_TRY((fapi2::collectRegisterAndAddressData >(l_scomAddresses, l_scomReader, l_offset, o_pHomerBuf)), "Failed in collectRegisterAndAddressData"); fapi_try_exit: FAPI_DBG("<< collectRegisterData"); return fapi2::current_err; }; //--------------------------------------------------------------------------------------------- // function pointer typedef definition for HWP call support typedef fapi2::ReturnCode (*p9_pm_recovery_ffdc_base_FP_t) ( const fapi2::Target&, void* ); extern "C" { // ----------------------------------------------------------------------------- // Function prototypes // ----------------------------------------------------------------------------- /// /// @brief Initializes the PM FFDC section in HOMER with default headers and /// other FFDC to be collection before the PM Reset Flow /// /// @param[in] i_procChipTarget Proc Chip target /// @param[in] i_pHomerImage Pointer to the base of the chip HOMER region /// /// @return FAPI2_RC_SUCCESS on success or error return code /// fapi2::ReturnCode p9_pm_recovery_ffdc_base ( const fapi2::Target& i_procChipTarget, void* i_pHomerImage ); /// @brief Updates the PM FFDC section in HOMER with miscellaneous, platform /// agnostic FFDC /// /// @param[in] i_procChipTarget Proc Chip target /// @param[in] i_pHomerImage Pointer to the base of the chip HOMER region /// /// @return FAPI2_RC_SUCCESS on success or error return code /// fapi2::ReturnCode p9_pm_recovery_ffdc_misc ( const fapi2::Target& i_procChipTarget, void* i_pHomerImage ); } } //namespace p9_stop_recov_ffdc ends #endif //__P9_PM_RECOVERY_FFDC_BASE_