diff options
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/targeting/hostboot_common.mk | 5 | ||||
-rw-r--r-- | src/usr/targeting/makefile | 2 | ||||
-rw-r--r-- | src/usr/targeting/runtime/attrPlatOverride_rt.C | 104 | ||||
-rw-r--r-- | src/usr/targeting/runtime/makefile | 7 | ||||
-rw-r--r-- | src/usr/targeting/runtime/test/makefile | 5 | ||||
-rw-r--r-- | src/usr/targeting/runtime/test/testtargeting.H | 111 |
6 files changed, 229 insertions, 5 deletions
diff --git a/src/usr/targeting/hostboot_common.mk b/src/usr/targeting/hostboot_common.mk index 8d69d436b..36f1342c5 100644 --- a/src/usr/targeting/hostboot_common.mk +++ b/src/usr/targeting/hostboot_common.mk @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2013,2014 +# Contributors Listed Below - COPYRIGHT 2013,2015 +# [+] 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. @@ -30,3 +32,4 @@ VPATH += ${TARGETING_REL_PATH}/adapters VPATH += ${COMMON_TARGETING_REL_PATH} VPATH += ${addprefix ${COMMON_TARGETING_REL_PATH}/, ${COMMON_TARGETING_SUBDIRS}} +HOSTBOOT_RT_IPL_COMMON_OBJS += attrPlatOverride.o diff --git a/src/usr/targeting/makefile b/src/usr/targeting/makefile index 2fd5a204d..eaa6dbb8d 100644 --- a/src/usr/targeting/makefile +++ b/src/usr/targeting/makefile @@ -39,7 +39,6 @@ include ${TARGETING_REL_PATH}/hostboot_common.mk ATTR_RP_OBJS += attrrp.o ATTR_RP_OBJS += attrsync.o ATTR_RP_OBJS += targplatutil.o -ATTR_RP_OBJS += attrPlatOverride.o EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi ENTRY_POINT_OBJS += targetservicestart.o @@ -49,6 +48,7 @@ DEBUG_OBJS += attributestrings.o HOSTBOOT_SPECIFIC_OBJS += ${ENTRY_POINT_OBJS} HOSTBOOT_SPECIFIC_OBJS += ${ATTR_RP_OBJS} HOSTBOOT_SPECIFIC_OBJS += ${DEBUG_OBJS} +HOSTBOOT_SPECIFIC_OBJS += ${HOSTBOOT_RT_IPL_COMMON_OBJS} HOSTBOOT_SPECIFIC_OBJS += namedtarget.o diff --git a/src/usr/targeting/runtime/attrPlatOverride_rt.C b/src/usr/targeting/runtime/attrPlatOverride_rt.C new file mode 100644 index 000000000..be39e65cf --- /dev/null +++ b/src/usr/targeting/runtime/attrPlatOverride_rt.C @@ -0,0 +1,104 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/targeting/attrPlatOverride.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ +/* [+] 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 <runtime/interface.h> +#include <runtime/rt_targeting.H> +#include <targeting/common/commontargeting.H> +#include <targeting/attrPlatOverride.H> +#include <hwpf/plat/fapiPlatAttrOverrideSync.H> +#include <targeting/common/trace.H> +#include <errl/errlmanager.H> + +using namespace TARGETING; + +namespace RT_TARG +{ + +int apply_attr_override(uint8_t* i_data, + size_t i_size ) +{ + int rc = 0; + errlHndl_t l_errl = NULL; + + TRACFCOMP(g_trac_targeting, "enter apply_attr_override"); + + // Clear fapi and targeting attribute override tanks. The tanks are + // expected to be empty. The passed overrides are added, not updated + // in place. + AttributeTank * l_pAttributeTank = + &fapi::theAttrOverrideSync().iv_overrideTank; + if ((*l_pAttributeTank).attributesExist()) + { + TRACFCOMP(g_trac_targeting, "apply_attr_override:" + " clear FAPI attribute overrides"); + (*l_pAttributeTank).clearAllAttributes(); + } + l_pAttributeTank = &Target::theTargOverrideAttrTank(); + if ((*l_pAttributeTank).attributesExist()) + { + TRACFCOMP(g_trac_targeting, "apply_attr_override:" + " clear targeting attribute overrides"); + (*l_pAttributeTank).clearAllAttributes(); + } + + // Pass attribute override blob as a pnor section + PNOR::SectionInfo_t l_sectionInfo; + l_sectionInfo.vaddr = (uint64_t)i_data; + l_sectionInfo.size = i_size; + l_sectionInfo.id = PNOR::ATTR_TMP; + l_sectionInfo.name = "Runtime TMP"; + + // Process attribute overrides + l_errl = TARGETING::getAttrOverrides(l_sectionInfo); + if (l_errl) + { + TRACFCOMP(g_trac_targeting, "apply_attr_override:" + " getAttrOverrides failed"); + errlCommit(l_errl, TARG_COMP_ID); + rc = -1; + } + else + { + TRACFCOMP(g_trac_targeting, "apply_attr_override succeed"); + } + return rc; +} + +//------------------------------------------------------------------------ + +struct registerTargRT +{ + registerTargRT() + { + runtimeInterfaces_t * rt_intf = getRuntimeInterfaces(); + rt_intf->apply_attr_override = &apply_attr_override; + } +}; + +registerTargRT g_registerTargRT; + +} // end of namespace + + diff --git a/src/usr/targeting/runtime/makefile b/src/usr/targeting/runtime/makefile index 74fbd6a33..1c78cbd98 100644 --- a/src/usr/targeting/runtime/makefile +++ b/src/usr/targeting/runtime/makefile @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2013,2014 +# Contributors Listed Below - COPYRIGHT 2013,2015 +# [+] 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. @@ -34,8 +36,11 @@ HOSTBOOT_RUNTIME_SPECIFIC_OBJS += attrrp_rt.o HOSTBOOT_RUNTIME_SPECIFIC_OBJS += start_rt.o HOSTBOOT_RUNTIME_SPECIFIC_OBJS += targplatutil.o HOSTBOOT_RUNTIME_SPECIFIC_OBJS += rt_targeting.o +HOSTBOOT_RUNTIME_SPECIFIC_OBJS += attrPlatOverride_rt.o +EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi OBJS += ${COMMON_TARGETING_OBJS} +OBJS += ${HOSTBOOT_RT_IPL_COMMON_OBJS} OBJS += ${HOSTBOOT_RUNTIME_SPECIFIC_OBJS} include $(ROOTPATH)/config.mk diff --git a/src/usr/targeting/runtime/test/makefile b/src/usr/targeting/runtime/test/makefile index 29b8d417e..2e0ba3552 100644 --- a/src/usr/targeting/runtime/test/makefile +++ b/src/usr/targeting/runtime/test/makefile @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2013,2014 +# Contributors Listed Below - COPYRIGHT 2013,2015 +# [+] 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. @@ -23,6 +25,7 @@ HOSTBOOT_RUNTIME = 1 ROOTPATH = ../../../../.. +EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi MODULE = testtargeting_rt TESTS = *.H diff --git a/src/usr/targeting/runtime/test/testtargeting.H b/src/usr/targeting/runtime/test/testtargeting.H index f23cee587..d5dae303a 100644 --- a/src/usr/targeting/runtime/test/testtargeting.H +++ b/src/usr/targeting/runtime/test/testtargeting.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2013,2014 */ +/* Contributors Listed Below - COPYRIGHT 2013,2015 */ +/* [+] 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. */ @@ -22,11 +24,14 @@ /* IBM_PROLOG_END_TAG */ #include <cxxtest/TestSuite.H> #include <targeting/common/commontargeting.H> +#include <runtime/interface.h> #include <runtime/rt_targeting.H> #include <errl/errlentry.H> #include <errl/errlmanager.H> #include <targeting/common/trace.H> #include <targeting/common/utilFilter.H> +#include <targeting/attrPlatOverride.H> +#include <hwpf/plat/fapiPlatAttrOverrideSync.H> class TargetingTestSuite : public CxxTest::TestSuite { @@ -112,4 +117,108 @@ class TargetingTestSuite : public CxxTest::TestSuite } } } + + void testApplyAttrOverrides() + { + using namespace TARGETING; + TRACFCOMP(g_trac_targeting,"testApplyAttrOverrides"); + do + { + + // Get the address of the runtime apply overrides function + runtimeInterfaces_t* rt_intf = getRuntimeInterfaces(); + if(rt_intf == NULL) + { + TS_FAIL("runtimeIntfaces not set"); + break; + } + if( rt_intf->apply_attr_override == NULL ) + { + TS_FAIL("runtimeInterfaces->apply_attr_override not set"); + break; + } + + // Get the initial value of the test attribute + TargetService& l_targetService = targetService(); + TARGETING::Target* l_pTarget = NULL; + (void) l_targetService.getTopLevelTarget(l_pTarget); + if (l_pTarget == NULL) + { + TS_FAIL("Top level target handle is NULL"); + break; + } + uint8_t l_attrVal = + l_pTarget->getAttr<TARGETING::ATTR_SCRATCH_UINT8_1>(); + uint8_t l_attrOverrideVal = l_attrVal + 1; + TRACFCOMP(g_trac_targeting, + "apply_attr_override attribute value = 0x%02x", + l_attrVal); + + // Set up attribute override binary blob + const uint64_t l_attrBlobSizeMax = 4096; + uint8_t l_pAttrOverrideBlob[l_attrBlobSizeMax] = {0xff}; + AttributeTank l_TargetTank; + l_TargetTank.setAttribute(ATTR_SCRATCH_UINT8_1, + TYPE_SYS, + AttributeTank::ATTR_POS_NA, + AttributeTank::ATTR_UNIT_POS_NA, + AttributeTank::ATTR_NODE_NA, + 0, + sizeof(l_attrOverrideVal), + &l_attrOverrideVal); + AttributeTank::AttributeSerializedChunks_t l_attributes; + l_TargetTank.serializeAttributes( + AttributeTank::ALLOC_TYPE_NEW, + l_attrBlobSizeMax, + l_attributes); + // Copy override chunk to form attribute override section + AttributeTank::AttributeSerializedChunk l_chunk; + AttrOverrideSection * l_pAttrOverSec = NULL; + uint32_t l_tmpIndex = 0; + for (AttributeTank::AttributeSerializedChunks_t::iterator + chunkIter = l_attributes.begin(); + chunkIter != l_attributes.end(); + ++chunkIter) + { + l_chunk = *chunkIter; + l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *> + (l_pAttrOverrideBlob + l_tmpIndex); + l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_TARG; + l_pAttrOverSec->iv_size = l_chunk.iv_size; + memcpy(&l_pAttrOverSec->iv_chunk, l_chunk.iv_pAttributes, + l_chunk.iv_size); + l_tmpIndex += sizeof(AttrOverrideSection)+ + l_pAttrOverSec->iv_size; + } + // Add termination section + l_pAttrOverSec = reinterpret_cast<AttrOverrideSection *> + (l_pAttrOverrideBlob + l_tmpIndex); + l_pAttrOverSec->iv_layer = AttributeTank::TANK_LAYER_TERM; + l_pAttrOverSec->iv_size = 0; + l_tmpIndex += sizeof(AttrOverrideSection); + // call runtime override attributes + int rc = rt_intf->apply_attr_override( + l_pAttrOverrideBlob, + l_tmpIndex); + if (rc) + { + TS_FAIL("apply_attr_override empty list failed rc=%x",rc); + break; + } + // verify the overriden value + uint8_t l_attrNewVal = + l_pTarget->getAttr<TARGETING::ATTR_SCRATCH_UINT8_1>(); + TRACFCOMP(g_trac_targeting, + "apply_attr_override overriden attribute value = 0x%02x", + l_attrNewVal); + if (l_attrNewVal != l_attrOverrideVal) + { + TS_FAIL("apply_attr_override value=0x%02x expected=0x%02x", + l_attrNewVal,l_attrOverrideVal); + break; + } + TRACFCOMP(g_trac_targeting,"testApplyAttrOverrides SUCCESS"); + + } while (0); + } }; |