From 5d64acfbc7dfb438688470b3c72230956624d86b Mon Sep 17 00:00:00 2001 From: Bilicon Patil Date: Thu, 24 Mar 2016 08:26:14 -0500 Subject: putRing on SBE Plat Conflicts: sbe/image/Makefile sbe/image/img_defs.mk tools/image/Makefile Change-Id: I4dc56c2b699724af2c6a57a0b62742998c4cf68b Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22439 Tested-by: Jenkins Server Reviewed-by: Gregory S. Still Reviewed-by: Jennifer A. Stofer --- sbe/hwpf/include/fapi2_hw_access.H | 31 ++- sbe/hwpf/include/hw_access.H | 89 +++----- sbe/hwpf/include/plat/plat_ring_traverse.H | 92 ++++++++ sbe/hwpf/src/fapi2sbefiles.mk | 26 ++- sbe/hwpf/src/plat_ring_traverse.C | 351 +++++++++++++++++++++++++++++ sbe/image/Makefile | 15 +- sbe/image/img_defs.mk | 12 +- 7 files changed, 544 insertions(+), 72 deletions(-) create mode 100644 sbe/hwpf/include/plat/plat_ring_traverse.H create mode 100644 sbe/hwpf/src/plat_ring_traverse.C (limited to 'sbe') diff --git a/sbe/hwpf/include/fapi2_hw_access.H b/sbe/hwpf/include/fapi2_hw_access.H index f1e60b52..4bd5eb64 100644 --- a/sbe/hwpf/include/fapi2_hw_access.H +++ b/sbe/hwpf/include/fapi2_hw_access.H @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: $ */ +/* $Source: sbe/hwpf/include/fapi2_hw_access.H $ */ /* */ -/* OpenPOWER HostBoot Project */ +/* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2016 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -49,6 +49,7 @@ typedef uint64_t spyId_t; #include #include #include +#include "imageProcs/p9_ringId.H" #ifdef FAPI_SUPPORT_MULTI_SCOM #include @@ -157,6 +158,17 @@ namespace fapi2 const buffer i_data, const ChipOpModifyMode i_modifyMode); +/// @brief Writes a ring to a chip. +/// @tparam K template parameter, passed in target. +/// @param[in] i_target Target to operate on. +/// @param[in] i_RingID Ring ID to write to. +/// @param[in] i_ringMode Ring operation mode. +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +template< TargetType K > +inline ReturnCode putRing(const Target& i_target, + const RingID i_ringID, + const RingMode i_ringMode = RING_MODE_HEADER_CHECK); + // variable_buffer isn't supported on PPE #ifndef __PPE__ /// @brief Reads a ring from a chip. @@ -172,19 +184,6 @@ namespace fapi2 variable_buffer& o_data, const RingMode i_ringMode = 0); - /// @brief Writes a ring to a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to write to. - /// @param[in] i_data Buffer that contains RS4 compressed ring data - /// to write into address - /// @param[in] i_ringMode Ring operation mode. - /// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline ReturnCode putRing(const Target& i_target, - const scanRingId_t i_address, - const variable_buffer& i_data, - const RingMode i_ringMode = 0); /// @brief Read-modify-write a ring on a chip. diff --git a/sbe/hwpf/include/hw_access.H b/sbe/hwpf/include/hw_access.H index 00079797..e7ed9e51 100644 --- a/sbe/hwpf/include/hw_access.H +++ b/sbe/hwpf/include/hw_access.H @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: $ */ +/* $Source: sbe/hwpf/include/hw_access.H $ */ /* */ -/* OpenPOWER HostBoot Project */ +/* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2016 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -41,6 +41,7 @@ #include #include #include +#include "plat_ring_traverse.H" // for findRS4InImageAndApply namespace fapi2 { @@ -100,18 +101,18 @@ namespace fapi2 /// @param[out] o_data Buffer that holds data read from HW target. /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. template< TargetType K > - __attribute__((always_inline)) - inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, - buffer& o_data) - { - fapi2::ReturnCode l_rc; - PLAT_GETSCOM(l_rc, - i_target, - i_address, - &(o_data())); + __attribute__((always_inline)) + inline ReturnCode getScom(const Target& i_target, const uint64_t i_address, + buffer& o_data) + { + fapi2::ReturnCode l_rc; + PLAT_GETSCOM(l_rc, + i_target, + i_address, + &(o_data())); - return l_rc; - } + return l_rc; + } /// @brief Writes a SCOM register on a chip. /// @tparam K template parameter, passed in target. @@ -270,6 +271,28 @@ __fapi2exit__: return FAPI2_RC_SUCCESS; } + /// @brief Platform-level implementation of putRing() + /// Hardware procedures writers will not call this function. + /// @tparam K template parameter, passed in target. + /// @param[in] i_target Target to operate on. + /// @param[in] i_ringID Ring ID that will identify the Ring in the image. + /// @param[in] i_ringMode Ring operation mode. + /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. + template< TargetType K > + inline ReturnCode putRing(const Target& i_target, + const RingID i_ringID, + const RingMode i_ringMode) + { + SBE_TRACE(">> putRing"); + ReturnCode l_rc = FAPI2_RC_SUCCESS; + + // Find the RS4 string in the SEEPROM + l_rc = findRS4InImageAndApply(i_target, i_ringID, i_ringMode); + + SBE_TRACE("<< putRing"); + return l_rc; + } + // variable_buffer isn't supported on PPE #ifndef __PPE__ /// @brief Reads a ring from a chip. @@ -300,44 +323,6 @@ __fapi2exit__: return FAPI2_RC_SUCCESS; } - /// @brief Writes a ring to a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to write to. - /// @param[in] i_data Buffer that contains RS4 compressed ring data - /// to write into address - /// @param[in] i_ringMode Ring operation mode. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline ReturnCode putRing(const Target& i_target, - const scanRingId_t i_address, - variable_buffer& i_data, - const RingMode i_ringMode = 0) - { - - return FAPI2_RC_SUCCESS; - } - - - /// @brief Writes a ring to a chip. - /// @tparam K template parameter, passed in target. - /// @param[in] i_target Target to operate on. - /// @param[in] i_address Ring address to write to. - /// @param[in] i_data Pointer to location that contains RS4 compressed - // ring data to write into address - /// @param[in] i_ringMode Ring operation mode. - /// @return fapi::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. - template< TargetType K > - inline ReturnCode putRing(const Target& i_target, - const scanRingId_t i_address, - const void* i_data, - const RingMode i_ringMode = 0) - { - uint64_t* dataPtr = reinterpret_cast(const_cast(i_data)); - - return FAPI2_RC_SUCCESS; - } - /// @brief Read-modify-write a ring on a chip. /// @tparam K template parameter, passed in target. /// @param[in] i_target Target to operate on. diff --git a/sbe/hwpf/include/plat/plat_ring_traverse.H b/sbe/hwpf/include/plat/plat_ring_traverse.H new file mode 100644 index 00000000..338de530 --- /dev/null +++ b/sbe/hwpf/include/plat/plat_ring_traverse.H @@ -0,0 +1,92 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: sbe/hwpf/include/plat/plat_ring_traverse.H $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] 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 _PLAT_RING_TRAVERSE_H_ +#define _PLAT_RING_TRAVERSE_H_ + +#include // for RS4 decompression utilities + +using namespace RING_TYPES; + +/// @brief This structure represents the layout of the Section-TOR +/// Section-TOR has the offsets to the different chiplet's +/// Common Ring section and Instance Ring section +struct SectionTOR +{ + uint32_t TOC_PERV_COMMON_RING; // Offset of Perv Common Ring section + uint32_t TOC_PERV_INSTANCE_RING; // Offset of Perv Instance Ring section + + uint32_t TOC_N0_COMMON_RING; // Offset of N0 Common Ring section + uint32_t TOC_N0_INSTANCE_RING; // Offset of N0 Instance Ring section + + uint32_t TOC_N1_COMMON_RING; // Offset of N1 Common Ring section + uint32_t TOC_N1_INSTANCE_RING; // Offset of N1 Instance Ring section + + uint32_t TOC_N2_COMMON_RING; // Offset of N2 Common Ring section + uint32_t TOC_N2_INSTANCE_RING; // Offset of N2 Instance Ring section + + uint32_t TOC_N3_COMMON_RING; // Offset of N3 Common Ring section + uint32_t TOC_N3_INSTANCE_RING; // Offset of N3 Instance Ring section + + uint32_t TOC_XB_COMMON_RING; // Offset of XB Common Ring section + uint32_t TOC_XB_INSTANCE_RING; // Offset of XB Instance Ring section + + uint32_t TOC_MC_COMMON_RING; // Offset of MC Common Ring section + uint32_t TOC_MC_INSTANCE_RING; // Offset of MC Instance Ring section + + uint32_t TOC_OB_COMMON_RING; // Offset of OB Common Ring section + uint32_t TOC_OB_INSTANCE_RING; // Offset of OB Instance Ring section + + uint32_t TOC_PCI0_COMMON_RING; // Offset of PCI0 Common Ring section + uint32_t TOC_PCI0_INSTANCE_RING; // Offset of PCI0 Instance Ring section + + uint32_t TOC_PCI1_COMMON_RING; // Offset of PCI1 Common Ring section + uint32_t TOC_PCI1_INSTANCE_RING; // Offset of PCI1 Instance Ring section + + uint32_t TOC_PCI2_COMMON_RING; // Offset of PCI2 Common Ring section + uint32_t TOC_PCI2_INSTANCE_RING; // Offset of PCI2 Instance Ring section + + uint32_t TOC_EQ_COMMON_RING; // Offset of Quad Common Ring section + uint32_t TOC_EQ_INSTANCE_RING; // Offset of Quad Instance Ring section + + uint32_t TOC_EC_COMMON_RING; // Offset of Core Common Ring section + uint32_t TOC_EC_INSTANCE_RING; // Offset of Core Instance Ring section +}; + + +/// +/// @brief This is a plat pecific (SBE Plat) function that locates the +/// Ring Container in the image and calls the functin to decompress the +/// RS4 string and apply it to the hardware. +/// @param i_target The target of Ring apply. +/// @param i_ringID The Ring ID that identifies the ring to be applied. +/// @return FAPI2_RC_SUCCESS on success, else error code. +/// +fapi2::ReturnCode findRS4InImageAndApply( + const fapi2::Target& i_target, + const RingID i_ringID, + const fapi2::RingMode i_ringMode); + +#endif diff --git a/sbe/hwpf/src/fapi2sbefiles.mk b/sbe/hwpf/src/fapi2sbefiles.mk index da7f3e7c..ada060cd 100644 --- a/sbe/hwpf/src/fapi2sbefiles.mk +++ b/sbe/hwpf/src/fapi2sbefiles.mk @@ -1,3 +1,27 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: sbe/hwpf/src/fapi2sbefiles.mk $ +# +# OpenPOWER sbe Project +# +# Contributors Listed Below - COPYRIGHT 2015,2016 +# [+] 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 fapi2ppefiles.mk # # @brief mk for including fapi2 object files @@ -17,7 +41,7 @@ # Object Files ########################################################################## -FAPI2-C-SOURCES += +FAPI2-C-SOURCES += plat_ring_traverse.C FAPI2-S-SOURCES = diff --git a/sbe/hwpf/src/plat_ring_traverse.C b/sbe/hwpf/src/plat_ring_traverse.C new file mode 100644 index 00000000..0309bfd5 --- /dev/null +++ b/sbe/hwpf/src/plat_ring_traverse.C @@ -0,0 +1,351 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: sbe/hwpf/src/plat_ring_traverse.C $ */ +/* */ +/* OpenPOWER sbe Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2016 */ +/* [+] 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 */ + +#include + +#include // for RS4 decompression utilities +#include +#include // for FAPI_ATTR_GET +#include // for plat_getChipTarget + +// SEEPROM start address +const uint32_t g_seepromAddr = SBE_SEEPROM_BASE_ORIGIN; +using namespace RING_TYPES; + +/// +/// @brief This is a plat pecific (SBE Plat) function that locates the +/// Ring Container in the image and calls the functin to decompress the +/// RS4 string and apply it to the hardware. +/// @param i_target The target of Ring apply. +/// @param i_ringID The Ring ID that identifies the ring to be applied. +/// @return FAPI2_RC_SUCCESS on success, else error code. +/// +fapi2::ReturnCode findRS4InImageAndApply( + const fapi2::Target& i_target, + const RingID i_ringID, + const fapi2::RingMode i_ringMode) +{ + SBE_TRACE(">> findRS4InImageAndApply"); + + fapi2::ReturnCode l_rc = fapi2::FAPI2_RC_SUCCESS; + + do + { + // Determine the Offset ID and Ring Type for the given Ring ID. + uint32_t l_torOffset = 0; + RINGTYPE l_ringType = COMMON_RING; + CHIPLET_TYPE l_chipLetType; + + getRingProperties(i_ringID, l_torOffset, l_ringType,l_chipLetType); + if(INVALID_RING == l_torOffset) + { + SBE_TRACE("Invalid Ring ID - %d", i_ringID); + l_rc = fapi2::FAPI2_RC_INVALID_PARAMETER; + break; + } + + // Get the address of the Section-TOR + P9XipHeader *l_hdr = getXipHdr(); + P9XipSection *l_section = &(l_hdr->iv_section[P9_XIP_SECTION_SBE_RINGS]); + SectionTOR *l_sectionTOR = (SectionTOR *)(g_seepromAddr + + l_section->iv_offset); + + CHIPLET_DATA l_chipletData; + l_chipletData.iv_base_chiplet_number = 0; + l_chipletData.iv_num_common_rings = 0; + l_chipletData.iv_num_instance_rings = 0; + + uint8_t l_chipletID = i_target.getChipletNumber(); + uint16_t l_cpltRingVariantSz = 0; + uint32_t l_sectionOffset = 0; + switch(l_chipLetType) + { + case PERV_TYPE: // PERV + l_chipletData = PERV::g_pervData; + l_cpltRingVariantSz = sizeof(PERV::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_PERV_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_PERV_INSTANCE_RING; + } + + break; + + case N0_TYPE: // Nest - N0 + l_chipletData = N0::g_n0Data; + l_cpltRingVariantSz = sizeof(N0::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_N0_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_N0_INSTANCE_RING; + } + + break; + + case N1_TYPE: // Nest - N1 + l_chipletData = N1::g_n1Data; + l_cpltRingVariantSz = sizeof(N1::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_N1_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_N1_INSTANCE_RING; + } + + break; + + case N2_TYPE: // Nest - N2 + l_chipletData = N2::g_n2Data; + l_cpltRingVariantSz = sizeof(N2::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_N2_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_N2_INSTANCE_RING; + } + + break; + + case N3_TYPE: // Nest - N3 + l_chipletData = N3::g_n3Data; + l_cpltRingVariantSz = sizeof(N3::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_N3_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_N3_INSTANCE_RING; + } + + break; + + case XB_TYPE: // XB - XBus2 + l_chipletData = XB::g_xbData; + l_cpltRingVariantSz = sizeof(XB::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_XB_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_XB_INSTANCE_RING; + } + + break; + + case MC_TYPE: // MC - MC23 + l_chipletData = MC::g_mcData; + l_cpltRingVariantSz = sizeof(MC::RingVariants)/ + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_MC_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_MC_INSTANCE_RING; + } + + break; + + case OB_TYPE: // OB - OB2 + l_chipletData = OB::g_obData; + l_cpltRingVariantSz = sizeof(OB::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_OB_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_OB_INSTANCE_RING; + } + + break; + + case PCI0_TYPE: // PCI - PCI0 + l_chipletData = PCI0::g_pci0Data; + l_cpltRingVariantSz = sizeof(PCI0::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_PCI0_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_PCI0_INSTANCE_RING; + } + + break; + + case PCI1_TYPE: // PCI - PCI1 + l_chipletData = PCI1::g_pci1Data; + l_cpltRingVariantSz = sizeof(PCI1::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_PCI1_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_PCI1_INSTANCE_RING; + } + + break; + + case PCI2_TYPE: // PCI - PCI2 + l_chipletData = PCI2::g_pci2Data; + l_cpltRingVariantSz = sizeof(PCI2::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_PCI2_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_PCI2_INSTANCE_RING; + } + + break; + + case EQ_TYPE: // EQ - Quad 0 - Quad 5 + l_chipletData = EQ::g_eqData; + l_cpltRingVariantSz = sizeof(EQ::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_EQ_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_EQ_INSTANCE_RING; + } + + break; + + case EC_TYPE: // EC - Core 0 - 23 + l_chipletData = EC::g_ecData; + l_cpltRingVariantSz = sizeof(EC::RingVariants) / + sizeof(l_cpltRingVariantSz); + + l_sectionOffset = l_sectionTOR->TOC_EC_COMMON_RING; + if(INSTANCE_RING == l_ringType) + { + l_sectionOffset = l_sectionTOR->TOC_EC_INSTANCE_RING; + } + + break; + + default: + SBE_TRACE("Invalid Target/ChipletID - %d", l_chipletID); + l_rc = fapi2::FAPI2_RC_INVALID_PARAMETER; + break; + + } // end of switch(l_chipletID) + + FAPI_INF("l_sectionOffset %08x",l_sectionOffset); + // Determine the section TOR address for the ring + uint32_t *l_sectionAddr = reinterpret_cast(g_seepromAddr + + l_section->iv_offset + l_sectionOffset); + + SBE_TRACE ("l_sectionAddr %08X",l_sectionAddr); + SBE_TRACE("l_section->iv_offset %08X",l_section->iv_offset); + + + if(INSTANCE_RING == l_ringType) + { + if ( l_chipletID > l_chipletData.iv_base_chiplet_number) + { + uint8_t l_chipletOffset = + (l_chipletID - l_chipletData.iv_base_chiplet_number); + l_sectionAddr += (l_chipletOffset * + (l_chipletData.iv_num_instance_rings * l_cpltRingVariantSz)); + } + else + { + l_sectionAddr += + (l_chipletData.iv_num_instance_rings * l_cpltRingVariantSz); + } + } + + // The ring variants in section TOR are expected to be in the sequence - + // 1. Base + // 2. Cache-Contained + // 3. Risk Level + + SBE_TRACE ("l_sectionAddr %08X",l_sectionAddr); + + // TOR records of Ring TOR are 2 bytes in size. + uint16_t *l_ringTorAddr = reinterpret_cast(l_sectionAddr) + + (l_torOffset * l_cpltRingVariantSz); + SBE_TRACE ("ring tor address %04X\n",l_ringTorAddr); + + // If there are non-base variants of the ring, we'll have to check + // attributes to determine the sequence of ring apply. + if( l_cpltRingVariantSz > 1) + { + // Check if this is cache-contained IPL + uint8_t l_iplPhase; + FAPI_ATTR_GET(fapi2::ATTR_SYSTEM_IPL_PHASE, + fapi2::Target (), + l_iplPhase); + + // 4 : Cache Contained mode + if(4 == l_iplPhase) + { + l_ringTorAddr += 1; + } + else + { +#if 0 + // Check if this is risk-level IPL + uint8_t l_riskLevel; + FAPI_ATTR_GET(fapi2::ATTR_RISK_LEVEL, + fapi2::plat_getChipTarget(), + l_riskLevel); + if(1 == l_riskLevel) + { + l_ringTorAddr += 2; + } +#endif + } + } + + SBE_TRACE("l_ringTorAddr %u",*l_ringTorAddr); + if(*l_ringTorAddr != 0) + { + uint8_t *l_addr = reinterpret_cast(l_sectionAddr); + uint8_t *l_rs4Address = reinterpret_cast(l_addr + *l_ringTorAddr); + l_rc = applyRS4_SS(i_target, l_rs4Address, i_ringMode); + if(l_rc != fapi2::FAPI2_RC_SUCCESS) + { + SBE_TRACE("Error from applyRS4_SS"); + break; + } + } + else + { + l_rc = fapi2::FAPI2_RC_PLAT_RING_ID_NOT_FOUND_IN_RS4_IMAGE; + SBE_TRACE("Ring image is not found for this is ringId %u",i_ringID); + } + }while(0); + + SBE_TRACE("<< findRS4InImageAndApply Exit"); + return l_rc; +} + diff --git a/sbe/image/Makefile b/sbe/image/Makefile index 133cf04e..df4fed14 100644 --- a/sbe/image/Makefile +++ b/sbe/image/Makefile @@ -69,6 +69,12 @@ HWPLIB := $(OBJDIR)/libcommon.a LLIBS += -lcommon include $(HWPERR_SRCDIR)/hwpErrors.mk +# Common Utils library +UTILS_MAKE_DIR := $(UTILS_SRCDIR) +LIB_DIRS += -L$(OBJDIR)/utils +UTILSLIB := $(OBJDIR)/utils/libutils.a +LLIBS += -lutils + # Common Cache HWP Exit library CACHE_MAKE_DIR := $(CACHE_SRCDIR) LIB_DIRS += -L$(OBJDIR)/cache @@ -127,7 +133,7 @@ SBE_TOOLS := $(TOOLS_IMAGE_DIR)/sbe_default_tool P9_XIP_TOOL := $(P9_XIP_BINDIR)/p9_xip_tool -LINK_OBJS = $(OBJS) $(SBEFWLIB) $(PKLIB) $(FAPI2LIB) $(CACHELIB) $(CORELIB) $(HWPLIB) $(P2PLIB) $(PERVLIB) $(NESTLIB) $(PMLIB) $(INITFILESLIB) +LINK_OBJS = $(OBJS) $(SBEFWLIB) $(PKLIB) $(FAPI2LIB) $(UTILSLIB) $(NESTLIB) $(CACHELIB) $(CORELIB) $(HWPLIB) $(P2PLIB) $(PERVLIB) $(NESTLIB) $(PMLIB) $(INITFILESLIB) # Define the objects OBJS := $(addprefix $(OBJDIR)/, $(TOP_OBJECTS)) @@ -289,7 +295,7 @@ $(OBJDIR): $(TOOLS_ATTR_DIR)/ppeCreateIfAttrService.pl $(PPE_FAPI2_DIR)/include $(IMPORT_XML_DIR)/attribute_info/p9_sbe_attributes.xml $(ATTRFILES) mkdir -p $(OBJDIR) -.PHONY: clean topfixedheaders $(PKLIB) $(P2PLIB) $(PPELIB) $(FAPI2LIB) $(CACHELIB) $(CORELIB) $(PERVLIB) $(NESTLIB) $(PMLIB) $(HWPLIB) $(INITFILESLIB) buildInfo +.PHONY: clean topfixedheaders $(PKLIB) $(P2PLIB) $(PPELIB) $(FAPI2LIB) $(CACHELIB) $(UTILSLIB) $(CORELIB) $(PERVLIB) $(NESTLIB) $(PMLIB) $(HWPLIB) $(INITFILESLIB) buildInfo #errxml: topfixedheaders attrids platattr attrserv @@ -319,6 +325,11 @@ $(PPELIB): @echo "Processing ppelibmakefile" $(MAKE) -I $(IMAGE_SRCDIR) -C $(LIB_MAKE_DIR) -f Makefile +#Build the utils code shared with the SBE +$(UTILSLIB): + @echo "Processing utils makefile" + $(MAKE) -I $(IMAGE_SRCDIR) -C $(UTILS_MAKE_DIR) -f Makefile + #Build the cache exit code shared with the SBE $(CACHELIB): @echo "Processing cache makefile" diff --git a/sbe/image/img_defs.mk b/sbe/image/img_defs.mk index cfab67d0..83a39448 100644 --- a/sbe/image/img_defs.mk +++ b/sbe/image/img_defs.mk @@ -71,6 +71,10 @@ ifndef IMAGE_SRCDIR export IMAGE_SRCDIR = $(abspath .) endif +ifndef UTILS_SRCDIR +export UTILS_SRCDIR = $(abspath ../../import/chips/p9/utils) +endif + ifndef CACHE_SRCDIR export CACHE_SRCDIR = $(abspath ../../import/chips/p9/procedures/hwp/cache) endif @@ -116,7 +120,7 @@ export P9_XIP_BINDIR = $(P9_XIP_SRCDIR)/bin endif ifndef IMG_INCLUDES -export IMG_INCLUDES = -I$(IMAGEPROCS_SRCDIR) -I$(P9_XIP_SRCDIR) -I$(IMAGE_SRCDIR) -I$(CACHE_SRCDIR) -I$(CORE_SRCDIR) -I$(PERV_SRCDIR) -I$(NEST_SRCDIR) -I$(PM_SRCDIR) -I$(INITFILES_SRCDIR) +export IMG_INCLUDES = -I$(IMAGEPROCS_SRCDIR) -I$(P9_XIP_SRCDIR) -I$(IMAGE_SRCDIR) -I$(CACHE_SRCDIR) -I$(UTILS_SRCDIR) -I$(CORE_SRCDIR) -I$(PERV_SRCDIR) -I$(NEST_SRCDIR) -I$(PM_SRCDIR) -I$(INITFILES_SRCDIR) endif ifndef BASE_OBJDIR @@ -141,6 +145,10 @@ ifndef IMPORT_XML_DIR export IMPORT_XML_DIR = $(abspath ../../import/chips/p9/procedures/xml) endif +ifndef IMPORT_UTILS_DIR +export IMPORT_UTILS_DIR = $(abspath ../../import/chips/p9/utils) +endif + ifndef IMPORT_COMMON_DIR export IMPORT_COMMON_DIR = $(abspath ../../import/chips/p9/common) endif @@ -295,6 +303,8 @@ INCLUDES += -I$(PK_SRCDIR)/../sbe/sbefw INCLUDES += -I$(PK_SRCDIR)/trace INCLUDES += -I$(PK_SRCDIR)/../tools/ppetracepp INCLUDES += -I$(IMPORT_COMMON_DIR)/include +INCLUDES += -I$(IMPORT_UTILS_DIR)/imageProcs +INCLUDES += -I$(IMPORT_UTILS_DIR)/ GCC-CFLAGS += -Wall -Werror -Wno-unused-label GCC-CFLAGS += -msoft-float -- cgit v1.2.1