From 1e846c106286181bf82e1e5bbc68b47b6e490ce1 Mon Sep 17 00:00:00 2001 From: Dzuy Nguyen Date: Wed, 19 Jul 2017 09:56:32 -0500 Subject: Update SCOMs in HCODE image before HOMER is established Change-Id: I988e897104d717746d5d40d0698350c0c7baa948 RTC: 167313 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/43555 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Reviewed-by: Martin Gloff Tested-by: Jenkins OP HW Reviewed-by: Matt Derksen Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell --- src/include/usr/isteps/pm/pm_common_ext.H | 15 ++- src/makefile | 1 + src/usr/isteps/pm/runtime/makefile | 2 + src/usr/isteps/pm/runtime/rt_pm.C | 32 ++++- src/usr/isteps/pm/runtime/test/makefile | 37 ++++++ src/usr/isteps/pm/runtime/test/pmtestRt.H | 138 +++++++++++++++++++++ .../common/xmltohb/attribute_types_hb.xml | 14 +++ .../targeting/common/xmltohb/target_types_hb.xml | 3 + src/usr/testcore/rtloader/loader.H | 16 +++ 9 files changed, 255 insertions(+), 3 deletions(-) create mode 100644 src/usr/isteps/pm/runtime/test/makefile create mode 100644 src/usr/isteps/pm/runtime/test/pmtestRt.H (limited to 'src') diff --git a/src/include/usr/isteps/pm/pm_common_ext.H b/src/include/usr/isteps/pm/pm_common_ext.H index 9a58c59ef..f93e4dc77 100644 --- a/src/include/usr/isteps/pm/pm_common_ext.H +++ b/src/include/usr/isteps/pm/pm_common_ext.H @@ -73,6 +73,16 @@ namespace HBPM PM_UNKNOWN = 0xFF, }; + /** + * @brief Enumeration of the HOMER_HCODE_LOADED attribute + * + */ + enum loadHCODE + { + HCODE_NOT_LOADED = 0x0, + HCODE_LOADED = 0x1, + }; + /** * @brief Convert HOMER physical address space to a vitual address * @param[in] i_proc_target Processsor target @@ -116,8 +126,11 @@ namespace HBPM * @return errlHndl_t Error log if resetPMAll failed */ errlHndl_t getRingOvd(void*& io_overrideImg); +} //namespace HBPM ends #if __HOSTBOOT_RUNTIME +namespace RTPM +{ /** * @brief Modify the SCOM restore section of the HCODE image with the * given register data @@ -135,7 +148,7 @@ namespace HBPM TARGETING::Target* i_target, uint64_t i_rel_scom_addr, uint64_t i_scom_data ); +} //namespace RTPM ends #endif -} //namespace HBPM ends #endif diff --git a/src/makefile b/src/makefile index a6f2c126e..66f3bc226 100644 --- a/src/makefile +++ b/src/makefile @@ -319,6 +319,7 @@ RUNTIME_TESTCASE_MODULES += testpnor_rt RUNTIME_TESTCASE_MODULES += testsecureboot_rt RUNTIME_TESTCASE_MODULES += testtargeting_rt RUNTIME_TESTCASE_MODULES += testsbeio_rt +RUNTIME_TESTCASE_MODULES += testpm_rt RELOCATABLE_IMAGE_LDFLAGS = -pie --export-dynamic diff --git a/src/usr/isteps/pm/runtime/makefile b/src/usr/isteps/pm/runtime/makefile index fa1aca5ae..8590c85fb 100644 --- a/src/usr/isteps/pm/runtime/makefile +++ b/src/usr/isteps/pm/runtime/makefile @@ -36,6 +36,8 @@ EXTRAINCDIR += ${ROOTPATH}/src/usr/scom/runtime ## Objects unique to HBRT OBJS += rt_pm.o +SUBDIRS += test.d + ## Objects common to HBRT and HB IPL include ../pm.mk diff --git a/src/usr/isteps/pm/runtime/rt_pm.C b/src/usr/isteps/pm/runtime/rt_pm.C index 32d3e0a25..070512b8d 100644 --- a/src/usr/isteps/pm/runtime/rt_pm.C +++ b/src/usr/isteps/pm/runtime/rt_pm.C @@ -158,6 +158,7 @@ namespace RTPM break; } + l_err = HBPM::loadPMComplex(proc_target, i_homer_addr, i_occ_common_addr, @@ -167,8 +168,18 @@ namespace RTPM TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK"load_pm_complex: " "load PM complex failed!" ); + proc_target->setAttr( + HBPM::HCODE_NOT_LOADED); break; } + else + { + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + "load_pm_complex: " + "load PM complex successfully." ); + proc_target->setAttr( + HBPM::HCODE_LOADED); + } } while(0); @@ -304,6 +315,24 @@ namespace RTPM int rc = 0; do { + const TARGETING::Target * l_pChipTarget = + getParentChip(const_cast(i_target)); + + // Check to see if hcode is loaded + uint8_t l_hcode_loaded = + l_pChipTarget->getAttr(); + + if(l_hcode_loaded == HBPM::HCODE_NOT_LOADED) + { + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, + ERR_MRK"hcode_update: HCODE not loaded." + " Target 0x%llX section 0x%X " + "operation 0x%X scomAddr 0x%llX scomData 0x%llX", + get_huid(i_target), i_section, + i_operation, i_rel_scom_addr, i_scom_data); + break; + } + if( g_hostInterfaces == NULL || g_hostInterfaces->hcode_scom_update == NULL ) { @@ -340,8 +369,6 @@ namespace RTPM } // Get the Proc Chip Id - const TARGETING::Target * l_pChipTarget = - getParentChip(const_cast(i_target)); RT_TARG::rtChipId_t l_chipId = 0; l_err = RT_TARG::getRtTarget(l_pChipTarget, l_chipId); @@ -371,6 +398,7 @@ namespace RTPM i_operation, l_scomAddr, i_scom_data); + if(rc) { TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, diff --git a/src/usr/isteps/pm/runtime/test/makefile b/src/usr/isteps/pm/runtime/test/makefile new file mode 100644 index 000000000..796b59386 --- /dev/null +++ b/src/usr/isteps/pm/runtime/test/makefile @@ -0,0 +1,37 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/isteps/pm/runtime/test/makefile $ +# +# OpenPOWER HostBoot Project +# +# Contributors Listed Below - COPYRIGHT 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 + +HOSTBOOT_RUNTIME = 1 + +ROOTPATH = ../../../../../.. + +MODULE = testpm_rt + +EXTRAINCDIR += ${ROOTPATH}/src/usr/isteps/pm +EXTRAINCDIR += ${ROOTPATH}/src/import/chips/p9/procedures/utils + +TESTS = *.H + +include ${ROOTPATH}/config.mk diff --git a/src/usr/isteps/pm/runtime/test/pmtestRt.H b/src/usr/isteps/pm/runtime/test/pmtestRt.H new file mode 100644 index 000000000..5a831919a --- /dev/null +++ b/src/usr/isteps/pm/runtime/test/pmtestRt.H @@ -0,0 +1,138 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/isteps/pm/runtime/test/pmtestRt.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 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 */ +#ifndef __TEST_PMTESTRT_H +#define __TEST_PMTESTRT_H + +/** + * @file pmtestRt.H + * + * @brief Unit test for runtime pm + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//trace +extern trace_desc_t* g_trac_isteps_trace; + +using namespace RTPM; +using namespace HBPM; +using namespace TARGETING; +using namespace CxxTest; + +class PMTest : public CxxTest::TestSuite +{ + public: + + void test_hcode_update(void) + { + errlHndl_t l_err; + + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, + ENTER_MRK "test_hcode_update Enter"); + + TARGETING::TargetHandleList l_coreList; + getAllChiplets(l_coreList, TYPE_CORE, true); + + for (const auto & l_core: l_coreList) + { + const TARGETING::Target * l_parentChip = + getParentChip(const_cast(l_core)); + + TARGETING::Target * l_parentTarget = + const_cast(l_parentChip); + + /* + * TODO RTC 177702 + * We should be calling load_pm_complex here, but due to a + * simics issue, load_pm_complex will fail. Instead, we'll + * just run these 2 tests which set the HOMER_HCODE_LOADED + * attribute and check for result. + */ + + // Set to not loaded, should get NULL for errl + TS_INFO("pm_runtime_test: hcode_update with" + " HCODE_NOT_LOADED on target 0x%llx", + get_huid(l_parentTarget)); + l_parentTarget->setAttr( + HCODE_NOT_LOADED); + + l_err = RTPM::hcode_update( + stopImageSection::P9_STOP_SECTION_CORE_SCOM, + stopImageSection::P9_STOP_SCOM_APPEND, + l_core, + 0x20010A43, + 0x0 ); + + if(l_err == NULL) + { + TS_INFO("hcode_update with HCODE_NOT_LOADED PASSED"); + } + else + { + TS_FAIL("hcode_update with HCODE_NOT_LOADED FAILED"); + } + + // Set to loaded, should not get errl + TS_INFO("pm_runtime_test: hcode_update with" + " HCODE_LOADED on target 0x%llx", + get_huid(l_parentTarget)); + l_parentTarget->setAttr( + HCODE_LOADED); + + l_err = RTPM::hcode_update( + stopImageSection::P9_STOP_SECTION_CORE_SCOM, + stopImageSection::P9_STOP_SCOM_APPEND, + l_core, + 0x20010A43, + 0x0 ); + + if(l_err) + { + TS_FAIL("hcode_update with HCODE_LOADED FAILED"); + } + else + { + TS_INFO("hcode_update with HCODE_LOADED PASSED"); + } + } + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, + EXIT_MRK "test_hcode_update Exit"); + } +}; + +#endif diff --git a/src/usr/targeting/common/xmltohb/attribute_types_hb.xml b/src/usr/targeting/common/xmltohb/attribute_types_hb.xml index 8a91bdbf4..9c92984b0 100644 --- a/src/usr/targeting/common/xmltohb/attribute_types_hb.xml +++ b/src/usr/targeting/common/xmltohb/attribute_types_hb.xml @@ -422,6 +422,20 @@ + + HOMER_HCODE_LOADED + + Attribute to check if HCODE is loaded in HOMER + + + + + volatile-zeroed + + + + + IPMI_SENSOR_ARRAY Enumeration defining the offsets into the diff --git a/src/usr/targeting/common/xmltohb/target_types_hb.xml b/src/usr/targeting/common/xmltohb/target_types_hb.xml index 51617b060..6aef9602b 100644 --- a/src/usr/targeting/common/xmltohb/target_types_hb.xml +++ b/src/usr/targeting/common/xmltohb/target_types_hb.xml @@ -74,6 +74,9 @@ HOMER_VIRT_ADDR + + HOMER_HCODE_LOADED + SBE_FFDC_ADDR diff --git a/src/usr/testcore/rtloader/loader.H b/src/usr/testcore/rtloader/loader.H index aa035d1eb..ac454e9f1 100644 --- a/src/usr/testcore/rtloader/loader.H +++ b/src/usr/testcore/rtloader/loader.H @@ -144,6 +144,7 @@ class RuntimeLoaderTest : public CxxTest::TestSuite intf->pnor_write= rt_pnor_write; intf->ipmi_msg= rt_ipmi_msg; intf->clock_gettime = clock_gettime; + intf->hcode_scom_update = rt_hcode_update; // Call init. runtimeInterfaces_t* rtInterface = @@ -686,6 +687,21 @@ class RuntimeLoaderTest : public CxxTest::TestSuite return l_plid; } + //-------------------------------------------------------------------- + static int rt_hcode_update( uint64_t i_chipId, + uint32_t i_section, + uint32_t i_operation, + uint64_t i_scomAddr, + uint64_t i_scomData ) + { + TRACFCOMP(g_trac_hbrt, + "Loading runtime hcode_update: " + "target 0x%llX chipId 0x%llX section 0x%X " + "operation 0x%X scomAddr 0x%llX scomData 0x%llX", + i_chipId, i_section, i_operation, i_scomAddr, i_scomData); + return 0; + } + static uint64_t cv_hb_data_addr; static uint64_t cv_comm_addr; static uint64_t cv_comm_phys_addr; -- cgit v1.2.1