diff options
-rw-r--r-- | src/hwpf/include/plat/plat_target_utils.H | 2 | ||||
-rw-r--r-- | src/hwpf/src/plat/plat_attribute_service.H | 4 | ||||
-rw-r--r-- | src/hwpf/src/plat/target.C | 66 | ||||
-rwxr-xr-x | src/tools/scripts/ppeCreateAttrGetSetMacros.pl | 31 |
4 files changed, 90 insertions, 13 deletions
diff --git a/src/hwpf/include/plat/plat_target_utils.H b/src/hwpf/include/plat/plat_target_utils.H index 523dfca4..9d3e520f 100644 --- a/src/hwpf/include/plat/plat_target_utils.H +++ b/src/hwpf/include/plat/plat_target_utils.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2016 */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ diff --git a/src/hwpf/src/plat/plat_attribute_service.H b/src/hwpf/src/plat/plat_attribute_service.H index c54a5f28..008132c3 100644 --- a/src/hwpf/src/plat/plat_attribute_service.H +++ b/src/hwpf/src/plat/plat_attribute_service.H @@ -46,6 +46,10 @@ #define PLAT_GET_CHIP_EC_FEATURE_OVERRIDE(ID, PTARGET, VAL) \ _getEcFeatureOverride<ID##_Type>(ID, PTARGET, VAL) +#define PLAT_ATTR_INIT(ID, TARGET, VAL) \ + (fapi2::checkIdType<ID##_Type>(ID, VAL), \ + ID##_PLAT_INIT(ID, TARGET, VAL)) + /* INSERT NEW ATTRIBUTES HERE */ diff --git a/src/hwpf/src/plat/target.C b/src/hwpf/src/plat/target.C index 60cfe47a..8ab8f0f4 100644 --- a/src/hwpf/src/plat/target.C +++ b/src/hwpf/src/plat/target.C @@ -28,6 +28,7 @@ #include <assert.h> #include <fapi2_target.H> #include <plat_target_utils.H> +#include <p9_perv_scom_addresses.H> // Global Vector containing ALL targets. This structure is referenced by // fapi2::getChildren to produce the resultant returned vector from that @@ -46,6 +47,51 @@ fapi2attr::EXAttributes_t* G_ex_attributes_ptr; namespace fapi2 { + static ReturnCode plat_AttrInit() + { + union + { + struct + { + uint64_t iv_majorEC : 4; + uint64_t iv_deviceIdDontCare : 4; + uint64_t iv_minorEC : 4; + uint64_t iv_chipId : 8; + uint64_t iv_deviceIdDontCare2 : 20; + uint64_t iv_c4Pin : 1; + uint64_t iv_deviceIdDontCare3 : 23; + }; + uint64_t iv_deviceIdReg; + } l_deviceId; + + uint8_t l_chipName = fapi2::ENUM_ATTR_NAME_NONE; + uint8_t l_ec = 0; + fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> l_chipTarget = + plat_getChipTarget(); + + FAPI_TRY(getscom_abs(PERV_DEVICE_ID_REG, &l_deviceId.iv_deviceIdReg)); + l_ec = (l_deviceId.iv_majorEC << 4) | (l_deviceId.iv_minorEC); + switch(l_deviceId.iv_chipId) + { + case 0xD1: + l_chipName = fapi2::ENUM_ATTR_NAME_NIMBUS; + break; + case 0xD4: + l_chipName = fapi2::ENUM_ATTR_NAME_CUMULUS; + break; + default: + FAPI_ERR("Unsupported chip ID: 0x%02X", + static_cast<uint8_t>(l_deviceId.iv_chipId)); + assert(false); + } + + FAPI_TRY(PLAT_ATTR_INIT(fapi2::ATTR_NAME, l_chipTarget, l_chipName)); + + FAPI_TRY(PLAT_ATTR_INIT(fapi2::ATTR_EC, l_chipTarget, l_ec)); +fapi_try_exit: + return fapi2::current_err; + } + // Get the plat target handle by chiplet number - For PERV targets template<> plat_target_handle_t plat_getTargetHandleByChipletNumber<TARGET_TYPE_PERV>( @@ -350,6 +396,10 @@ namespace fapi2 bool & b_present) { + uint8_t l_chipName = fapi2::ENUM_ATTR_NAME_NONE; + + FAPI_TRY(FAPI_ATTR_GET_PRIVILEGED(fapi2::ATTR_NAME, plat_getChipTarget(), l_chipName)); + // TODO via RTC 164026 // In nimbus all pervasive chiplets (non quad, non core), are present // other than OBUS1 and OBUS2. In cumulus all chiplets are present. @@ -363,9 +413,15 @@ namespace fapi2 // attribute to differentiate between nimbus versus cumulus config. static const size_t OBUS1 = 10; static const size_t OBUS2 = 11; - if(( i_chiplet_target.getChipletNumber() != OBUS1 ) && - ( i_chiplet_target.getChipletNumber() != OBUS2 ) && - ( i_chiplet_target.getChipletNumber() < EQ_CHIPLET_OFFSET ) ) + if((OBUS1 == i_chiplet_target.getChipletNumber()) || + (OBUS2 == i_chiplet_target.getChipletNumber())) + { + if(fapi2::ENUM_ATTR_NAME_CUMULUS == l_chipName) + { + static_cast<plat_target_handle_t&>((i_chiplet_target.operator()())).setPresent(); + } + } + else if( i_chiplet_target.getChipletNumber() < EQ_CHIPLET_OFFSET ) { static_cast<plat_target_handle_t&>((i_chiplet_target.operator()())).setPresent(); } @@ -439,6 +495,10 @@ fapi_try_exit: fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP> chip_target((createPlatTargetHandle<fapi2::TARGET_TYPE_PROC_CHIP>(0))); G_vec_targets.at(l_beginning_offset) = revle32((fapi2::plat_target_handle_t)(chip_target.get())); + // Initialize platform attributes. Needs to be after the chip target is + // created. + FAPI_TRY(plat_AttrInit()); + /* * Nest Targets - group 1 */ diff --git a/src/tools/scripts/ppeCreateAttrGetSetMacros.pl b/src/tools/scripts/ppeCreateAttrGetSetMacros.pl index a77054c9..7fae0ced 100755 --- a/src/tools/scripts/ppeCreateAttrGetSetMacros.pl +++ b/src/tools/scripts/ppeCreateAttrGetSetMacros.pl @@ -6,7 +6,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2015,2016 +# Contributors Listed Below - COPYRIGHT 2015,2017 # [+] International Business Machines Corp. # # @@ -52,6 +52,7 @@ my %attributeArrayTypes; my %getMacros; my %setMacros; my %targetMacros; +my %platInitMacros; @@ -124,12 +125,16 @@ while (<FILE>) { $targetMacros{$1} = $2; # print "DEBUG:: attribute = $1 : TARGET = $2\n"; if ($DEBUG) { print "DEBUG:: attribute = $1 : TARGET = $2\n"; } + } elsif (m/\s*const\s*bool\s+(\w+)_PlatInit\s*=\s*true\s*;\s*/) { + $platInitMacros{$1} = 'true'; + if ($DEBUG) { print "DEBUG:: attribute = $1 is platInit\n"; } } + } close (FILE); -#find copy of fapiPlatAttributeService.H +#find copy of plat_attribute_service.H if (!$servicePath) { #$CTEPATH/tools/ecmd/$ECMD_RELEASE/ext/fapi/capi my $ctepath = $ENV{CTEPATH}; @@ -155,13 +160,13 @@ if (!-d $servicePath) { exit 1; } -# test that fapiPlatAttributeService.H is in that directory +# test that plat_attribute_service.H is in that directory if (!-f "$servicePath/$fapiPlatAttributeServiceFile") { print "ERROR:: $fapiPlatAttributeServiceFile does not exist in $servicePath\n"; exit 1; } -# copy fapiPlatAttributeService.H to local dir +# copy plat_attribute_service.H to local dir #my $systemRc = system("cp $servicePath/$fapiPlatAttributeServiceFile $includePath"); copy("$servicePath/$fapiPlatAttributeServiceFile","$includePath") or die "Copy failed: $!"; @@ -172,7 +177,7 @@ copy("$servicePath/$fapiPlatAttributeServiceFile","$includePath") or die "Copy f -# look in fapiPlatAttributeService.H for MACROs +# look in plat_attribute_service.H for MACROs open (FILE, $includePath . "/". $fapiPlatAttributeServiceFile) or die "ERROR:: could not open $fapiPlatAttributeServiceFile\n"; while (<FILE>) { if (m/\s*#define\s+(\w+)_GETMACRO\s+(\S+)\s*/) { @@ -224,6 +229,7 @@ for my $attribute (sort keys %{$enums{AttributeId}}) { my $setMacro = $setMacros{$attribute}; my $getMacro = $getMacros{$attribute}; + my $platInitMacro = $platInitMacros{$attribute}; my $targetMacro = $targetMacros{$attribute}; # print "$attribute $setMacro $getMacro $targetMacro \n"; @@ -307,10 +313,17 @@ $targetImplementation .= "\n" . $targetFunction . "\n{\n uint32_t index = stat push(@newTargetImplementations, $targetImplementation); } } - if (!$setMacro) { - if ($VERBOSE) { print "INFO:: did not find ${attribute}_SETMACRO\n"; } - my $attributeDefine = "#define ${attribute}_SETMACRO ${macroPrefix}SET${macroPostfix}"; - push(@newAttributeDefines, $attributeDefine); + if (!$setMacro || $platInitMacro) { + if(!$setMacro) { + if ($VERBOSE) { print "INFO:: did not find ${attribute}_SETMACRO\n"; } + my $attributeDefine = "#define ${attribute}_SETMACRO ${macroPrefix}SET${macroPostfix}"; + push(@newAttributeDefines, $attributeDefine); + } + if($platInitMacro) { + if ($VERBOSE) { print "INFO:: Generating plat init macro for ${attribute}\n"; } + my $attributeDefine = "#define ${attribute}_PLAT_INIT ${macroPrefix}SET${macroPostfix}"; + push(@newAttributeDefines, $attributeDefine); + } if(defined $targetMacro) { |