diff options
author | George Keishing <gkeishin@in.ibm.com> | 2016-02-03 03:03:07 -0600 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2016-04-27 11:07:34 -0400 |
commit | 29319e3a075801a154e4b95434bd7d49797274ca (patch) | |
tree | 8550826fa5f5f055a38323e205ffee822a6734ff /src/usr/fapi2 | |
parent | 9c0009a21f815a05a5ce052243e25462682cd25c (diff) | |
download | talos-hostboot-29319e3a075801a154e4b95434bd7d49797274ca.tar.gz talos-hostboot-29319e3a075801a154e4b95434bd7d49797274ca.zip |
FAPI2 Plat support for spd accessors
Change-Id: Ib490662418cd91b6a545462f2aa6566f5fd9c4ae
RTC:140332
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/688
Tested-by: Jenkins Server
Tested-by: FSP CI Jenkins
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/fapi2')
-rwxr-xr-x | src/usr/fapi2/fapi2.mk | 1 | ||||
-rw-r--r-- | src/usr/fapi2/plat_spd_access.C | 131 | ||||
-rw-r--r-- | src/usr/fapi2/test/fapi2SpdTestCxx.H | 128 | ||||
-rw-r--r-- | src/usr/fapi2/test/makefile | 1 |
4 files changed, 261 insertions, 0 deletions
diff --git a/src/usr/fapi2/fapi2.mk b/src/usr/fapi2/fapi2.mk index 1adbbf340..cde9535e2 100755 --- a/src/usr/fapi2/fapi2.mk +++ b/src/usr/fapi2/fapi2.mk @@ -40,6 +40,7 @@ OBJS += plat_attr_override_sync.o OBJS += plat_hwp_invoker.o OBJS += target.o OBJS += plat_hw_access.o +OBJS += plat_spd_access.o #EKB Objects (mirrored in src/import) OBJS += error_info.o diff --git a/src/usr/fapi2/plat_spd_access.C b/src/usr/fapi2/plat_spd_access.C new file mode 100644 index 000000000..c8466f5da --- /dev/null +++ b/src/usr/fapi2/plat_spd_access.C @@ -0,0 +1,131 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/fapi2/plat_spd_access.C $ */ +/* */ +/* OpenPOWER HostBoot 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 plat_attribute_service.C +/// +/// @brief Implements the specialized platform functions that access +/// attributes for FAPI2 +/// + +#include <attribute_service.H> +#include <target_types.H> +#include <errl/errlentry.H> +#include <errl/errlmanager.H> +#include <fapi2_spd_access.H> + +namespace fapi2 +{ + +//****************************************************************************** +// Function : getSPD() +// Return a blob of SPD data from a DIMM +//****************************************************************************** +fapi2::ReturnCode getSPD( + const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_pTarget, + uint8_t * o_blob, + size_t& o_size) +{ + FAPI_DBG(ENTER_MRK "getSPD"); + + const uint8_t MEM_DDR3 = 0xB; + const uint8_t MEM_DDR4 = 0xC; + const uint32_t DDR3_KEYWORD_SIZE = 256; + const uint32_t DDR4_KEYWORD_SIZE = 512; + + errlHndl_t l_errl = NULL; + fapi2::ReturnCode l_rc; + TARGETING::Target* l_pTarget = NULL; + + do + { + l_errl = fapi2::platAttrSvc::getTargetingTarget(i_pTarget, + l_pTarget, + TARGETING::TYPE_DIMM); + if (l_errl) + { + FAPI_ERR("getSPD: Error from getTargetingTarget"); + break; + } + + // If the caller passed a nullptr for blob then + // return size of the SPD + if ( o_blob == NULL ) + { + // Get the DDR device type from SPD + uint8_t l_memType = 0x0; + size_t l_memSize = sizeof(l_memType); + + l_errl = deviceRead(l_pTarget, + (void *)&l_memType, + l_memSize, + DEVICE_SPD_ADDRESS(SPD::BASIC_MEMORY_TYPE)); + + if ( !l_errl ) + { + if ( l_memType == MEM_DDR3 ) + { + o_size = DDR3_KEYWORD_SIZE; + } + else if ( l_memType == MEM_DDR4 ) + { + o_size = DDR4_KEYWORD_SIZE; + } + else + { + FAPI_ERR("getSPD: Invalid DIMM DDR Type"); + break; + } + + FAPI_DBG("getSPD: Returning the size of the SPD :%d ", o_size); + } + } + else + { + l_errl = deviceRead(l_pTarget, + o_blob, + o_size, + DEVICE_SPD_ADDRESS(SPD::ENTIRE_SPD)); + } + + break; + + } while(0); + + if ( l_errl ) + { + FAPI_ERR("getSPD: Error getting SPD data for HUID=0x%.8X Size %d", + TARGETING::get_huid(l_pTarget),o_size); + + l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl)); + } + + FAPI_DBG("getSPD: SPD data for HUID=0x%.8X Size %d Blob %d", + TARGETING::get_huid(l_pTarget),o_size,o_blob); + + FAPI_DBG(EXIT_MRK "getSPD"); + return l_rc; +} + +} // End fapi2 namespace diff --git a/src/usr/fapi2/test/fapi2SpdTestCxx.H b/src/usr/fapi2/test/fapi2SpdTestCxx.H new file mode 100644 index 000000000..2ccd457dc --- /dev/null +++ b/src/usr/fapi2/test/fapi2SpdTestCxx.H @@ -0,0 +1,128 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/fapi2/test/fapi2SpdTestCxx.H $ */ +/* */ +/* OpenPOWER HostBoot 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 __SPDTEST_H +#define __SPDTEST_H + +/** + * @file spdtest.H + * + * @brief Test cases for SPD code + */ +#include <sys/time.h> + +#include <cxxtest/TestSuite.H> +#include <errl/errlmanager.H> +#include <errl/errlentry.H> +#include <devicefw/driverif.H> +#include <fapi2_spd_access.H> + +using namespace TARGETING; + +void getDIMMTargets ( TargetHandleList & o_dimmList ) +{ + // Get Dimm list. + getAllLogicalCards( o_dimmList, + TARGETING::TYPE_DIMM ); + return; +} + +class SPDTest: public CxxTest::TestSuite +{ + public: + + /** + * @brief Test SPD get Interface DIMMs. + */ + void testGetSPD ( void ) + { + fapi2::ReturnCode l_rc; + size_t l_size = 0; + uint8_t * l_blobData = NULL; + + FAPI_INF( "testGetSPD - Enter" ); + + do + { + TARGETING::Target * i_pTarget = NULL; + + // Get DIMM Targets + TargetHandleList dimmList; + getDIMMTargets( dimmList ); + + // Should get atleast one + if( ( 0 == dimmList.size() ) || + ( NULL == dimmList[0] ) ) + { + FAPI_INF( "testGetSPD- No DIMMs found!"); + break; + } + + // Work on the first DIMM target + i_pTarget = dimmList[0]; + + // convert to fapi2 target + fapi2::Target<fapi2::TARGET_TYPE_DIMM> fapi2_Target(i_pTarget); + + // SPD interface call with NULL blob to get size data + l_rc = fapi2::getSPD(fapi2_Target, NULL, l_size); + + // Expect to return the size or non failure + if( !l_size || (l_rc != fapi2::FAPI2_RC_SUCCESS) ) + { + TS_FAIL("testGetSPD: Failed getting the size of the mem buffer"); + break; + } + + // allocate the blob data of mem size length to hold data + l_blobData = reinterpret_cast<uint8_t *>(malloc(l_size)); + memset(l_blobData,0,l_size); + + l_rc = fapi2::getSPD(fapi2_Target,l_blobData, l_size); + if ( l_rc != fapi2::FAPI2_RC_SUCCESS ) + { + TS_FAIL( "testGetSPD- Failed to read data from DIMM with HUID= 0x%x", + TARGETING::get_huid(i_pTarget)); + break; + } + + FAPI_DBG("getSPD: SPD data for DIMM with HUID=0x%.8X Size %d Blob %d", + TARGETING::get_huid(i_pTarget), + l_size, + l_blobData); + + } while(0); + + if( NULL != l_blobData ) + { + free( l_blobData ); + l_blobData = NULL; + } + + FAPI_INF( "testGetSPD - Exit" ); + } + +}; + +#endif diff --git a/src/usr/fapi2/test/makefile b/src/usr/fapi2/test/makefile index 990f82e31..ae19dd34d 100644 --- a/src/usr/fapi2/test/makefile +++ b/src/usr/fapi2/test/makefile @@ -48,6 +48,7 @@ TESTS += fapi2GetParentTest.H TESTS += fapi2GetChildrenTest.H TESTS += fapi2BasicTryTest.H TESTS += fapi2GetOtherEndTest.H +TESTS += fapi2SpdTestCxx.H include ${ROOTPATH}/config.mk |